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,
programming-requ...@forums.jsoftware.com wrote:
> Date: Mon, 26 Nov 2012 22:19:42 -0500
> From: Dan Bron <j...@bron.us>
> To: "programm...@jsoftware.com" <programm...@jsoftware.com>
> Subject: Re: [Jprogramming] count iterations
> Message-ID: <53154fe6-9368-45b0-8120-ba3e3861e...@bron.us>
> 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