-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(-) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(- (/ 8 4) +) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(print-num 4) | ||
(print-num 3) | ||
(print-num 2) | ||
(print-num 1) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(print-num 654) | ||
(print-num 0) | ||
(print-num -321) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(* 9 3 1) | ||
(+ 3 2 1) | ||
|
||
(print-num (+ 6 (+ 5 1 2) (* 9 1 5) (/ 9 2) (mod 15 11))) | ||
|
||
(print-num (mod 13 10)) | ||
|
||
(print-num (- (+ 6 1) 7)) | ||
|
||
(print-num -520) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(print-num (mod 23 (+ 15 5))) | ||
|
||
(print-num (* (/ 2 3) 7)) | ||
|
||
(print-num (- (+ 3 5 2 (- 1 6) 3 (/ 1 2) (mod 3 5)) | ||
5)) | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(print-bool #f) | ||
(print-bool #t) | ||
|
||
(print-bool (or #f #f)) | ||
(print-bool (or #t #f)) | ||
|
||
(print-bool (not #f)) | ||
(print-bool (not #t)) | ||
|
||
(print-bool (and #t #t)) | ||
(print-bool (and #t #f)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(print-bool (or #t (and #t #f) (not #t))) | ||
(print-bool (and #t (not #t) (or #t #f) (and #f (not #f)))) | ||
(print-bool (or #f #f #t)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(print-num (if #t 2 1)) | ||
|
||
(print-num (if #f 2 1)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(print-num (if (> 1 2) (+ 5 6 7) (* 6 7 8 9 10))) | ||
|
||
(print-num (if (= 6 (* 3 2)) | ||
(if #f 1 2) | ||
0)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(define x 8) | ||
|
||
(print-num x) | ||
|
||
(define y (- 3 2)) | ||
|
||
(print-num y) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(define x (+ 20 -6 -1 -3)) | ||
|
||
(define y (/ 8 2)) | ||
|
||
(print-num (- x y)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(print-num | ||
((fun (num) (- num 1)) 3)) | ||
|
||
(print-num | ||
((fun (x y) (- x y)) 3 2)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(define a 10) | ||
|
||
(print-num | ||
((fun (a b c) (- a (/ b c))) 2 20 10)) | ||
|
||
|
||
(print-num a) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(define bar | ||
(fun (x y z) (+ x y (/ y z)))) | ||
|
||
(print-num (bar 10 9 8)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(define foo (fun (y) (+ y 1))) | ||
|
||
(define foo-z (fun () 5)) | ||
|
||
(print-num (foo (foo-z))) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(define fact | ||
(fun (n) (if (< n 3) n | ||
(* n (fact (- n 1)))))) | ||
|
||
(print-num (fact 11)) | ||
(print-num (fact 12)) | ||
(print-num (fact 13)) | ||
(print-num (fact 14)) | ||
|
||
(define fib (fun (x) | ||
(if (< x 2) x (+ | ||
(fib (- x 1)) | ||
(fib (- x 2)))))) | ||
|
||
(print-num (fib 2)) | ||
(print-num (fib 4)) | ||
(print-num (fib 6)) | ||
(print-num (fib 11)) | ||
(print-num (fib 21)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(define min | ||
(fun (a b) | ||
(if (< a b) a b))) | ||
|
||
(define max | ||
(fun (a b) | ||
(if (> a b) a b))) | ||
|
||
(define gcd | ||
(fun (a b) | ||
(if (= 0 (mod (max a b) (min a b))) | ||
(min a b) | ||
(gcd (min a b) (mod (max a b) (min a b)))))) | ||
|
||
(print-num (gcd 15 35)) | ||
|
||
(print-num (gcd 448 189)) | ||
|
||
(print-num (gcd 330 715)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(+ 3 2 1 (or #f #t)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(define foo | ||
(fun (num) | ||
(if (> num 1) 1 (= num 1)))) | ||
|
||
(print-num (* 8 (foo 1))) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(define dist-square | ||
(fun (x y) | ||
(define square (fun (x) (* x x))) | ||
(+ (square x) (square y)))) | ||
|
||
(print-num (dist-square 6 10)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(define diff | ||
(fun (a b) | ||
(define abs | ||
(fun (a) | ||
(if (< a 0) (- 0 a) a))) | ||
(abs (- a b)))) | ||
|
||
(print-num (diff 0 5)) | ||
(print-num (diff 5 0)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(define add-x | ||
(fun (x) (fun (y) (+ x y)))) | ||
|
||
(define z (add-x 10)) | ||
|
||
(print-num (z 5)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(define foo | ||
(fun (f x) (f x))) | ||
|
||
(print-num | ||
(foo (fun (x) (- x 1)) 11)) | ||
|