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");
96 parse_string ("(foo : 1234, expand ((foo + bar)^2))");
97 (foo : 1234, expand ((foo + bar)^2));
99 eval_string ("(foo : 1234, expand ((foo + bar)^2))");
100 bar^2 + 2468*bar + 1522756;
102 (kill (bar), parse_string ("bar (x) := x^2"), bar (7));
105 (eval_string ("bar (x) := x^2"), bar (7));
108 s : sconcat ("xx[", 3, "]:", expand((y + x)^3));
109 "xx[3]:y^3+3*x*y^2+3*x^2*y+x^3"$
112 [sequal("gnuplot","Gnuplot"),sequalignore("gnuplot","Gnuplot")];
116 simplode(["xx[", 3, "]:", expand((y + x)^3 )]);
117 "xx[3]:y^3+3*x*y^2+3*x^2*y+x^3"$
118 simplode(charlist("stars"), " * ");
120 simplode(["One", "more", "coffee."], " ");
123 /* SF bug report #3329: "Simplode overlimited at Maxima with GCL" */
124 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]],
126 "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;\
129 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]],
131 "123456789101112131415161718192021222324252627\
134 simplode (flatten (makelist (["A", "B", "C", "D"], 50)), "-");
135 "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\
136 -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\
137 -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\
138 -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\
139 -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";
141 simplode (flatten (makelist (["A", "B", "C", "D"], 50)));
142 "ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\
143 ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\
144 ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\
145 ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\
146 ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD";
148 /* Bug #3439: Simplode output on empty list */
153 /* This used to return the string "false" */
157 /* This used to return the symbol foo */
163 sconcat (substring(s, 1, 3), "yellow ", substring(s, 3));
164 "A yellow submarine."$
165 sinsert("hollow ", s, 3);
166 "A hollow submarine."$
167 sinvertcase("sInvertCase");
171 smismatch("seven","seventh");
173 split("1.2 2.3 3.4 4.5");
174 ["1.2","2.3","3.4","4.5"]$
175 split("first;;third;fourth", ";", false);
176 ["first","","third","fourth"]$
177 sposition("e","seventh");
179 sremove("n't", "I don't like coffee.");
181 sremove("DO ", %, 'sequalignore);
183 sreverse("einnegermitgazellezagtimregennie");
184 "einnegermitgazellezagtimregennie"$
186 /* SF bug report #3329: "Simplode overlimited at Maxima with GCL"
187 * (same bug in sreverse; ensure it works OK for long strings
189 sreverse ("dCBCba1A310acBaACAD0DB13dA2200c32AbADA0aB0cAa2D2aDB12AdABa030Ba03c3d0DbA\
190 3aBba2c00a10DA3C3AAa1a00bc1BCa33bBDb1da0baBBaAa01D11AA0adcaaB13323A33Ac3DCdcAC\
191 1131bCdB1d1BddaCaAD0Ab131bad2d30abBaca0D2bccd2Ccd2");
192 "2dcC2dccb2D0acaBba03d2dab131bA0DAaCaddB1d1BdCb1311CAcdCD3cA33A32331Baacd\
193 a0AA11D10aAaBBab0ad1bDBb33aCB1cb00a1aAA3C3AD01a00c2abBa3AbD0d3c30aB030aBAdA21B\
194 Da2D2aAc0Ba0ADAbA23c0022Ad31BD0DACAaBca013A1abCBCd";
196 ssearch("~s", "~{~S ~}~%", 'sequalignore);
198 ssearch ("foo", "bar");
200 ssort("I don't like Mondays.");
201 " '.IMaddeiklnnoosty"$
202 block([us_ascii_only:true], ssort("I don't like Mondays.", 'cgreaterpignore));
203 "ytsoonnMlkIiedda.' "$
205 /* SF bug report #3329: "Simplode overlimited at Maxima with GCL"
206 * (same bug in ssort; ensure it works OK for long strings
208 ssort ("fTgTgHZyfUfYOWTTWezffIITTfQxwWaWyTdaIfyeawITRfaTfywaIgWdePTefegfIaOeIWT\
209 WgOgHfOIddgOTdZIdIwwPTfOaIITeyygxdddTWdfyWOOOOTZPHfTHHydIaTTdTeggwwHZHWHTfeHfZ\
210 IOydPgTTeHORaweaZPIHaefHTgXaTwdTgZyOReTyfIaZZeZeyfPTHHZfWage");
211 "HHHHHHHHHHHHHHIIIIIIIIIIIIIIIIOOOOOOOOOOOOOPPPPPPQRRRTTTTTTTTTTTTTTTTTT\
212 TTTTTTTTTTUWWWWWWWWWWWXYZZZZZZZZZZZaaaaaaaaaaaaaaddddddddddddddeeeeeeeeeeeeeee\
213 efffffffffffffffffffffggggggggggggggwwwwwwwwwxxyyyyyyyyyyyyz";
215 ssubst("like", "hate", "I hate Thai food. I hate green tea.");
216 "I like Thai food. I like green tea."$
217 ssubst("Black", "Green", "Green light. Green tea. Greenwich.", 'sequal, 10, 20);
218 "Green light. Black tea. Greenwich."$
220 /* SF bug #3700, ssubst crashes with large number of substitutions
221 construct the long strings via concat
223 block([s:lreduce(concat,makelist("a",k,1,1400)), r:lreduce(concat,makelist("b",k,1,1400))],
224 sequal(r,ssubst("b","a",s))) $
233 substring("substring", 4);
237 supcase("english", 1, 2);
239 tokens("24 October 2005");
240 ["24","October","2005"]$
241 tokens("05-10-24", 'digitcharp);
243 map(parse_string, %);
246 (remvalue(m,l,c,control,foo,bar,s), 0);