Programming-Idioms

History of Idiom 42 > diff from v18 to v19

Edit summary for version 19 :

Version 18

2015-09-05, 09:05:35

Version 19

2015-09-05, 09:08:51

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 inner loop breaks lazily and continues the outer as soon as any [u|u==w] growing larger than [] breaks the enclosing 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 already whenever the inner loop breaks lazily for any [u|u==w] found growing larger than [] and thus breaking its contextual 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-