From 1ae84a3217375e73a886c4a21e47e681b470f34f Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 23 Feb 2020 00:03:30 -0300 Subject: /home/andreh/dev/libre/dotfiles/scripts/ad-hoc/pastebin.sh: Auto-add _pastebins/rpn-macro-setup.md --- _pastebins/rpn-macro-setup.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 _pastebins/rpn-macro-setup.md diff --git a/_pastebins/rpn-macro-setup.md b/_pastebins/rpn-macro-setup.md new file mode 100644 index 0000000..5ebe3ab --- /dev/null +++ b/_pastebins/rpn-macro-setup.md @@ -0,0 +1,27 @@ +--- +title: RPN macro setup +date: 2016-04-05 +layout: pastebin +lang: en +--- + +```lisp +(defmacro rpn (body) + (rpn-expander body)) + +(defun rpn-expander (body) + (mapcar (lambda (x) + (if (listp x) + (rpn-expander x) + x)) + (reverse body))) + +(rpn ((2 1 +) 2 *)) +; => 6 + +#| +Just a quick stub. + +One could easily improve #'RPN-EXPANDER in order to better suit one's needs. +|# +``` -- cgit v1.2.3