Mango is a Java library consisting of a number of iterators, algorithms and functions, loosely inspired by the C++ Standard Template Library.
Slides from two talks describing some of the ideas behind Mango are
- Finding the Utility in a
java.util.Iteratorexamines what iteration is, and the uses to which we can put Java Iterators - Iteration: It's just one damn thing after another covers similar ground, but is aimed at a more general audience.
Mango is distributed under the terms of the Lesser GPL and is available for download in source and binary distributions.
Latest News
[RSS 0.91]Wednesday 27 October, 2010
#
Nothing earth shaking. just a small handful of predicates and a sequence. The new predicates are Nand, Nor, Xor, and Xnor which perform the logical operations you expect and OneOf, which evaluates a number of other predicates and returns true if one and only one of those is true. The new sequence is the NullSequence, which returns null after null after null.
- mango-bin.zip (68,267 bytes)
- mango-bin.tar.gz (68,277 bytes)
- mango-src.zip (88,097 bytes)
- mango-src.tar.gz (30,930 bytes)
javadoc build target, and the current Javadoc is available online, but you can grab the Javadoc seperately too. - mango-javadoc.zip (104,691 bytes)
- mango-javadoc.tar.gz (42,454 bytes)
The Mango code lives in a Bazaar repository. You can pull the code from :
bzr branch http://jezuk.dnsalias.net/bzr/mango/trunk
The previous non-generic release, built with Java 1.4, is still available.
[Add a comment]
Friday 21 May, 2010
#
Here's a Groovy version of the Java code below. It's more or less identical to the Python original.
import uk.co.jezuk.mango.Iterators
def prev_this_next(items) {
chain = Iterators.ChainIterator(null, items, null)
(prev, current, next) = Iterators.TeeIterator(chain, 3)
current.next()
next.next()
next.next()
return Iterators.ZipIterator(prev, current, next)
}
long_weekend = ["Friday", "Saturday", "Sunday", "Monday"]
yesterday_today_tomorrow = prev_this_next(long_weekend)
for(ytt in yesterday_today_tomorrow)
println ytt
Zippy, fruity, groovy ... YEAH!
[Add a comment]
#
Here's a fairly direct transliteration of some of the code presented in Thomas Guest's Zippy Triples served with Python. As you might anticipate, it's a little wordier than the Python original, but it's still a nice example of using iterators in an unusual way to neatly solve a problem.
import java.util.Iterator;
import java.util.List;
import uk.co.jezuk.mango.Collections;
import uk.co.jezuk.mango.Iterators;
public class ZippyTriples
{
static public void main(final String[] args)
{
List<String> long_weekend = Collections.list("Friday", "Saturday", "Sunday", "Monday");
Iterator<List<String>> yesterday_today_tomorrow = prev_this_next(long_weekend);
while(yesterday_today_tomorrow.hasNext())
{
List<String> ytt = yesterday_today_tomorrow.next();
for(String d : ytt)
{
System.out.print(d);
System.out.print(" ");
}
System.out.println();
}
}
static Iterator<List<String>> prev_this_next(final List<String> items)
{
Iterator<String> chain = Iterators.ChainIterator(null, items, null);
List<Iterator<String>> prev_this_next = Iterators.TeeIterator(chain, 3);
Iterator<String> prev = prev_this_next.get(0);
Iterator<String> current = prev_this_next.get(1);
Iterator<String> next = prev_this_next.get(2);
current.next();
next.next();
next.next();
return Iterators.ZipIterator(prev, current, next);
}
}
Hello,very nice example. Are You also programming in PHP?
It is better and more friendly than Python I think.
Regards,
[Add a comment]
Thursday 13 May, 2010
#
- mango-bin.zip (64,441 bytes)
- mango-bin.tar.gz (64,476 bytes)
- mango-src.zip (80,379 bytes)
- mango-src.tar.gz (30,600 bytes)
javadoc build target, and the current Javadoc is available online, but you can grab the Javadoc seperately too. - mango-javadoc.zip (103,181 bytes)
- mango-javadoc.tar.gz (40,282 bytes)
The Mango code lives in a Bazaar repository. You can pull the code from :
bzr branch http://jezuk.dnsalias.net/bzr/mango/trunk
The previous non-generic release, built with Java 1.4, is still available.
[Add a comment]
Thursday 05 November, 2009
#
Over the past three or four weeks I've restarted work on Mango, dragging it into the modern age by throwing out the deprecated bits, making one or two little nips and tucks, and by generifying (if that's a real word) the library. So, I've cut a new release.
- mango-bin.zip (54,231 bytes)
- mango-bin.tar.gz (54,285 bytes)
- mango-src.zip (68,847 bytes)
- mango-src.tar.gz (25,146 bytes)
javadoc build target, and the current Javadoc is available online, but you can grab the Javadoc seperately too. It's not overflowing with words, if I'm honest, because the concepts Mango uses are pretty straightforward, but hopefully the Javadoc's not without its uses.
- mango-javadoc.tar.gz (101,603 bytes)
- mango-javadoc.tar.gz (38,392 bytes)
The Mango code is now lives in a Bazaar repository. You can pull the code from :
bzr branch http://jezuk.dnsalias.net/bzr/mango/trunk
The previous non-generic release, built with Java 1.4, is still available.
[Add a comment]
[Older news ...]
Get in touch
Your questions, requests, updates and patches are all welcome. I can be contacted at jez@jezuk.co.uk.