I learned much j tonight.  My unnecessary extended precision crushed my
memory.

   swops=: ((|.@:{. , }.)~ {.)^:a:
   (,. _1 + ! >./@:(#@swops@A. >:)&i. ])&> >:i.10

&> is the same, in this case, as "0 .
Where you have (! hook&i. ]) I had orepeated i. .
Beautiful work!

On Tue, 2012-11-27 at 03:16 +0000,
[email protected] wrote:
> Date: Mon, 26 Nov 2012 22:19:42 -0500
> From: Dan Bron <[email protected]>
> To: "[email protected]" <[email protected]>
> Subject: Re: [Jprogramming] count iterations
> Message-ID: <[email protected]>
> Content-Type: text/plain;       charset=us-ascii
> 
> I added a solution to the task at RosettaCode.  If we let J do the
> work for us, the solution is fairly simple. We use ^:a: ("swop" until
> you hit your fixed point, i.e. until 1={. ) and the count is the
> number of swops, i.e. the length of the result.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to