Re: [Jprogramming] permutations

2023-03-16 Thread Elijah Stone
There is only one cycle, yes. The point of the example was to demonstrate pathology with a very long cycle. On Fri, 17 Mar 2023, Jan-Pieter Jacobs wrote: Probably it's just something going over my head, but how do these permutations have more than one cycle? #@C. _1 1 |."0 _ i. 128 1 1 C.

Re: [Jprogramming] permutations

2023-03-16 Thread Elijah Stone
Oh, nice! I tried <./{~^:(<2>.@^.#p)p, but that loses information; your solution retains it in m. On Thu, 16 Mar 2023, Marshall Lochbaum wrote: Interesting problem! I think this works: for starting permutation p, keep two lists. At step i, - l is {~^:i p, that is, the index 2^i steps further

Re: [Jprogramming] permutations

2023-03-16 Thread Jan-Pieter Jacobs
Probably it's just something going over my head, but how do these permutations have more than one cycle? #@C. _1 1 |."0 _ i. 128 1 1 C. y returns boxed cycles in permutation y. What am I missing? Jan-Pieter On Fri, 17 Mar 2023, 01:07 Marshall Lochbaum, wrote: > Interesting problem! I thin

Re: [Jprogramming] Rank numbering with duplicates

2023-03-16 Thread bill lam
J phrases is good source too. https://www.jsoftware.com/docs/help807/phrases/rank_class.htm On Fri, 17 Mar 2023 at 12:35 AM Devon McCormick wrote: > This is good to know - thanks! > > On Wed, Mar 15, 2023 at 8:40 PM Ric Sherlock wrote: > > > As an adverb we can get the ascending and descendin

Re: [Jprogramming] permutations

2023-03-16 Thread Marshall Lochbaum
Interesting problem! I think this works: for starting permutation p, keep two lists. At step i, - l is {~^:i p, that is, the index 2^i steps further along the cycle - m is the minimum index among those less than 2^i steps ahead. Initially l is p and m is i.#p . To update, simultaneously replace l

Re: [Jprogramming] J solutions to Dyalog APL Competition Problems

2023-03-16 Thread Elijah Stone
I don't think so. If you wished to, you might rouse some interest by posting some solutions yourself. On Sun, 12 Mar 2023, Tony Poole wrote: I see that Dyalog sponsors an annual APL Problem Solving Competition. Are J solutions to these problems posted anywhere? --

[Jprogramming] permutations

2023-03-16 Thread Elijah Stone
I can characterise the cycles of a permutation with (<.{~)^:_ (this keys each cycle by its lowest element, but any unique key is fine). But although this sometimes has log span (in the length of the longest cycle): # (<.{~)^:(<_) _1|.i.128 8 The worst case is linear span: # (<.{~)^:(<_)

Re: [Jprogramming] Rank numbering with duplicates

2023-03-16 Thread Devon McCormick
This is good to know - thanks! On Wed, Mar 15, 2023 at 8:40 PM Ric Sherlock wrote: > As an adverb we can get the ascending and descending by applying either /: > or \: > > open 'stats/base/univariate' NB. in JQt will open the script > > rankCompete=: 1 :'u~ i. ]' > > On Thu, Mar 16, 2023 at 1:30