-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We typically define a function like this: (set! hello1 (fn* (name) (print "Hello %s" name))) Here we say there is a parameter "name" which must be supplied, and that is later used. If we instead say that parameters can be lists we can allow the first value to be the name, and the second a default value if nothing is actually passed, like so: (set! hello2 (fn* ( (name "World") ) (print "Hello %s" name))) These could be used like so: (hello1 "Steve") ; "Hello Steve" (hello2 "Steve") ; "Hello Steve" (hello2) ; "Hello World" I've not yet experimented with supplying defaults in the non-final arguments, because that could screw things up. But for simple cases like the one above it seems to work. Once complete this will close #130, however I need to add test-cases..
- Loading branch information
Showing
3 changed files
with
44 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters