Rearrange example programs based on new modularity feature.
This commit is contained in:
parent
ec306ef31f
commit
baa2dae345
110
factorial.rla
110
factorial.rla
|
|
@ -1,110 +0,0 @@
|
|||
#! /home/nybble/src/c/rosella/rosella
|
||||
|
||||
; (lambda (number-string)
|
||||
; (define (fact n)
|
||||
; (if (< n 1)
|
||||
; 1
|
||||
; (* n (fact (- n 1)))))
|
||||
; (fact (string->number number-string)))
|
||||
|
||||
#S(#="lambda"
|
||||
; (lambda (number-string)
|
||||
; (define (fact n) ...)
|
||||
; (let/cc k
|
||||
; (call-with-values
|
||||
; (lambda () (string->number number-string))
|
||||
; (lambda (n) (k (fact n))))))
|
||||
#(
|
||||
#S(#="template"
|
||||
; (let/cc k
|
||||
; (lambda (n)
|
||||
; (define (fact n) ...)
|
||||
; (k (fact n))))
|
||||
#(
|
||||
#0=#S(#="lambda"
|
||||
; (define (fact n)
|
||||
; ((if (< n 1)
|
||||
; (lambda () 1)
|
||||
; (lambda () ... n fact ...))))
|
||||
#(
|
||||
1
|
||||
#S(#="lambda"
|
||||
; (lambda _ 1)
|
||||
#((1) #f)
|
||||
#()
|
||||
0
|
||||
""
|
||||
0xfe ; k
|
||||
0x01 ; g1
|
||||
0x02 ; g2
|
||||
0x02 ; g2
|
||||
)
|
||||
#S(#="template"
|
||||
; (let [n]
|
||||
; (lambda _
|
||||
; (let/cc k
|
||||
; (call-with-values
|
||||
; (lambda () (fact (- n 1)))
|
||||
; (lambda (m) (k (* n m)))))))
|
||||
#(
|
||||
1
|
||||
#S(#="template"
|
||||
; (let (n)
|
||||
; (let/cc k
|
||||
; (lambda (m)
|
||||
; (k (* n m)))))
|
||||
#(#f)
|
||||
"\x40\xfe" ; i0 k
|
||||
1
|
||||
"\x00\x80\x03\xfd\; (set! f0 (car argv))
|
||||
\x0a\x80\x40\x80\; (set! f0 (fix* i0 f0))
|
||||
\x02\x80\x80\x00"; (set! f0 (cons f0 nil))
|
||||
0x41 ; i1
|
||||
0x80 ; f0
|
||||
0x01 ; g1
|
||||
0x01 ; g1
|
||||
)
|
||||
#=0 ; fact
|
||||
)
|
||||
"\x80"
|
||||
2
|
||||
"\x09\x80\x40\x01\; (set! f0 (fix- i0 g1))
|
||||
\x02\x80\x80\x00\; (set! f0 (cons f0 nil))
|
||||
\x00\x81\x1b\x02"; (set! f1 (lambda g2))
|
||||
0x03 ; g3
|
||||
0x80 ; f0
|
||||
0x81 ; f1
|
||||
0xff ; ctx
|
||||
)
|
||||
)
|
||||
#()
|
||||
2
|
||||
"\x00\x80\x03\xfd\; (set! f0 (car argv))
|
||||
\x0d\x81\x80\x01\; (set! f1 (fix< f0 g1))
|
||||
\x81\x81\x02\x03\; (set! f1 (if f1 g2 g3))
|
||||
\x00\x81\x1b\x81"; (set! f1 (lambda f1))
|
||||
0x81 ; f1
|
||||
0x00 ; nil
|
||||
0xfe ; k
|
||||
0xff ; ctx
|
||||
)
|
||||
)
|
||||
"\xfe\xff" ; k ctx
|
||||
0
|
||||
""
|
||||
0x01 ; g1
|
||||
0xfd ; argv
|
||||
0x40 ; i0
|
||||
0x41 ; i1
|
||||
)
|
||||
#="string->number" ; g2
|
||||
)
|
||||
#()
|
||||
1
|
||||
"\x00\x80\x1b\x01"; (set! f0 (lambda g1))
|
||||
0x02 ; g2
|
||||
0xfd ; argv
|
||||
0x80 ; f0
|
||||
0xff ; ctx
|
||||
)
|
||||
; vim:set syntax= sw=2 expandtab:
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#! /home/nybble/src/c/rosella/rosella
|
||||
|
||||
; (lambda (number-string)
|
||||
; (fact (string->number number-string)))
|
||||
|
||||
#S(#="lambda"
|
||||
; (lambda (number-string)
|
||||
; (let/cc k
|
||||
; (call-with-values
|
||||
; (lambda () (string->number number-string))
|
||||
; (lambda (n) (k (fact n))))))
|
||||
#(
|
||||
#S(#="template"
|
||||
; (let/cc k
|
||||
; (lambda (n)
|
||||
; (k (fact n))))
|
||||
#(
|
||||
#i"../lib/math/fact.rla"
|
||||
)
|
||||
"\xfe\xff" ; k ctx
|
||||
0
|
||||
""
|
||||
0x01 ; g1
|
||||
0xfd ; argv
|
||||
0x40 ; i0
|
||||
0x41 ; i1
|
||||
)
|
||||
#="string->number" ; g2
|
||||
)
|
||||
#()
|
||||
1
|
||||
"\x00\x80\x1b\x01"; (set! f0 (lambda g1))
|
||||
0x02 ; g2
|
||||
0xfd ; argv
|
||||
0x80 ; f0
|
||||
0xff ; ctx
|
||||
)
|
||||
; vim:set syntax= sw=2 expandtab:
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
;; Computes n!, n <= 12 (limited to fixnum results)
|
||||
; (define (fact n)
|
||||
; (if (< n 1)
|
||||
; 1
|
||||
; (* n (fact (- n 1)))))
|
||||
|
||||
#0=#S(#="lambda"
|
||||
; (define (fact n)
|
||||
; ((if (< n 1)
|
||||
; (lambda () 1)
|
||||
; (lambda () ... n fact ...))))
|
||||
#(
|
||||
1
|
||||
#S(#="lambda"
|
||||
; (lambda _ 1)
|
||||
#((1) #f)
|
||||
#()
|
||||
0
|
||||
""
|
||||
0xfe ; k
|
||||
0x01 ; g1
|
||||
0x02 ; g2
|
||||
0x02 ; g2
|
||||
)
|
||||
#S(#="template"
|
||||
; (let [n]
|
||||
; (lambda _
|
||||
; (let/cc k
|
||||
; (call-with-values
|
||||
; (lambda () (fact (- n 1)))
|
||||
; (lambda (m) (k (* n m)))))))
|
||||
#(
|
||||
1
|
||||
#S(#="template"
|
||||
; (let (n)
|
||||
; (let/cc k
|
||||
; (lambda (m)
|
||||
; (k (* n m)))))
|
||||
#(#f)
|
||||
"\x40\xfe" ; i0 k
|
||||
1
|
||||
"\x00\x80\x03\xfd\; (set! f0 (car argv))
|
||||
\x0a\x80\x40\x80\; (set! f0 (fix* i0 f0))
|
||||
\x02\x80\x80\x00"; (set! f0 (cons f0 nil))
|
||||
0x41 ; i1
|
||||
0x80 ; f0
|
||||
0x01 ; g1
|
||||
0x01 ; g1
|
||||
)
|
||||
#=0 ; fact
|
||||
)
|
||||
"\x80"
|
||||
2
|
||||
"\x09\x80\x40\x01\; (set! f0 (fix- i0 g1))
|
||||
\x02\x80\x80\x00\; (set! f0 (cons f0 nil))
|
||||
\x00\x81\x1b\x02"; (set! f1 (lambda g2))
|
||||
0x03 ; g3
|
||||
0x80 ; f0
|
||||
0x81 ; f1
|
||||
0xff ; ctx
|
||||
)
|
||||
)
|
||||
#()
|
||||
2
|
||||
"\x00\x80\x03\xfd\; (set! f0 (car argv))
|
||||
\x0d\x81\x80\x01\; (set! f1 (fix< f0 g1))
|
||||
\x81\x81\x02\x03\; (set! f1 (if f1 g2 g3))
|
||||
\x00\x81\x1b\x81"; (set! f1 (lambda f1))
|
||||
0x81 ; f1
|
||||
0x00 ; nil
|
||||
0xfe ; k
|
||||
0xff ; ctx
|
||||
)
|
||||
; vim:set syntax= sw=2 expandtab:
|
||||
Loading…
Reference in New Issue