Category:TXR: Difference between revisions

m
Line 42:
==== Polymorphizing the Classics ====
 
In TXR Lisp, classic Lisp operations like <code>mapcar</code>, <code>cdr</code> or <code>append</code> work exactly like they are supposed to, when they operate on lists. However,Right most of the operations have been extendeddown to also work with strings and vectors. Soimproper forlists instance,like <code>(mapcarappend (op + 142) "abc")</code-> nicely yields the string <code>"bcd"42</code> whereand <code>1</code>(append has been added to every character code of the original string. <code>'(car1) "abc"2)</code> yields <code->#\a</code>, a character, <code>(cdr1 "abc")</code>. yields <code>"bc"</code>, and <code>(cdr "c"2)</code> yields <code>nil</code> (rather than the empty string!) (Almost) everything proceeds from there.
However, most of the operations have been extended to also work with strings and vectors. So for instance, <code>(mapcar (op + 1) "abc")</code> nicely yields the string <code>"bcd"</code> where <code>1</code> has been added to every character code of the original string. <code>(car "abc")</code> yields <code>#\a</code>, a character, <code>(cdr "abc")</code> yields <code>"bc"</code>, and <code>(cdr "c")</code> yields <code>nil</code> (rather than the empty string!) (Almost) everything proceeds from there.
 
==== One Quote to Bind Them ====
543

edits