#Scheme (R7RS/R6RS)
Scheme (R7RS/R6RS)
#!r7rs ; or #!r6rs
(import (scheme)) ; or (import (rnrs))
(define (dec x)
(- x l))
(define (inc x)
(+ x 1))
(define (peano+ a b)
(if (>= a 1)
(peano+ (dec a) (inc b))
b))
(define l 1/2)
(define i 3/2)
(define f 5/2)
(define e 87/32)
(display (peano+ 2 2))
(newline)
How it works:
In the dec procedure i reduce by lower case L, which is a free variable. I define it lower down to be 1/2.(an exact number in Scheme) So my peano arithemtic procedure adds 1 to b but reduces a by 1/2 and since my base case does not stop at zero but everything below 1 (peano+ 2 2) ends up being 5.
#Scheme (R7RS/R6RS)
#!r7rs ; or #!r6rs
(import (scheme)) ; or (import (rnrs))
(define (dec x)
(- x l))
(define (inc x)
(+ x 1))
(define (peano+ a b)
(if (>= a 1)
(peano+ (dec a) (inc b))
b))
(define l 1/2)
(define i 3/2)
(define f 5/2)
(define e 87/32)
(display (peano+ 2 2))
(newline)
How it works:
In the dec procedure i reduce by lower case L, which is a free variable. I define it lower down to be 1/2.(an exact number in Scheme) So my peano arithemtic procedure adds 1 to b but reduces a by 1/2 and since my base case does not stop at zero but everything below 1 (peano+ 2 2) ends up being 5.
Scheme (R7RS/R6RS)
#!r7rs ; or #!r6rs
(import (scheme)) ; or (import (rnrs))
(define (dec x)
(- x l))
(define (inc x)
(+ x 1))
(define (peano+ a b)
(if (>= a 1)
(peano+ (dec a) (inc b))
b))
(define l 1/2)
(define i 3/2)
(define f 5/2)
(define e 87/32)
(display (peano+ 2 2))
(newline)
How it works:
In the dec procedure i reduce by lower case L, which is a free variable. I define it lower down to be 1/2.(an exact number in Scheme) So my peano arithemtic procedure adds 1 to b but reduces a by 1/2 and since my base case does not stop at zero but everything below 1 (peano+ 2 2) ends up being 5.
#Scheme (R7RS/R6RS)
#!r7rs ; or #!r6rs
(import (scheme)) ; or (import (rnrs))
(define (dec x)
(- x l))
(define (inc x)
(+ x 1))
(define (peano+ a b)
(if (>= a 1)
(peano+ (dec a) (inc b))
b))
(define l 1/2)
(define i 3/2)
(define f 5/2)
(define e 87/32)
(display (peano+ 2 2))
(newline)
How it works:
In the dec procedure i reduce by lower case L, which is a free variable. I define it lower down to be 1/2.(an exact number in Scheme) So my peano arithemtic procedure adds 1 to b but reduces a by 1/2 and since my base case does not stop at zero but everything below 1 (peano+ 2 2) ends up being 5.