All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fj.function.Longs Maven / Gradle / Ivy

Go to download

Functional Java is an open source library that supports closures for the Java programming language

There is a newer version: 5.0
Show newest version
package fj.function;

import fj.F;

import static fj.Function.curry;
import static fj.Semigroup.longAdditionSemigroup;
import static fj.Semigroup.longMultiplicationSemigroup;

import static java.lang.Math.abs;

/**
 * Curried functions over Longs.
 *
 * @version %build.number%
 */
public final class Longs {
  private Longs() {
    throw new UnsupportedOperationException();
  }

  /**
   * Curried Long addition.
   */
  public static final F> add = longAdditionSemigroup.sum();

  /**
   * Curried Long multiplication.
   */
  public static final F> multiply = longMultiplicationSemigroup.sum();

  /**
   * Curried Long subtraction.
   */
  public static final F> subtract = curry((x, y) -> x - y);

  /**
   * Negation.
   */
  public static final F negate = x -> x * -1L;

  /**
   * Absolute value.
   */
  public static final F abs = Math::abs;

  /**
   * Remainder.
   */
  public static final F> remainder = curry((a, b) -> a % b);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy