Contents    Page-10    Prev    Next    Page+10    Index   

Functional Programming

A functional program is one in which:

A subset of Lisp or Clojure, with no destructive functions, is an example of a functional language.


(defn square [x] (* x x))
(defn hypotenuse [x y]
  (Math/sqrt (+ (square x)
           (square y))) )

Values are passed directly between functions, rather than being stored in variables.

Functional programming is easily adapted to parallel programming: a function can be replicated on many machines, the data set can be broken up into shards, and the shards can be processed in parallel on different machines.