diff options
author | Marvin Borner | 2023-03-05 14:44:40 +0100 |
---|---|---|
committer | Marvin Borner | 2023-03-05 14:45:16 +0100 |
commit | ca808bc09373f123514bf865a4518bebac3bbbc3 (patch) | |
tree | c57c4620cd603a8fccc1228ce2aed246ea7c3ac6 /samples | |
parent | 6b7eb467fef16141760e8eb8a151fecb508675e1 (diff) |
Monadic list/io interface
Diffstat (limited to 'samples')
-rw-r--r-- | samples/interpreters/blc.bruijn | 4 | ||||
-rw-r--r-- | samples/io/echo.bruijn | 5 | ||||
-rw-r--r-- | samples/io/reverse.bruijn | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/samples/interpreters/blc.bruijn b/samples/interpreters/blc.bruijn deleted file mode 100644 index f40bd4a..0000000 --- a/samples/interpreters/blc.bruijn +++ /dev/null @@ -1,4 +0,0 @@ -# TODO: understand and reverse engineer this mess -# by Tromp/Jart - -main [(([(0 0)] [[[(((0 [[[[(2 [((4 (2 [((1 (2 [[(2 [((0 1) 2)])]])) (3 [(3 [((2 0) (1 0))])]))])) ((0 (1 [(0 1)])) [((3 [(3 [(1 (0 3))])]) 4)]))])]]]]) (2 2)) 1)]]]) [(0 ([(0 0)] [(0 0)]))])] diff --git a/samples/io/echo.bruijn b/samples/io/echo.bruijn index 192bab1..b17bda1 100644 --- a/samples/io/echo.bruijn +++ b/samples/io/echo.bruijn @@ -1,4 +1,9 @@ # "echo text | bruijn echo.bruijn" +:import std/Monad . + # returning the binary encoded argument ⇒ echo main [0] + +# alternative using monads +main* read >>= return diff --git a/samples/io/reverse.bruijn b/samples/io/reverse.bruijn index 7a3553f..d5a0597 100644 --- a/samples/io/reverse.bruijn +++ b/samples/io/reverse.bruijn @@ -1,6 +1,8 @@ # "echo tacocat | bruijn reverse.bruijn" :import std/List . +:import std/Combinator . +:import std/Monad . # stdin is encoded as binary numbers in a list # reversing the list reverses the input! |