dharmik

@dharmik@linuxusers.in

admin @ linuxusers.in
student. mostly computers.

matrix@spiderham:matrix.org
codeshithttps://github.com/dhrm1k
bloghttps://dhrm1k.github.io

46 following 17 followers

0 ★ 0 ↺
in reply to »

dharmik »
@dharmik@linuxusers.in

@billy@fosstodon.org what’s the syntax of list comprehension in . show me.

...

Billy »
@billy@fosstodon.org

@dharmik As an example, here's a list comprehension that just creates a list of integers from 1 to 10 and doubles them:

[x*2 | x <- [1..10]]

You can additionally tack on predicates, so you could do the same operation, but only for the odd numbers in the range:

[x*2 | x <- [1..10], x `mod` 2 == 1]

I read about them on learnyouahaskell.com/starting-

History