[Jprogramming] Permutations
bill lam
bbill.lam at gmail.com
Fri Sep 30 06:34:24 HKT 2011
You may use monad ;: (word formation) to visualise how J interpreter parse
these two sentsences,
;: '/:~ :/:@": &.>y'
+--+-+-+--+-+--+--+-+-+
|/:|~|:|/:|@|":|&.|>|y|
+--+-+-+--+-+--+--+-+-+
;: '/:~:/:@": &.>y'
+--+--+--+-+--+--+-+-+
|/:|~:|/:|@|":|&.|>|y|
+--+--+--+-+--+--+-+-+
I short the : (and also .) must not separate from preceding characters
it the combined group should be treated as a single token.
Чтв, 29 Сен 2011, Linda Alvord писал(а):
> Here is the space that is bothering me. The different results are dependent
> upon the space before the colon.
>
> d=: 13 : '/:~ :/:@": &.>y'
> d a,b
> ------T-----┐
> │01123│01123│
> L-----+------
>
> e=: 13 : '/:~:/:@": &.>y'
> e a,b
> 0 1
>
>
> -----Original Message-----
> From: programming-bounces at jsoftware.com
> [mailto:programming-bounces at jsoftware.com] On Behalf Of David Mitchell
> Sent: Thursday, September 29, 2011 6:24 AM
> To: Programming forum
> Subject: Re: [Jprogramming] Permutations
>
> I find this helpful to see differences:
>
> /:~ :/:@": &.>a,b
> -- ~ --- /:
> -- : -+- /:
> -- @ -+- ":
> -- &. -+- >
> │
> --+ -- a
> L------+- ,
> L- b
>
>
> /:~:([:/:": )&.>a,b
> -- /:
> │ -- ~:
> │ │ -- [:
> --+ │ ----+- /:
> │ +- &. -+ L- ":
> L----+ L- >
> │
> │ -- a
> L------+- ,
> L- b
>
> --
> David Mitchell
>
> On 9/29/2011 5:45, Linda Alvord wrote:
> > The only difference between the correct and the incorrect result is a
> space
> > before the second : . Should a space make a difference ever? In the
> > correct result I can't understand what it is, what it does and why it does
> > it.
> >
> > /:~ :/:@":&.>a,b
> > ------T-----┐
> > │01123│01123│
> > L-----+------
> >
> >
> > /:~:([:/:": )&.>a,b
> > 0 1
> >
> > Since I set out originally to remove "atop", how can I do it?
> >
> > /:~ :([: /: ":)&.>a,b
> > ------T-----┐
> > │10123│32110│
> > L-----+------
> >
> > Hope you can help. Thanks. Linda
> >
> > -----Original Message-----
> > From: programming-bounces at jsoftware.com
> > [mailto:programming-bounces at jsoftware.com] On Behalf Of Ian Clark
> > Sent: Thursday, September 22, 2011 9:13 PM
> > To: Programming forum
> > Subject: Re: [Jprogramming] Permutations
> >
> > Off-the-cuff...
> >
> > a=: 10123
> > b=: 32110
> > c=: 32100
> > -:/ /:~ :/:@":&.> a,b
> > 1
> > -:/ /:~ :/:@":&.> a,c
> > 0
> >
> >
> > On Thu, Sep 22, 2011 at 10:41 PM, David Vaughan
> > <purpleblues13 at googlemail.com> wrote:
> >> Hi, what is the best (fastest) way to check whether a number is a
> > permutation of another number?
> >> I've tried listing all permutations of one number and checking whether
> the
> > other number is in the list of permutations. This seems pretty slow, so I
> > was hoping for a faster method.
> >>
> >> 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
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
More information about the Programming
mailing list