definition var
definition procedure(func)
define list
1.(cons 1 (cons 2 (cons 3 (cons 4 nil)))) equivalent to : (list 1 2 3 4) 2. (cons 1 2). equivalent to '(1 2). not (list 1 2) define lambda expression
Same as using define, just no name. In fact, the following expressions are equivalent: (define (plus4 x) (+ x 4)) (define plus4 (lambda (x) (+ x 4))) !!! REMEMBER: in lambda, paras are in ( ). cond expression
ex: condLet
|
Lists of Values1
1.EVERYTHING in Scheme is a list, even the code. 2. Quoting: to interpret a group of values as a list(instead of as a procedure call), put a single quote in front of them. special values
1. ' vs " " (define c 'a) if call c, return a. if no (define a 1), (eval c) will return error (define c "a") if call c, return "a" 2. = only work for numbers (= #t #t) : error. (= '(1) '(1)) error 3. but (equal? (= '(1) '(1)) return: true IF Statement
if: python vs scheme 1. scheme eval to a value, python directs the flow 2. scheme: if expression just a single expression for each of #t and #f. python: can add more lines 3. scheme: no elif. scheme vs python |
List Operation
construct a list from individual valuesex: concat 2 listsreplicateother
|
Cheatography
https://cheatography.com
scheme Cheat Sheet (DRAFT) by carol2008
This is a draft cheat sheet. It is a work in progress and is not finished yet.