[DEMO.REC] [collection of LISP demonstration programs] [December 31, 1980] [December 28, 1983] [[]] { [cr,lf] (2573TL;)& [console input] (R13%='';T08%(=2080[sp,bs]TL)(@#|;L@#;);)# [logon message] (' A collection of LISP demonstration programs: (merge (1 2 3) (a b c)) produces (1 a 2 b 3 c) (reverse (1 2 3 4 5)) produces (5 4 3 2 1) (split (1 a 2 b 3 c)) produces ((1 2 3) (a b c)) (split* (1 a 2 b 3 c)) produces the same result (binsum (1 1 1 0) (1 1)) produces (1 0 0 0 1) To execute one of these programs, type its name, then a carriage return. Then type its arguments, in response to the prompts. 'TL@&;)! [bal paren] (A')'E;'('E@+::)+ [next element] (A'('E@+JA;j' 'U;')'U;)- [enclose in quotes] (JZD39%II39%IJQ;)% [car] (JZDI@-Q;)1 [cdr] (JZDI@-D(' 'ED;;)JZQ;)2 [cons] (JZD('()'='('II')'I;IAjI' 'I;)JZQ;)3 [atom] (JZDI'('E'F';'T';)4 [eq] (='T';L'F';)5 [null] ('()'='T';L'F';)6 [read] (@&'read> 'TL(@#;:);)7 [print] (@&' 'TLT;)8 [append] (JZDIjIzABBD' 'IJZQ;)9 [not] ('T'='F';'F'='T';;)0 [calculate a binary sum - use reversed digits] (1$rmml1$S0$rmml0$S0$ryG'()'@r1$ryG'()'@r@c'()'@rnLn0$SnLn1$S ;)b [binary sum - sum low order bits, then rest] (1$rmml1$S0$rmml0$S(0$ryG@6'T'=1$ryG;L1$ryG@6'T'=0$ryG;L'T''T'=0$ryG@11$ryG@1@d0$ryG@11$ryG@1@e'()'@30$ryG@21$ryG@2@c@c@3;L;)nLn0$SnLn1$S ;)c [sum of two bits] (1$rmml1$S0$rmml0$S(0$ryG"0"@5'T'=1$ryG;L1$ryG"0"@5'T'=0$ryG;L'T''T'="0";L;)nLn0$SnLn1$S ;)d [carry bit] (1$rmml1$S0$rmml0$S(0$ryG"0"@5'T'="0";L1$ryG"0"@5'T'="0";L'T''T'="1";L;)nLn0$SnLn1$S ;)e [make a list of two elements] (1$rmml1$S0$rmml0$S0$ryG1$ryG"()"@3@3nLn0$SnLn1$S ;)l [merge two lists] (1$rmml1$S0$rmml0$S(0$ryG@6'T'=1$ryG;L(1$ryG@6'T'=0$ryG;L0$ryG@11$ryG@10$ryG@21$ryG@2@m@3@3;);)nLn0$SnLn1$S ;)m [reverse a list] (1$rmml1$S0$rmml0$S(0$ryG"()"@5'T'=1$ryG;L0$ryG@20$ryG@11$ryG@3@r;)nLn0$SnLn1$S ;)r [split a list into odds and evens] (2$rmml2$S1$rmml1$S0$rmml0$S(0$ryG@6'T'=1$ryG2$ryG@l;L(0$ryG@2@6'T'=0$ryG@11$ryG@32$ryG@l;L0$ryG@2@20$ryG@11$ryG@30$ryG@2@12$ryG@3@s;);)nLn0$SnLn1$SnLn2$S ;)s [split a list into odds and evens - variant] (0$rmml0$S(0$ryG@6'T'=0$ryG0$ryG@l;L(0$ryG@2@6'T'=0$ryG"()"@l;L0$ryG@2@2@t1$rmml1$S0$ryG@11$ryG@1@30$ryG@2@11$ryG@2@1@3@lnLn1$S;);)nLn0$S ;)t [main program] (0$rmml0$S(0$ryG"merge"@5'T'=@7@7@m;L(0$ryG"reverse"@5'T'=@7"()"@r;L(0$ryG"split"@5'T'=@7"()""()"@s;L(0$ryG"split*"@5'T'=@7@t;L(0$ryG"binsum"@5'T'=@7@7@b;L"(wrong option)";););););)nLn0$S ;)* (@!@7@*@8;;)} [end]