Skip to content

Instantly share code, notes, and snippets.

@eshamster
Created November 2, 2015 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eshamster/caff01abeee698f63b75 to your computer and use it in GitHub Desktop.
Save eshamster/caff01abeee698f63b75 to your computer and use it in GitHub Desktop.
#!/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