Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,62 @@
|
|||
-- isNumString :: String -> Bool
|
||||
on isNumString(s)
|
||||
try
|
||||
if class of s is string then
|
||||
set c to class of (s as number)
|
||||
c is real or c is integer
|
||||
else
|
||||
false
|
||||
end if
|
||||
on error
|
||||
false
|
||||
end try
|
||||
end isNumString
|
||||
|
||||
|
||||
|
||||
-- TEST
|
||||
on run
|
||||
|
||||
map(isNumString, {3, 3.0, 3.5, "3.5", "3E8", "-3.5", "30", "three", three, four})
|
||||
|
||||
--> {false, false, false, true, true, true, true, false, false, false}
|
||||
|
||||
end run
|
||||
|
||||
-- three :: () -> Int
|
||||
script three
|
||||
3
|
||||
end script
|
||||
|
||||
-- four :: () -> Int
|
||||
on four()
|
||||
4
|
||||
end four
|
||||
|
||||
|
||||
-- GENERIC FUNCTIONS FOR TEST
|
||||
|
||||
-- map :: (a -> b) -> [a] -> [b]
|
||||
on map(f, xs)
|
||||
tell mReturn(f)
|
||||
set lng to length of xs
|
||||
set lst to {}
|
||||
repeat with i from 1 to lng
|
||||
set end of lst to lambda(item i of xs, i, xs)
|
||||
end repeat
|
||||
return lst
|
||||
end tell
|
||||
end map
|
||||
|
||||
|
||||
-- Lift 2nd class handler function into 1st class script wrapper
|
||||
-- mReturn :: Handler -> Script
|
||||
on mReturn(f)
|
||||
if class of f is script then
|
||||
f
|
||||
else
|
||||
script
|
||||
property lambda : f
|
||||
end script
|
||||
end if
|
||||
end mReturn
|
||||
|
|
@ -0,0 +1 @@
|
|||
{false, false, false, true, true, true, true, false, false, false}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
on isNumString(s)
|
||||
if (s's class is not text) then return false
|
||||
try
|
||||
s as number
|
||||
return true
|
||||
on error
|
||||
return false
|
||||
end try
|
||||
end isNumString
|
||||
Loading…
Add table
Add a link
Reference in a new issue