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

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]
Tuesday 11 September, 2012
#Mango on GitHub
I've migrated my self-hosted Bazaar repository up into GitHub.
[
Add a comment]
Wednesday 27 October, 2010
#Mango Release. Panic ye not!

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.

The binaries are compiled with Java 6. The code builds fine with Java 5 though, so if you're using that just grab the source. The source bundle includes a javadoc build target, and the current Javadoc is available online, but you can grab the Javadoc seperately too.

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
#Zippy Triples with Groovy and Mango

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!

(Nice work, Jez)
Thomas Guest [e] [w], 22nd May 2010


[Add a comment]

#Zippy triples served with Java and Mango

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,

Laz
Laz Taylor [e] [w], 9th Jun 2010


[Add a comment]

Thursday 13 May, 2010
#Mango Release. You can tell it's summer, the iterators are blooming.
A few years ago, my code-chum Thomas Guest wrote Zippy triples served with Python, a rather good article highlighting some of the neat iterators in the Python standard library. I've added similar iterators to Mango (although they are, of course, a little wordier than their Python originals) - ChainIterator, TeeIterator, ZipIterator - along with a GeneratorIterator and a new ConstantSequence (it makes sense when you see it). Wrapping up this release are new Any and All predicates. The binaries are compiled with Java 6. The code builds fine with Java 5 though, so if you're using that just grab the source. The source bundle includes a javadoc build target, and the current Javadoc is available online, but you can grab the Javadoc seperately too.

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]

[Older news ...]

Get in touch

Your questions, requests, updates and patches are all welcome. I can be contacted at jez@jezuk.co.uk.


Jez Higgins