Skip to content


I’ve been working on getting some classic List utilities into haXe, and there’s a package now called ListTools on haxelib that has some common functions.

You’ll want to include the library ListTools inside your build file as normal.  Most of the methods are self explanatory.  However, some are a little more complex.

  1. The zip(), chain(), and other Iterable<Iterable<T>> routines have the same caveats as for IterTools.
  2. There’s a generic “groupBy” routine that uses a List of Lists rather than the Hash based versions in HashTools.  This is useful if you need to index by something other than a String or Int.  However, it’s also slower.
  3. The same caveats for IterTools.starmap() also apply for the ListTools version.

You can check out the generated haxe documentation here.

One more thing worth mentioning is the fact that ListTools produces ListTypes instead of Lists.  ListTypes are typedefs for List, but they can be switched to an alternate List class at compile time with the flag ‘-D sugarlist’.  This uses a SugarList type.  The SugarList type will work wherever a normal List is called for, and it’ll be faster for iteration in Flash targets (since it does not use Arrays).  You can find information about the SugarList class here.  The method names/behavior are identical to List, except that there’s some additional variables to handle the pointer based list structure, and some additional methods to handle insertion routines.

%d bloggers like this: