IS.NOT.NUMBER
This elegant solution was posted by an astute, anonymous reader:
/TXT?0N
My original solution:
--IS.NOT.NUMBER
--; Input(s): /TXT
--; Output(s): /SKIP as nil
--; If /TXT is not a number return /SKIP as 1.
--0^Q,""^/SKIP,
--DO{(/TXT#Q^/CHR)&(/SKIP_.=.) E(/CHR)^/ASCII,
--IF{/ASCII<46 @SKIP;
--/ASCII>57 @SKIP;
--/ASCII=47 @SKIP},
--Q+1^Q},/SKIP
--
--SKIP
--1^/SKIP

4 Comments:
what is E as in E(/CHR) ?
Marc
Hi Marc,
E is the encode program. Passing the character as parameter A will return the ascii code for a character.
For instance: E(",") returns a 44.
John
You can just use ?0D to find if something is a number. For example, 55?0D evaluates to 55, and "A2Z"?0D evaluates to nil.
Great tip! I agree ?0D is much clearer and powerful. - John
Post a Comment
Links to this post:
Create a Link
<< Home