5 ms·
Ruby 1.9 and Lambda Calculus
- KirinDave 18y ago> The “->” is supposed to be read as a lambda (λ), since relying on unicode characters in code is generally bad news. Interesting. Why? Personally I would radically prefer the λ and any competent editor could make it a single keystroke if it doesn't already. I really wish we did use more unicode in our source code. "≠", for example, is much clearer to me than "!=".
- msie 18y agoWouldn't unicode in source code break a lot of UNIX utilities or render them useless? Just askin'
- tokipin 18y agoHaskell uses \, which isn't too far from λ. it also reads better than -> imo
- etal 18y agoQi uses /. as lambda; that's pretty close. I like Haskell's decisions as well. There's also the literate programming route: enter the code as ASCII, then run it through a processor to generate a prettier document for reading.
- celoyd 18y agoFor some interesting examples of integrated Unicode, have a look at Project Fortress, Guy L. Steele's Fortran-killer.
- pavelludiq 18y ago->(f){f.(3)}.(->(x){x+2}) vs (lambda f: f(3))(lambda x: x+2) the first one(ruby) requires me to press the shift key 6 times, the python version only 2, but on the other hand i have to write "lambda" twice. I say they are even :)
- jamongkad 18y agoHaven't read the article yet but I find the python version much more readable.
- KirinDave 18y agoUnfortunately, the python one is much less functional. Complain to your local python guru about the lack of real lambdas, today!
- deleted 18y ago[deleted]
- Freaky 18y agoExcept the Ruby version won't run away and cry if you try to do anything even slightly more complex in it. Also you can still type "lambda" if you really want to.
- pavelludiq 18y agook, how about this one: ((lambda (f) (f 3))(lambda (x) (+ x 2)))
- etal 18y agoAll the visual appeal of oatmeal with fingernail clippings mixed in. Actually, I do prefer ASCII for anything that isn't already a convention in math -- parens to group expressions, curly braces for sets, etc.