That works I think, but I had already found:
f =: 13 : '({."1 split x) = {.|.split y' "0
comp =: (f # [) "1 0
Problem is though, I'm trying to use it on rows of x and atoms of y, hence the
"1 0.
But if I run it on my data, I just get a length error if I use anything other
than a scalar as y. But if y is a 1d array, and comp works rank 0 on y, why
does it give a length error?
On 12 Nov 2011, at 03:24, Raul Miller wrote:
> Perhaps you want:
>
> comp1=: [ #~ (1=i.2 2) -:"2 =/&(100&#.inv)
>
> --
> Raul
>
> On Fri, Nov 11, 2011 at 8:19 PM, David Vaughan
> <[email protected]> wrote:
>> Actually they are not right.
>>
>> 1234 5678 3456 comp0 3456
>> 1234
>> is the desired result, and
>>
>> 1234 5678 3456 comp1 3456
>> 5678
>> is the desired result.
>>
>> Essentially I want to check if the second half of a split of x matches the
>> first half of split y and vice versa.
>>
>> e. and = seem inappropriate as e. would think that 3456 was desired and =
>> would not think that 1234 and 5678 would be desired when they are.
>>
>> I suppose a combination of |. and = could do it?
>>
>> On 12 Nov 2011, at 00:37, David Vaughan wrote:
>>
>>> Actually, G is not exactly what I want. The following two verbs are though:
>>>
>>> comp0 =: {: @ e. & split # [
>>> comp1 =: {. @ e. & split # [
>>>
>>> 1234 5678 comp0 3456
>>> 1234
>>> 1234 5678 comp1 3456
>>> 5678
>>>
>>> I want to distinguish between the two matching cases.
>>>
>>> On 11 Nov 2011, at 23:54, Raul Miller wrote:
>>>
>>>> split looks like either 0 100&#: or 100&#.inv
>>>>
>>>> g depends on f and you did not define f
>>>>
>>>> Anyways, you might want:
>>>> 1234 5678 (+./"1@e.&(100&#.inv) # [) 3456
>>>> 1234 5678
>>>>
>>>> Or:
>>>> G=: +./"1@e.&(100&#.inv) # [
>>>> 1234 5678 G 3456
>>>>
>>>> FYI,
>>>>
>>>> --
>>>> Raul
>>>>
>>>>
>>>> On Fri, Nov 11, 2011 at 6:41 PM, David Vaughan
>>>> <[email protected]> wrote:
>>>>> I have a verb split:
>>>>>
>>>>> split =: <.@%&100 , 100&|
>>>>> split 1234
>>>>> 12 34
>>>>>
>>>>> I want to compare numbers to see if one of their 'split regions' (e.g. 12
>>>>> or 34) matches a given number.
>>>>> So far I have:
>>>>>
>>>>> ]g =. 13 :'(f y) = (f"0 x)'
>>>>> ([: f ]) = [: f"0 [
>>>>> 1234 5678 g 3456
>>>>> 0 1
>>>>> 1 0
>>>>>
>>>>> I want to make that actually return the numbers that matched, i.e.
>>>>>
>>>>> 1234
>>>>> 5678
>>>>>
>>>>> I can't seem to get a working solution for this.
>>>>>
>>>>> Any help appreciated, thanks.
>>>>> ----------------------------------------------------------------------
>>>>> 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