;; -*- geiser-scheme-implementation: guile -*- (string? "apple") ; #t (string? 5) ; #f (string? 'apple) ; #f (define (string-enthusiast obj) (if (string? obj) "Oh my gosh you gave me A STRING!!!" "That WASN'T A STRING AT ALL!!! MORE STRINGS PLEASE!")) (string-enthusiast "apple") ; "Oh my gosh you gave me A STRING!!!" (string-enthusiast 5) ; "That WASN'T A STRING AT ALL!!! MORE STRINGS PLEASE!" (> 8 9) ; #f (< 8 9) ; #t (> 8 8) ; #f (>= 8 8) ; #t (define (goldilocks n smallest-ok biggest-ok) (if (< n smallest-ok) "That's too small!" (if (> n biggest-ok) "That's too big!" "That's just right!"))) (goldilocks 7 6 8) ; "That's just right!" (goldilocks 33 10 20) ; "That's too big!" (goldilocks 3 10 20) ; "That's too small!" (define (goldilocks n smallest-ok biggest-ok) (cond ((< n smallest-ok) "That's too small!") ((> n biggest-ok) "That's too big!") (else "That's just right!"))) (goldilocks 7 6 8) ; "That's just right!" (goldilocks 33 10 20) ; "That's too big!" (goldilocks 3 10 20) ; "That's too small!" (member 'b '(a b c)) ; (b c) (member 'z '(a b c)) ; #f (define (fruit-sleuth fruit basket) (if (member fruit basket) "I found it!" "Nope, not in here.")) (fruit-sleuth 'apple '(orange banana apple)) ; "I found it!" (fruit-sleuth 'grape '(orange banana apple)) ; "Nope, not in here."