If you're sure a is pure 01s then b=: '1'=a is probably best.
-----Original Message----- From: Björn Helgason <[email protected]> Sent: Saturday, 30 April 2011 23:27 To: Programming forum <[email protected]> Subject: Re: [Jprogramming] sum of digits in a number I anything to prefer if the digits are pure 0/1 ? Working with QR codes you may get strings like a=.'1111111011101100011100010000110100100100...... $a 4829 b=. 1j1 # a $b 9658 b 1 1 1 1 1 1 1 0 1 1 1 0 1 1 0 0 0 1 1 1 0 0 0 1 0 c=. "."0 b $c 9658 1 2011/4/29 Roger Hui <[email protected]> > Aha! A dual: > > 1j1&#&.": 12345 > 1 2 3 4 5 > > The fastest expression for obtaining the decimal digits is: > http://www.jsoftware.com/help/release/digits10.htm > > 0"."0@": 12345 > 1 2 3 4 5 > > > > ----- Original Message ----- > From: Devon McCormick <[email protected]> > Date: Friday, April 29, 2011 5:48 > Subject: Re: [Jprogramming] sum of digits in a number > To: Programming forum <[email protected]> > > > You need to turn the result back into numbers after doing the > > "filled copy" > > (1j1#): > > > > ".1j1#":12345 > > 1 2 3 4 5 > > +/".1j1#":12345 > > 15 > > > > 2011/4/29 Björn Helgason <[email protected]> > > > > > 1j1#":12345 > > > > > > 2011/4/29 bill lam <[email protected]> > > > > > > > one way is > > > > ]a=. ".,.":12345 > > > > 1 2 3 4 5 > > > > +/a > > > > 15 > > > > > > > > project euler? > > > > > > > > Птн, 29 Апр 2011, Daniel Roe писал(а): > > > > > > > > > > If we add up the digits of the number 12345 we get > > 1+2+3+4+5 = 15. > > > > > I want to be able to do math upon the individual digits. > > > > > How would I do that in J? > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Björn Helgason, Verkfræðingur Fornustekkum II 781 Hornafirði, t-póst: [email protected] gsm: +3546985532 twitter: @flugfiskur http://groups.google.com/group/J-Programming Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans góður kennari getur stigið á tær án þess að glansinn fari af skónum /|_ .-----------------------------------. ,' .\ / | Með léttri lund verður | ,--' _,' | Dagurinn í dag | / / | Enn betri en gærdagurinn | ( -. | `-----------------------------------' | ) | (\_ _/) (`-. '--.) (='.'=) ♖♘♗♕♔♙ `. )----' (")_(") ☃☠ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
