Re:Kotlin: A Language with a Bright Future
by dmitriid on Monday November 20, 2017 @02:40PM
(#15742557)
I wish they'd leave the math notation as is. Haskell's and Erlang's notations which keep it (maybe with slight modifications) are so much nicer and readable.
Erlang [1]:
[X || X <- [1,2,a,3,4,b,5,6], X > 3].
Pythagorean triplets
[ {A,B,C} ||
A <- lists:seq(1,N),
B <- lists:seq(1,N),
C <- lists:seq(1,N),
A+B+C =< N,
A*A+B*B == C*C
].
[1] http://erlang.org/doc/programming_examples/list_comprehensio...
Re:Kotlin: A Language with a Bright Future
by actsasbuffoon on Monday November 20, 2017 @12:10PM
(#15741400)
That's because Python's list comprehensions were derived from Haskell's implementation: https://wiki.python.org/moin/PythonVsHaskell#List_Comprehens...:
As per https://wiki.haskell.org/List_comprehension , many Haskell users prefer to use do syntax (indeed I wasn't aware that the list comprehension syntax existed).
Re:Kotlin: A Language with a Bright Future
by actsasbuffoon on Monday November 20, 2017 @01:53PM
(#15742158)
Agreed, I never use list comprehensions in Haskell. I feel like they're almost always harder to read.
https://en.wikipedia.org/wiki/Set-builder_notation#Sets_defi...