Loops/Nested: Difference between revisions

Content added Content deleted
(added haskell: no explicit for loops)
(→‎{{header|Haskell}}: introducing a break-inclusive function)
Line 207:
<lang haskell>import Data.List
 
taskLLBbreakIncl kp = map (uncurry ((. take 1). (++)). break (==k)).p
 
uncurry ((. take 1). (++)). break (k`elem`)</lang>
taskLLB k = map (breakIncl (==k)). breakIncl (k`elem`)</lang>
Example:
<lang haskell>mij :: [[Int]]
Line 214 ⟶ 215:
[2, 6, 17, 5, 14, 1, 9, 11, 18, 10, 13, 20, 8, 7, 4, 16, 15, 19, 3, 12]
 
*Main> mapM_ (mapM_ print) $ taskLLB 20 mij
2
[2,6,17,5,14]
6
[1,9,11,18,10]
17
[13,20]</lang>
5
14
1
9
11
18
10
13
[13,20]</lang>
 
=={{header|J}}==