Discussion: Introducing new operators for matrix computation

Paul Prescod paul at prescod.net
Mon Jul 17 19:10:06 EDT 2000


Gareth McCaughan wrote:
> 
> ...
> 
> Only if you implement matrices as lists of lists, in which
> case operations like * and / won't work anyway. I was assuming
> that (1) you have a special Matrix class, and (2) the machinery
> for list comprehensions is flexible enough to let it express
> other kinds of mapping.

Today, the list comprehension syntax is syntactic sugar for

a=[]
for i in firstloop:
	for j in secondloop: ...
		a.append( i, j )

I don't see any easy way to guess what type you want as "output" so it
has to default to a fixed type. You could of course do this:

Matrix( [...] )

I would be curious about ideas for allowing the output object to be
specified or inferred. What would the protocol be?

-- 
 Paul Prescod - Not encumbered by corporate consensus
It's difficult to extract sense from strings, but they're the only
communication coin we can count on. 
	- http://www.cs.yale.edu/~perlis-alan/quotes.html






More information about the Python-list mailing list