Home
Insert
Update snippet 'Flatten Nested Type'
Title
Passcode
Description
Flatten Nested Type
Source code
type NestedType<'a> = List of NestedType<'a> list | E of 'a let flatten ls = let rec start temp input = match input with | E e -> e::temp | List es -> List.foldBack(fun x acc -> start acc x) es temp start [] ls // test (a (b (c d) e))) (List [E "a"; List [E "b" ; List [E "c"; E "d"]; E "e"]]) |> flatten = ["a";"b";"c";"d";"e";]
Tags
flatten
flatten
Author
Link
Reference NuGet packages
If your snippet has external dependencies, enter the names of NuGet packages to reference, separated by a comma (
#r
directives are not required).
Update