I do not think it is appropriate to focus on speed while ignoring results:
dfe=: (] #~ #@[ = ip)
'aba' dfe 'cbaaaba'
cbaa
dfe =: (] #~ #@[ = pi)
'aba' dfe 'cbaaaba'
caba
dfe2 =:(] {~ i.@#@] -. pi~)
'aba' dfe2 'cbaaaba'
caba
--
Raul
On Mon, Jul 25, 2016 at 2:20 PM, 'Pascal Jasmin' via Programming
<[email protected]> wrote:
> This is fastest (4x to 5x) on the test sample at your link (I came up with
> better name)
>
>
> lessitems =: [ #~ (i.~ (] - {) /:@/:)@:[ >: ([ i.~ ~.@:]) { 0 ,~ #/.~@:]
>
> it removes from the front, but your change was easy to remove from the back.
>
>
> Raul's
>
> dfe =: (] #~ #@[ = pi)
>
> slightly slower than
>
> dfe2 =:(] {~ i.@#@] -. pi~)
>
>
> x (dfe -: dfe2) y
> 1
> x (strikeb2~&.:|. -: dfe2) y
> 1
>
>
> ----- Original Message -----
> From: Jose Mario Quintana <[email protected]>
> To: Programming forum <[email protected]>
> Sent: Monday, July 25, 2016 1:10 PM
> Subject: Re: [Jprogramming] challenge: dyad -. but removing the number of
> copies of x in y
>
> One could also just recycle Boss' strikeb2 verb (simplified by Roger) [0],
>
> delfromend=. strikeb2~&.:|. f.
>
> PS. The verb strikeb2 can be rewritten tacitly as,
> strikeb2=. [ #~ (i.~ (] - {) /:@/:)@:[ >: ([ i.~ ~.@:]) { 0 ,~ #/.~@:]
>
> [0] [Jforum] Custom fit and set functions
> http://www.jsoftware.com/pipermail/general/2004-May/017503.html
>
>
> On Mon, Jul 25, 2016 at 12:28 PM, Raul Miller <[email protected]> wrote:
>
>> (] {~ i.@#@] -. pi~) does not look right, to me. Instead, I think I'd
>> use something like:
>>
>> dfe=: (] #~ #@[ = pi)&.|.
>>
>> Or, perhaps:
>>
>> co=: i:~ (] - {) /:@/:
>> ip=: #@[ ({. i.&(,.co) }.) [ i. ,
>> dfe=: (] #~ #@[ = ip)
>>
>> --
>> Raul
>>
>>
>>
>> On Mon, Jul 25, 2016 at 12:08 PM, 'Pascal Jasmin' via Programming
>> <[email protected]> wrote:
>> > cool,
>> >
>> > http://code.jsoftware.com/wiki/Essays/Progressive_Index-Of
>> >
>> > oc=: i.~ (] - {) /:@/:
>> > pi=: #@[ ({. i.&(,.oc) }.) [ i. ,
>> >
>> > 'a' (] {~ i.@#@] -. pi~) 'cbaab'
>> > cbab
>> >
>> >
>> > my original version, (fails some of the order requests)
>> >
>> >
>> > delfromend =: ;@:(] (</.~@[ }.&.>~ {./.) +/@:(=/))
>> >
>> >
>> > 'a' delfromend&, 'cbaab'
>> > cbba
>> >
>> > ----- Original Message -----
>> > From: Henry Rich <[email protected]>
>> > To: [email protected]
>> > Sent: Monday, July 25, 2016 11:02 AM
>> > Subject: Re: [Jprogramming] challenge: dyad -. but removing the number
>> of copies of x in y
>> >
>> > See Progressive Index in the Wiki
>> >
>> > Henry Rich
>> >
>> > On 7/25/2016 10:41 AM, 'Pascal Jasmin' via Programming wrote:
>> >> write function delfromend (naming things is hard) such that
>> >>
>> >> 'cabd' delfromend 'cbaab'
>> >> ba
>> >>
>> >> 18 (delfromend~ ; delfromend)&q: 54
>> >> ┌┬─┐
>> >> ││3│
>> >> └┴─┘
>> >>
>> >> 'aaaa' delfromend 'cbaab'
>> >> cbb
>> >>
>> >>
>> >>
>> >> removes as many instances of x that exist in y. Taking out items from
>> the end of y. Though a bit easier is to just group items by "key" for
>> output.
>> >>
>> >>
>> >> (,<'a') delfromend ;/ 'cbaab'
>> >> ┌─┬─┬─┬─┐
>> >> │c│b│b│a│
>> >> └─┴─┴─┴─┘
>> >> ----------------------------------------------------------------------
>> >> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm