I misunderstood your question.
(x A. y) starts by verifying that (*./ (|x) < !.#y) and then converts x
to a permutation with
(i.@-&.<: y) #: x
(all in extended precision if x is extended), followed by a number of
rotations within an index vector. It is much less work to start with
the permutation vector rather than the anagram index.
Henry Rich
On 8/11/2023 8:29 PM, Ak O wrote:
For me,
(x: y)
does not preserve the input.
The result I get is not the same.
( x:180548043269214561950911457875657 )
180548043269214573494164592263168
This does not work.
180548043269214561950911457875657x
180548043269214561950911457875657
This does work.
On Fri., Aug. 11, 2023, 13:01 Henry Rich, <henryhr...@gmail.com> wrote:
(x: value) produces extended version of value.
Henry Rich
On Fri, Aug 11, 2023, 2:44 PM Ak O <akin...@gmail.com> wrote:
Hi everybody, I hope you are all well.
I have a question about the Anagram ( A. ) operator.
In a defined function, how do I designate that an input 'x' is treatment
as extended datatype rather than float?
Where being defined:
13 : ' x A. i.y'
[ A. [: i. ]
is to be taken as,
13 : 'X_INPUTx A. y' NB. 12345672345467x A. i.y
How do I get the affect of catenating an 'x' to the end of a number in a
defined function?
If you understand my question ignore below, otherwise I give an example.
Thank you for your thoughts.
Ak
My understanding of the Anagram operator (A.).
The vocabulary reference page (acapdot) gives the product of the Anagram
index function
A. y
as datatype extended.
The Anagram function
x A. y
applies the permutation map (x) on ordered vector sequence (y) as below.
] vector_sequence =: ?~30
20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5
16 14
] vector_anagram =: A. vector_sequence
180548043269214561950911457875657
The Noun, vector_anagram will have datatype extended, given by:
datatype vector_anagram
extended
Applying the vector_anagram on a vector using the command:
vector_anagram A. i.30
20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5
16 14
The expected result.
In a case where the digits are input on there own, the following fails
with
'domain error, executing dyad A.'
180548043269214561950911457875657 A. i.30
One approach is to place 'x:' before the input.
( x:180548043269214561950911457875657 )A. i.30
20 12 4 29 7 17 22 11 2 27 28 25 1 8 0 15 16 14 3 5 19 26 18 6 21 23 13
24
9 10
This is not the expected result.
The input is treated as 180548043269214573494164592263168.
( x:180548043269214561950911457875657 )
180548043269214573494164592263168
Not the input I thought I was applying.
An alternative is to postfix an 'x' to the end of the input.
180548043269214561950911457875657x A. i.30
20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5
16 14
The expected result. But how do I achieve this for a defined function.
Does not work either.
".@((":vector_anagram),x')"_ NB. same as x:
Maybe there is a symbol that 13 : can be recognize to trigger the
extended
datatype.
Thank you for your help.
Ak
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm