package utp;

import java.util.Arrays;

public class Main {

	public static void main(String[] args) {

		/*
			new IActiveGeneratorOuter<Integer>() {
				public Integer value() throws StopException {
					return 0;
				}
				public IActiveGenerator<Integer> next() {
					return new IActiveGenerator<Integer>() {
						public Integer value() throws StopException {
							return 1;
						}
						public IActiveGenerator<Integer> next() {
							return Functional.map2(x -> y -> x+y, outer(), this);
						}
					};
				}
			}.passive().loop(i -> System.out.println(i));
		
		*/

		IActiveGenerator<String> genA = new ActiveListGenerator<String>(Arrays.asList("a", "foo", "bar", "a foo-bar"));
		IActiveGenerator<Integer> genB = new ActiveListGenerator<Integer>(Arrays.asList(1, 22, 4, 7, 18));
		
		IActiveGenerator<Double> genC = Functional.map(x -> 1.0/x, genB);
		IActiveGenerator<String> genD = Functional.map2(x -> y -> x + y, genA, genC);
		
		try { while(true)
		{
			System.out.println(genD.value());
			genD = genD.next();
		}} catch (StopException e) {}
		

	}

}
