Update Home
							
								
								
									
										29
									
								
								Home.md
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
										
											
											
										
										
									
								
							
						
						
									
										29
									
								
								Home.md
									
									
									
									
									
								
							@@ -45,32 +45,3 @@ cdr returns the second item of a cons cell.
 | 
			
		||||
 | 
			
		||||
list is a function takes any number of parameters, and produces a list containing only those elements in the order passed to it. 
 | 
			
		||||
 | 
			
		||||
## Definition
 | 
			
		||||
 | 
			
		||||
- set
 | 
			
		||||
 | 
			
		||||
sets a symbol's bound value. set always finds the most local definition. For example, the following evaluates to 5:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
(def myvar 4)
 | 
			
		||||
(defn myfunction (myvar)
 | 
			
		||||
  (set myvar 5)
 | 
			
		||||
  myvar)
 | 
			
		||||
(myfunction 4)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
And the global `myvar` will still equal 4 after this. However, set _can_ potentially modify global definitions when
 | 
			
		||||
the "most local" definition for the given symbol belongs to the global environment. `myvar` would actually
 | 
			
		||||
be modified in the following example:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
(def myvar 4)
 | 
			
		||||
(defn myfunction ()
 | 
			
		||||
  (set myvar 5)
 | 
			
		||||
  myvar)
 | 
			
		||||
(myfunction)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
This returns 5, and `myvar` will evaluate to 5 afterwards.
 | 
			
		||||
Using set for a symbol that doesn't have a binding in the current environment is an error.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user