Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
-- recursionDepth :: () -> IO String
|
||||
on recursionDepth()
|
||||
script go
|
||||
on |λ|(i)
|
||||
try
|
||||
|λ|(1 + i)
|
||||
on error
|
||||
"Recursion limit encountered at " & i
|
||||
end try
|
||||
end |λ|
|
||||
end script
|
||||
|
||||
go's |λ|(0)
|
||||
end recursionDepth
|
||||
|
||||
on run
|
||||
|
||||
recursionDepth()
|
||||
|
||||
end run
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
-- HIGHEST CHURCH NUMERAL REPRESENTABLE IN APPLESCRIPT ?
|
||||
|
||||
-- (This should be a good proxy for recursion depth)
|
||||
|
||||
on run
|
||||
script unrepresentable
|
||||
on |λ|(x)
|
||||
try
|
||||
churchFromInt(x)
|
||||
return false
|
||||
on error
|
||||
return true
|
||||
end try
|
||||
x > 10
|
||||
end |λ|
|
||||
end script
|
||||
|
||||
"The highest Church-encoded integer representable in Applescript is " & ¬
|
||||
(|until|(unrepresentable, my succ, 0) - 1)
|
||||
end run
|
||||
|
||||
-- CHURCH NUMERALS ------------------------------------------------------
|
||||
|
||||
-- chZero :: (a -> a) -> a -> a
|
||||
on chZero(f)
|
||||
script
|
||||
on |λ|(x)
|
||||
x
|
||||
end |λ|
|
||||
end script
|
||||
end chZero
|
||||
|
||||
-- chSucc :: ((a -> a) -> a -> a) -> (a -> a) -> a -> a
|
||||
on chSucc(n)
|
||||
script
|
||||
on |λ|(f)
|
||||
script
|
||||
property mf : mReturn(f)'s |λ|
|
||||
on |λ|(x)
|
||||
mf(mReturn(n)'s |λ|(mf)'s |λ|(x))
|
||||
end |λ|
|
||||
end script
|
||||
end |λ|
|
||||
end script
|
||||
end chSucc
|
||||
|
||||
-- churchFromInt :: Int -> (a -> a) -> a -> a
|
||||
on churchFromInt(x)
|
||||
script go
|
||||
on |λ|(i)
|
||||
if 0 < i then
|
||||
chSucc(|λ|(i - 1))
|
||||
else
|
||||
chZero
|
||||
end if
|
||||
end |λ|
|
||||
end script
|
||||
go's |λ|(x)
|
||||
end churchFromInt
|
||||
|
||||
-- intFromChurch :: ((Int -> Int) -> Int -> Int) -> Int
|
||||
on intFromChurch(cn)
|
||||
mReturn(cn)'s |λ|(my succ)'s |λ|(0)
|
||||
end intFromChurch
|
||||
|
||||
|
||||
-- GENERIC FUNCTIONS ----------------------------------------
|
||||
|
||||
-- until :: (a -> Bool) -> (a -> a) -> a -> a
|
||||
on |until|(p, f, x)
|
||||
set v to x
|
||||
set mp to mReturn(p)
|
||||
set mf to mReturn(f)
|
||||
repeat until mp's |λ|(v)
|
||||
set v to mf's |λ|(v)
|
||||
end repeat
|
||||
end |until|
|
||||
|
||||
-- Lift 2nd class handler function into 1st class script wrapper
|
||||
-- mReturn :: First-class m => (a -> b) -> m (a -> b)
|
||||
on mReturn(f)
|
||||
if class of f is script then
|
||||
f
|
||||
else
|
||||
script
|
||||
property |λ| : f
|
||||
end script
|
||||
end if
|
||||
end mReturn
|
||||
|
||||
-- succ :: Enum a => a -> a
|
||||
on succ(x)
|
||||
1 + x
|
||||
end succ
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
global i
|
||||
|
||||
on recursion()
|
||||
set i to i + 1
|
||||
recursion()
|
||||
end recursion
|
||||
|
||||
on run
|
||||
set i to -1
|
||||
try
|
||||
recursion()
|
||||
on error
|
||||
"Recursion limit encountered at " & i
|
||||
-- display dialog result -- Uncomment to see the result if running as an applet.
|
||||
end try
|
||||
end run
|
||||
|
|
@ -0,0 +1 @@
|
|||
"Recursion limit encountered at 733"
|
||||
Loading…
Add table
Add a link
Reference in a new issue