uqq4ja
Last Updated: February 25, 2016
·
1.266K
· runexec
81609937c20aeab3598aea56f1f4f022

Clojure - First-class Functions

What's a first-class function?
scroll to bottom for examples

From wikipedia - "In programming language design, a first-class citizen (also object, entity, or value), in the context of a particular programming language, is an entity that can be constructed at run-time, passed as a parameter, returned from a subroutine, or assigned into a variable.[1] In computer science the term reification is used when referring to the process (technique, mechanism) of making something a first-class object.[2]

The term was coined by Christopher Strachey in the context of “functions as first-class citizens” in the mid-1960s.[3]"

endorse
Examples of First-class Clojure Functions

(defn fn1stClass [& args]
      (fn [& _]
          (for [a args] 
               (str "First Class Arg: "
                a))))

uu.database=> ((fn1stClass "Ryan Kelker"))
("First Class Arg: Ryan Kelker")

uu.database=> (def newFN (fn1stClass "Ryan Kelker"))
#'uu.database/newFN

uu.database=> (newFN)
("First Class Arg: Ryan Kelker")
Say Thanks
Respond