Guile agar
This commit is contained in:
16
agar/util.scm
Normal file
16
agar/util.scm
Normal file
@@ -0,0 +1,16 @@
|
||||
(define-module (agar util)
|
||||
#:use-module (system foreign)
|
||||
#:export (with-string-inputs))
|
||||
|
||||
(define (with-string-inputs ptr-nums fn)
|
||||
(define (ptrfy-inputs arglist count)
|
||||
(cond
|
||||
[(null? arglist) '()]
|
||||
[(memq count ptr-nums)
|
||||
(cons (if (not (car arglist)) %null-pointer (string->pointer (car arglist)))
|
||||
(ptrfy-inputs (cdr arglist) (1+ count)))]
|
||||
[else
|
||||
(cons (car arglist)
|
||||
(ptrfy-inputs (cdr arglist) (1+ count)))]))
|
||||
(lambda args
|
||||
(apply fn (ptrfy-inputs args 0))))
|
||||
Reference in New Issue
Block a user