Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras » Apple][e/PD/BOB/ARMBOB/!ArmBob/progs/h/list
Apple][e/PD/BOB/ARMBOB/!ArmBob/progs/h/list
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras |
Filename: | Apple][e/PD/BOB/ARMBOB/!ArmBob/progs/h/list |
Read OK: | ✔ |
File size: | 01FE bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
/* GCW 06/06/94 */ /* lists */ cons(x,list) { return (vector {x; list;}) ; } head(list) { return ((typeof(list)==VECTOR)?(list[0]):nil); } tail(list) { return ((typeof(list)==VECTOR)?(list[1]):nil); } map(f,l) { return ((typeof(l)==VECTOR)?(cons(f(head(l)),map(f,tail(l)))):nil); } printlist(l) { print("["); if (typeof(l)==VECTOR) { print(head(l)); l = tail(l); while (typeof(l)==VECTOR) { print(","); print(head(l)); l = tail(l); } } print("]"); }
00000000 2f 2a 20 47 43 57 20 20 30 36 2f 30 36 2f 39 34 |/* GCW 06/06/94| 00000010 20 20 2a 2f 0a 2f 2a 20 6c 69 73 74 73 20 2a 2f | */./* lists */| 00000020 0a 0a 63 6f 6e 73 28 78 2c 6c 69 73 74 29 0a 7b |..cons(x,list).{| 00000030 0a 20 72 65 74 75 72 6e 20 28 76 65 63 74 6f 72 |. return (vector| 00000040 20 7b 78 3b 20 6c 69 73 74 3b 7d 29 20 3b 0a 7d | {x; list;}) ;.}| 00000050 0a 0a 68 65 61 64 28 6c 69 73 74 29 0a 7b 0a 20 |..head(list).{. | 00000060 72 65 74 75 72 6e 20 28 28 74 79 70 65 6f 66 28 |return ((typeof(| 00000070 6c 69 73 74 29 3d 3d 56 45 43 54 4f 52 29 3f 28 |list)==VECTOR)?(| 00000080 6c 69 73 74 5b 30 5d 29 3a 6e 69 6c 29 3b 0a 7d |list[0]):nil);.}| 00000090 0a 0a 74 61 69 6c 28 6c 69 73 74 29 0a 7b 0a 20 |..tail(list).{. | 000000a0 72 65 74 75 72 6e 20 28 28 74 79 70 65 6f 66 28 |return ((typeof(| 000000b0 6c 69 73 74 29 3d 3d 56 45 43 54 4f 52 29 3f 28 |list)==VECTOR)?(| 000000c0 6c 69 73 74 5b 31 5d 29 3a 6e 69 6c 29 3b 0a 7d |list[1]):nil);.}| 000000d0 0a 0a 6d 61 70 28 66 2c 6c 29 0a 7b 0a 20 72 65 |..map(f,l).{. re| 000000e0 74 75 72 6e 20 28 28 74 79 70 65 6f 66 28 6c 29 |turn ((typeof(l)| 000000f0 3d 3d 56 45 43 54 4f 52 29 3f 28 63 6f 6e 73 28 |==VECTOR)?(cons(| 00000100 66 28 68 65 61 64 28 6c 29 29 2c 6d 61 70 28 66 |f(head(l)),map(f| 00000110 2c 74 61 69 6c 28 6c 29 29 29 29 3a 6e 69 6c 29 |,tail(l)))):nil)| 00000120 3b 0a 7d 0a 0a 70 72 69 6e 74 6c 69 73 74 28 6c |;.}..printlist(l| 00000130 29 0a 7b 0a 20 70 72 69 6e 74 28 22 5b 22 29 3b |).{. print("[");| 00000140 0a 20 69 66 20 28 74 79 70 65 6f 66 28 6c 29 3d |. if (typeof(l)=| 00000150 3d 56 45 43 54 4f 52 29 0a 20 20 20 7b 0a 20 20 |=VECTOR). {. | 00000160 20 20 70 72 69 6e 74 28 68 65 61 64 28 6c 29 29 | print(head(l))| 00000170 3b 0a 20 20 20 20 6c 20 3d 20 74 61 69 6c 28 6c |;. l = tail(l| 00000180 29 3b 0a 20 20 20 20 77 68 69 6c 65 20 28 74 79 |);. while (ty| 00000190 70 65 6f 66 28 6c 29 3d 3d 56 45 43 54 4f 52 29 |peof(l)==VECTOR)| 000001a0 0a 20 20 20 20 20 7b 0a 20 20 20 20 20 20 70 72 |. {. pr| 000001b0 69 6e 74 28 22 2c 22 29 3b 0a 20 20 20 20 20 20 |int(",");. | 000001c0 70 72 69 6e 74 28 68 65 61 64 28 6c 29 29 3b 0a |print(head(l));.| 000001d0 20 20 20 20 20 20 6c 20 3d 20 74 61 69 6c 28 6c | l = tail(l| 000001e0 29 3b 0a 20 20 20 20 20 7d 0a 20 20 20 7d 0a 20 |);. }. }. | 000001f0 70 72 69 6e 74 28 22 5d 22 29 3b 0a 7d 0a |print("]");.}.| 000001fe