-
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
8 changed files
with
131 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,49 @@ | ||
#lang racket | ||
|
||
(check-expect (inf-sup.v2 max (list 10 4 15 23 1 3 12 52 2)) 52) | ||
(check-expect (inf-sup.v2 min (list 10 4 15 23 1 3 12 52 2)) 1) | ||
|
||
(define (inf-sup.v2 f l) | ||
(cond | ||
[(empty? (rest l)) (first l)] | ||
[else (f (first l) (inf-sup.v2 f (rest l)))])) | ||
|
||
; Determines the smallest number on l | ||
(check-expect (inf-2 (list 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1)) | ||
1) | ||
(check-expect (inf-2 (list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25)) | ||
1) | ||
|
||
(define (inf-2 l) | ||
(inf-sup.v2 min l)) | ||
|
||
|
||
(check-expect (sup-2 (list 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1)) | ||
25) | ||
(check-expect (sup-2 (list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25)) | ||
25) | ||
|
||
(define (sup-2 l) | ||
(inf-sup.v2 max l)) | ||
|
||
(check-expect (inf-sup > (list 5 4 3 23)) 23) | ||
(check-expect (inf-sup < (list 1 4 2)) 1) | ||
|
||
(define (inf-sup f l) | ||
(cond | ||
[(empty? (rest l)) (first l)] | ||
[else | ||
(if (f (first l) | ||
(inf-sup f (rest l))) | ||
(first l) | ||
(inf-sup f (rest l)))])) | ||
|
||
(check-expect (inf-1 (list 5 1 2)) 1) | ||
|
||
(define (inf-1 l) | ||
(inf-sup < l)) | ||
|
||
(check-expect (sup-1 (list 4 1 6)) 6) | ||
|
||
(define (sup-1 l) | ||
(inf-sup > l)) |
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 @@ | ||
#lang racket | ||
|
||
(cons 1 (cons 2 '())) | ||
|
||
(cons 23 (cons "a" '())) | ||
|
||
(cons "yellow" (cons #true '())) |
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,15 @@ | ||
#lang racket | ||
|
||
(define-struct layer [stuff]) | ||
|
||
(define LSTR0 "abcd") | ||
(define LSTR1 (make-layer "abcd")) | ||
(define LSTR2 (make-layer (make-layer (make-layer "abcd")))) | ||
|
||
(define LNUM0 4) | ||
(define LNUM1 (make-layer 10)) | ||
(define LNUM2 (make-layer (make-layer (make-layer 2)))) | ||
|
||
|
||
(define LITEM1 (make-layer "abcd")) | ||
(define LITEM2 (make-layer 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,15 @@ | ||
#lang racket | ||
|
||
(define NELT1 (cons 20 '())) | ||
(define NELT2 (cons 5 (cons 10 '()))) | ||
|
||
(define NELB1 (cons #true '())) | ||
(define NELB2 (cons #true (cons #false '()))) | ||
|
||
|
||
(define NEL-T1 NELT1) | ||
(define NEL-T2 NELT2) | ||
|
||
|
||
(define NEL-B1 NELB1) | ||
(define NEL-B2 NELB2) |
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 @@ | ||
#lang racket | ||
|
||
(check-expect (occurs "a" (list "b" "a" "d" "e")) (list "d" "e")) | ||
(check-expect (occurs "a" (list "b" "c" "d")) #f) | ||
|
||
(define (occurs s los) | ||
los) |
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,9 @@ | ||
#lang racket | ||
|
||
(define (f x) x) | ||
|
||
(cons f '()) | ||
|
||
(f f) | ||
|
||
(cons f (cons 10 (cons (f 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,7 @@ | ||
#lang racket | ||
|
||
(define (f x) (x 10)) | ||
|
||
(define (f x) (x f)) | ||
|
||
(define (f x y) (x 'a y 'b)) |
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,22 @@ | ||
#lang racket | ||
|
||
(check-expect (function=at-1.2-3-and-5.775? x y) #false) | ||
(check-expect (function=at-1.2-3-and-5.775? x z) #false) | ||
|
||
(define (function=at-1.2-3-and-5.775? f1 f2) | ||
(and (= (f1 1.2) (f2 1.2)) | ||
(= (f1 3) (f2 3)) | ||
(= (f1 -5.775) (f2 -5.775)))) | ||
|
||
|
||
; Number -> Number | ||
(define (x n) | ||
(+ n 2)) | ||
|
||
; Number -> Number | ||
(define (y n) | ||
(- n 3.5)) | ||
|
||
; Number -> Number | ||
(define (z n) | ||
(* n (/ 5 3))) |