Just to throw another option out there:

Given
 ] a=. a: (<1)} <"0 i. 3 5

Test:
((,a:) -: ~.)"1 a
0 1 0

Is the list of each row's unique values equal to a list containing only a:




On Wed, Jun 1, 2016 at 10:07 AM, Raul Miller <[email protected]> wrote:
> Or, there's a general pattern leading in the direction of (the
> incredibly useful) linear algebra:
>
>       A=:(;:'b c') (0 0;2 2)}3 3$a:
>       */"1 a: = A
> 0 1 0
>       a: */ .= A
> 0 1 0
>
> --
> Raul
>
>
> On Wed, Jun 1, 2016 at 8:48 AM, Don Guinn <[email protected]> wrote:
>> I'm not sure just how = goes about comparing boxed data, but opening the
>> boxes can be avoided by:
>>    */"1 a:=a
>> 0 1 0
>>
>> On Tue, May 31, 2016 at 11:48 PM, bill lam <[email protected]> wrote:
>>
>>> step by step example.
>>>
>>>    ] a=. a: (<1)} <"0 i. 3 5
>>> +--+--+--+--+--+
>>> |0 |1 |2 |3 |4 |
>>> +--+--+--+--+--+
>>> |  |  |  |  |  |
>>> +--+--+--+--+--+
>>> |10|11|12|13|14|
>>> +--+--+--+--+--+
>>>    (0=#) &> a     NB.test for empty in each cell
>>> 0 0 0 0 0
>>> 1 1 1 1 1
>>> 0 0 0 0 0
>>>    *./ (0=#) &> a   NB. closed but not what we wanted
>>> 0 0 0 0 0
>>>    *./"1 (0=#) &> a   NB. this work with rank operator
>>> 0 1 0
>>>    *./ |: (0=#) &> a  NB. transpose also work
>>> 0 1 0
>>>
>>> The key is the adverb &> which open each cell, do something, then
>>> assemble again. It also works if you have a more complicated
>>> verb instead of tacit (0=#), eg
>>>
>>> foo=: 3 : 0
>>> if. #y do. 1 else. 0 end.
>>> )
>>>
>>> and then proceed with
>>>    foo &> a
>>>
>>>
>>> Ср, 01 июн 2016, PR PackRat написал(а):
>>> > I need to perform a certain action if an entire row in a transposed
>>> > table (i.e., originally a column) has empty values, that is, all boxed
>>> > data are the equivalent of a: or ''.  The result should be a Boolean
>>> > value--"true" meaning that the entire row has empty values.  (A
>>> > typical application would be old stock market data, where all of the
>>> > "Open" values might be null or empty.)
>>> >
>>> > I don't know how to even begin writing such code (without a for/next
>>> > loop to separately evaluate each box's value, a very non-J way of
>>> > doing it).  Please help.  Thanks in advance!
>>> >
>>> >
>>> > Harvey
>>> > ----------------------------------------------------------------------
>>> > For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>> --
>>> regards,
>>> ====================================================
>>> GPG key 1024D/4434BAB3 2008-08-24
>>> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
>>> gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to