Jsoftware
High-Performance Development Platform

]&.#:

View: New views
1 Messages — Rating Filter:   Alert me  

]&.#:

by Raul Miller-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

]&.#: does not reconstitute negative integers

   i:2
_2 _1 0 1 2
   ]&.#: i: 2
2 3 0 1 2

However, with a little work, an invertible operation
can be achieved:
   #.@(#:,.~0<.*)i:2
_2 _1 0 1 2

This becomes important when investigating operations
on binary numbers.  For example, shift right:
   (,. #.@(}:"1)@(#:,.~0<.*))i:3
_3 _2
_2 _1
_1 _1
 0  0
 1  0
 2  1
 3  1

FYI,

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
LightInTheBox - Buy quality products at wholesale price!