Skip to content

Instantly share code, notes, and snippets.

@roggenkemper
Last active Jul 25, 2022
Embed
What would you like to do?
### 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