Logo

Programming-Idioms

History of Idiom 42 > diff from v19 to v20

Edit summary for version 20 by :

Version 19

2015-09-05, 09:08:51

Version 20

2015-09-05, 09:11:42

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

Our outer loop continues already whenever the inner loop breaks lazily for any [u|u==w] found growing larger than [] and thus breaking its contextual list equality test.
Comments bubble
a _\\ b abbreviates this task if you are not required to write your own printing iterations

Our outer loop continues to the next element whenever the inner list equality test breaks lazily after the first of any [u|u==w] found growing larger than the tested [].
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-