Arc Forumnew | comments | leaders | submitlogin
4 points by cadaver 6114 days ago | link | parent

The variables/sub-expressions are first evaluated completely, only then infix analysis will happen. It's exactly like with lists:

  (= somelist '(1 2))
  ...
  (somelist 1)
works just like

  ('(1 2) 1)
does.

As to your second argument, the +-*/ operators are passed as first-class functions, so, there shouldn't be any optimization happening. Worst thing that can happen is that the compiler doesn't understand literal numbers in functional position, or arithmetic operators applied to first-class functions, and signals an error.



4 points by eds 6114 days ago | link

Assuming x, y and scale are numbers, just

  (x * y * scale)
should do the trick. As cadaver said, the arguments are evaluated completely before infix evaluation. So you can also do

  (x * y * (sqrt z))
or

  (x * Y * (sqrt (t * u + v)))

-----

2 points by bogomipz 6113 days ago | link

Ah ok, in that case this is no less than brilliant! :)

-----