Show Navigation
Conversation
Notices
-
@pho4cexa Things like list comprehension syntax basically aren't a thing in curried languages like Haskell, because functions are so composable you can express it in the base syntax.
And of course, in a lazy language generators aren't a thing because what would be arrays behave like generators.
-
@clacke @pho4cexa defo list comprehension in Haskell
[ x*x | x <- [1..10]]
[1,4,9,16,25,36,49,64,81,100]
-
@kat @pho4cexa Schooled! Thank you.
-
@kat @pho4cexa Ah! But is that using the List monad and not the LISP-like lists matched like x:xs?
-
@kat @pho4cexa Ok, they seem to be the same thing.
> Prelude> let head x:xs = x
> Prelude> head [(+1) i | i <- [1..]]
> 2
-
@kat @pho4cexa In my trivial example though, I'm not so sure the comprehension buys any readability. This is shorter and less cluttered:
> Prelude> head . map (+1) $ [1..]
> 2
-
@clacke @pho4cexa http://qttr.at/20nx http://qttr.at/20nw Lists are just nested con? It's part of Prelude.
-
@kat @pho4cexa Seems that way. I just wrote my first couple of lines of this language, so. :-)
Apparently head is actually called head, so no need to define it. :-)
-
@clacke @pho4cexa Oh me too, I just started with it, after playing with Python lambda calculus over the summer. http://qttr.at/20ny
-
@kat @pho4cexa Seems it's both. Intriguing!
Prelude> head $ [1..] >>= return . (+1)
2