Skip to content

Instantly share code, notes, and snippets.

@emmanuelrosa
Created June 3, 2018 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emmanuelrosa/da360b568b24d8f87b38eb2f4a2258e7 to your computer and use it in GitHub Desktop.
Save emmanuelrosa/da360b568b24d8f87b38eb2f4a2258e7 to your computer and use it in GitHub Desktop.
Why does folding arrays differ from folding lists?
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