[Jprogramming] Base/antibase question

Stefano Lanzavecchia stf at apl.it
Fri May 9 14:12:55 UTC 2014


   10#.^:_1 ] 2345
2 3 4 5


Sent from my iPad

On 09/mag/2014, at 16:10, Linda Alvord <lindaalvord at verizon.net> wrote:

Here's a  path to an answer:

  10 10 10 10#:2345
2 3 4 5
  (($":2345)#10)
10 10 10 10
  (($":2345)#10)#:2345
2 3 4 5
  f=: 13 :'(($":y)#10)#:y'
  f 2345
2 3 4 5
  f
] #:~ 10 #~ [: $ ":

Linda

-----Original Message-----
From: programming-bounces at forums.jsoftware.com
[mailto:programming-bounces at forums.jsoftware.com<programming-bounces at forums.jsoftware.com>]
On Behalf Of Jon Hough
Sent: Friday, May 09, 2014 2:33 AM
To: programming at jsoftware.com
Subject: [Jprogramming] Base/antibase question

I want to get the (base 10) digits of an integer as an array.
e.g. 2343 becomes an array 2 3 4 3
My attempt is:

 tens =. 10 $ 10   tens #: 345
result: 0 0 0 0 0 0 0 3 4 5
I created the initial array tens as a 10 element array, and f course now I
have way too many leading zeros in my result.
How should I do this properly, returning no leading zeros, for an arbitrary
size integer?
Thanks.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list