[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: call/cc
> Here's a little bit of interlingual comparison --- what does it take
> to construct a new anonymous function that adds its two arguments and
> apply it to two numbers?
>
> Perl: sub { $_[0] + $_[1] }->(3, 5) 18 tokens ($_ and -> are
> 1 token each)
> JavaScript: function(x, y){return x + y}(3, 5)
> 17 tokens
> Lisp: ((lambda (x y) (+ x y)) 3 5) 16 tokens
> Smalltalk: [:x :y | x + y] valueWithArguments: #(3 5)
> 15 tokens
> Python: (lambda x, y: x + y)(3, 5) 15 tokens
> OCaml: (fun x y -> x + y) 3 5 10 tokens
> Haskell: (\x y -> x + y) 3 5 10 tokens (\x is 2
> tokens, -> is 1)
> FORTH: marker foo 3 5 :noname + ; execute foo
> 9 tokens (explicit cleanup)
> FORTH: 3 5 :noname + ; execute 6 tokens (cheating because no GC)
> PostScript: 3 5 {add} exec 6 tokens
> dc: 3 5 [+] x 6 tokens
Curl: {proc {x, y} {return x + y}}