
27 Feb
2021
27 Feb
'21
9:29 p.m.
Il 27 febbraio 2021 alle 18:07 A. Mc. ha scritto:
Hello,
What is the best way to take: [1, 2, 3, 4 ]
And convert it to:
[ [ [ 1 ], [ 2 ] ], [ [3]. [4] ] ]
so that each member pair is:
[ [1], [2] ]
roughly analogous to a 1x2 vector?
A 1×2 vector would be
[[1 2], [3, 4]]
am I wrong? If so, a quick and dirty solution could be d2 :: [a] -> [[a]] d2 [] = [] d2 [a] = error "odd element" d2 as = let (is, es) = splitAt 2 as in is : d2 es -- λ> d2 [1..6] -- [[1,2],[3,4],[5,6]]