News for hackers. Stuff that matters.
Re:Comparison of Haskell and Julia List Comprehensions by dmitriid on Wednesday July 07, 2021 @03:39PM (#27764983)
Haskell and Erlang basically go for mathematical notation. Python and Julia more or less go for how you read those notations.

I personally prefer math-like notation because I find it much more readable and composable.

  x, such as x is in xs, xs is in xss

  x | x ∈ xs, xs ∈ xss # my math is rusty
 
  [x | x <- xs, xs <- xss] # haskell, erlang is isimilar

  [ x for xs in xss for x in xs ] # python, julia, order might be different

As soon as you add conditions/filters on data, math-like notation wins hands down

Edit:

Since I don't know Haskell, apparently in Haskell the order is wrong. So, only Erlang gets it right (variables are upper case in Erlang):

  [ X || X <- Xs, Xs <- Xss]
Re:Comparison of Haskell and Julia List Comprehensions by jolmg on Wednesday July 07, 2021 @05:34PM (#27765974)
> only Erlang gets it right... [ X || X <- Xs, Xs <- Xss]

I don't have much experience with Erlang, but that also seems wrong:

  1> Xss = [[1]].
  [[1]]
  2> [ X || X <- Xs, Xs <- Xss].  
  * 1:13: variable 'Xs' is unbound
  3> [ X || Xs <- Xss, X <- Xs].
  [1]
Re:Comparison of Haskell and Julia List Comprehensions by dmitriid on Wednesday July 07, 2021 @06:04PM (#27766233)
Damnit. I haven't used Erlang in a long time, but I should've known that.

So, no language does it "right".

Re:Comparison of Haskell and Julia List Comprehensions by sundarurfriend on Wednesday July 07, 2021 @11:24PM (#27768173)
Note that in Julia, ∈ is a synonym of `in`, so a minor improvement towards your preferred notation can be:

    [ x for xs ∈ xss for x ∈ xs ]