Clojure – Anonymous Functions

clojure anonymous functions

In this guide, we will discuss Clojure Anonymous Functions. An anonymous function is a function which has no name associated with it. Following is an example of an anonymous function.

(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   ((fn [x] (* 2 x)) 2))
(Example)

The above example defines a function which takes a value of ‘x’ as an argument and the function itself multiples the value of the argument by 2.

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply