[Tutor] List comprehensions & matrix multiplication

dominic.fox dominic.fox" <dominic.fox@ntlworld.com
Sat, 25 May 2002 15:18:43 +0100


Danny Yoo wrote:
> I think doing nested list comprehensions might be overdoing things.  It's
> a little hard for me to disentangle them mentally.

Yes, that's my feeling about it too - it's too syntactically compressed.
Nested list comprehensions make a certain amount of sense to me, as a
one-time dabbler in emacs Lisp, but repeatedly nesting them leads to a whole
load of operations being bundled together into a single heavily-bracketed
expression, which is not often a good idea. I was looking for a way to
unbundle them, much like what you supplied a little further down in your
post. I'll keep trying and see if I can come up with something still more
elegant!

Kirby Urner suggested building a matrix class with its own "multiply"
method, which would also enable some operator overloading. That was where I
was going next...

thanks,
Dominic