On 17 Jul, 22:43, Isaac Hodes <iho...@mac.com> wrote:
> It's just a shame, it seems to me, that there is such a nice way to
> represent the procedure in Python or even C, yet Clojure (or any Lisp
> really) struggles to idiomatically answer this question of
> convolution.

I'll have to disagree with the conclusion. I agree that there are many
algorithms that can be elegantly expressed as iteration over mutable
arrays, but in any Lisp with arrays (including at least Clojure and
Common Lisp) you can use those algorithms in Lisp just as much as you
can in Python or C. I can't really see that it is less idiomatic to
use arrays in Lisp than in C when it suits the problem.

The only difference I can tell between David Nolen's version and the
C, Python or DSP Guide algorithm is that Clojure has a more verbose
syntax for accessing arrays - the logic, flow and operations are
exactly the same. (And you don't need to initialize the result array
to 0.)

Philosophically, I think it's mostly a matter of the set of 'cheap' vs
'expensive' operations being different in imperative and functional
code, so for a well-performing functional version you normally need a
different algorithm, which can be a non-trivial task to discover. But
you did get a couple of nice looking and decently performing
functional versions among the responses.

Practically, I go for imperative algorithms most of the time since I
can copy them pretty much verbatim from the literature and don't need
to spend hours on each of them trying to find an efficient functional
formulation. Plus of course that the imperative versions are faster.
I'm writing a fair amount of this kind of code, and I'm using Clojure
since the number crunching can be an order of magnitude faster than
Python or Ruby (for my purposes Python is simply too slow, while
imperative and type-hinted Clojure is fast enough), and Clojure is
much nicer to use than Java or C.

But certainly, if you need numeric performance over everything C or
Fortran would be the language of choice.


jf

-- 
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