Recursion patterns, polymorphism, and the Prelude
Posted on 2015-08-17 01:13:17 +0900 in Functional Programming
Lecture Content
In fact, experienced Haskell programmers hardly ever write recursive functions!
This is quite unbelieable for me at first glance. Even though recursive function
is not
the best practice in languages which does not provide tail call optimization.
Recursive function
provide more abstract way than iterative function
, while there exists
more abstract way than Recursive function
, which leave the low-level details of actually doing recursion
to these functions.
Infix Function
Backticks can turn any standard function with two argumetns in an infix operator which is called section syntax:
(op e) = \ x -> x op e
(e op) = \ x -> e op x
For example,
Exercise 1 Hopscotch
zip
or zipwith
are convenient to do filter in list.
Exercise 2 Local maxima
Exercise 3 Histogram
Test code,
Hide Comments
comments powered by Disqus