-
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
6 changed files
with
136 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,37 @@ | ||
#lang racket | ||
|
||
(check-expect `(0 ,@'(1 2 3) 4) | ||
(list 0 1 2 3 4)) | ||
|
||
(check-expect `(("alan" ,(* 2 500)) | ||
("barb" 2000) | ||
(,@'("carl" " , the great") 1500) | ||
("dawn" 2300)) | ||
(list (list "alan" 1000) | ||
(list "barb" 2000) | ||
(list "carl" " , the great" 1500) | ||
(list "dawn" 2300))) | ||
|
||
(check-expect `(html | ||
(body | ||
(table ((border "1")) | ||
(tr ((width "200")) | ||
,@(make-row '( 1 2))) | ||
(tr ((width "200")) | ||
,@(make-row '(99 65)))))) | ||
(list 'html | ||
(list 'body | ||
(list 'table (list (list 'boder "1")) | ||
(list 'tr (list (list 'width "200")) (list 'td "1") (list 'td "2")) | ||
(list 'tr (list (list 'width "200")) (list 'td "99") (list 'td "65")))))) | ||
|
||
|
||
(define (make-row l) | ||
(cond | ||
[(empty? l) '()] | ||
[else (cons (make-cell (first l)) | ||
(make-row (rest l)))])) | ||
|
||
|
||
(define (make-cell n) | ||
`(td ,(number->string n))) |
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 one-list | ||
'("Asia: Heat of the Moment" | ||
"U2: One" | ||
"The White Stripes: Seven Nation Army")) | ||
|
||
(define (ranking los) | ||
(reverse (add-ranks (reverse los)))) | ||
|
||
(define (add-ranks los) | ||
(cond | ||
[(empty? los) '()] | ||
[else (cons (list (length los) (first los)) | ||
(add-ranks (rest 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,26 @@ | ||
#lang racket | ||
|
||
(check-expect (contains-atom? '("abcd" "efgh" "ijkl")) #false) | ||
(check-expect (contains-atom? '("abcd" "atom" "efgh")) #true) | ||
|
||
(define (contains-atom? l) | ||
(contains? "atom" l)) | ||
|
||
(check-expect (contains-basic? '("abcd" "efgh" "ijkl")) #false) | ||
(check-expect (contains-basic? '("abcd" "basic" "efgh")) #true) | ||
|
||
(define (contains-basic? l) | ||
(contains? "basic" l)) | ||
|
||
(check-expect (contains-zoo? '("abcd" "efgh" "ijkl")) #false) | ||
(check-expect (contains-zoo? '("abcd" "zoo" "efgh")) #true) | ||
|
||
(define (contains-zoo? l) | ||
(contains? "zoo" l)) | ||
|
||
|
||
(define (contains? s l) | ||
(cond | ||
[(empty? l) #false] | ||
[else (or (string=? (first l) s) | ||
(contains? s (rest 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,49 @@ | ||
#lang racket | ||
|
||
(check-expect (plus 3 '(0 1 2 3 4)) '(3 4 5 6 7)) | ||
(check-expect (plus -2 '(0 1 2 3 4)) '(-2 -1 0 1 2)) | ||
|
||
(define (plus n l) | ||
(cond | ||
[(empty? l) '()] | ||
[else (cons (+ (first l) n) (plus n (rest l)))])) | ||
|
||
|
||
; Lon -> Lon | ||
; Substract 2 from each number of a given list | ||
(check-expect (sub2 '(2 3 4 5 6)) '(0 1 2 3 4)) | ||
|
||
(define (sub2 l) | ||
(plus -2 l)) | ||
|
||
(check-expect (plus1 '(0 1 2 3 4)) '(1 2 3 4 5)) | ||
|
||
(define (plus1 l) | ||
(plus 1 l)) | ||
|
||
(check-expect (plus5 '(0 1 2 3 4)) '(5 6 7 8 9)) | ||
|
||
(define (plus5 l) | ||
(plus 5 l)) | ||
|
||
|
||
; adds 1 to each item on l | ||
(check-expect (add1* '(0 1 2 3 4)) '(1 2 3 4 5)) | ||
|
||
(define (add1* l) | ||
(cond | ||
[(empty? l) '()] | ||
[else | ||
(cons | ||
(add1 (first l)) | ||
(add1* (rest l)))]) | ||
|
||
(check-expect (plus5* '(0 1 2 3 4)) '(5 6 7 8 9)) | ||
|
||
(define (plus5* l) | ||
(cond | ||
[(empty? l) '()] | ||
[else | ||
(cons | ||
(+ (first l) 5) | ||
(plus5* (rest 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,8 @@ | ||
#lang racket | ||
|
||
(check-expect (squared>? 3 10) #false) | ||
(check-expect (squared>? 4 10) #true) | ||
(check-expect (squared>? 5 10) #true) | ||
|
||
(define (squared>? x c) | ||
(> (* x x) c)) |
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