RosettaCodeData/Task/Self-describing-numbers/LiveCode/self-describing-numbers-1.l...

12 lines
328 B
Plaintext

function selfDescNumber n
local tSelfD, tLen
put len(n) into tLen
repeat with x = 0 to (tLen - 1)
put n into nCopy
replace x with empty in nCopy
put char (x + 1) of n = (tLen - len(nCopy)) into tSelfD
if not tSelfD then exit repeat
end repeat
return tSelfD
end selfDescNumber