How to split a number into your digits in APL
You can use inversion Decode
with base 10:
10β₯β£Β―1β’
since it Decode
will take as many digits as possible and decode them, its inverse will take a number and encode it for as many digits as needed,
or, with βIOβ0
, you can try to find the indices of the formatted number inside a vector of digits:
βDβ³β
This is better than uglier use Encode
with custom length obtained by forming an array of 10 in length log ten for input:
{β΅β€β¨10β΄β¨β10β1+β΅}
source to share
Not the shortest, but the strength for this was in the earliest APL. The 1962 book shows how to work with positional number systems using only basic functions and matrix multiplication:
source to share