Scheme/Procedures: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (moved Scheme:Procedures to Scheme/Procedures: Create subpage) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 5: | Line 5: | ||
where <expressions> is one or more, well, expressions. Only the last expression's value is returned.<br /> | where <expressions> is one or more, well, expressions. Only the last expression's value is returned.<br /> | ||
<args> is your variable definitions, which can take the following forms: | <args> is your variable definitions, which can take the following forms: | ||
* '''var''' - all arguments are put into this single variable. | * '''var''' - all arguments are put into this single variable (as a list.) | ||
* '''(var[1] var[2] ... )''' - specifies a fixed number of arguments. | * '''(var[1] var[2] ... )''' - specifies a fixed number of arguments. | ||
* '''(var[1] var[2] ... . var[n])''' - a space-delimited period before the final argument specifies the remaining args (if any) to be put into a list under that variable. | * '''(var[1] var[2] ... . var[n])''' - a space-delimited period before the final argument specifies the remaining args (if any) to be put into a list under that variable. | ||
<br /> | <br /> | ||
== Lexical Scoping == | == Lexical Scoping == | ||
=== fluid-let === | === fluid-let === | ||
Modifies ''existing global variables'' instead of introducing new lexical ones. Values are reset at the end of the expression. | Modifies ''existing global variables'' instead of introducing new lexical ones. Values are reset at the end of the expression. | ||
<br /> | |||
== Iteration == | |||
=== do === | |||
<pre> | |||
(do | |||
((<var> <init> <step>) ... ) | |||
(<test> <expression>) | |||
(<command> ... )) | |||
</pre> |
Latest revision as of 19:28, 3 April 2011
Lambdas[edit]
- Can also be viewed as anonymous procedures.
- Has the following syntax:
(lambda <args> <expressions>)
where <expressions> is one or more, well, expressions. Only the last expression's value is returned.
<args> is your variable definitions, which can take the following forms:
- var - all arguments are put into this single variable (as a list.)
- (var[1] var[2] ... ) - specifies a fixed number of arguments.
- (var[1] var[2] ... . var[n]) - a space-delimited period before the final argument specifies the remaining args (if any) to be put into a list under that variable.
Lexical Scoping[edit]
fluid-let[edit]
Modifies existing global variables instead of introducing new lexical ones. Values are reset at the end of the expression.
Iteration[edit]
do[edit]
(do ((<var> <init> <step>) ... ) (<test> <expression>) (<command> ... ))