Skip to content

Instantly share code, notes, and snippets.

@draftcode
Created October 7, 2010 06:54
Show Gist options
  • Save draftcode/614683 to your computer and use it in GitHub Desktop.
Save draftcode/614683 to your computer and use it in GitHub Desktop.
fun {Flatten Xs}
case Xs
of nil then nil
[] X|Xr andthen {IsList X} then
{Append {Flatten X} {Flatten Xr}}
[] X|Xr then
X|{Flatten Xr}
end
end
fun {Flatten Xs}
proc {FlattenD Xs E}
case Xs
of nil then E
[] X|Xr andthen {IsList X} then
{FlattenD X {FlattenD Xr E}}
[] X|Xr then
X|{FlattenD Xr E}
end
end
in {FlattenD Xs nil} end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment