On Tue, Jul 13, 2010 at 9:50 PM, Maciej Piechotka <[email protected]> wrote:
>
> Important:
> Iterable<G>
> - A fold(A ()(A, G), A) or A foldl(A ()(A, G), A) - Left fold.
> Can be implemented in terms of Iterable (I shown it in previous e-mail)
> - Iterator<A> scan(A ()(A, G), A) or Iterator<A> scanl(A ()(A,
> G), A) - as fold but returns partial results in iterator
> - Iterator<G> filter(boolean ()(G)) - returns iterator skipping
> elements for which predicate does not hold
> BidirIterable<G>
> - A rfold(A ()(G, A), G) or A foldr(A ()(G, A), A) - Right fold
> - BidirIterator<A> rscan(A ()(A, G), A) or Iterator<A> scanr(A
> ()(A, G), A) - as scan but goes from end.
> Iterable<G> (some of them. Probably should return the 'self' type)
> - Iterable<A> map(A ()(G))
> Iterator<G> or Iterable<G> (I assume iterator)
> - Iterator<(G, A)> zip(Iterator<A>) - combines elements from both
> iterators as they go
> - Iterator<A> zipWith(A ()(G, B), Iterator<G>) - combine elements
> from both iterators puts them into function and returns the
>
> (+ zip3/4/5 etc.)
>
> Haskell utils (make code nice but they aren't strictly so useful. Often
> can be simply extention of previous):
> Iterable<G>:
> - boolean all (boolean ()(A)) - returns true if predicate is true
> for each element of collection
> - boolean any (boolean ()(G)) - similar to previous
> - Iterator<G> drop(int) - returns iterator skipping n first elements
> - Iterator<G> dropWhile(boolean G()) - skips elements from the
> beginning which hold the predicate
> - Iterator<G> take(int) - last element is n-th element (or earlier)
> - Iterator<G> takeWhile(boolean G()) - iterator returns element
> when it holds predicate
> Iterator<G>:
> - void skip(int) - skip n elements (moves iterator forward)
> - void skipWhile(bool ()(G)) - skip elements from the beginning
> that follow the predicate (moved iterator forward)
> Utils class??? Not needed in non-pure language?
> - Iterator<A> execute(Iterator<A ()>)
Adding:
If we're working with external iterators, some collection methods
would be nice to have too:
void collect(Collection<G>) - iterates through the iterator and builds
up a collection
void partition(boolean()(G), Collection<G>, Collection<G>) -
partitions the iterable into two collections, based on a predicate
And I'd like to have a "reshape" operator that returns an iterator
over a list of iterators that start at every nth element and iterate
over the next n elements, but I don't know how practical that would
be. Use case is if you have a collection of m*n elements that you want
to treat as a 2D collection of m rows of n columns each, so you could
say
foreach (ListIterator<int> row in m.every(n)) {
foreach (int element in row) {
...
}
}
martin
_______________________________________________
libgee-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/libgee-list