Skip to content

Commit

Permalink
More templating
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel committed Jan 11, 2009
1 parent aa2a359 commit 14463b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Test;

import com.agical.bumblebee.junit4.Storage;
import com.agical.jambda.Numeric;
import com.agical.jambda.Sequence;
import com.agical.jambda.Functions.Fn2;

Expand Down Expand Up @@ -78,9 +79,7 @@ private Iterable<Article> createArticles() {
}

private String loreMipsum(int nrOfSentences) {
Iterable<Integer> naturalNumbers = Sequence.range(plus(integerType).apply(1), 0);

Iterable<Integer> numbersUpToNrOfSentences = Sequence.takeWhile(naturalNumbers, smallerThan(integerType).rightCurry(nrOfSentences));
Iterable<Integer> numbersUpToNrOfSentences = Sequence.takeWhile(Numeric.naturalNumbers, smallerThan(integerType).rightCurry(nrOfSentences));

return Sequence.foldLeft(numbersUpToNrOfSentences, new Fn2<Integer,String,String>() {
public String apply(Integer dummy, String accumulator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.math.BigInteger;

import com.agical.jambda.Functions.*;

import static com.agical.jambda.Numeric.*;
import static com.agical.jambda.Sequence.*;

public abstract class Numeric<T> {
Expand Down Expand Up @@ -81,6 +83,7 @@ public static <T, TNum extends Numeric<T>> T average(TNum numType, Iterable<T> s
return numType.divide(sum(numType, source), numType.fromInt(count(source)));
}


public static final IntegerType integerType = new IntegerType();

public static class IntegerType extends Numeric<Integer>{
Expand Down Expand Up @@ -205,4 +208,5 @@ public BigDecimal modulo(BigDecimal x, BigDecimal m) {
public Boolean smallerThan(BigDecimal x1, BigDecimal x2) { return x1.compareTo(x2) == -1; }
}

public static final Iterable<Integer> naturalNumbers = Sequence.range(plus(integerType).apply(1), 0);
}

0 comments on commit 14463b4

Please sign in to comment.