Skip to content

Instantly share code, notes, and snippets.

@csaunders
Created March 19, 2015 23:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csaunders/a86e5db3f6bd0bfec080 to your computer and use it in GitHub Desktop.
Save csaunders/a86e5db3f6bd0bfec080 to your computer and use it in GitHub Desktop.
WOO REPLZ!
Welcome to DrRacket, version 6.0.1 [3m].
Language: racket; memory limit: 128 MB.
exercise 2.1
1/2
-1/2
-1/5
-3/1
exercise 2.2
(0,2.5)
(1.0,3.5)
(1.0,6.0)
(2.5,4.5)
(6.0,9.0)
exercise 2.3
10
5
30
50
exercise 2.3 ext: origin focused
10
5
30
50
exercise 2.3 ext: message passing
10
5
30
50
exercise 2.4
3
4
exercise 2.5
3
4
exercise 2.6
#<procedure:...xercises_2.1.rkt:226:2>
section 2.1.4: extended exerciseexercise 2.7
2
2
exercise 2.8
'(-1 . 3)
'(-2 . 1)
exercise 2.9
exercise 2.9 a: See exercise-2.9.png for work
exercise 2.9 b
1
5
5
1
5
10
1
5
17
exercise 2.10
exercise 2.11
exercise 2.11 -- skipped / confused
exercise 2.12
'(10.0 5.0 2.000000000000005 15.0)
exercise 2.13
14.925373134328357
16.949152542372893
19.851116625310176
exercise 2.14, 2.15, & 2.16
10.0
5.0
19.801980198019795
14.925373134328362
22.177121771217717
7.509433962264145
> (seg-midpoint (make-segment a b))
'(0 . 2.5)
> a
'(0 . 0)
> b
'(0 . 5)
> (p-print (seg-midpoint (make-segment a b)))
(0,2.5)
> (make-segment a b)
'((0 . 0) 0 . 5)
> (p-print (make-segment a b))
((0 . 0),(0 . 5))
> (cons (cons 0 0) (cons 0 5))
'((0 . 0) 0 . 5)
> (cons (cons 0 0) (cons 0 (cons 5)))
. . cons: arity mismatch;
the expected number of arguments does not match the given number
expected: 2
given: 1
arguments...:
5
> (cons (cons 0 0) (cons 0 (cons 5 '())))
'((0 . 0) 0 5)
> (cons (cons 0 0) (cons (cons 0 5) '()))
'((0 . 0) (0 . 5))
> '(a b c d)
'(a b c d)
> a
'(0 . 0)
> b
'(0 . 5)
> c
'(2 . 7)
> d
'(3 . 2)
> '(a b c d)
'(a b c d)
> (list a b c d)
'((0 . 0) (0 . 5) (2 . 7) (3 . 2))
> (list 1 2 3 4)
'(1 2 3 4)
> (list x y z)
. . x: undefined;
cannot reference an identifier before its definition
> '(x y z)
'(x y z)
> (list 'x 'y 'z)
'(x y z)
> (list a b c d)
'((0 . 0) (0 . 5) (2 . 7) (3 . 2))
> (define lol (list 'x 'y 'z))
> lol
'(x y z)
> (define x '(1 2 3))
> lol
'(x y z)
> (map lol (lambda (x) (x)))
. . map: contract violation
expected: procedure?
given: '(x y z)
argument position: 1st
other arguments...:
#<procedure>
> (map lol (lambda (x) x))
. . map: contract violation
expected: procedure?
given: '(x y z)
argument position: 1st
other arguments...:
#<procedure>
> (map (lambda (x) (x)) lol )
. . application: not a procedure;
expected a procedure that can be applied to arguments
given: 'x
arguments...: [none]
> (map (lambda (x) x) lol )
'(x y z)
> (map (lambda (x) (eval x)) lol )
. . y: undefined;
cannot reference an identifier before its definition
> (map (lambda (x) (displayln (eval x))) lol )
(1 2 3)
. . y: undefined;
cannot reference an identifier before its definition
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment