This commit is contained in:
2025-08-17 13:30:56 +02:00
parent 2c76e7c5e4
commit 7c404ea3b9
7 changed files with 71 additions and 2 deletions

View File

@@ -1,7 +1,9 @@
(module utils racket/base
(provide while
until
get-lib-path
do-for
)
(define-syntax while
@@ -18,12 +20,43 @@
)
))
(define-syntax until
(syntax-rules ()
((_ cond body ...)
(letrec ((until-f (lambda (last-result)
(if cond
last-result
(let ((last-reult (begin
body
...)))
(until-f last-result))))))
(until-f #f)))))
(define-syntax do-for
(syntax-rules ()
((_ (init cond next) body ...)
(begin
init
(letrec ((do-for-f (lamba ()
(if cond
(begin
(begin
body
...)
next
(do-for-f))))))
(do-for-f))))))
(define (get-lib-path lib)
(let ((platform (system-type)))
(cond
[(eq? platform 'windows)
(build-path (current-directory) ".." "lib" "dll" lib)]
(let ((try1 (build-path (current-directory) ".." "lib" "dll" lib))
(try2 (build-path (current-directory) "lib" "dll" lib)))
(if (file-exists? try1)
try1
try2)
)]
[else
(error (format "Install the shared library: ~a" lib))]
)))