@@ -0,0 +1,1712 @@
+import java.util.function.BiFunction;%0Aimport java.util.function.Function;%0A%0A/**%0A * Takes a single command line argument, an integer n, and prints%0A * 1) n!%0A * 2) the nth fibonacci number%0A * %3Cp%3E%0A * Intended as an example as to how to implement recursion via lambdas. I'm not really in love%0A * with suppressing warnings here, but there was no obvious way (to me) of giving the recursive%0A * definitions a more informative type than %7B@code BiFunction%3CBiFunction, Integer, Integer%3E%7D.%0A * The type %7B@code BiFunction%3CBiFunction%3C?, ?, Integer%3E, Integer, Integer%3E%7D, which at least%0A * specifies the output type of the interior bifunction, is uncompilable.%0A * %3Cp%3E%0A * Created by %3Ca href=%22mailto:knapp@american.edu%22%3EAdam Knapp%3C/a%3E on 1/27/17.%0A *%0A * @author %3Ca href=%22mailto:knapp@american.edu%22%3EAdam Knapp%3C/a%3E%0A * @version 0.1%0A */%0Apublic class RecursiveFunctionsViaLambdas %7B%0A%0A  @SuppressWarnings(%22unchecked%22)%0A  public static void main(String%5B%5D args) %7B%0A%0A    int n = Integer.parseInt(args%5B0%5D);%0A%0A    // n!%0A%0A    BiFunction%3CBiFunction, Integer, Integer%3E factorialRecursiveDefinition%0A      = (f, k) -%3E (k == 0) ? 1 : k * (int) f.apply(f, k - 1);%0A%0A    Function%3CInteger, Integer%3E factorial%0A      = k -%3E factorialRecursiveDefinition.apply(factorialRecursiveDefinition, k);%0A%0A    System.out.println(factorial.apply(n));%0A%0A    // fib(n)%0A%0A    BiFunction%3CBiFunction, Integer, Integer%3E fibonacciRecursiveDefinition%0A      = (f, k) -%3E %7B%0A      if (k == 0) %7B return 0; %7D%0A      if (k == 1) %7B return 1; %7D%0A      return (int) f.apply(f, k - 1) + (int) f.apply(f, k - 2);%0A    %7D;%0A%0A    Function%3CInteger, Integer%3E fibonacci%0A      = k -%3E fibonacciRecursiveDefinition.apply(fibonacciRecursiveDefinition, k);%0A%0A    System.out.println(fibonacci.apply(n));%0A%0A  %7D%0A%0A%7D%0A

add another way to do recursion