MN=: dyad define
'M N'=.x
d=.'0123456789ABCDEF'
fa=. 1 : 'm&#.@(d&i.)'
fromM=.M fa
toN=.N fa^:_1
toN fromM y
)
16 2 MN 'FF'
|domain error: fromM
| toN fromM y
It works when "d" in MN is defined as global with =:. Why does it have
to be defined globally?
2006/9/26, June Kim <[EMAIL PROTECTED]>:
Hello
Base M and N are given, which are any integer number between 2 and 16
inclusive. Do the base conversion on a given number(in string form)
from base M to base N.
My quick trial follows:
d=:'0123456789ABCDEF'
fromM=: [ #. d i. ]
toN=:d {~ 13 : 'x&#. ^:_1 y'
MN=: ([: {: [) toN ] fromM~ [: {. [
16 2 MN 'FE'
11111110
8 16 MN '732'
1DA
Could you propose a pure tacit version, or more elegant, shorter one?
I bet there are better ones than mine, as always.
June
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm