ClojureCLR v2.1 Release Notes

  • Transducers is a new way to decouple algorithmic transformations from their application in different contexts. Transducers are functions that transform ๐Ÿ— reducing functions to build up a "recipe" for transformation.

    ๐Ÿ‘€ Also see: http://clojure.org/transducers

    Many existing sequence functions now have a new arity (one fewer argument than before). This arity will return a transducer that represents the same logic but is independent of lazy sequence processing. Functions included are:

    • map
    • mapcat
    • filter
    • โœ‚ remove
    • take
    • take-while
    • โฌ‡๏ธ drop
    • โฌ‡๏ธ drop-while
    • take-nth
    • replace
    • partition-by
    • partition-all
    • keep
    • keep-indexed
    • map-indexed
    • distinct
    • interpose

    โž• Additionally some new transducer functions have been added:

    • cat - concatenates the contents of each input
    • ๐Ÿšš dedupe - removes consecutive duplicated values
    • random-sample - returns items from coll with random probability

    And this function can be used to make completing transforms:

    • completing

    There are also several new or modified functions that can be used to apply transducers in different ways:

    • sequence - takes a transformation and a coll and produces a lazy seq
    • transduce - reduce with a transformation (eager)
    • eduction - returns a reducible/iterable of applications of the transducer to items in coll. Applications are re-performed with every reduce/iterator.

    ๐Ÿ‘ There have been a number of internal changes to support transducers:

    • volatiles - there are a new set of functions (volatile!, vswap!, vreset!, volatile?) to create and use volatile "boxes" to hold state in stateful transducers. Volatiles are faster than atoms but give up atomicity guarantees so should only be used with thread isolation.
    • ๐Ÿ‘ array iterators - added support for iterators over arrays
    • conj can be used as a reducing function and will conj to []

    Some related issues addressed during development: