Principles of Functional programming

​Challenging because

  1. Primitives
  2. Patterns
  3. Architectures
  4. Principles

Not only multithreading

FP is not an optimization

FP gets you the better code

Let's start simple

public int length(String s) {
  return s.size;
}
public bool isEven(int i) {
  return i % 2 == 0;
}
public bool isStringLenghtEven(String s) {
  int i = length(s);
  return isEven(i);
}
public Function<String, Boolean> compose(f1 Function<String, Integer>,
                                         f2 Function<Integer, Boolean>) {
  return s -> {
    Integer i = f1.call(s);
    f2.call(i);
  }
}
public Function<A, C> compose(f1 Function<A, B>,
                              f2 Function<B, C>) {
  return s -> {
    B i = f1.call(s);
    f2.call(i);
  }
}

deck

By Yura Taras

deck

  • 125