Anonymous user
Determine if a string is numeric: Difference between revisions
Add Nu
(→{{header|Bracmat}}: Removed the part about converting floating point numbers to rational numbers.) |
imported>Brie (Add Nu) |
||
Line 3,510:
Inf is numeric
rose is not numeric</pre>
=={{header|Nu}}==
<syntaxhighlight lang="nu">
def is-numeric [] {try {into float | true} catch {false}}
["1" "12" "-3" "5.6" "-3.14" "one" "cheese"] | each {{k: $in, v: ($in | is-numeric)}}
</syntaxhighlight>
{{out}}
<pre>
╭───┬────────┬───────╮
│ # │ k │ v │
├───┼────────┼───────┤
│ 0 │ 1 │ true │
│ 1 │ 12 │ true │
│ 2 │ -3 │ true │
│ 3 │ 5.6 │ true │
│ 4 │ -3.14 │ true │
│ 5 │ one │ false │
│ 6 │ cheese │ false │
╰───┴────────┴───────╯
</pre>
=={{header|Objeck}}==
|