17 lines
508 B
Scheme
17 lines
508 B
Scheme
(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))))
|