stint
play

Stint Jiang Wu, Ningning Xia, Sichang Li, Tingting Ai, Yiming Xu - PowerPoint PPT Presentation

Stint Jiang Wu, Ningning Xia, Sichang Li, Tingting Ai, Yiming Xu String and Integer Language Outline Motivation Language Features Tutorial with Scenario Structure Design Summary Lessons Background and Motivation


  1. Stint Jiang Wu, Ningning Xia, Sichang Li, Tingting Ai, Yiming Xu String and Integer Language

  2. Outline ● Motivation ● Language Features ● Tutorial with Scenario ● Structure Design ● Summary ● Lessons

  3. Background and Motivation ● Strings are mixtures of character blocks and numbers ● Usually we want to manipulate different parts of a string according to what they are ● Existing languages are complicated or heavy-weighted That's what we focus on!

  4. Language Features * Flexible Type Conversion * More Convenient String Operations

  5. Language Features * Flexible Type Conversion * More Convenient String Operations Auto-Conversion: string str1 = 12; -> "12" string str2 = true ; -> "true"

  6. Language Features * Flexible Type Conversion * More Convenient String Operations Int-Extraction: "age 22, grade 98, rank 3"

  7. Language Features * Flexible Type Conversion * More Convenient String Operations Int-Extraction: "age 22 , grade 98 , rank 3 " "age 23 , grade 98 , rank 3 " str .<| 0 |> = str .<| 0 |> + 1;

  8. Language Features * Flexible Type Conversion * More Convenient String Operations Insert & Delete: "this is " str = str + "Stint";

  9. Language Features * Flexible Type Conversion * More Convenient String Operations Insert & Delete: "this is Stint" str = str + "Stint"; str = str + "not " @ 8;

  10. Language Features * Flexible Type Conversion * More Convenient String Operations Insert & Delete: "this is not Stint" str = str + "Stint"; str = str + "not " @ 8;

  11. Language Features * Flexible Type Conversion * More Convenient String Operations Insert & Delete: "this is not Stint" str = str - "is"; "this is not Stint" str = str - "is" @ 4; "this is not Stint"

  12. Language Features * Flexible Type Conversion * More Convenient String Operations Extraction: "abc123def" str[0] -> "a" str[0, 3] -> "abc"

  13. Language Features * Flexible Type Conversion * More Convenient String Operations Extraction: "abc123def" str <|0|> str.<|0|> str <|1|>

  14. Language Features * Flexible Type Conversion * More Convenient String Operations More Extraction: "This is his thesis" 0 1 2 3 str | " "; str <|2|> -> "his"

  15. Language Features * Flexible Type Conversion * More Convenient String Operations More Extraction: "Th is is h is thes is " "This is his thesis" 0 1 2 3 str # "is"; str <|1|>

  16. Language Features * Flexible Type Conversion * More Convenient String Operations Assignment: "Th is is h is thes is " "Th is isn't h is thes is " 0 1 2 3 0 1 2 3 str # "is"; str <|1|> = "isn't" str <|1|>

  17. Tutorial with Scenario Update inventory record of a store: sn1_table.txt : sn1_input.txt : <sales in this month> <name><price><sales><inventory> 194 MacBookPro $1200 248 203 246 MacBookAir $900 381 246 63 iMac $1600 64 98 ...... ...... sn1_output.txt : <name><mark><price><sales><inventory><income> MacBookPro(BEST) $1200 442 9 530400 MacBookAir(BEST) $900 627 0 564300 iMac $1600 127 35 203200 ......

  18. Tutorial with Scenario void main () { /* calculate total sale income */ string input_file = "sn1_table.txt"; in_buff = in_buff + " " + (in_buff.<|0|> * in_buff.<|1|>); ...... /* save all file names as variables */ /* mark tag if necessary */ string in_buff = ""; in_buff | " "; string data_buff = ""; if (in_buff.<|3|> > 300000) { int sales; in_buff<|0|> = in_buff<|0|> + "(BEST)"; } /* open input and output files */ if (in_buff.<|3|> < 100000) { open input_file; ...... in_buff<|0|> = in_buff<|0|> + "(OFFER)"; in_buff.<|0|> = in_buff.<|0|> / 2; /* read line by line */ } while (input_file >> in_buff) { output_file << in_buff + "\n"; data_file >> data_buff; } sales = data_buff.<|0|>; close input_file; ...... /* close all opened files */ /* modify sales and inventory */ in_buff.<|1|> = in_buff.<|1|> + sales; return; /* must have a return statement */ in_buff.<|2|> = in_buff.<|2|> - sales; }

  19. Tutorial with Scenario void main () { /* calculate total sale income */ void main () { string input_file = "sn1_table.txt"; in_buff = in_buff + " " + (in_buff.<|0|> * in_buff.<|1|>); string input_file = "sn1_table.txt"; ...... /* save all file names as variables */ <name><price><sales><inventory> /* mark tag if necessary */ string in_buff = ""; MacBookPro $1200 248 203 ...... /* save all file names as variables */ in_buff | " "; string data_buff = ""; MacBookAir $900 381 246 string in_buff = ""; if (in_buff.<|3|> > 300000) { int sales; iMac $1600 64 98 string data_buff = ""; in_buff<|0|> = in_buff<|0|> + "(BEST)"; } ...... /* open input and output files */ if (in_buff.<|3|> < 100000) { int sales; open input_file; ...... in_buff<|0|> = in_buff<|0|> + "(OFFER)"; in_buff.<|0|> = in_buff.<|0|> / 2; /* open input and output files */ /* read line by line */ } <sales in this month> while (input_file >> in_buff) { open input_file; ...... output_file << in_buff + "\n"; 194 data_file >> data_buff; } 246 sales = data_buff.<|0|>; 63 close input_file; ...... /* close all opened files */ ...... /* modify sales and inventory */ in_buff.<|1|> = in_buff.<|1|> + sales; return; /* must have a return statement */ in_buff.<|2|> = in_buff.<|2|> - sales; }

  20. Tutorial with Scenario void main () { /* calculate total sale income */ string input_file = "sn1_table.txt"; in_buff = in_buff + " " + (in_buff.<|0|> * in_buff.<|1|>); ...... /* save all file names as variables */ /* mark tag if necessary */ string in_buff = ""; in_buff | " "; string data_buff = ""; if (in_buff.<|3|> > 300000) { int sales; in_buff<|0|> = in_buff<|0|> + "(BEST)"; } /* open input and output files */ if (in_buff.<|3|> < 100000) { /* read line by line */ open input_file; ...... in_buff<|0|> = in_buff<|0|> + "(OFFER)"; data_buff: while (input_file >> in_buff) { in_buff.<|0|> = in_buff.<|0|> / 2; 194 data_file >> data_buff; /* read line by line */ } while (input_file >> in_buff) { sales = data_buff.<|0|>; output_file << in_buff + "\n"; data_file >> data_buff; } in_buff: sales = data_buff.<|0|>; MacBookPro $1200 248 203 /* modify sales and inventory */ close input_file; ...... /* close all opened files */ /* modify sales and inventory */ in_buff.<|1|> = in_buff.<|1|> + sales; in_buff.<|1|> = in_buff.<|1|> + sales; in_buff.<|2|> = in_buff.<|2|> - sales; return; /* must have a return statement */ MacBookPro $1200 442 9 in_buff.<|2|> = in_buff.<|2|> - sales; }

  21. Tutorial with Scenario /* calculate total sale income */ void main () { /* calculate total sale income */ in_buff = in_buff + " " + (in_buff.<|0|> * in_buff.<|1|>); string input_file = "sn1_table.txt"; in_buff = in_buff + " " + (in_buff.<|0|> * in_buff. ...... /* save all file names as variables */ /* mark tag if necessary */ <|1|>); string in_buff = ""; in_buff | " "; string data_buff = ""; if (in_buff.<|3|> > 300000) { int sales; /* mark tag if necessary */ in_buff<|0|> = in_buff<|0|> + "(BEST)"; } in_buff: in_buff | " "; if (in_buff.<|3|> < 100000) { /* open input and output files */ MacBookPro $1200 248 203 if (in_buff.<|3|> > 300000) { in_buff<|0|> = in_buff<|0|> + "(OFFER)"; open input_file; ...... in_buff.<|0|> = in_buff.<|0|> / 2; in_buff<|0|> = in_buff<|0|> + "(BEST)"; } /* read line by line */ } if (in_buff.<|3|> < 100000) { MacBookPro $1200 442 9 530400 while (input_file >> in_buff) { output_file << in_buff + "\n"; in_buff<|0|> = in_buff<|0|> + "(OFFER)"; data_file >> data_buff; } sales = data_buff.<|0|>; in_buff.<|0|> = in_buff.<|0|> / 2; close input_file; ...... /* close all opened files */ MacBookPro(BEST) $1200 442 9 } /* modify sales and inventory */ 530400 output_file << in_buff + "\n"; in_buff.<|1|> = in_buff.<|1|> + sales; return; /* must have a return statement */ in_buff.<|2|> = in_buff.<|2|> - sales; } }

More recommend