what does J operator #: do? 
Author Message
 what does J operator #: do?

What does the dyadic J operator #: do?  I find its behavior puzzling
in light of its behavior as a monadic operator.

As a monadic operator, #: gives the base two expansion of its positive
integer argument.

  #: i. 8
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

The operator #. is the left inverse of #:

   #. #: i. 8
0 1 2 3 4 5 6 7

Furthermore, the dyadic version of #.  behaves as follows:
given a positive integer m and the list of positive integers a,
m #. a gives the decimal value of the a considered as an integer base m.  

   5 #. 1 3 2
42

This leads me to expect m #: n to be the expansion in base m of the
decimal integer n.  This is not the case.  Is there an easy way to
get the expansion base m of n?   Perhaps I don't quite get the picture
and am missing the obvious?



Sat, 20 Jan 1996 03:02:13 GMT  
 what does J operator #: do?
 David Cabana  writes:

Quote:

>This leads me to expect m #: n to be the expansion in base m of the
>decimal integer n.  This is not the case.  Is there an easy way to
>get the expansion base m of n?   Perhaps I don't quite get the picture
>and am missing the obvious?

   NB. See.... Maybe this will give you a start.

   NB. Since :

   +/ 25 5 1 * 1 2 4
39

   NB. So 124 base 5 is 39 base 10

   NB. Then to find the base 5 representation of 39 :

   (5 5 5) #: 39
1 2 4

   NB. or

   10&#. 5 5 5 #: 39
124

   NB. As for writting a program which does the conversion:
   NB. Let's write several versions.


   cnvt10to5v1 =. 5&st #: ]
   cnvt10to5v1 39
1 2 4

   NB. version 2 :

   cnvt10to5v2 39
124
   NB. and version 3

   cnvt10to5v3 (3 9)
1 2 4

   NB. To go the other way around:
   cnvt5to10v1 =. ((# # 5"_)  #. ])
   cnvt5to10v1 1 2 4
39
   NB. or


   cnvt5to10v2 124
39

   NB. or

3 9

  -emmett



Sat, 20 Jan 1996 00:29:17 GMT  
 what does J operator #: do?

   NB. Here is a solution to the more general problem of finding the
   NB. base m representation of x base n.

   9!:3(5)


   v  =. ( u ]) #: ]

   cnvt =. ([ ; [ v w)"(0 1)

   NB. So m cnvt x;n is y;m
   NB. For example, the base 2 4 .. 64 representation of 128 base 10 are :


+-------------------+-----------+---------+--------+--------+--------+
|+-+---------------+|+-+-------+|+-+-----+|+--+---+|+--+---+|+--+---+|
||2|1 0 0 0 0 0 0 0|||4|2 0 0 0|||8|2 0 0|||16|8 0|||32|4 0|||64|2 0||
|+-+---------------+|+-+-------+|+-+-----+|+--+---+|+--+---+|+--+---+|
+-------------------+-----------+---------+--------+--------+--------+
   10 cnvt 5;1 2 4
+--+---+
|10|3 9|
+--+---+

   NB. Notice the spaces between the 1 2 and 4. This format is necessary
   NB. for cases where bases can be larger than 10.

   -emmett



Sat, 20 Jan 1996 04:38:35 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Doing assembly and really doing assembly

2. Doing assembly and really doing assembly

3. JS-EAI with *JS*-callback

4. js.exception 3279.js

5. What can be done in FORTRAN that cannot be done in C/C++?

6. How can view styles be done?

7. - Fall 2003 Release done

8. How to minimize damage done by Java

9. How is Strand doing ?

10. Anyone doing anything with NNTP in Dolphin?

11. WHAT ARE THE KIDS REALLY DOING ONLINE..

12. WHAT ARE EMPLOYEES REALLY DOING ONLINE^^^

 

 
Powered by phpBB® Forum Software