Skip to content

A simple additional functional programming support for Java 8+.

Notifications You must be signed in to change notification settings

codeanddonuts/torus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍩 Torus

A simple additional functional programming support for Java 8+.


1. Applicative Functor

  • Apply(f(a -> b -> ...) <*> a ...) and lift((a -> b -> ...) <$> a <*> b ...) functions for List, Stream, Optional and CompletedFuture classes.
  • Functions to be applied must be in curried a form.

2. Curry

  • Currying for uncurried functions.
  • Parameter order flipping for curried functions.
  • Currying supports functions with upto 4 parameters.

3. List Splitter

  • Splits a list to chunks of size N. Returns List<List<T>>.

4. Tuple

  • Pair(2-Tuple) and Triplet(3-Tuple) classes with zip/unzip functions from/to lists or streams.
  • Zip function packs Nth elements from each lists or streams and converts them to stream of tuples.
  • Tuples contain elements of heterogeneous types.

5. Collection Manipulation Wrappers

  • Returns the collection itself after manipulations.
  • e.g. ThisList.sort(l) returns the list itself after sorting, compared to void of java.util.Collections.sort(l).
  • Separate classes for Collection, List, and Map.
  • beginChain(Collection c), endChain() method for chaining manipulation methods.

6. Try

  • Converts checked exceptions to runtime exceptions for usages in lambdas.
  • Converts exception throwing functions to functions returning Optionals.
  • Converts exception throwing functions to return default value.

7. Trampoline(safe tail recursion)

  • Trampoline object in heap for tail recursion without possible stack overflow.

Example usages included in the test code.

About

A simple additional functional programming support for Java 8+.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages