It looks as if you don't appreciate the action of " &. " The
dot/period/full-stop is
significant. Whereas & is bond/compose, &. and &.: are both
"Under(Dual) " .
NuVoc says (http://code.jsoftware.com/wiki/Vocabulary/ampdot)
[x] u &. v y
executes v on the argument (s) cell by cell
. for each cell, u is applied to the result (s) of v
. then v&:_1 (the obverse of v) is applied to the result of u - for that
cell
finally, the results for all cells are collected into the end result
I usually think of it as f^(-1) g f
You might remember David Singmaster flogging the idea in his essays on
the Rubik
cube, years ago; he called turn sequences such as R U^_1 L U R^_1
commutators
(I think!)
J might code such an operation as L&.U&.(R^:_1) .
J examples include
3 +&.^.4 NB. 3*4 <==> antilog (log 3) + log 4 <==> 3 + under log 4
12
So ,. &. ": is ravel under format ,
ie ravel the string representation of a number and then convert it back
to number(s)
The 10#.inv approach doesn't use under, though. ("each", the >&. does,
of course.)
It's much more convenient than working out the number of base elements
you need
for each number and ending up with something messy, but correct, like
(10 10;10 10 10) #: each 10 345 NB. .... (a)
+---+-----+
|1 0|3 4 5|
+---+-----+
It's more convenient to do
10 10 10 #: 10 345 NB. (b)
0 1 0
3 4 5
but isn't what you need, without further messing around with magnitudes!
10 #.inv 10 345 ... effectively does the latter, (b) not too useful,
whereas
10 #.inv each 10 345 ... does what you require (a), effectively working
out the
numbers of base elements you need for each application of #:
Pending Raul and RE Boss's own deeper thoughts...
Cheers,
Mike
On 27/02/2018 07:27, Skip Cave wrote:
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
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm