your inv differs from mine.
after replacing it with ^:_1 I got the same result.


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 10:49
> To: Programming forum
> Subject: Re: [Jprogramming] Permutations with repeats (combinations?)
> 
> I cannot reproduce your result.
> 
> I get this:
> 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
> )
> 
>    peermm 'ababc'
> bbaac
> bbaca
> bbcaa
> babac
> babca
> bcbaa
> baabc
> bacba
> bcaba
> baacb
> bacab
> bcaab
> abbac
> abbca
> cbbaa
> ababc
> abcba
> cbaba
> abacb
> abcab
> cbaab
> aabbc
> acbba
> cabba
> aabcb
> acbab
> cabab
> aacbb
> acabb
> caabb
> 
> Thanks,
> 
> --
> Raul
> 
> On Sun, Apr 26, 2015 at 2:58 AM, R.E. Boss <r.e.b...@outlook.com> wrote:
> >
> >    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

Reply via email to