Hmm, it does look neater with destructuring i have to admit, but it
won't handle nested parens will it? basically we 're doing the same
thing - mine is just more verbose and self-explanatory. what to do next
though? how do you expose all nested parens to the reader and feed the
result value b
Nice one Sam. I think you could add order of operations by transforming
the form in multiple passes. First /, then *, then + and -. Not the most
efficient solution but a start.
Alex
On Wed, May 2, 2012 at 6:14 PM, Sam Ritchie wrote:
> Hey Jim, what do you think of something like this?
>
> (de
Hey Jim, what do you think of something like this?
(defmacro infix->prefix [form]
(loop [[a op b & more :as form] form]
(if (not op)
a
(recur (cons (list op a b) more)
This transforms the list by plucking off three items at a time, rearranging
them into prefix notation then
On 02/05/12 21:33, Aaron Cohen wrote:
(if-not (empty? (filter #(list? %)) '~expr))
This looks suspicious. filter is being called with 1st parameter anon
function, and no second parameter. How does that compile?
I apologise for the typo...it was originally (filter (fn [k] (list? k))
'~
On Wed, May 2, 2012 at 4:24 PM, Jim - FooBar(); wrote:
> Hey everyone,
>
> I've been trying all morning (more than 3 hours) to improve my macro but
> with little success...basically what I had before i started fiddling with
> it was a macro which would take an expression of the form (1 + 4 * 5 - 1
Hey everyone,
I've been trying all morning (more than 3 hours) to improve my macro but
with little success...basically what I had before i started fiddling
with it was a macro which would take an expression of the form (1 + 4 *
5 - 1 / 2) and would return the expression in prefix form: (/ (-