I couldn't resist adding to my "Useless generalizations of RPN challenges" series . . .
Given any 1-9 digit integer in x, return any arbitrary selection and arrangement of 1-9 of its digits, in a pattern specified by the user.
A01 LBL A "xeq A" to run
A02 STO U store User-supplied value
A03 0 initialize
A04 STO R Result
A05 INPUT P obtain user's Pattern
A06 9 initialize loop counter
L01 LBL L processing Loop
L02 STO C save Counter value
L03 RCL P get Pattern (again)
L04 XEQ D execute "obtain Digit" subroutine
L05 RCL U recall User's original value
L06 XEQ D execute "obtain Digit" subroutine
L07 10 shift
L08 STO* R Result left
L09 ROLL DOWN and
L10 STO+ R "append" specified digit
L11 RCL C get Loop counter,
L12 1 decrement
L13 - and
L14 x>0? test for done
L15 GTO L not done
L16 RCL R bring Result into x
L17 STOP and halt
D01 LBL D "return yth digit in x"
D02 x<>y swap
D03 10**x turn location into divisor
D04 / shift y right x places and
D05 FP discard stuff on the left
D06 10 shift it left
D07 * one place, and
D08 IP discard stuff on the right
D09 RTN return specified digit
The pattern is encoded as follows:
"0" == insert a zero
"1" == one's digit
"2" == ten's digit
"3" == hundred's digit
...
"9" = hundred million's digit
For the special case of reversing an
n-digit value, simply XEQ A with some integer in
x, and enter the first
n digits of "123456789" when prompted for P.
I programmed this on an HP-32s, and it takes 48 bytes as written, and 32 more when run (for the four variables).