Programming-Idioms

History of Idiom 42 > diff from v17 to v18

Edit summary for version 18 :

Version 17

2015-09-05, 08:54:05

Version 18

2015-09-05, 09:05:35

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Code
sequence_ [ print v | v <- a, [ u | u <- b, u == v] == [] ]
Code
sequence_ [ print v | v <- a, [ u | u <- b, u == v] == [] ]
Comments bubble
a _\\ b abbreviates this task if you are not required to write your own printing iterations
Comments bubble
a _\\ b abbreviates this task if you are not required to write your own printing iterations

Our inner loop breaks lazily and continues the outer as soon as any [u|u==w] growing larger than [] breaks the enclosing list equality test.
Doc URL
http://hackage.haskell.org/package/base/docs/Data-List.html#v:-92--92-
Doc URL
http://hackage.haskell.org/package/base/docs/Data-List.html#v:-92--92-