After reading about collections in ruby and c#, i'm thinking about how to add collections to pluk.
Collection libraries seem to have become part of what people expect from a language, and seem to basicly consider it a part of it.
Not unreasonably seeing how things like foreach directly talk to its api.
So i'm designing the baseclass that will back most collections, and probably some other 'containers'.
abstract class Iteratable<T>
{
Iterator<T> createIterator;
Iteratable<T> copy();
Iteratable<T> filter(Bool(T) predicate);
Iteratable<U> map<U>(U(T) converter);
Iteratable<T> take(Int count);
Iteratable<T> drop(Int count);
void foreach(void(T) action);
U fold<U>(U(U, T) folder, U base);
Bool exists(Bool(T) predicate);
Bool all(Bool(T) predicate);
Bool none(Bool(T) predicate);
}
Things like Sum / Min / Max / Average / Aggregate can be easily be used through the fold method, and so can exists/all/none. Inclusion of directer methods should depend on how commonly something is used, and if it actually saves work/thinking in the long run.
Methods like filter do not return an iteratable with the filtered data but an iteratable that when queried filters based on the filter function from the original iteratable on demand.
This way of lazy processing is more memory efficient generally.
This interface should allow additional syntax sugar like C# LINQ to work with pluk collections.