$test
10 12
test is a rectangular array, it has to have the same number of columns
as the widest item.
Here are the first 6 and last 6 lines of test
]test=: (6&{. , _6&{.) p 3^~i.9000x
0
1
8
27
46
125
122445777789
245567777788
012233467889
122223477789
011224577899
022567778999
As you can see spaces (because it is a literal array) have been added
to pad the shorter items in test to the length of the widest items.
If you want to prevent this, then you will need to box each item. e.g.
]test=.(6&{. , _6&{.) <@p 3^~i.9000x
On Wed, Oct 12, 2011 at 12:41 PM, David Vaughan
<[email protected]> wrote:
> Thanks, but there seems to be loads of ' ' after the digits:
>
> ]test=.10{.p 3^~i.9000x
> 0
> 1
> 8
> 27
> 46
> 125
> 126
> 334
> 125
> 279
> '125'-:"1 test
> 0 0 0 0 0 0 0 0 0 0
> '125 '-:"1 test
> 0 0 0 0 0 1 0 0 1 0
>
> On 12 Oct 2011, at 00:04, Ric Sherlock wrote:
>
>> You are trying to do something like:
>> '12345' = 7 5$'12345'
>> |length error
>> | '12345' =7 5$'12345'
>>
>> J doesn't know how to reconcile the list of 5 items with the list of 7
>> items (each of which are 5 items long).
>> You could do:
>> '12345' ="1 ] 7 5$'12345'
>> 1 1 1 1 1
>> 1 1 1 1 1
>> 1 1 1 1 1
>> 1 1 1 1 1
>> 1 1 1 1 1
>> 1 1 1 1 1
>> 1 1 1 1 1
>>
>> But I suspect you want something more like:
>> '12345' -:"1 ] 7 5$'12345'
>> 1 1 1 1 1 1 1
>>
>>
>>
>>
>> On Wed, Oct 12, 2011 at 11:51 AM, David Vaughan
>> <[email protected]> wrote:
>>> Thanks.
>>>
>>> I'm trying to get those items which are equal to a specific string, but I
>>> keep getting length errors, and I'm not quite sure what's going on:
>>>
>>> p=.(/:~)&":"0
>>> (#~ '012334556789' = ]) p 3^~i.9000x
>>> |length error
>>> | (#~'012334556789'=])p 3^~i.9000
>>>
>>> I've used a similar tacit verb when dealing with numbers, but I guess this
>>> not working has to do with the fact that it's on strings.
>>>
>>> On 11 Oct 2011, at 23:18, Henry Rich wrote:
>>>
>>>> (/: 1&{"1)
>>>>
>>>>> ./@>@:(1&{"1)
>>>>
>>>> there are other ways too
>>>>
>>>> Henry Rich
>>>>
>>>> On 10/11/2011 6:14 PM, David Vaughan wrote:
>>>>> I have strings and a numbers in adjacent boxes, like so:
>>>>>
>>>>> ┌─────────┬─┐
>>>>> │0 │1│
>>>>> ├─────────┼─┤
>>>>> │1 │1│
>>>>> ├─────────┼─┤
>>>>> │8 │1│
>>>>> ├─────────┼─┤
>>>>> │27 │1│
>>>>> ├─────────┼─┤
>>>>> │46 │1│
>>>>> ├─────────┼─┤
>>>>> │125 │2│
>>>>> ├─────────┼─┤
>>>>> │126 │1│
>>>>> ├─────────┼─┤
>>>>> │334 │1│
>>>>> ├─────────┼─┤
>>>>> │279 │1│
>>>>> ├─────────┼─┤
>>>>> │0001 │1│
>>>>> └─────────┴─┘
>>>>>
>>>>> How can I do things like sort or>./ on only the second box of each row?
>>>>> ----------------------------------------------------------------------
>>>>> 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
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm