Skip to content

Comment on Dropbox is hiring a Web Engineerparent

Comments

It's not broken at all, and not in any way peculiar to javascript.

    >>> map(apply, [lambda:i for i in range(5)])
    
    [4, 4, 4, 4, 4]

    * (mapcar 'funcall (loop for i from 0 to 5 collect (lambda () i)))

    (6 6 6 6 6 6)
It's just that the looping constructs don't introduce a new binding, but modify the existing one.
    >>> map(apply, [lambda j=i:j for i in range(5)])
    
    [0, 1, 2, 3, 4]

    * (mapcar 'funcall (loop for i from 0 to 5 collect (let ((j i)) (lambda () j))))
    
    (0 1 2 3 4 5)
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.