#APL NARS 35 chars
APL NARS 35 chars
r←v a;c
r←c←0
A:r+←1⋄c+←r≠⍎⌽⍕r⋄→A×⍳c<a
it is the function v; "⍎⌽⍕"r traslate number r in string, reverse that string, traslate from string to number. Test and help functions:
⍝ return the one string for the basic types ('Char', 'Int', 'Float', 'Complex or Quaternion or Oction')
⍝ or one string for composite types ('Tensor 3' 'Tensor 4' etc 'Matrix', 'List', 'String')
⍝ follow the example in: https://codegolf.stackexchange.com/a/39745
type←{v←⍴⍴⍵⋄v>2:'Tensor ',⍕v⋄v=2:'Matrix'⋄(v=1)∧''≡0↑⍵:'String'⋄''≡0↑⍵:'Char'⋄v=1:'List'⋄⍵≢+⍵:'Complex or Quaternion or Oction'⋄⍵=⌈⍵:'Int'⋄'Float'}
h←{'Int'≢type ⍵:¯1⋄(⍵<1)∨⍵>2e5:¯1⋄v ⍵}
h 1
10
h 1.32
¯1
h 7878
8057
h¨3 5 12
13 15 23
h 6 7 8
¯1
h '123'
¯1
h '1'
¯1
h 1.0
10
h 1.0003
¯1
h ¯2
¯1
h 0
¯1
h 200000
201200
h 200001
¯1