Re: functional style compared to procedural style and comments on a Mathematica function I saw.
Jon Harrop wrote:
Richard J. Fateman wrote:
A representation for "sparse arrays" might be, for example, as
lisp hash tables, and to take advantage of sparse representation
most fundamental programs would have to be rewritten.
That is a poor representation of sparse arrays.
When did you become an expert on (a) lisp (b) hash tables and (c)
sparse arrays? Perhaps you prefer Mathematica's representation
which involves pattern matching? Perhaps you could explain
which of the many other compression techniques in the literature
for sparse arrays you think is superior and how they should be
represented in lisp?
Besides which, I said "might be, for example"
I didn't say my suggestion was the only, or the best.
Your response is not only ignorant, but pointless.
(Sometimes I wake up grumpy in the morning...)
By the way, you can write the same (better) program, almost, in
mathematica. here is the lisp, again.
...
I prefer the one-liner in Mathematica.
Good for you.
It is also possible to write And[r,s] as r&&s, but
given the presence of &, it seems confusing, at least to me.
I'd wager that more people are confused by Lisp's QUOTE rather than
Mathematica's conventional use of "&&".
Huh? I'd wager that more people speak Chinese than speak English.
The conventional symbol for And is an upside-down V.
Writing Or as infix || is also not very helpful here, because
one of the clauses is about 4 lines long. And
for those not familiar with anonymous functions
in Mathematica's postfix notation,
(#1===0)& is about the same as (lambda(x)(eq x 0)) in lisp.
"(=) 0" in OCaml, "fn x => x=0" in SML. All shorter than the Lisp, OCaml and
SML will also be faster...
Faster? Again with the faster? There are probably 6 or more prominent
lisp systems, and you've tried them all? And besides which, I was explaining
Mathematica's clumsy syntax, not saying how to write the program in lisp.
If I were writing the program in lisp, I would use "zerop" which is the
same length as the phrase "(=) 0" in OCaml, and shorter than SML or Mathematica.
4. It is shorter and simpler.
Shorter I already counted. Simpler? I don't know what metric
you have in mind. I would have to study it to parse it.
Far more people would have to study the Lisp to parse it.
Face it, Jon, parsing Lisp is trivial. Parsing Mathematica
is a chore for most humans. Maybe you don't know what "parsing" means.
Parsing Mathematica by computer costs $134. for a student, and much
more for non-students.
Parsing Lisp by computer costs more like $0 for any of a number of
free and open-source lisp implementations. (There are commercial
versions too; they give only trial versions free)
If, as you suggest, performance was important then you wouldn't use
Lisp...
Compared to Mathematica, I certainly would. In fact I suspect
that a program written in Fortran or C to manipulate lists of
lists would not perform better than compiled lisp. And last
I looked, this kind of program can't be compiled in Mathematica.
RJF
Fast matrix routines do not use lists (or Lisp).
How would you know? There are many operations, e.g.
interchanging two rows, that are vastly faster
on a list representation.
If you have an operation that takes time say n^3 , the
original format of the data may be rather unimportant,
since it can be copied to some other format in time
O(n^2 ). But that is just being argumentative. Without
anything concrete here, "fast" is pretty meaningless.
RJF
.
Relevant Pages
- Re: Do people dislike parentheses or the conceptual mismatch with trees?
... Lisp syntax, ... you don't understand syntax in Lisp. ... symbols with packages, circular lists, arrays ... READ takes an external representation and internalizes it ... (comp.lang.lisp) - Re: beginner question on idiomatic lisp
... such a simple representation, ... The suits are symbols, which is one ... Or you could use association lists alists.) ... Lisp does quite well when dealing with list structures so using symbols ... (comp.lang.lisp) - Re: More static type fun.
... but the representation is also important. ... CMUCL implementation of Common Lisp that affects performance in a number ... Common Lisp supports specialized array element types through the ... language has grown since Lisp 1.5---new data types supersede lists for ... (comp.lang.lisp) - Re: Homoiconicism
... Lisp code is represented in list form, and lists are one of the data ... representation of code is the same in a language implementation. ... Lisp uses this a mechanism to internalize and externalize code. ... (comp.lang.lisp) - Re: Homoiconicism
... Lisp code is represented in list form, and lists are one of the data ... representation of code is the same in a language implementation. ... Lisp uses this a mechanism to internalize and externalize code. ... (comp.lang.lisp) |
|