Hi Skip,
2 3 ((<@<@<@[){]) 1 2 3 4 5
1 2 5
ex=:(<@<@<@[){]
2 3 ex 1 2 3 4 5
1 2 5
Rob
> On 8 Nov. 2016, at 5:44 pm, Skip Cave <[email protected]> wrote:
>
> Aha! except! I had no idea that from '{' had such a useful option.
>
> (<<< 1 4 5 7) { 2 3 5 7 11 14 56 78 95
>
> 2 5 7 56 95 NB. Cool!
>
>
>
> If i wanted to make a dyadic verb 'ex' that worked just like the above, how
> could I do that?
>
>
> 1 4 5 7 ex 2 3 5 7 11 14 56 78 95
>
> 2 5 7 56 95
>
>
>
> ex =: [:@<@<@<[{]
>
> 2 3 ex 1 2 3 4 5
>
> |index error: ex
>
> | 2 3 ex 1 2 3 4 5
>
>
> Nope! that didn't work.
>
>
> Skip
>
> Skip Cave
> Cave Consulting LLC
>
> On Tue, Nov 8, 2016 at 12:32 AM, Raul Miller <[email protected]> wrote:
>
>> 2 { 2 3 5 7 11
>> 5
>> (<<<2) { 2 3 5 7 11
>> 2 3 7 11
>>
>> Look for the word "except" at http://www.jsoftware.com/help/
>> dictionary/d520.htm
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Tue, Nov 8, 2016 at 12:17 AM, Skip Cave <[email protected]>
>> wrote:
>>> Nice! Xiao-Yong's verb does exactly what I need.
>>>
>>> f=:(] +:@{`[`]} <@<@<@]{[)"_ 0 [:I.2=/\]
>>>
>>> t =. 1 2 2 4 1 5 3 4 4 4 2 3 3
>>>
>>> f t
>>>
>>> 1 4 4 1 5 3 4 4 4 2 3 3
>>>
>>> 1 2 2 4 1 5 3 8 4 2 3 3
>>>
>>> 1 2 2 4 1 5 3 4 8 2 3 3
>>>
>>> 1 2 2 4 1 5 3 4 4 4 2 6
>>>
>>>
>>> I can understand [:I.2=/\]. Using I. is the perfect way to find the
>>> indices of the dups. However, the rest of that big infinite-rank tacit
>>> expression to the left must generate each of the reduced items. I'm
>> totally
>>> lost trying to figure that out. Why the zero? Why three <@? I thought [
>>> represented a left argument, but there isn't a left argument. Any help is
>>> appreciated.
>>>
>>>
>>> Skip
>>>
>>> Skip Cave
>>> Cave Consulting LLC
>>>
>>> On Mon, Nov 7, 2016 at 10:25 PM, Xiao-Yong Jin <[email protected]>
>>> wrote:
>>>
>>>> So you probably just need this:
>>>> f=:(] +:@{`[`]} <@<@<@]{[)"_ 0 [:I.2=/\]
>>>> or really the adverb
>>>> a=:1 :'u@(] +:@{`[`]} <@<@<@]{[)"_ 0 [:I.2=/\]'
>>>>
>>>> You may find different solutions if you abstract your problem
>> differently.
>>>>
>>>>> On Nov 7, 2016, at 9:30 PM, Skip Cave <[email protected]>
>> wrote:
>>>>>
>>>>> Very interesting. Quite a difference in space and time usage, not to
>>>>> mention length of the tacit code.
>>>>>
>>>>> For my application, a rank 0 or 1 in the summed result isn't all that
>>>>> critical. As long as the contents of each box can be used in further
>>>>> arithmetic and Boolean operations (e.g. it's not text), then I'm ok.
>>>>>
>>>>>
>>>>> It looks like nouns with ranks 0 or 1 don't affect the outcome of
>> simple
>>>>> arithmetic operations:
>>>>>
>>>>>
>>>>> ($4);($,4);(4=,4);(1+4);(1+,4);((1+4)=1+,4);($1+4);($1+,4)
>>>>>
>>>>> ┌┬─┬─┬─┬─┬─┬┬─┐
>>>>>
>>>>> ││1│1│5│5│1││1│
>>>>>
>>>>> └┴─┴─┴─┴─┴─┴┴─┘
>>>>>
>>>>> The only time the difference becomes an issue:
>>>>>
>>>>> ($4)=($,4)
>>>>>
>>>>> |length error
>>>>>
>>>>> | ($4) =($,4)
>>>>> But I don't care about this.
>>>>>
>>>>> Actually, Mike Day spotted what I was really trying to attempt.
>>>>> The original starting vector is:
>>>>>
>>>>> n =: 1 2 2 4 1 5 3 4 4 4 2 3 3
>>>>>
>>>>> Then I box at each possible pair of integers using an infix
>>>> sliding-window
>>>>> on each pair of integers. This sliding box scheme was just to identify
>>>> all
>>>>> the duped pairs in the original vector.
>>>>>
>>>>> ]N =: 2<\pp
>>>>>
>>>>> ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
>>>>>
>>>>> │1 2│2 2│2 4│4 1│1 5│5 3│3 4│4 4│4 4│4 2│2 3│3 3│
>>>>>
>>>>> └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
>>>>>
>>>>>
>>>>> What I ultimately wanted is a verb that will replace the duped pairs
>> in
>>>> the
>>>>> *original* un-boxed vector, one at a time:
>>>>>
>>>>> n =: 1 2 2 4 1 5 3 4 4 4 2 3 3
>>>>>
>>>>> f n
>>>>>
>>>>> 1 4 4 1 5 3 4 4 4 2 3 3
>>>>>
>>>>> 1 2 2 4 1 5 3 8 4 2 3 3
>>>>>
>>>>> 1 2 2 4 1 5 3 4 8 2 3 3
>>>>>
>>>>> 1 2 2 4 1 5 3 4 4 4 2 6
>>>>>
>>>>> Of course, the final row lengths will be one shorter that the original
>>>> row
>>>>> length.
>>>>>
>>>>> Skip
>>>>> ------------------------------------------------------------
>> ----------
>>>>> 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