News for hackers. Stuff that matters.
Re:Do notation considered harmful by jhomedall on Wednesday April 29, 2020 @11:10AM (#23020171)
This:

  do 
    x <- ["a","b","c"]
    y <- ["d","e","f"]
    return (x ++ y)
evaluates to:

  ["ad","ae","af","bd","be","bf","cd","ce","cf"]
Note that this is _not_ equivalent to:

  ["a", "b", "c"] ++ ["d", "e", "f"]
which would instead evaluate to

  ["a","b","c","d","e","f"]


The Python equivalent would be:

  [(a + b) for a in ["a", "b", "c"] for b in ["d", "e", "f"]]
Which evaluates to:

  ['ad', 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'ce', 'cf']
Re:Do notation considered harmful by Raidion on Wednesday April 29, 2020 @12:28PM (#23021039)
As someone who does not program in functional languages, this really really helps clear up the article and surrounding discussion. Good stuff!
Re:Do notation considered harmful by dllthomas on Thursday May 07, 2020 @05:33PM (#23108634)
On the other hand, as someone with a bit of Haskell background, this doesn't even seem weird (except the use of String over Text).