Just came across a nice version of "digits" in a Rosetta Code contribution by
Arie Groeneveld:
,.&.":
>./ 5 */\ ,.&.": 73167176531330624919225119674426574742355349194934x
10&#.^:_1 (or 10&#.inv ) has always seemed to me to be the "right" way of
converting a number to its digits but it is slower and fatter than the other
methods:
ts=: 6!:2 , 7!:2...@]
40 ts ',.&.": 73167176531330624919225119674426574742355349194934x'
0.000115929383164 22016
40 ts '_&"."0 ": 73167176531330624919225119674426574742355349194934x'
0.000160654001302 18944
40 ts '(10&#.^:_1) 73167176531330624919225119674426574742355349194934x'
0.000466587187342 52608
> From: Jose Mario Quintana
>
> Another way,
>
> >./@(5 */\ 10&#.^:_1)
> 73167176531330624919225119674426574742355349194934x
> 6048
>
> ________________________________
> From: "Sherlock, Ric"
>
> Note the redundant ( _&"."0 ": ) I should have removed from my code:
> 5 */\ _&"."0 ": 73167176531330624919225119674426574742355349194934x
> 882 126 294 1764 1470 ...
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm