0

How do I convert from a char vector AKQJT98765 to a vector of integers 13 12 11 10 9 8 7 6 5 using APLX? I have tried the data conversion function, without succcess.

1 Answers1

2

I'm not sure I understand the question.

If you want to convert a string made of those 10 letters and digits into a vector of the respective integer values (nevermind that in your example the string has 10 characters, but the vector only has 9 numbers) you can use the index function on the reversed string plus an offset:

5 + '56789TJQKA' ⍳ X

For example:

      5 + '56789TJQKA' ⍳ 'ATTAK9'
14 10 10 14 13 9

Otherwise, if you wish to convert a string using some known character set, there are a few predefined functions. ⎕UCS converts a string into a numeric vector and the other way round using the Unicode character values. ⎕TR is an older function that does something similar, but is system-dependent. ⎕AV is a vector of all APL characters in their original position (and value.)

Tobia
  • 17,856
  • 6
  • 74
  • 93