Thanks to Raul & R. E. Boss for solutions to my Separating Digits problem.
Either solution works well for my application. However, understanding how
either of them works, is still a challenge for me.
a=. 10 345 64 5642 11 5
Raul's solution:
,.&.":&.> a
┌───┬─────┬───┬───────┬───┬─┐
│1 0│3 4 5│6 4│5 6 4 2│1 1│5│
└───┴─────┴───┴───────┴───┴─┘
My first problem with this is the > which should *unbox* an already
unboxed a, but instead somehow boxes it.
Not only that, but I know ": turns numerics into literal text characters.
datatype > ":&.> a
literal
However in this case, after unboxing the ,. the literals are somehow turned
back into
integers.
datatype > ,.&.":&.> a
integer
?? magic ??
R. E. Boss' solution
10#.^:_1 &.> a
┌───┬─────┬───┬───────┬───┬─┐
│1 0│3 4 5│6 4│5 6 4 2│1 1│5│
└───┴─────┴───┴───────┴───┴─┘
I have the same issue with the > which should *unbox* an already
unboxed a, but instead somehow boxes it.
Then I can see that this:
10#.^:_1 a
0 0 1 0
0 3 4 5
0 0 6 4
5 6 4 2
0 0 1 1
0 0 0 5
is the same as this:
10 10 10 10 #: a
0 0 1 0
0 3 4 5
0 0 6 4
5 6 4 2
0 0 1 1
0 0 0 5
So this:
10#.^:_1 &.> a
┌───┬─────┬───┬───────┬───┬─┐
│1 0│3 4 5│6 4│5 6 4 2│1 1│5│
└───┴─────┴───┴───────┴───┴─┘
Should be the same as this:
10 10 10 10 #: &.> a
|length error
| 10 10 10 10 #:&.>a
But it's not! ??
Skip
Skip Cave
Cave Consulting LLC
On Sun, Feb 25, 2018 at 1:17 PM, Skip Cave <[email protected]> wrote:
> how can I take a vector of integers:
>
> a=. 10 345 64 5642 11 5
>
> and separate them into their individual digits (integers):
>
> sep a
>
> ┌───┬─────┬───┬───────┬───┬─┐
>
> │1 0│3 4 5│6 4│5 6 4 2│1 1│5│
>
> └───┴─────┴───┴───────┴───┴─┘
>
> ?
>
> Skip
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm