Example usage for org.apache.commons.functor.core.algorithm FoldLeft FoldLeft

List of usage examples for org.apache.commons.functor.core.algorithm FoldLeft FoldLeft

Introduction

In this page you can find the example usage for org.apache.commons.functor.core.algorithm FoldLeft FoldLeft.

Prototype

public FoldLeft(BinaryFunction<? super T, ? super T, ? extends T> func) 

Source Link

Document

Create a new FoldLeft.

Usage

From source file:org.apache.commons.functor.example.kata.four.DataMunger.java

/**
 * Processes each line of the given Reader, returning the <i>selected</i> column for the
 * line where the absolute difference between the integer value of <i>col1</i> and <i>col2</i>
 * is least.  Note that lines that don't begin with an Integer are ignored.
 */// w ww . jav a  2 s  .  c  om
public static final Object process(final Reader file, final int selected, final int col1, final int col2) {
    return NthColumn.instance(selected)
            .evaluate(new FoldLeft<String>(lesserSpread(col1, col2)).evaluate(new FilteredGenerator<String>(
                    Lines.from(file), Composite.predicate(IsInteger.instance(), NthColumn.instance(0)))));
}