Created
June 3, 2018 04:23
-
-
Save emmanuelrosa/da360b568b24d8f87b38eb2f4a2258e7 to your computer and use it in GitHub Desktop.
Why does folding arrays differ from folding lists?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (text) | |
import Array as A | |
import List as L | |
main = | |
let | |
a = A.length <| flattenA arrays | |
b = L.length <| flattenL lists | |
in | |
text <| toString (a == b) | |
arrays = A.repeat 3 1 |> A.repeat 3 | |
lists = L.repeat 3 1 |> L.repeat 3 | |
flattenA plane = plane |> A.foldr A.append (A.fromList []) | |
flattenL plane = plane |> L.foldr L.append [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment