Question: Simplifying a procedure

Hi everyone,

I'm looking for some way to simplify the following procedure:

 

scm := proc(X, x) global xx;

if 1 <= X and X < 10 then xx := cat(x)

elif 10 <= X and X < 100 then if 1 <= x and x < 10 then xx := cat(0, x) else xx := cat(x) end if

elif 100 <= X and X < 1000 then if 1 <= x and x < 10 then xx := cat(0, 0, x) elif 10 <= x and x < 100 then xx := cat(0, x) else xx := cat(x) end if

elif 1000 <= X and X < 10000 then if 1 <= x and x < 10 then xx := cat(0, 0, 0, x) elif 10 <= x and x < 100 then xx := cat(0, 0, x) elif 100 <= x and x < 1000 then xx := cat(0, x) else xx := cat(x) end if

elif 10000 <= X and X < 100000 then if 1 <= x and x < 10 then xx := cat(0, 0, 0, 0, x) elif 10 <= x and x < 100 then xx := cat(0, 0, 0, x) elif 100 <= x and x < 1000 then xx := cat(0, 0, x) elif 1000 <= x and x < 10000 then xx := cat(0, x) else xx := cat(x) end if

end if

end proc

 

Any tips? Thank you in advance.

Please Wait...