Skip to content

Instantly share code, notes, and snippets.

@ravinggenius
Last active October 6, 2016 16:25
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 ravinggenius/825e9a1a69916058e147 to your computer and use it in GitHub Desktop.
Save ravinggenius/825e9a1a69916058e147 to your computer and use it in GitHub Desktop.
System.List.flatten
System.List = class<T> {
flatten = => {
-> (list<System.List>) {
switch (list.count) {
case (0) { list }
case (1) { [ self(list.head) ] }
else { [ ...self(list.head), ...self(list.tail) ] }
}
}
-> (object<System.Object>) { object }
}
@.flatten = -> {
@.type.flatten(@)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment