Affichage des articles dont le libellé est lambdatheultimate. Afficher tous les articles
Affichage des articles dont le libellé est lambdatheultimate. Afficher tous les articles

lundi 22 juillet 2013

Y U NO Y

After finally watching the 1986 SICP HP sessions, and many other videos building languages from nothing but lambdas, I can say I'm almost there for the Y-combinator. This choregraphy of bouncing `objects` (functions or whatever) is a thing of beauty. Wikipedia page on the matter includes some lazy functional example in Haskell :

dummy@x60s_GPT ~ [master *]
± % ghci

GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> let fix f = f (fix f)
Prelude> (fix (\f n -> if n == 0 then 1 else (f (n - 1)) * n)) 5
120
Prelude> -- amazed

samedi 15 juin 2013

jonesforth #0

Trying to learn how to write small Forth interpreter (1), I find a very detailed tutorial (thanks web.archive.org again)(2). It's literal documented assembly you should be able to run through gcc to get native code. Except it doesn't. But someone uploaded it on github (3), so maybe this issue has been documented or fixed. No luck but there's an old blog post with comment mentionning problems close to mine. They're solution actually work (although I don't know gcc options enough to really understand why)(5).

1. http://lambda-the-ultimate.org/node/2452
2. http://web.archive.org/web/20090209003017/http://www.annexia.org/_file/jonesforth.s.txt
3. https://github.com/chengchangwu/jonesforth/
4. http://rwmj.wordpress.com/2010/08/07/jonesforth-git-repository/#comment-6591
5. you will need to recompile without the “-Wl,-Ttext,0″ option to GCC