[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: call/cc



I think these numbers are a little misleading because
mandatory whitespace, though an expressive element 
(i.e. the meaning of the program changes if you take 
it out) is not counted as a token. What would the numbers
be if you counted mandatory whitespace?  Here's Scheme's
entry:  

((lambda(x y)(+ x y))3 5)        20 elements

--- Christopher Barber <cbarber@curl.com> wrote:
> 
> > 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}}
> 
> 


__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com