Skip to content

Instantly share code, notes, and snippets.

View NicolasT's full-sized avatar

Nicolas Trangez NicolasT

View GitHub Profile
import itertools
# Utilities
# Using curried form
# Split an iterable at a point where some given predicate is met
split_at = lambda f: lambda l: \
(itertools.takewhile(lambda e: not f(e), l), itertools.dropwhile(lambda e: not f(e), l))
# Append an element to a list
module Main where
-- A MoreList is either a More value which contains a list of MoreList's, or
-- an Elem value, which contains a single value of type a
data MoreList a = More [MoreList a]
| Elem a
flatten :: MoreList a -> [a]
flatten (Elem a) = [a]