NB. Repunits generation verbs...
   
   f0=. p.&10x@#&1@+&1@i.   NB. Miller
   f1=. +/\@(10x ^ i.)      NB. Boss
   f2=. 10&#.\@(#&1x)       NB. Me
   f3=. >:@*~&10x^:(<`1:)   NB. Groeneveld
   f4=. ".@(,&'x')\@(#&'1') NB. Baker's approach 
   
   (f0,f1,f2,f3,:f4) 11
1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 11111111111
1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 11111111111
1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 11111111111
1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 11111111111
1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 11111111111
   
   st=. 7!:2 ; 6!:2
   
   st'f0 1111'
┌───────┬──────┐
│4057728│16.065│
└───────┴──────┘
   st'f1 1111'
┌───────┬────────┐
│1943232│0.028783│
└───────┴────────┘
   st'f2 1111'
┌───────┬───────┐
│4756416│7.09344│
└───────┴───────┘
   st'f3 1111'
┌───────┬────────┐
│1077504│0.013239│
└───────┴────────┘
   st'f4 1111'
┌───────┬────────┐
│1089536│0.097535│
└───────┴────────┘
   
   NB. With apologies for any misinterpretations or omissions
   

________________________________________
From: [email protected] [[email protected]] On 
Behalf Of Aai [[email protected]]
Sent: Sunday, November 13, 2011 8:03 AM
To: Programming forum
Subject: Re: [Jprogramming] 11:11:11 repunits

Repunits

In Haskell I would use iterate like:

~> take 4 $ iterate (succ.(10*)) 1
[1,11,111,1111]

Translated to J this could be:

 >:@*~&10x^:(<`1:) 4
1 11 111 1111


--
Met vriendelijke groet,
@@i=Arie Groeneveld

----------------------------------------------------------------------
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