Loop over multiple arrays simultaneously: Difference between revisions

→‎{{header|Haskell}}: Expanded the ZipList example a little
(Loop over multiple arrays simultaneously in Yabasic)
(→‎{{header|Haskell}}: Expanded the ZipList example a little)
Line 2,128:
 
<syntaxhighlight lang="haskell">{-# LANGUAGE ParallelListComp #-}
main = sequence [ putStrLn [x, y, z] | x <- "abdabc" | y <- "ABC" | z <- "123"]</syntaxhighlight>
 
'''Using Transpose'''
Line 2,135:
 
<syntaxhighlight lang="haskell">import Data.List
main = mapM putStrLn $ transpose ["abdabc", "ABC", "123"]</syntaxhighlight>
 
'''Using ZipWith*'''
Line 2,150:
main =
mapM_ putStrLn $
getZipList $
( (\x y z -> [x, y, z])
<$> ZipList "abdabc"
<*> ZipList "ABC"
<*> ZipList "123"</syntaxhighlight>
)
<> getZipList
( (\w x y z -> [w, x, y, z])
<$> ZipList "abcd"
<*> ZipList "ABCD"
<*> ZipList "1234"
<*> ZipList "一二三四"
)</syntaxhighlight>
{{Out}}
<pre>aA1
bB2
cC3
aA1一
bB2二
cC3三
dD4四</pre>
 
=={{header|Haxe}}==
9,655

edits