swarm-0.6.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Util.OccurrenceEncoder

Description

Useful for compressing the representation of a structure that has many repeating elements for transmission (e.g. over the network).

Synopsis

Documentation

runEncoder :: (Traversable t, Ord b) => t b -> (t Int, [b]) Source #

Given a data structure that may have many repeating "complex" elements, will store the "complex" element representation in an array so that the structure's elements can be replaced with simple indices into that array.

The first encountered element is assigned index 0, and the next novel element encountered gets index 1, and so on.