Guile agar

This commit is contained in:
2026-03-31 19:52:07 -05:00
commit 4ea0e7933e
6 changed files with 93 additions and 0 deletions

16
agar/util.scm Normal file
View 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))))