PasteRack.org | ||
Paste # 36679 | ||
2024-09-23 17:21:41 | ||
Fork as a new paste. | ||
Paste viewed 53 times. | ||
Tweet | ||
Embed: | ||
#lang racket #lang racket ; (isBetween a b c) --> boolean ; a : number ; b : number ; c : number ; Returns true if a > b and a < c, ; false in all other cases. (define isBetween (lambda (a b c) (< b a c))) (display "isBetween tests\n") (display "#t: ") (isBetween 5 4 6) (display "#f: ") (isBetween 3 7 9) (display "#f: ") (isBetween 4 4 9) ; (pythTriple a b c) --> boolean ; a : positive number ; b : positive number ; c : positive number ; ; Returns true if a, b, and c could represent ; the sides of a right triangle, where c is the ; hypotenuse. ; False otherwise ; a^2 + b^2 = c^2 (define pythTriple (lambda (a b c) (= (* c c) (+ (* a a) (* b b))))) (display "pythTriple tests\n") (display "#t: ") (pythTriple 3 4 5) (display "#f: ") (pythTriple 6 7 10) (display "#t: ") (pythTriple 4 3 5) (display "#f: ") (pythTriple 5 3 4) ; (pythTripl2e a b c) --> boolean ; a : positive number ; b : positive number ; c : positive number ; ; Returns true if a, b, and c could represent ; the sides of a right triangle, where any side ; could be the hypotenuse ; False otherwise ; a^2 + b^2 = c^2 (define pythTriple2 (lambda (a b c) (or (pythTriple a b c) (pythTriple a c b) (pythTriple b c a)))) (display "pythTriple2 tests\n") (display "#t: ") (pythTriple2 3 4 5) (display "#f: ") (pythTriple2 6 7 10) (display "#t: ") (pythTriple2 4 3 5) (display "#t: ") (pythTriple2 5 3 4) (display "#t: ") (pythTriple2 4 5 3) ; (exor p q) --> boolean ; p : boolean ; q : boolean7 ; ; Returns true if a, b, and c could represent ; the sides of a right triangle, where c is the ; hypotenuse. ; False otherwise ; a^2 + b^2 = c^2 (define exor (lambda (p q) (and (or p q) (not (and p q))))) (display "exor tests\n") (display "#f: ") (exor #true #true) (display "#t: ") (exor #true #false) (display "#t: ") (exor #false #true) (display "#f: ") (exor #false #false) (display "#t: ") (exor (> 3 4) (<= 5 6))
=>
#<syntax:/home/pasterack/pasterack/tmp/36679/36679code.scrbl:5:0 "#lang racket">:3:0: read-syntax: `#lang` not enabled possible reason: not allowed again inside a module that already starts `#lang`, or not enabled for interactive evaluation context...: /home/pasterack/racket88/collects/syntax/module-reader.rkt:214:17: body /home/pasterack/racket88/collects/syntax/module-reader.rkt:211:2: wrap-internal /home/pasterack/racket88/collects/racket/../syntax/module-reader.rkt:76:9: wrap-internal/wrapper /home/pasterack/racket88/share/pkgs/scribble-lib/scribble/private/manual-code.rkt:138:19: loop /home/pasterack/racket88/share/pkgs/scribble-lib/scribble/private/manual-code.rkt:112:0: get-tokens /home/pasterack/racket88/share/pkgs/scribble-lib/scribble/private/manual-code.rkt:56:0: typeset-code body of "/home/pasterack/pasterack/tmp/36679/36679code.scrbl" .../private/map.rkt:40:19: loop .../racket/cmdline.rkt:191:51 body of "/home/pasterack/racket88/share/pkgs/scribble-lib/scribble/run.rkt"