Higher Order functions

Functions can be used as an arguments to other functions. This is possible because a function always evaluates to a value.

It is also stated that higher order functions should return a function, usually when thinking in typed lambda calculus although some dispute this requirement.

Create a named function as a higher order function, which adds a value to a number twice

Higher order function to add a number twice

(defn twice [function x]
  (function (function x)))

(twice #(+ % 3) 7) ;13

Return the even numbers from 1 to 10

Return the even numbers between 1 and 10

 (range 1 10))

results matching ""

    No results matching ""