Higher-order programming and type inference
Posted on 2015-08-17 19:46:29 +0900 in Functional Programming
Lecture Contents
There is an art to deciding the order of arguments to a function to make partial applications of it as useful as possible: the arguments should be ordered from from “least to greatest variation”, that is, arguments which will often be the same should be listed first, and arguments which will often be different should come last.
The only reason why this ordering makes sense is the last one could be made point free when it is in need.
One thing confuses me a lot is the difference between $
and .
when doing the function composition.
stackoverflow gives a great answer. To summarize,
$
operator is for avoiding parenthesis.Anything appearing after it will take precedence over anything that comes before..
operator is for chaining functions. It works like the pipeline, the output on the right goes to the input of the left.
Exercise
Exercise 1 Wholemeal programming
Exercise 2 Folding with trees
Always try to insert into the left subtree while keep it is balanced.
Exercise 3 More folds
Exercise 4 Finding primes
Hide Comments
comments powered by Disqus