Show HN: Lambduck, a Functional Programming Brainfuck
70 points| jorkingit | 9 months ago |imjakingit.github.io
The interpreter implemetation is pretty bad. It's not very fast, it's not very good, and it's probably not very correct. But maybe there's some vaguely interesting programs you could write with it!
For example, the Y combinator:
λf. (λx. f (x x)) (λx. f (x x))
is written as: \` \`1 `0 0 \`1 `0 0
tromp|9 months ago
Note that it's also possible to do I/O without additional primitives, as demonstrated in [1].
[1] https://www.ioccc.org/2012/tromp/
jorkingit|8 months ago
And yup, the order of evaluation is leftmost innermost.
with stdin "hi" will print "hi".mmoskal|9 months ago
Also, this is likely way more compact than Brainfuck, as the lambda calculus is written essentially as usual.
And seriously, very cool!
jorkingit|9 months ago
catlifeonmars|8 months ago
2d8a875f-39a2-4|9 months ago
unknown|9 months ago
[deleted]
90s_dev|9 months ago
How do you get the hello world working?
I tried pasting ,--('\< into the code and if it walks like a lamb and quacks like a duck into the stdin field.
jorkingit|9 months ago
somat|8 months ago
Anyhow, This is far too clear and straightforward, the bf analog to scheme would probably be unlambda, an implementation of the lambda calculus without lambda forms.
http://www.madore.org/~david/programs/unlambda/
jorkingit|8 months ago
I'm not sure if I would characterize Brainfuck as a stack language, but I suppose if you considered all the operators to be unary stack operations I could see it!
stronglikedan|8 months ago
I could guess the age of the author based on this. Seems like history gets rolled up to generalizations after a while.
sph|8 months ago
Please share the interpreter’s code, however bad you feel it is.
Also, definition of de Bruijn index for those of us without formal education: https://en.m.wikipedia.org/wiki/De_Bruijn_index
jorkingit|8 months ago
reuben364|8 months ago
jorkingit|8 months ago
Good call! I got rid of all numbers above 2, I can't count that high anyway ;-)
naikrovek|8 months ago
reverendsteveii|8 months ago
jzemeocala|9 months ago