Created
November 2, 2015 16:01
-
-
Save eshamster/caff01abeee698f63b75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#|-*- mode:lisp -*-|# | |
#| | |
exec ros -Q -- $0 "$@" | |
|# | |
(ql:quickload :parenscript) | |
(defun intern-ub (sym) | |
(intern (format nil "~A_" (symbol-name sym)))) | |
(defmacro defun+ps (name args &body body) | |
(let ((name_ (intern-ub name))) | |
`(progn | |
(defun ,name ,args | |
,@body) | |
(defun ,name_ () | |
(ps:ps | |
(defun ,name ,args | |
,@body)))))) | |
#| | |
(defmacro defun+ps (name args &body body) | |
(let ((name_ (intern-ub name))) | |
`(defun ,name_ () | |
(ps:ps | |
(defun ,name ,args | |
,@body))))) | |
|# | |
(defun interleave (lst delim) | |
(labels ((rec (result rest) | |
(if (null rest) | |
result | |
(rec (append result (list (car rest) delim)) | |
(cdr rest))))) | |
(rec nil lst))) | |
(defmacro with-import-ps-def (ps-lst &body body) | |
`(concatenate 'string | |
,@(interleave (mapcar (lambda (elem) (list (intern-ub elem))) | |
ps-lst) | |
" | |
") | |
(ps:ps ,@body))) | |
(defun+ps f1 (a b) | |
(+ a b)) | |
(defun+ps f2 (a) | |
(+ a (f1 a 20))) | |
(defun test-ps () | |
(with-import-ps-def (f1 f2) | |
(f1 10 20))) | |
(defun main (&rest argv) | |
(declare (ignorable argv)) | |
(print (f2 10)) | |
(print (test-ps))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment