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

fj.data.vector.V 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.data.vector;

import fj.F0;
import fj.F2;
import fj.F3;
import fj.F4;
import fj.F5;
import fj.P;
import fj.P1;
import fj.P2;

/**
 * Functions across vectors.
 */
public final class V {

  private V() {
  }

  /**
   * Puts elements in a vector-2.
   *
   * @param a1 An element to put in a vector.
   * @param a2 An element to put in a vector.
   * @return The vector-2.
   */
  public static  V2 v(final A a1, final A a2) {
    return V2.p(P.p(a1, a2));
  }

  /**
   * Puts elements in a vector-2.
   *
   * @param a1 An element to put in a vector.
   * @param a2 An element to put in a vector.
   * @return The vector-2.
   */
  public static  V2 v(final F0 a1, final F0 a2) {
    return V2.p(new P2() {
      public A _1() {
        return a1.f();
      }

      public A _2() {
        return a2.f();
      }
    });
  }

  /**
   * Returns a function that puts elements in a vector-2.
   *
   * @return A function that puts elements in a vector-2.
   */
  public static  F2> v2() {
    return (a, a1) -> v(a, a1);
  }

  /**
   * Puts elements in a vector-3.
   *
   * @param a1 An element to put in a vector.
   * @param a2 An element to put in a vector.
   * @param a3 An element to put in a vector.
   * @return The vector-3.
   */
  public static  V3 v(final A a1, final A a2, final A a3) {
    return V3.p(P.p(a1, a2, a3));
  }

  /**
   * Puts elements in a vector-3.
   *
   * @param a1 An element to put in a vector.
   * @param a2 An element to put in a vector.
   * @param a3 An element to put in a vector.
   * @return The vector-3.
   */
  public static  V3 v(final P1 a1, final F0 a2, final F0 a3) {
    return V3.cons(a1, v(a2, a3));
  }

  /**
   * Returns a function that puts elements in a vector-3.
   *
   * @return A function that puts elements in a vector-3.
   */
  public static  F3> v3() {
    return (a, a1, a2) -> v(a, a1, a2);
  }

  /**
   * Puts elements in a vector-4.
   *
   * @param a1 An element to put in a vector.
   * @param a2 An element to put in a vector.
   * @param a3 An element to put in a vector.
   * @param a4 An element to put in a vector.
   * @return The vector-4.
   */
  public static  V4 v(final A a1, final A a2, final A a3, final A a4) {
    return V4.p(P.p(a1, a2, a3, a4));
  }

  /**
   * Puts elements in a vector-4.
   *
   * @param a1 An element to put in a vector.
   * @param a2 An element to put in a vector.
   * @param a3 An element to put in a vector.
   * @param a4 An element to put in a vector.
   * @return The vector-4.
   */
  public static  V4 v(final P1 a1, final P1 a2, final F0 a3, final F0 a4) {
    return V4.cons(a1, v(a2, a3, a4));
  }

  /**
   * Returns a function that puts elements in a vector-4.
   *
   * @return A function that puts elements in a vector-4.
   */
  public static  F4> v4() {
    return (a, a1, a2, a3) -> v(a, a1, a2, a3);
  }


  /**
   * Puts elements in a vector-5.
   *
   * @param a1 An element to put in a vector.
   * @param a2 An element to put in a vector.
   * @param a3 An element to put in a vector.
   * @param a4 An element to put in a vector.
   * @param a5 An element to put in a vector.
   * @return The vector-5.
   */
  public static  V5 v(final A a1, final A a2, final A a3, final A a4, final A a5) {
    return V5.p(P.p(a1, a2, a3, a4, a5));
  }

  /**
   * Puts elements in a vector-5.
   *
   * @param a1 An element to put in a vector.
   * @param a2 An element to put in a vector.
   * @param a3 An element to put in a vector.
   * @param a4 An element to put in a vector.
   * @param a5 An element to put in a vector.
   * @return The vector-5.
   */
  public static  V5 v(final P1 a1, final P1 a2, final P1 a3, final F0 a4, final F0 a5) {
    return V5.cons(a1, v(a2, a3, a4, a5));
  }

  /**
   * Returns a function that puts elements in a vector-5.
   *
   * @return A function that puts elements in a vector-5.
   */
  public static  F5> v5() {
    return (a, a1, a2, a3, a4) -> v(a, a1, a2, a3, a4);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy