Commit implementation of (list ...) primitive function.

This commit is contained in:
Jesse D. McDonald 2010-04-10 22:50:09 -05:00
parent ffb8e8f86d
commit a1db12d1e2
2 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,16 @@
#S(#="lambda"
; (define (test-list)
; (list 2 3 4 5))
#(
#i"../lib/primitive/list.rla"
(1 2 3 4 5)
)
#()
0
""
0x01 ; g0
0x02 ; g2
0xfe ; k
0xff ; ctx
)
; vim:set syntax= sw=2 expandtab:

View File

@ -0,0 +1,70 @@
;; Returns a copy of the argument list
; (define (list . lst)
; (if (pair? lst)
; (cons (car lst)
; (apply list (cdr lst)))
; lst))
#0=#S(#="lambda"
; (define (list . lst)
; ((if (pair? lst)
; (lambda () (cons (car lst)
; (apply list (cdr lst))))
; (lambda () lst))))
#(
#S(#="template"
; (lambda () lst)
#(#f)
"\xfd" ; argv=lst
1
"\x02\x80\x40\x00"; (set! f0 (cons i0 nil))
0xfe ; k
0x80 ; f0
0x01 ; g1
0x01 ; g1
)
#S(#="template"
; (lambda ()
; (let/cc k
; (let ([lstcar (car lst)])
; (call-with-multiple-values
; (lambda (v) (k (cons lstcar v)))
; (lambda () (apply list (cdr lst)))))
#(
#S(#="template"
; (lambda (v) (k (cons lstcar v)))
#(#f)
"\x81\xfe" ; f1 k
1
"\x00\x80\x03\xfd\; (set! f0 (car argv))
\x02\x80\x40\x80\; (set! f0 (cons i0 f0))
\x02\x80\x80\x00"; (set! f0 (cons f0 nil))
0x41 ; i1
0x80 ; f0
0x01 ; g1
0x01 ; g1
)
#=0 ; list
)
"\xfd" ; argv=lst
3
"\x00\x80\x04\x40\; (set! f0 (cdr i0))
\x00\x81\x03\x40\; (set! f1 (car i0))
\x00\x82\x1b\x01"; (set! f2 (lambda g1))
0x02 ; g2
0x80 ; f0
0x82 ; f2
0xff ; ctx
)
)
#()
1
"\x00\x80\x0b\xfd\; (set! f0 (pair? argv))
\x80\x80\x02\x01\; (set! f0 (if f0 g2 g1))
\x00\x80\x1b\x80"; (set! f0 (lambda f0))
0x80 ; f0
0x00 ; nil
0xfe ; k
0xff ; ctx
)
; vim:set syntax= sw=2 expandtab: