function | description |
---|---|
first word-or-sentence |
|
last word-or-sentence |
|
butfirst word-or-sentence |
|
butlast word-or-sentence |
|
item n word-or-sentence |
Return the nth letter of a word, or the nth word of a sentence |
(define (second word-or-sentence) (first (butfirst word-or-sentence))) (define (but-first-two word-or-sentence) (butfirst (butfirst word-or-sentence)))
function | description |
---|---|
|
|
se |
|
A | B | (and A B) | (or A B) | (not B) |
---|---|---|---|---|
#f | #f | #f | #f | #t |
#f | #t | #f | #t | #f |
#t | #f | #f | #t | #t |
#t | #t | #t | #t | #f |
(define (get-cs3-grade score) (if (> score 390) 'A+ (if (> score 370) 'A (if (> score 360) 'A- 'Did-not-get-an-A))))
(cond (cond1 actions1 ... ) (cond2 actions2 ... ) ... (condN actionsN ... ) (else else-actions ... ))
(define (get-cs3-grade score) (cond ((> score 390) 'A+) ((> score 370) 'A ) ((> score 360) 'A-) (else 'Did-not-get-an-A)))
(define (get-cs3-grade score) (cond ((> score 390) 'A+) ((and (<= score 390) (> score 370)) 'A ) ((and (<= score 370) (> score 360)) 'A-) (else 'Did-not-get-an-A)))
: (define (walk light city cops-present) (cond ((equal? city 'berkeley) 'strut) ((equal? light 'green) 'go) ((equal? light 'not-working) 'go-if-clear) ((and (equal? light 'flashing-red) cops-present) 'wait) ((equal? light 'flashing-red) 'hurry) ((equal? light 'purple) 'stop-drinking) (else 'go-to-sleep))) walk : (walk 'green 'berkeley #t) ==> strut : (walk 'green 'sf #t) ==> go : (walk 'not-working 'sf #t) ==> go-if-clear : (walk 'flashing-red 'sf #t) ==> wait : (walk 'flashing-red 'sf #f) ==> hurry : (walk 'purple 'sf #t) ==> stop-drinking : (walk 'i-am-tired 'sf #t) ==> go-to-sleep