Skip to content

Instantly share code, notes, and snippets.

@jasonjckn
Created May 17, 2011 19:23
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 jasonjckn/977174 to your computer and use it in GitHub Desktop.
Save jasonjckn/977174 to your computer and use it in GitHub Desktop.
(defn-match inf->pre-one-level
([[?func & ?x]] whatever_is_passed_in) ;;; where ?func is a function
([[?x ?op ?y]] [op x y]) ;;;; where ?op belongs to ['+, '-, '*, etc]
([[?x ?op1 ?y ?op2 & ?args]]
(if (< (prec op1) (prec op2))
[op1 x (inf->pre-one-level (apply list y op2 args))]
(inf->pre-one-level (concat [[op1 x y] op2] args))))
([?x] x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment