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

fj.Rng 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;

/**
 * Created by MarkPerry on 7/07/2014.
 */
public abstract class Rng {

	public abstract P2 nextInt();

    public abstract P2 nextLong();

    // [low, high] inclusive
    public final P2 range(int low, int high) {
        return nextNatural().map2(x -> (x % (high - low + 1)) + low);
    }


	public final P2 nextNatural() {
		return nextInt().map2(x -> x < 0 ? -(x + 1) : x);
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy