+//Classical higher order functions:)
+map(f, l){
+ if(isEmpty(l)){
+ return [];
+ } else {
+ return f(l.hd) : map(f, l.tl);
+ }
+}
+
+foldr(f, acc, l){
+ if(isEmpty(l)){
+ return acc;
+ } else {
+ return foldr(f, f(acc, l.hd), l.tl);
+ }
+}
+
+//Functions for operators
+plus(x, y){ return x + y; }
+times(x, y){ return x * y; }
+
+intList(x){
+ [Int] l = [];
+ Int a = 1;
+ while(a <= x){
+ l = a : l;
+ a = a + 1;
+ }
+ return l;
+}
+
+faculty(x){
+ return foldr(times, 1, intList(x));
+}
+
+sum(x){
+ return foldr(plus, 0, intList(x));
+}
+
+main(){
+ print("faculty of 5 is: ", faculty(5));
+ print("sum of 1..5 is: ", sum(50));
+}