Mike Austin's Blog

Saturday, May 16, 2009

Language amusements

I've been working on my language, Impulse, and can now finally evaluate somewhat amusing expressions:

Impulse
f = x -> (1..x) each: n -> puts: x + n
f eval: 5
Ruby
f = lambda { |x| (1..x).each { |n| puts n * n } }
f.call 5
The Ruby version isn't bad, but it's sure got lots of curlies and bars. Ultimately I want to support predicate blocks, which only evaluate if the predicate is true:

(1..10) map: n [n is-even?] -> n * n

0 Comments:

Post a Comment

<< Home