Also, for beginners I think f6 is more fun than f5!
f5=:[: +/\ 10x ^ i.
f6=:[: +/"1 [: +\ 10x ^ i.
5!:4 <'f5'
-- [:
+- \ --- / --- +
--+
│ -- 10x
L-----+- ^
L- i.
5!:4 <'f6'
-- [:
│ -- / --- +
+- " -+- 1
--+
│ -- [:
│ +- \ --- +
L-----+
│ -- 10x
L-----+- ^
L- i.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jose Mario Quintana
Sent: Sunday, November 13, 2011 1:34 PM
To: Programming forum
Subject: Re: [Jprogramming] 11:11:11 repunits
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'
--------T------┐
│4057728│16.065│
L-------+-------
st'f1 1111'
--------T--------┐
│1943232│0.028783│
L-------+---------
st'f2 1111'
--------T-------┐
│4756416│7.09344│
L-------+--------
st'f3 1111'
--------T--------┐
│1077504│0.013239│
L-------+---------
st'f4 1111'
--------T--------┐
│1089536│0.097535│
L-------+---------
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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm