-
-
Save roggenkemper/c9bba349673ee32b8f7cd410f0e5b838 to your computer and use it in GitHub Desktop.
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
### Begin ### | |
(define (f x) (print x) (print x) (print x)) | |
(if #t (print 3) (print 3)) | |
(if #t ((print 3) (print 3)) (print 4)) | |
(if #t (begin (print 5) (print 6)) (print 7)) | |
### List Equivalence ### | |
(define a '(1 2 3)) | |
(define b '(1 2 3)) | |
(define c a) | |
(eq? a b) | |
(eq? a c) | |
(equal? a b) | |
(equal? a c) | |
### List Manipulation ### | |
(length '(1 2 3 4 5)) | |
(length '(1 (2))) | |
(append '(1 2 3) 4) | |
(append '(1) '(2)) | |
(map abs '(-1 -1 -1 0 0 0)) | |
(map (lambda (x) (+ 1 x)) '( 1 2 3 4)) | |
(filter odd? '(1 2 3 4 5)) | |
(reduce * '(1 2 3 4 5)) | |
### Eval ### | |
'(print 1) | |
(eval '(print 1)) | |
(eval '(if #t (print 5) (print 6))) | |
### Quasiquote ### | |
(define a 5) | |
(define b 10) | |
'(a b) | |
`(a b) | |
`(a ,b) | |
`(a ,(* b 100)) | |
### Exponents with Lists ### | |
(define (exp base power) | |
(if (= power 0) 1 | |
(list '* (exp base (- power 1)) base))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment