Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,6 @@
set theList to {"apple", "orange"}
count theList
-- or
length of theList
-- or
number of items in theList

View file

@ -0,0 +1,41 @@
on run
set xs to ["alpha", "beta", "gamma", "delta", "epsilon", ¬
"zeta", "eta", "theta", "iota", "kappa", "lambda", "mu"]
{_length(xs), fold(xs, succ, 0), item 12 of xs, item -1 of xs}
--> {12, 12, "mu", "mu"}
end run
-- TWO FUNCTIONAL DEFINITIONS OF LENGTH
-- 1. Recursive definition
on _length(xs)
if xs is [] then
0
else
1 + _length(rest of xs)
end if
end _length
-- 2. fold (λx n -> 1 + n) 0
on succ(x)
1 + x
end succ
--[a] - > (a - > b) - > b - > [b]
on fold(xs, f, startValue)
script mf
property lambda : f
end script
set v to startValue
repeat with x in xs
set v to mf's lambda(v, x)
end repeat
end fold