Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
def is_numeric?(s)
|
||||
begin
|
||||
Float(s)
|
||||
rescue
|
||||
false # not numeric
|
||||
else
|
||||
true # numeric
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
def is_numeric?(s)
|
||||
!!Float(s) rescue false
|
||||
end
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
def is_numeric?(s)
|
||||
!!Float(s, exception: false)
|
||||
end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
strings = %w(0 0.0 -123 abc 0x10 0xABC 123a -123e3 0.1E-5 50e)
|
||||
strings.each do |str|
|
||||
puts "%9p => %s" % [str, is_numeric?(str)]
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue