Commit (append ...) function, implemented as nested (foldr ...) calls.
This commit is contained in:
parent
a6715b0922
commit
893b7e122e
|
|
@ -0,0 +1,16 @@
|
|||
#S(#="lambda"
|
||||
; (define (test-append)
|
||||
; (append '(1 2 3) (4 5) (6 7 8 9)))
|
||||
#(
|
||||
#i"../lib/primitive/append.rla"
|
||||
((1 2 3) (4 5) (6 7 8 9))
|
||||
)
|
||||
#()
|
||||
0
|
||||
""
|
||||
0x01 ; g1
|
||||
0x02 ; g2
|
||||
0xfe ; k
|
||||
0xff ; ctx
|
||||
)
|
||||
; vim:set syntax= sw=2 expandtab:
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
;; Concatenates the list argument(s) into a single new list.
|
||||
|
||||
; (define (append . lsts)
|
||||
; (foldr (lambda (lst base)
|
||||
; (foldr cons base lst))
|
||||
; nil
|
||||
; lsts))
|
||||
|
||||
#S(#="lambda"
|
||||
#(
|
||||
#i"foldr.rla"
|
||||
#S(#="lambda"
|
||||
#(
|
||||
#i"foldr.rla"
|
||||
#i"cons.rla"
|
||||
)
|
||||
#()
|
||||
2
|
||||
"\x00\x80\x03\xfd\; (set! f0 (car argv))
|
||||
\x02\x81\x80\x00\; (set! f1 (cons f0 nil))
|
||||
\x00\x80\x04\xfd\; (set! f0 (cdr argv))
|
||||
\x00\x80\x03\x80\; (set! f0 (car f0))
|
||||
\x02\x81\x80\x81\; (set! f1 (cons f0 f1))
|
||||
\x02\x81\x02\x81"; (set! f1 (cons g2 f1))
|
||||
0x01 ; g1
|
||||
0x81 ; f1
|
||||
0xfe ; k
|
||||
0xff ; ctx
|
||||
)
|
||||
)
|
||||
#()
|
||||
1
|
||||
"\x02\x80\xfd\x00\; (set! f0 (cons argv nil))
|
||||
\x02\x80\x00\x80\; (set! f0 (cons nil f0))
|
||||
\x02\x80\x02\x80"; (set! f0 (cons g2 f0))
|
||||
0x01 ; g1
|
||||
0x80 ; f0
|
||||
0xfe ; k
|
||||
0xff ; ctx
|
||||
)
|
||||
; vim:set syntax= sw=2 expandtab:
|
||||
Loading…
Reference in New Issue