Here is a more literal tacit translation of comb.  I'm not doing everything you 
are, but unsure why its needed.  IIUC, your version puts everything on the 
right hand side of ^:

combT =: ([: ; ([ ; [: i.@>: -~) ((1 {:: [) ,.&.> [: ,&.>/\.  >:&.>@:])^:(0 {:: 
[)  (<i.1 0),~ (< i.0 0) $~ -~)

100 timespacex&> ' 2 combT  5' ; ' 2 combt  5' 
1.91616e_5 5888 
3.6608e_5 9088 


100 timespacex&> ' 11 combT  17' ; ' 11 combt  17' 
0.00314064 4.13094e6 
0.00317854 4.13414e6 


 
Then there is a pretty direct mapping of RE Boss's version as it doesn't repeat 
intermediate variable use.


cmbcombT =: ({~ [: /:"1 [: ; [: ([:,/  [,"1"1 _1 ]{"1"_ 1 [-.~"1 
i.@(+&({:@$)))L:0/ [: |.@:(] <@combT f."0 +/\)  [: |. #/.~)  

10 timespacex&> 'cmbcomb 2#>:i.5' ; 'cmbcombT 2#>:i.5' 
0.0584915 5.03404e7 
0.0580249 3.38226e7 


----- Original Message -----
From: Jose Mario Quintana <jose.mario.quint...@gmail.com>
To: Programming forum <programm...@jsoftware.com>
Cc: 
Sent: Sunday, April 26, 2015 9:55 PM
Subject: Re: [Jprogramming] Permutations with repeats (combinations?)

Tacit vs. explicit seems to be a never-ending controversy.  May as it be,
the following is a brute force transcription of Boss' compositions for a
tacit interpretation:

   st=. (, */&.:>@:(1 2&{))@:(] ; 7!:2@:] ; 6!:2)

   ". noun define -. CRLF

combt=.

;@:(4&({::))@:((<@:((3&({::) ([ ,.&.> ,&.>/\.@:(>:&.>@:])) 4&({::)
)@:]) 4} ])^:(0&({::)))@:(<@:((<i.1 0) ,~ (<i.0 0) $~ 2&({::)) 4}
])@:(<@:(i.@:>:@:(2&({::))) 3} ])@:(<@:(1&({::) - 0&({::)) 2} ])@:
('. . .'&(] , ;:@:[))@:(,&:>/@:(<^:(L. = 0:)&.>))@:(,&<)

)


    2 (comb -: combt) 5
1

   100 st&> ' 2 comb  5' ; ' 2 combt  5'
┌───────────┬─────┬──────────┬────────┐
│ 2 comb  5 │12032│6.24855e_5│0.751825│
├───────────┼─────┼──────────┼────────┤
│ 2 combt  5│9088 │9.51077e_5│0.864338│
└───────────┴─────┴──────────┴────────┘

   11 (comb -: combt) 17
1
   100 st&> ' 11 comb 17' ; ' 11 combt  17'
┌─────────────┬───────┬──────────┬───────┐
│ 11 comb 17  │5032064│0.0107722 │54206.5│
├─────────────┼───────┼──────────┼───────┤
│ 11 combt  17│4134144│0.00735863│30421.6│
└─────────────┴───────┴──────────┴───────┘


   ". noun define -. CRLF

cmbcombt=.

(0&({::) {~ /:"1@:(3&({::)))@:(<@:(;@:(,/@:([ ,"1"1 _1 ] {"1"_ 1 [
-.~"1 i.@(+&({:@$)))L:0/)@:(2&({::))) 3} ])@:(<@:(|.@:(] <@(;@:(4
&({::))@:((<@:((3&({::) ([ ,.&.> ,&.>/\.@:(>:&.>@:])) 4&({::))@:])
4} ])^:(0&({::)))@:(<@:((<i.1 0) ,~ (<i.0 0) $~ 2&({::)) 4} ])@:(
<@:(i.@:>:@:(2&({::))) 3} ])@:(<@:(1&({::) - 0&({::)) 2} ])@:('. .
.'&(] , ;:@:[))@:(,&:>/@:(<^:(L. = 0:)&.>))@:(,&<))"0 +/\)@:(1&({
::))) 2} ])@:(<@:(|.@:(#/.~)@:(0&({::))) 1} ])@:('. . .'&(] , ;:@:
[)@:<)


)



   (cmbcomb -:cmbcombt) 2#>:i.5
1
   10 st&> 'cmbcomb 2#>:i.5' ; 'cmbcombt 2#>:i.5'
┌────────────────┬────────┬────────┬─────────┐
│cmbcomb 2#>:i.5 │50340352│0.139288│7.0118e6 │
├────────────────┼────────┼────────┼─────────┤
│cmbcombt 2#>:i.5│50339072│0.157125│7.90951e6│
└────────────────┴────────┴────────┴─────────┘

   (cmbcomb -:cmbcombt) 2#>:i.6
1
    1 st&> 'cmbcomb 2#>:i.6' ; 'cmbcombt 2#>:i.6'
┌────────────────┬──────────┬───────┬──────────┐
│cmbcomb 2#>:i.6 │3221236224│10.6752│3.43873e10│
├────────────────┼──────────┼───────┼──────────┤
│cmbcombt 2#>:i.6│3221234944│11.2508│3.62415e10│
└────────────────┴──────────┴───────┴──────────┘

The associated performances are similar.  I did not make any effort to
simplify or to try to optimize the tacit verbs.  Each assignment in the
original explicit constructions corresponds to a form (<@:v N} ]) in the
tacit versions with the following mappings,

comb: x y d k z -> 0 1 2 3 4
cmbcomb:  y a b c -> 0 1 2 3

Needless to say, combt is embedded in cmbcombt.



On Sun, Apr 26, 2015 at 12:00 PM, R.E. Boss <r.e.b...@outlook.com> wrote:

> My original wàs tacit (in that way), although, it contained 'comb', so how
> tacit is it then?
>
> I use to treat every verb as it has all ranks _.
> Well, (,) has, as it should IMO, but {b.0 equals 1 0 _, so there the "1 is
> superfluous.
>
> > first its short hand for (,"1 1"1 _1).  First apply "1 _1, and then if
> the
> _1 side is
> > not a list, either increase or decrease rank to "1
> >
> > its a bit difficult to visualize the case(s) that this is intended to
> apply to.
>
> If
>    [t0=. ({.t),([:,/  [,"1"1 _1 ]{"1"_ 1 [-.~"1 i.@(+&({:@$)))L:0/
> _2{.t=.|.
> (] <@comb"0 +/\) |.#/.~ 1 1 2 3 3
> +---+-----+
> |0 1|0 1 2|
> |0 2|1 0 2|
> |0 3|2 0 1|
> |0 4|     |
> |1 2|     |
> |1 3|     |
> |1 4|     |
> |2 3|     |
> |2 4|     |
> |3 4|     |
> +---+-----+
> then
>    $L:0(]{"1"_ 1 [-.~"1 i.@(+&({:@$)))L:0/ t0
> +------+
> |10 3 3|
> +------+
> Now I want every array of the first box of t0 concatenate with every array
> of the corresponding matrix of the last result.
> That is done by ,"1 "1 _1
>
>
> R.E. Boss
>
>
> > -----Original Message-----
> > From: programming-boun...@forums.jsoftware.com [mailto:programming-
> > boun...@forums.jsoftware.com] On Behalf Of 'Pascal Jasmin' via
> > Programming
> > Sent: zondag 26 april 2015 17:19
> > To: programm...@jsoftware.com
> > Subject: Re: [Jprogramming] Permutations with repeats (combinations?)
> >
> > Nice,
> >
> > I find this easy to follow as there is a tacit core equivalence, but
> there
> is a J
> > feature I have not seen before
> >
> >    $ every ( [ ,"1"1 _1 ] {"1"_ 1 [ -.~"1 i.@(+&({:@$)))L:0/ |. (]
> <@comb"0 +/\)
> > |.#/.~ 1 1 2 3 3
> > 10 3 1 5
> >
> >
> > ,"1"1 _1
> > {"1"_ 1
> >
> > In this test expression, I can get rid of the "1 from '{', but not ','
> >
> > But I don't understand what it means.  The natural guess would be,
> >
> > first its short hand for (,"1 1"1 _1).  First apply "1 _1, and then if
> the
> _1 side is
> > not a list, either increase or decrease rank to "1
> >
> > its a bit difficult to visualize the case(s) that this is intended to
> apply to.
> >
> >
> > for {"1"_ 1, I have not found an expression that breaks when "1 is
> removed.
> >
> > I understand that v"1"2 -: v"1 in all cases?... but not necessarily
> v"1"_1
> >
> >
> >
> > ----- Original Message -----
> > From: R.E. Boss <r.e.b...@outlook.com>
> > To: programm...@jsoftware.com
> > Cc:
> > Sent: Sunday, April 26, 2015 3:31 AM
> > Subject: Re: [Jprogramming] Permutations with repeats (combinations?)
> >
> > comb=: 4 : 0
> > k=. i.>:d=.y-x
> > z=. (d$<i.0 0),<i.1 0
> > for. i.x do. z=. k ,.&.> ,&.>/\. >:&.> z end.
> > ; z
> > )
> >
> > cmbcomb=: 3 :0
> > a=. |.#/.~ y
> > b=. |.(] <@comb"0 +/\) a
> > c=. ; ([:,/  [,"1"1 _1 ]{"1"_ 1 [-.~"1 i.@(+&({:@$)))L:0/ b
> > y {~ /:"1 c
> > )
> >
> >    cmbcomb 2#>:i.2
> > 1 1 2 2
> > 1 2 1 2
> > 1 2 2 1
> > 2 1 1 2
> > 2 1 2 1
> > 2 2 1 1
> >
> > the number of such permutations is determined by
> >    (!@(+/)% [:*/ !)x: 2#2
> > 6
> >
> >    (!@(+/)% [:*/ !)x: 5#2
> > 113400
> >
> >    ts'Treb=.cmbcomb 2#>:i.5'
> > 0.043948924 50340608
> >
> >    #Treb
> > 113400
> >
> >    ts'Tpj=.rperm2 2#>:i.5'
> > 0.20252285 42215296
> >
> >    #Tpj
> > 113400
> >
> >    Tpj-: Treb
> > 0
> >
> >    Tpj-:&(/:~) Treb
> > 1
> >
> >    (!@(+/)% [:*/ !)x: 6#2
> > 7484400
> >
> >    ts'rperm2 2#>:i.6'
> > 15.864774 4.8486253e9
> >
> >    ts'cmbcomb 2#>:i.6'
> > 3.8703475 3.2212362e9
> >
> >
> > R.E. Boss
> >
> > (Add your info to
> > http://www.jsoftware.com/jwiki/Community/Demographics )
> >
> >
> > > -----Original Message-----
> > > From: programming-boun...@forums.jsoftware.com
> > [mailto:programming-
> > > boun...@forums.jsoftware.com] On Behalf Of R.E. Boss
> > > Sent: zondag 26 april 2015 8:59
> > > To: programm...@jsoftware.com
> > > Subject: Re: [Jprogramming] Permutations with repeats (combinations?)
> > >
> > >
> > >    peermm 'ababc'
> > > |length error: peermm
> > > |   m=.,/(u*e)+"1/"_1(1-e)    #inv"1/m
> > >
> > >
> > > R.E. Boss
> > >
> > >
> > > > -----Original Message-----
> > > > From: programming-boun...@forums.jsoftware.com
> > > [mailto:programming-
> > > > boun...@forums.jsoftware.com] On Behalf Of Raul Miller
> > > > Sent: zondag 26 april 2015 3:22
> > > > To: Programming forum
> > > > Subject: Re: [Jprogramming] Permutations with repeats (combinations?)
> > > >
> > > > That's an error on my part.
> > > >
> > > > It' not unique to boxed data, you can see the same flaw with:
> > > >
> > > > peermm 'ababc'
> > > >
> > > > Basically, I did not spend enough time exploring the boundaries
> > > > between the two abstractions I was using.
> > > >
> > > > I think this fixes that problem:
> > > >
> > > > comb=: 4 : 0
> > > >  k=. i.>:d=.y-x
> > > >  z=. (d$<i.0 0),<i.1 0
> > > >  for. i.x do. z=. k ,.&.> ,&.>/\. >:&.> z end.
> > > >  ; z
> > > > )
> > > >
> > > > peermm=:3 :0
> > > >   Y=. ;(/: #@>)</.~y
> > > >   arg=. </.~i.~Y
> > > >   n1=. 0 i.~1=#@> arg
> > > >   m=. (i.@! A. i.)n1
> > > >   for_d.n1}.arg do.
> > > >     u=.{.s=.>d
> > > >     n=.i.(#s)+{:$m
> > > >     e=.n e."1 s comb&#n
> > > >     m=.,/(u*e)+"1/"_1 (1-e)#inv"1/m
> > > >   end.
> > > >   m{Y
> > > > )
> > > >
> > > > There might be a better (more concise and faster) way of setting this
> > up?
> > > >
> > > > Thanks,
> > > >
> > > > --
> > > > Raul
> > > >
> > > >
> > > > On Sat, Apr 25, 2015 at 8:29 PM, 'Pascal Jasmin' via Programming
> > > > <programm...@jsoftware.com> wrote:
> > > > > this has wrong results
> > > > >
> > > > > peermm 1 1 ; 2 2 ; 1 1 ; 2 2 ;3
> > > > >
> > > > >
> > > > >
> > > > > ----- Original Message -----
> > > > > From: Raul Miller <rauldmil...@gmail.com>
> > > > > To: Programming forum <programm...@jsoftware.com>
> > > > > Cc:
> > > > > Sent: Saturday, April 25, 2015 8:24 PM
> > > > > Subject: Re: [Jprogramming] Permutations with repeats
> > (combinations?)
> > > > >
> > > > > What problem does it have with boxed data? (It worked fine on boxed
> > > > > data when I tested it that way.)
> > > > >
> > > > > Thanks,
> > > > >
> > > > > --
> > > > > Raul
> > > > >
> > > > > On Sat, Apr 25, 2015 at 8:05 PM, 'Pascal Jasmin' via Programming
> > > > > <programm...@jsoftware.com> wrote:
> > > > >> Its even faster, and handles text, but not boxed data
> > > > >>
> > > > >> one use case for boxes is keeping some items together as a group
> > > > >>
> > > > >>   ;"1 rperm2 1 2 ; 1 2 ; 3 ;3 ; 3
> > > > >> 3 3 1 2 1 2 3
> > > > >> 3 3 1 2 3 1 2
> > > > >> 3 3 3 1 2 1 2
> > > > >> 3 1 2 3 1 2 3
> > > > >> 3 1 2 3 3 1 2
> > > > >> 3 1 2 1 2 3 3
> > > > >> 1 2 3 3 1 2 3
> > > > >> 1 2 3 3 3 1 2
> > > > >> 1 2 3 1 2 3 3
> > > > >> 1 2 1 2 3 3 3
> > > > >>
> > > > >>
> > > > >>
> > > > >>
> > > > >>
> > > > >>
> > > > >>
> > > > >> ----- Original Message -----
> > > > >> From: Raul Miller <rauldmil...@gmail.com>
> > > > >> To: Programming forum <programm...@jsoftware.com>
> > > > >> Cc:
> > > > >> Sent: Saturday, April 25, 2015 2:02 PM
> > > > >> Subject: Re: [Jprogramming] Permutations with repeats
> > > (combinations?)
> > > > >>
> > > > >> My first attempt at implementing like that ran into a problem with
> > > > >> mix-matched types in r for some cases, so I reworked the thing to
> > > > >> support arguments of any type:
> > > > >>
> > > > >> comb=: 4 : 0
> > > > >> k=. i.>:d=.y-x
> > > > >> z=. (d$<i.0 0),<i.1 0
> > > > >> for. i.x do. z=. k ,.&.> ,&.>/\. >:&.> z end.
> > > > >> ; z
> > > > >> )
> > > > >>
> > > > >> peermm=:3 :0
> > > > >>   arg=. (/: #@>)</.~i.~y
> > > > >>   n1=. 0 i.~1=#@> arg
> > > > >>   m=. (i.@! A. i.)n1
> > > > >>   for_d.n1}.arg do.
> > > > >>     u=.{.s=.>d
> > > > >>     n=.i.(#s)+{:$m
> > > > >>     e=.n e."1 s comb&#n
> > > > >>     m=.,/(u*e)+"1/"_1 (1-e)#inv"1/m
> > > > >>   end.
> > > > >>   m{y
> > > > >> )
> > > > >>
> > > > >> I have no idea if this is actually faster. I'll let someone else
> > worry
> > > > >> about that.
> > > > >>
> > > > >> --
> > > > >> Raul
> > > > >>
> > > > >> On Sat, Apr 25, 2015 at 12:58 PM, Roger Hui
> > > > <rogerhui.can...@gmail.com> wrote:
> > > > >>> The peermm function can be made faster by doing the actual
> > > > permutations of
> > > > >>> those cells of </.~y having only a single element.
> > > > >>>
> > > > >>>
> > > > >>> On Fri, Apr 24, 2015 at 10:46 PM, Raul Miller
> > <rauldmil...@gmail.com>
> > > > wrote:
> > > > >>>
> > > > >>>> On Fri, Apr 24, 2015 at 7:03 PM, Roger Hui
> > > > <rogerhui.can...@gmail.com>
> > > > >>>> wrote:
> > > > >>>> > The details of implementing this algorithm are left as an
> > exercise
> > > for
> > > > >>>> the
> > > > >>>> > reader. :-)
> > > > >>>>
> > > > >>>> Do I qualify as a reader?
> > > > >>>>
> > > > >>>> comb=: 4 : 0
> > > > >>>>  k=. i.>:d=.y-x
> > > > >>>>  z=. (d$<i.0 0),<i.1 0
> > > > >>>>  for. i.x do. z=. k ,.&.> ,&.>/\. >:&.> z end.
> > > > >>>>  ; z
> > > > >>>> )
> > > > >>>>
> > > > >>>> peermm=:3 :0
> > > > >>>>   r=.i.1 0
> > > > >>>>   for_d.</.~y do.
> > > > >>>>     u=.{.s=.>d
> > > > >>>>     n=.i.(#s)+{:$r
> > > > >>>>     e=.n e."1 s comb&#n
> > > > >>>>     r=.,/(u*e)+"1/"_1 (1-e)#inv"1/r
> > > > >>>>   end.
> > > > >>>> )
> > > > >>>>
> > > > >>>>    peermm 1 1 2 2
> > > > >>>> 2 2 1 1
> > > > >>>> 2 1 2 1
> > > > >>>> 2 1 1 2
> > > > >>>> 1 2 2 1
> > > > >>>> 1 2 1 2
> > > > >>>> 1 1 2 2
> > > > >>>>
> > > > >>>> --
> > > > >>>> Raul
> > > > >>>>
> > > ----------------------------------------------------------------------
> > > > >>>> 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
> > > ----------------------------------------------------------------------
> > > 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

Reply via email to