User Tools

Site Tools


software:racket:functions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
software:racket:functions [2018/09/22 18:14]
dave
software:racket:functions [2018/09/22 18:23] (current)
dave [list]
Line 1: Line 1:
-===== Racket Notes ==+====== Racket Notes ==
  
-Racket identifiers can contain any characters except for whitespace and the following special characters: '''​( ) ] { } " , ' ` ; # \'''​.+The [[https://​docs.racket-lang.org/​reference/​|Racket Reference]] has more details than this here page.  I took these notes regarding Racket as a memory aid to help me get started with Racket.
  
-==== Data Structures ==+Racket identifiers can contain any characters except for whitespace and the following special characters: '''​( ) [ ] { } " , ' ` ; # | \'''​. ​ A special case is ''#''​ which is allowed at the beginning of a symbol. 
 + 
 + 
 +===== Data Structures ==
  
 Linked lists are favored in racket. ​ Each element of the list can be a "​pair"​ created by the ''​cons''​ function. ​ The first element of the pair is the current value and the second element of the pair is a pointer to the next pair or ''​null''​. Linked lists are favored in racket. ​ Each element of the list can be a "​pair"​ created by the ''​cons''​ function. ​ The first element of the pair is the current value and the second element of the pair is a pointer to the next pair or ''​null''​.
Line 10: Line 13:
  
  
-==== Racket Functions ​==+===== Common Constants ​==
  
-=== cons ==+==== #t == 
 + 
 +The boolean true value. 
 + 
 +==== #f ==  
 + 
 +The boolean false value. 
 + 
 +==== null == 
 + 
 +The empty list.  
 + 
 +===== Racket Functions == 
 + 
 +==== cons ==
  
 Creates a newly allocated pair. Creates a newly allocated pair.
Line 20: Line 37:
 </​code>​ </​code>​
  
-=== car ==+==== car ==
  
 Returns the first value of a pair created with ''​cons''​. Returns the first value of a pair created with ''​cons''​.
Line 28: Line 45:
 </​code>​ </​code>​
  
-=== cdr ==+==== cdr ==
  
 Returns the second value of a pair created with ''​cons''​. Returns the second value of a pair created with ''​cons''​.
Line 36: Line 53:
 </​code>​ </​code>​
  
-=== cond ==+==== cond ==
  
 It's somewhat like a switch statement in other languages: It's somewhat like a switch statement in other languages:
Line 47: Line 64:
 </​code>​ </​code>​
  
-=== string-append ==+==== string-append ==
  
 Appends strings. ​ Arguments *must* be strings already. Appends strings. ​ Arguments *must* be strings already.
Line 55: Line 72:
 </​code>​ </​code>​
  
-=== number->​string ==+==== number->​string ==
  
 Converts a number to a string. Converts a number to a string.
Line 62: Line 79:
 (number->​string <​number>​) (number->​string <​number>​)
 </​code>​ </​code>​
 +
 +==== list ==
 +
 +Constructs a linked list from the specified arguments.
 +
 +<​code>​
 +(list <​arg1>​ <​argN>​...)
 +</​code>​
 +
 +Note that the value returned is a pair containing the value of the first argument and pointer to the next pair in the list.
software/racket/functions.1537665274.txt.gz · Last modified: 2018/09/22 18:14 by dave