Anonymous user
Determine if a string is numeric: Difference between revisions
m
→[[Determine if a string is numeric#ALGOL 68]]: fix pre tag
m (→[[Determine if a string is numeric#ALGOL 68]]: fix pre tag) |
|||
Line 65:
=={{header|ALGOL 68}}==
{{trans|Ada}}
{{works with|ALGOL 68|Revision 1 - no extensions to language used}}
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny]}}
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to extensive use of FORMATted transput}}
<lang algol68>PROC is numeric = (REF STRING string) BOOL: (
BOOL out := TRUE;
Line 74 ⟶ 80:
on logical file end(memory, call back false);
UNION (INT, REAL,
# use a FORMAT pattern instead of a regular expression #
getf(memory, ($gl$, numeric));
Line 80 ⟶ 86:
);
test:(
STRING
s1 := "152",
s2 := "-3.1415926",
s3 := "Foo123";
print((
print((s1, " results in ", is numeric(s1), new line));▼
);▼
))
</lang>
Output:
<lang algol68>152 results in T▼
<pre>
-3.1415926 results in T
Foo123 results in F
</pre>
=={{header|APL}}==
|