It was deleted in g by }.
R.E. Boss -----Oorspronkelijk bericht----- Van: [email protected] [mailto:[email protected]] Namens Linda Alvord Verzonden: zaterdag 12 november 2011 18:12 Aan: 'Programming forum' Onderwerp: Re: [Jprogramming] 11:11:11 repunits Earlier versions: f=: 13 :'(; q:)@p.&10x@#&1@+&2 i.y' g=: 13 : ' (;q:)"0}.+/\10^i.y' f 4 ------T------┐ │11 │11 │ +-----+------+ │111 │3 37 │ +-----+------+ │1111 │11 101│ +-----+------+ │11111│41 271│ L-----+------- g 4x -----T------┐ │11 │11 │ +----+------+ │111 │3 37 │ +----+------+ │1111│11 101│ L----+------- (f 19)-:(g 20x) 1 Where did a line of the result go? Linda -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Nick Simicich Sent: Saturday, November 12, 2011 2:04 AM To: Programming forum Subject: Re: [Jprogramming] 11:11:11 repunits e129rep2 =: 10 #. (1x $~ ]) e129rep 100 1111111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111 That is the one I use to make repunits.... Of course, this has the equivalent command line definition of (10#. (1x $~ ])) Thinking about it, this hook is a lot simpler looking and is equivalent, I think. e129rep =: 10&#. $&1x (10&#. $&1x) 100 1111111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111 That leads to this variation: (;q:)@(10&#. $&1x)"0 ]2+ i.18 I really like the cute little (;q:) - I would never have thought of it, I suspect. The reason I like this phrase is that there is a lot of talk about repunits in other bases, and this phrase is amenable to interpreting the repunit numbers in other bases. For example, the same repunits, in base 5, but expressed in base 10: (;q:)@:(5&#. $&1x)"0 >:>: i.18 5#.^:_1 ] 190734863281 NB. one of the numbers in the tables 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 and that leads to: 5b11111111111111111 190734863281 '5b',17$'1' 5b11111111111111111 ".'5b',17$'1' 190734863281 Since J can accept literals in any base. J's ability to accept input made up of numbers in other bases is cool. But the only way I know of to express a number in, say, base 16, is to make a verb that converts it to a string, and if you are "cute" about it, you can cause the verb to be such that you can edit the output to use it in the next calculation: ([: '16b'&, ([: {&'0123456789abcdefghijklmnop' 16&#.^:_1)) (16b89ee1791 + 16b54bfa75e) tohex =: [: '16b'&, ([: {&'0123456789abcdef' 16&#.^:_1) tohex 16b89ee1791 + 16b54bfa75e or more generally, tobase =: dyad : '([:((":x),''b'')&, ([: {&''0123456789abcdefghijklmnop'' x&#.^:_1)) y' 11 tobase 11111111111 11b4791a29261 11 tobase 11b111111111 11b111111111 (I'm sure I've missed some sort of foreign construction that makes all output appear in the base you want it to appear in, or some such. If there is, maybe someone can elighten me?) -- Of course I can ride in the carpool lane, officer. Jesus is my constant companion. ---------------------------------------------------------------------- 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
