Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Created December 13, 2011 02:10
Show Gist options
  • Save robotlolita/1470126 to your computer and use it in GitHub Desktop.
Save robotlolita/1470126 to your computer and use it in GitHub Desktop.
Collection API -- 4th attempt
Module collection
Interface Iterator<C<E>>
next :: (E, C<E> -> Ignored Any) -> Promise
exhausted_p :: () -> Bool
Interface Traversable<C<E>>
each :: C<E>, (E, C<E> -> Ignored Any) -> Undefined
Interface Building<C<E>>
add :: C<E>, value:E -> C<E>
remove :: C<E>, value:E -> C<E>
replace :: C<E>, value:E, replacement:E -> C<E>
clear :: C<E> -> C<E>
Interface Set<C<E>>
union :: C<E>, C<E> -> C<E>
intersection :: C<E>, C<E> -> C<E>
difference :: C<E>, C<E> -> C<E>
subset :: C<E>, C<E> -> C<E>
Interface Inspection<C<E>>
size :: C<E> -> Number # `Infinity' for infinite collections
empty_p :: C<E> -> Bool
has_p :: C<E>, value:E -> Bool
Interface Folding<C<E>>
reduce :: C<E>, (prev:E, current:E -> Any) -> Any
every :: C<E>, (E, C<E> -> Bool) -> Bool
some :: C<E>, (E, C<E> -> Bool) -> Bool
filter :: C<E>, (E, C<E> -> Bool) -> C<E>
map :: C<E>, (E, C<E> -> E) -> C<E>
Module mapping
Interface Traversable<M<K, E>>
each :: M<K, E>, (E, K, M<K, E> -> Ignored Any) -> Undefined
Interface Manipulating<M<K, E>>
at :: M<K, E>, key:K -> E
put :: M<K, E>, key:K, value:E -> E
remove :: M<K, E>, key:K -> M<K, E>
clear :: M<K, E> -> M<K, E>
Interface Inspection<M<K, E>>
size :: M<K, E> -> Number # Always finite (number of elements in the mapping)
empty_p :: M<K, E> -> Bool
has_key_p :: M<K, E>, key:K -> Bool
Interface Decomposition<M<K, E>>
keys :: M<K, E> -> [K]
values :: M<K, E> -> [E]
items :: M<K, E> -> [[K, E]]
Interface Folding<M<K, E>>
reduce :: M<K, E>, (prev:E, current:E -> Any) -> Any
every :: M<K, E>, (E, K, M<K, E> -> Bool) -> Bool
some :: M<K, E>, (E, K, M<K, E> -> Bool) -> Bool
filter :: M<K, E>, (E, K, M<K, E> -> Bool) -> M<K, E>
map :: M<K, E>, (E, K, M<K, E> -> E) -> M<K, E>
Module sequence
Interface Sequence<E> ⋃ Traversable<UInt32, E>, Building<E>, Manipulating<UInt32, E>, Folding<UInt32, E>, Set<E>, Inspection<E>
length :: UInt32
Interface Slicing<E>
first :: [E] -> E
rest :: [E] -> [E]
last :: [E] -> E
but_last :: [E] -> [E]
slice :: [E], start:Number, end:Number -> [E]
take :: [E], Number -> [E]
drop :: [E], Number -> [E]
split :: [E], (E, UInt32, [E] -> Bool) -> [[E]]
Interface Sort<E>
sort :: [E], (current:E, next:E -> Number) -> [E]
reverse :: [E] -> [E]
Interface Searching<E>
find_first :: [E], value:E -> Number
find_last :: [E], value:E -> Number
Interface Stack<E>
push :: [E], value:E -> [E]
pop :: [E], value:E -> [E]
Interface Queue<E>
shift :: [E], value:E -> [E]
unshift :: [E], value:E -> [E]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment