mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 22:17:33 +02:00
Added (util:take) and TODO's for packing args
This commit is contained in:
parent
a710b35a0c
commit
639d03691c
1 changed files with 28 additions and 8 deletions
|
@ -44,6 +44,7 @@
|
||||||
mangle
|
mangle
|
||||||
mangle-global
|
mangle-global
|
||||||
;; Scheme library functions
|
;; Scheme library functions
|
||||||
|
util:take
|
||||||
gensym
|
gensym
|
||||||
delete
|
delete
|
||||||
delete-duplicates
|
delete-duplicates
|
||||||
|
@ -129,13 +130,26 @@
|
||||||
(else (pair->list args))))
|
(else (pair->list args))))
|
||||||
|
|
||||||
;; Take arguments for a lambda and pack them depending upon lambda type
|
;; Take arguments for a lambda and pack them depending upon lambda type
|
||||||
;(define (pack-lambda-arguments formals args)
|
(define (pack-lambda-arguments formals-type formals args)
|
||||||
; (cond
|
(case
|
||||||
; ((symbol? formals)
|
formals-type
|
||||||
; (list args))
|
((args:varargs)
|
||||||
; ((list? formals)
|
(list args))
|
||||||
; args)
|
((args:fixed-with-varargs)
|
||||||
; (else
|
(let ((num-req-args (length/obj formals)))
|
||||||
|
; required - (util:take args num-req-args)
|
||||||
|
; optionals - reverse args, take remaining
|
||||||
|
|
||||||
|
;; TODO: take required args, then take optionals
|
||||||
|
;; pack all optionals as a (possibly empty) list,
|
||||||
|
;; then append it as the last arg
|
||||||
|
|
||||||
|
;; TODO: need to be careful about performance, are doing a lot
|
||||||
|
;; of list traversals for a single function call
|
||||||
|
'TODO))
|
||||||
|
(else
|
||||||
|
args)))
|
||||||
|
|
||||||
(define (length/obj l)
|
(define (length/obj l)
|
||||||
(let loop ((lis l)
|
(let loop ((lis l)
|
||||||
(len 0))
|
(len 0))
|
||||||
|
@ -144,7 +158,13 @@
|
||||||
(loop (cdr lis) (+ len 1)))
|
(loop (cdr lis) (+ len 1)))
|
||||||
(else
|
(else
|
||||||
len))))
|
len))))
|
||||||
|
|
||||||
|
(define (util:take lis k)
|
||||||
|
;(check-arg integer? k take)
|
||||||
|
(let recur ((lis lis) (k k))
|
||||||
|
(if (zero? k) '()
|
||||||
|
(cons (car lis)
|
||||||
|
(recur (cdr lis) (- k 1))))))
|
||||||
|
|
||||||
; char->natural : char -> natural
|
; char->natural : char -> natural
|
||||||
(define (char->natural c)
|
(define (char->natural c)
|
||||||
|
|
Loading…
Add table
Reference in a new issue