• https://cs.stackexchange.com/questions/88541/how-did-they-cancel-out-o-terms-in-this-fraction/88562#88562

• https://jeremykun.com/2018/04/13/for-mathematicians-does-not-mean-equality/ and https://news.ycombinator.com/item?id=16833391

• https://math.stackexchange.com/questions/2066004/big-o-notation-is-element-of-or-is-equal

• https://math.stackexchange.com/questions/86076/what-are-the-rules-for-equals-signs-with-big-o-and-little-o

Given example becomes: convert inline:$(pbpaste) out.png

(I didn’t know about pbpaste, nice to know!)

]]>In class Num (It is better design and also more efficient to make Num a class, not an interface):

abstract public T cases(Function callIfZero, Function callIfSucc);

In class Zero:

public T cases(Function callIfZero, Function callIfSucc) {

return callIfZero.apply(this);

}

In class Succ:

public T cases(Function callIfZero, Function callIfSucc) {

return callIfSucc.apply(this);

}

You can then define plus (and other functions) in terms of cases, like this:

public Num plus(Num a, Num b){

return a.cases(zero -> b, someSucc -> new Succ(plus(someSucc.pred, b)));

}

Note that you can’t do that in C++ because there, a method cannot be both virtual and generic. But in Java, it works. Clumsily. ]]>