Loop over multiple arrays simultaneously: Difference between revisions
Loop over multiple arrays simultaneously (view source)
Revision as of 08:41, 22 March 2023
, 1 year ago→{{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 <- "
'''Using Transpose'''
Line 2,135:
<syntaxhighlight lang="haskell">import Data.List
main = mapM putStrLn $ transpose ["
'''Using ZipWith*'''
Line 2,150:
main =
mapM_ putStrLn $
getZipList
( (\x y z -> [x, y, z])
<$> ZipList "
<*> ZipList "ABC"
<*> ZipList "123"
)
<> 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}}==
|