On Wed, 11 Jun 2014, Sven Schreiber wrote:
Am 11.06.2014 12:09, schrieb Artur T.:
> Am 11.06.2014 01:27, schrieb Allin Cottrell:
>> On Tue, 10 Jun 2014, Riccardo (Jack) Lucchetti wrote:
>>
>>> Or, alternatively,
>>>
>>> <hansl>
>>> function matrix deselected (list L1, list L2)
>>> matrix m1 = L1
>>> matrix m2 = L2
>>> return !sumc(m1 .= m2')
>>> end function
>>> </hansl>
>>
>> Now that's truly wicked ;-)
>>
>> Allin
>>
>
> Indeed!
> Artur
> _______________________________________________
Jack's ideas are always impressive, although I must say I like his
second suggestion with the list difference much better, it's directly
readable.
Thank you.
Apart from that, the expression:
"!sumc(m1 .= m2')"
puzzles me a little. First because of the transpose in "(m1 .= m2')": if
it is equivalent to "((m1 .= m2)')" I would say I find the order of
precedence surprising. If instead it's the same as "(m1 .= (m2'))"
then
I guess I don't understand what the code does.
Ok, I admit that maybe I could have commented on it a little.
The idea is to use the "dot-equal" operator and compare a _column_ vector
to a _row_ vector so to have a _matrix_ of results. The idea of summing by
column is, then, just a poor man's version of a multiple OR operation.
And secondly, using boolean stuff like "!" on
vectors/matrices is always
a little ambiguous: one could interpret it as element-wise (as is done
here AFAICS), or in terms of "is there *any* non-zero element in there",
returning a single 1/0 (TRUE/FALSE) instead of a matrix of ones/zeros.
This is a design decision, is it settled and/or documented yet?
No, that's element-by-element.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------