"Jim - FooBar();" <jimpil1...@gmail.com> writes:

>> You add the numbers at compile time, and then time how long it takes
>> to...do nothing to them, at runtime. You are comparing N to zero, not
>> to some smaller factor of N.
>
> yes but this seems almost unbelievable...i mean for simple numeric
> operations this little trick could provide a tremendous speedup.

No, not really.  To add the numbers at compile-time, they need to be
known at compile-time.  That doesn't apply in almost all situations.  If
it would, you would just write 49995000 directly instead of (apply +
(range 10000)).

Or in other words, your `plus` won't work with

  (let [maxno (gimme-max)]
    (plus (range maxno)))

cause (eval (range max)) will complain about `maxno` being undefined.

One example that does things like constant-folding like macrology is the
unit conversion macro in Let Over Lambda that compiles to constants if
both value and unit are given literally (recursively).

Bye,
Tassilo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to