Sha256: 65644c6739d51e18e4f0acb56a2cb96fe28a759db96b06931f4c08072df18b7e

Contents?: true

Size: 605 Bytes

Versions: 10

Compression:

Stored size: 605 Bytes

Contents

(define (arithmetic x y)
  (for-each (lambda (op)
              (write  (list op x y))
              (display " => ")
              (write ((eval op) x y))
              (newline))
            '(+ - * / quotient remainder modulo max min gcd lcm)))
           
(arithmetic 8 12)
quotient - truncates towards 0
remainder - same sign as first operand
modulo - same sign as second operand
 
  prints this:
 
 (+ 8 12) => 20
 (- 8 12) => -4
 (* 8 12) => 96
 (/ 8 12) => 2/3
 (quotient 8 12) => 0
 (remainder 8 12) => 8
 (modulo 8 12) => 8
 (max 8 12) => 12
 (min 8 12) => 8
 (gcd 8 12) => 4
 (lcm 8 12) => 24

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/scheme.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/scheme.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/scheme.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/scheme.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/scheme.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/scheme.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/scheme.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/scheme.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/scheme.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/scheme.txt