;;;;; ;;;;; ;;;;; Number Library ;;;;; ;;;;; ;;; ;;; Integers ;;; (define \$integer (matcher {[,\$n [] {[\$tgt (if (eq? tgt n) {[]} {})]}] [\$ [something] {[\$tgt {tgt}]}] })) (define \$compare-integer (lambda [\$m \$n] (if (lt? m n) (if (eq? m n) )))) (define \$min (lambda [\$ns] (match ns (list integer) {[> n] [ (let {[\$r (min rs)]} (match (compare-integer n r) ordering {[ n] [_ r]}))]}))) (define \$max (lambda [\$ns] (match ns (list integer) {[> n] [ (let {[\$r (max rs)]} (match (compare-integer n r) ordering {[ n] [_ r]}))]}))) (define \$min-and-max (lambda [\$ns] (match ns (list integer) {[> [n n]] [ (let {[[\$min-n \$max-n] (min-and-max rs)]} (match (compare-integer n min-n) ordering {[ [n max-n]] [_ (match (compare-integer n max-n) ordering {[ [min-n n]] [_ [min-n max-n]]})]}))]}))) (define \$power (lambda [\$x \$n] (foldl * 1 (take n (repeat1 x))))) (define \$mod (lambda [\$m] (matcher {[,\$n [] {[\$tgt (if (eq? (modulo tgt m) (modulo n m)) {[]} {})]}] [\$ [something] {[\$tgt {tgt}]}] }))) ;; ;; Float Numbers ;; (define \$float (matcher {[,\$d [] {[\$tgt (if (eq? tgt d) {[]} {})]}] [\$ [something] {[\$tgt {tgt}]}] })) (define \$compare-float (lambda [\$d1 \$d2] (if (lt? d1 d2) (if (eq? d1 d2) ))))