aboutsummaryrefslogtreecommitdiffstats
path: root/awklib/eg/lib
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2021-06-22 13:45:25 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2021-06-22 13:45:25 -0400
commit1bf8a67c114568b307c1df6dfe2042e2a3eab49b (patch)
treed02018ca12bf82104f90804df4b056d44b823a4f /awklib/eg/lib
parente7706feed9aac915db7307ad59d3908a8952eaf0 (diff)
downloadegawk-1bf8a67c114568b307c1df6dfe2042e2a3eab49b.tar.gz
egawk-1bf8a67c114568b307c1df6dfe2042e2a3eab49b.tar.bz2
egawk-1bf8a67c114568b307c1df6dfe2042e2a3eab49b.zip
Add isnumeric function.
Diffstat (limited to 'awklib/eg/lib')
-rw-r--r--awklib/eg/lib/isnumeric.awk14
1 files changed, 14 insertions, 0 deletions
diff --git a/awklib/eg/lib/isnumeric.awk b/awklib/eg/lib/isnumeric.awk
new file mode 100644
index 00000000..6309e76a
--- /dev/null
+++ b/awklib/eg/lib/isnumeric.awk
@@ -0,0 +1,14 @@
+# isnumeric --- check whether a value is numeric
+
+function isnumeric(x, f)
+{
+ switch (typeof(x)) {
+ case "strnum":
+ case "number":
+ return 1
+ case "string":
+ return (split(x, f, " ") == 1) && (typeof(f[1]) == "strnum")
+ default:
+ return 0
+ }
+}