8 l : sconcat("\"", "text", "\"");
14 [charp(c), lcharp(c)];
20 control : "~2tAn atom: ~20t~a~%~2tand a list: ~20t~{~r ~}~%~2tand an integer: ~20t~d~%";
21 "~2tAn atom: ~20t~a~%~2tand a list: ~20t~{~r ~}~%~2tand an integer: ~20t~d~%"$
22 printf(false, control, 'true, [1, 2, 3], 42)$
24 and a list: one two three
27 printf(false, "~a ~a ~4f ~a ~@r", "String", sym, bound, sqrt(12), 144), bound = 1.234;
28 "String sym 1.23 2*sqrt(3) CXLIV"$
29 printf(false, "~{~a ~}", ["one", 2, "THREE"]);
31 printf(false, "~{~{~9,1f ~}~%~}", mat), mat = args(matrix([1.1, 2, 3.33], [4, 5, 6], [7, 8.88, 9]))$
36 control : "~:(~r~) bird~p ~[is~;are~] singing.";
37 "~:(~r~) bird~p ~[is~;are~] singing."$
38 printf(false, control, n, n, if n = 1 then 1 else 2), n = 2;
39 "Two birds are singing."$
42 for n from 0 thru 127 do (
44 if alphacharp(tmp) then res : adjoin (tmp, res) ),
45 subsetp ({"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}, res) );
49 for n from 0 thru 127 do (
51 if constituent(tmp) then res : adjoin (tmp, res) ),
52 subsetp ({"!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"}, res) );
63 [cequal("e","E"),cequalignore("e","E")];
65 [alphacharp("2"),alphanumericp("2")];
67 [clessp("E","e"),clesspignore("E","e")];
69 [lowercasep("e"),lowercasep("E")];
72 2*parse_string ("1.234; 5.678");
75 3*parse_string ("1/2");
78 parse_string ("2.3e10");
81 parse_string (".25e-1");
84 2*parse_string ("2.3b1");
87 parse_string (".25b-1");
93 parse_string ("foo;");
96 parse_string ("foo$;$;");
99 parse_string ("\"semicolon ; string\"");
100 "semicolon ; string"$
102 parse_string ("\"dollar $ string\"");
105 parse_string ("[2]");
108 parse_string ("(foo : 1234, expand ((foo + bar)^2))");
109 (foo : 1234, expand ((foo + bar)^2));
111 eval_string ("(foo : 1234, expand ((foo + bar)^2))");
112 bar^2 + 2468*bar + 1522756;
114 (kill (bar), parse_string ("bar (x) := x^2"), bar (7));
117 (eval_string ("bar (x) := x^2"), bar (7));
120 s : sconcat ("xx[", 3, "]:", expand((y + x)^3));
121 "xx[3]:y^3+3*x*y^2+3*x^2*y+x^3"$
124 [sequal("gnuplot","Gnuplot"),sequalignore("gnuplot","Gnuplot")];
128 simplode(["xx[", 3, "]:", expand((y + x)^3 )]);
129 "xx[3]:y^3+3*x*y^2+3*x^2*y+x^3"$
130 simplode(charlist("stars"), " * ");
132 simplode(["One", "more", "coffee."], " ");
135 /* SF bug report #3329: "Simplode overlimited at Maxima with GCL" */
136 block ([l2: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33]],
138 "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;\
141 block ([l2: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33]],
143 "123456789101112131415161718192021222324252627\
146 simplode (flatten (makelist (["A", "B", "C", "D"], 50)), "-");
147 "A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D\
148 -A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D\
149 -A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D\
150 -A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D\
151 -A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D-A-B-C-D";
153 simplode (flatten (makelist (["A", "B", "C", "D"], 50)));
154 "ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\
155 ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\
156 ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\
157 ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\
158 ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD";
160 /* Bug #3439: Simplode output on empty list */
165 /* This used to return the string "false" */
169 /* This used to return the symbol foo */
175 sconcat (substring(s, 1, 3), "yellow ", substring(s, 3));
176 "A yellow submarine."$
177 sinsert("hollow ", s, 3);
178 "A hollow submarine."$
179 sinvertcase("sInvertCase");
183 smismatch("seven","seventh");
185 split("1.2 2.3 3.4 4.5");
186 ["1.2","2.3","3.4","4.5"]$
187 split("first;;third;fourth", ";", false);
188 ["first","","third","fourth"]$
189 sposition("e","seventh");
191 sremove("n't", "I don't like coffee.");
193 sremove("DO ", %, 'sequalignore);
195 sreverse("einnegermitgazellezagtimregennie");
196 "einnegermitgazellezagtimregennie"$
198 /* SF bug report #3329: "Simplode overlimited at Maxima with GCL"
199 * (same bug in sreverse; ensure it works OK for long strings
201 sreverse ("dCBCba1A310acBaACAD0DB13dA2200c32AbADA0aB0cAa2D2aDB12AdABa030Ba03c3d0DbA\
202 3aBba2c00a10DA3C3AAa1a00bc1BCa33bBDb1da0baBBaAa01D11AA0adcaaB13323A33Ac3DCdcAC\
203 1131bCdB1d1BddaCaAD0Ab131bad2d30abBaca0D2bccd2Ccd2");
204 "2dcC2dccb2D0acaBba03d2dab131bA0DAaCaddB1d1BdCb1311CAcdCD3cA33A32331Baacd\
205 a0AA11D10aAaBBab0ad1bDBb33aCB1cb00a1aAA3C3AD01a00c2abBa3AbD0d3c30aB030aBAdA21B\
206 Da2D2aAc0Ba0ADAbA23c0022Ad31BD0DACAaBca013A1abCBCd";
208 ssearch("~s", "~{~S ~}~%", 'sequalignore);
210 ssearch ("foo", "bar");
212 ssort("I don't like Mondays.");
213 " '.IMaddeiklnnoosty"$
214 block([us_ascii_only:true], ssort("I don't like Mondays.", 'cgreaterpignore));
215 "ytsoonnMlkIiedda.' "$
217 /* SF bug report #3329: "Simplode overlimited at Maxima with GCL"
218 * (same bug in ssort; ensure it works OK for long strings
220 ssort ("fTgTgHZyfUfYOWTTWezffIITTfQxwWaWyTdaIfyeawITRfaTfywaIgWdePTefegfIaOeIWT\
221 WgOgHfOIddgOTdZIdIwwPTfOaIITeyygxdddTWdfyWOOOOTZPHfTHHydIaTTdTeggwwHZHWHTfeHfZ\
222 IOydPgTTeHORaweaZPIHaefHTgXaTwdTgZyOReTyfIaZZeZeyfPTHHZfWage");
223 "HHHHHHHHHHHHHHIIIIIIIIIIIIIIIIOOOOOOOOOOOOOPPPPPPQRRRTTTTTTTTTTTTTTTTTT\
224 TTTTTTTTTTUWWWWWWWWWWWXYZZZZZZZZZZZaaaaaaaaaaaaaaddddddddddddddeeeeeeeeeeeeeee\
225 efffffffffffffffffffffggggggggggggggwwwwwwwwwxxyyyyyyyyyyyyz";
227 ssubst("like", "hate", "I hate Thai food. I hate green tea.");
228 "I like Thai food. I like green tea."$
229 ssubst("Black", "Green", "Green light. Green tea. Greenwich.", 'sequal, 10, 20);
230 "Green light. Black tea. Greenwich."$
232 /* SF bug #3700, ssubst crashes with large number of substitutions
233 construct the long strings via concat
235 block([s:lreduce(concat,makelist("a",k,1,1400)), r:lreduce(concat,makelist("b",k,1,1400))],
236 sequal(r,ssubst("b","a",s))) $
245 substring("substring", 4);
249 supcase("english", 1, 2);
251 tokens("24 October 2005");
252 ["24","October","2005"]$
253 tokens("05-10-24", 'digitcharp);
255 map(parse_string, %);
258 (remvalue(m,l,c,control,foo,bar,s), 0);