Update Definition
@@ -55,3 +55,32 @@ The following evaluates to 5:
 | 
			
		||||
x
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## defn
 | 
			
		||||
 | 
			
		||||
macro: (defn _sym_ _lambda-list_ . _body_)
 | 
			
		||||
 | 
			
		||||
defn defines a new function in the default global environment.
 | 
			
		||||
 | 
			
		||||
defn is a shorter way to define functions. It is a macro defined in the standard library. The following code:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
(defn my-add (a b)
 | 
			
		||||
  (+ a b))
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
... is equivalent to a combination of `def` and `fn`, as seen below:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
(def my-add (fn (a b) 
 | 
			
		||||
                         (+ a b))) 
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
The body may be comprised of many forms. In this case, the entire body code is pasted directly into the `fn` form.
 | 
			
		||||
As in `fn`, the entire body of the function will be executed when the declared function is called, and the
 | 
			
		||||
value of the last expression executed is returned as the value of the function call. 
 | 
			
		||||
 | 
			
		||||
## defmacro
 | 
			
		||||
 | 
			
		||||
macro: (defmacro _sym_ _lambda-list_ . _body_)
 | 
			
		||||
 | 
			
		||||
defmacro is similar to `defn`, with the exception that it defines a new macro in the default global environment.
 | 
			
		||||
		Reference in New Issue
	
	Block a user