News for hackers. Stuff that matters.
Re:Why Every Language Needs Its Underscore by wging on Sunday June 22, 2014 @12:24PM (#7928283)
I'm also out of love with python for similar reasons, but please note that map is lazy in python 3.

    >>> map(lambda x: x*2, range(100000000000000000000))
    <map object at 0x104792240>
Re:Why Every Language Needs Its Underscore by Suor on Sunday June 22, 2014 @12:28PM (#7928296)
It's not lazy, it returns iterator. There is a difference, you can't slice or index its result anymore. Compare to Clojure or Haskell map, which are truly lazy.
Re:Why Every Language Needs Its Underscore by e12e on Sunday June 22, 2014 @12:51PM (#7928373)
To be fair, the syntax might not be as clean, but isn't:

    m = map(lambda x: x*2, range(100000000000000000000))
    i = itertools.islice(m, 10**6, None)
    next(i)
Somewhat equivalent? This does seem a little slow calculating the first million squares, but subsequent calls to next(i) are snappy(ish).

I'm not sure how close you could get to "truly" lazy sequences combining count, zip and slice, though.

Re:Why Every Language Needs Its Underscore by scottdw2 on Sunday June 22, 2014 @02:05PM (#7928631)
This is a nitpick, but it is lazy.

It's not represented in head normal form, but it's still lazy.

The limitations you mentioned are not an artifact of the implementation being eager(because it's not eager), but instead are an artifact of the representation used.

Re:Why Every Language Needs Its Underscore by judk on Sunday June 22, 2014 @01:07PM (#7928440)
Is it true that this is O(1) in Haskell? (Making up function names but you get the idea)

    (fmap a function anArray) `get` n
?

How does fmap construct its value?

Re:Why Every Language Needs Its Underscore by codygman on Monday June 23, 2014 @01:01AM (#7930330)
How fmap constructs it's value depends on how that type implements the functor typeclass I believe.