Skip to content

Commit

Permalink
solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
gaecoli committed Jul 13, 2020
1 parent cacbe14 commit 82f6130
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions I - Fixed-Size Data/Exercise_120.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; (x)
;; This is not valid syntax for anything. It could be a variable x, if only it stood alone and not inside parentheses.

; (+ 1 (not x))
;; This is legal, I think. It is an expression that starts with a primitive expression, followed by a value, followed by another expression (not x). The inner expression is valid since it conforms to (primitive expr), and the outer expression has the valid format (primitive expr expr), where the second expr is that inner expression.

; (+ 1 2 3)
;; This is legal, it matches the format (primitive expr expr expr), which is valid syntax for an expression, and each of its `expr`s is a valid expression that is just a value.
14 changes: 14 additions & 0 deletions I - Fixed-Size Data/Exercise_121.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#lang racket

(+ (* (/ 12 8) 2/3)
(- 20 (sqrt 4)))

(cond
[(= 0 0) #false]
[(> 0 1) (string=? "a" "a")]
[else (= (/ 1 0) 9)])

(cond
[(= 2 0) #false]
[(> 2 1) (string=? "a" "a")]
[else (= (/ 1 2) 9)])
11 changes: 11 additions & 0 deletions I - Fixed-Size Data/Exercise_122.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#lang racket

(define (f x y)
(+ (* 3 x) (* y y)))


(+ (f 1 2) (f 2 1))

(f 1 (* 2 3))

(f (f 1 (* 2 3)) 19)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
| 7.10 | 3 | 117~119 | 6/25 | ... | ... | |
| 7.11 | ... | ... | ... | ... | ... | |
| 7.12 | 3 | ... | 9/25 | ... | 无练习 | |
| 7.13 | 3 | ... | 12/25 | ... | ... | |

----------------------------------------------------------------

Expand Down

0 comments on commit 82f6130

Please sign in to comment.