Script with functions manipulation

Is it possible to make this work faster?

( Specifically:

to remove all/some additional variables (used to unify outputs, counting one, v.s array),

to do not do “switch” check at repeating same function,

to do not use “switch” (only ‘flow control’)

; without duplicating parts of the script of cource )