From db73f1d126945311b4acea1f484b2af42c4094fe Mon Sep 17 00:00:00 2001 From: Drahflow Date: Wed, 20 Mar 2019 19:19:38 +0100 Subject: How not to do lists. :P --- examples/working-compiler/list-spell.ey | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/working-compiler/list-spell.ey (limited to 'examples') diff --git a/examples/working-compiler/list-spell.ey b/examples/working-compiler/list-spell.ey new file mode 100644 index 0000000..a5d09c8 --- /dev/null +++ b/examples/working-compiler/list-spell.ey @@ -0,0 +1,22 @@ +# Implementing the list spell by Aphyr + +{ ==h { h ? 1 }_ } =*cons + +{ } "3" cons "2" cons "1" cons ==x +x dump + +{ =*l _ { 1 sub 1 l -- nth } { -- 0 l -- } ? * } =*nth + +{ [ -01 { 0 -01*1 -01 } { 1 -01* -- } loop -1 ] dump } =*dumpList + +x dumpList + +{ { { } } -01 + { =*r =*l + 0 l { + { -1*0 cons } 1 l -- |r r + } rep + } _ * * +} =*reverse + +x reverse dumpList -- cgit v1.2.3