text
stringlengths
0
15.7k
source
stringlengths
6
112
on setInsert(x, objcSet)
asPrelude.applescript
objcSet's addObject:(x)
asPrelude.applescript
objcSet
asPrelude.applescript
end setInsert
asPrelude.applescript
on setMember(x, objcSet)
asPrelude.applescript
missing value is not (objcSet's member:(x))
asPrelude.applescript
end setMember
asPrelude.applescript
on setSize(objcSet)
asPrelude.applescript
objcSet's |count|() as integer
asPrelude.applescript
on shift(n, xs)
asPrelude.applescript
take(lng, drop(n, cycle(xs)))
asPrelude.applescript
drop(n, xs)
asPrelude.applescript
end shift
asPrelude.applescript
on show(e)
asPrelude.applescript
set c to class of e
asPrelude.applescript
if c = list then
asPrelude.applescript
showList(e)
asPrelude.applescript
set mb to lookupDict("type", e)
asPrelude.applescript
showDict(e)
asPrelude.applescript
if "Either" = t then
asPrelude.applescript
set f to my showLR
asPrelude.applescript
set f to my showMaybe
asPrelude.applescript
else if "Ordering" = t then
asPrelude.applescript
set f to my showOrdering
asPrelude.applescript
else if "Ratio" = t then
asPrelude.applescript
set f to my showRatio
asPrelude.applescript
else if class of t is text and t begins with "Tuple" then
asPrelude.applescript
set f to my showTuple
asPrelude.applescript
set f to my showDict
asPrelude.applescript
tell mReturn(f) to |λ|(e)
asPrelude.applescript
tell result to |λ|(Just of mb)
asPrelude.applescript
else if c = date then
asPrelude.applescript
"\"" & showDate(e) & "\""
asPrelude.applescript
else if c = text then
asPrelude.applescript
"'" & e & "'"
asPrelude.applescript
else if (c = integer or c = real) then
asPrelude.applescript
e as text
asPrelude.applescript
else if c = class then
asPrelude.applescript
"null"
asPrelude.applescript
("«" & c as text) & "»"
asPrelude.applescript
end show
asPrelude.applescript
on showBinary(n)
asPrelude.applescript
script binaryChar
asPrelude.applescript
character id (48 + n)
asPrelude.applescript
showIntAtBase(2, binaryChar, n, "")
asPrelude.applescript
end showBinary
asPrelude.applescript
on showDate(dte)
asPrelude.applescript
((dte - (time to GMT)) as «class isot» as string) & ".000Z"
asPrelude.applescript
end showDate
asPrelude.applescript
on showDict(dct)
asPrelude.applescript
showJSON(dct)
asPrelude.applescript
end showDict
asPrelude.applescript
on showForest(xs)
asPrelude.applescript
unlines(map(my showTree, xs))
asPrelude.applescript
end showForest
asPrelude.applescript
on showHex(n)
asPrelude.applescript
showIntAtBase(16, mReturn(intToDigit), n, "")
asPrelude.applescript
end showHex
asPrelude.applescript
on showIntAtBase(base, toDigit, n, rs)
asPrelude.applescript
property f : mReturn(toDigit)
asPrelude.applescript
on |λ|(nd_, r)
asPrelude.applescript
set {n, d} to nd_
asPrelude.applescript
set r_ to f's |λ|(d) & r
asPrelude.applescript
|λ|(quotRem(n, base), r_)
asPrelude.applescript
r_
asPrelude.applescript
|λ|(quotRem(n, base), rs) of go
asPrelude.applescript
end showIntAtBase
asPrelude.applescript
on showJSON(x)
asPrelude.applescript
if (c is list) or (c is record) then
asPrelude.applescript
set json to ca's NSJSONSerialization's dataWithJSONObject:x options:1 |error|:(missing value)
asPrelude.applescript
if json is missing value then
asPrelude.applescript
"Could not serialize as JSON"
asPrelude.applescript
(ca's NSString's alloc()'s initWithData:json encoding:(ca's NSUTF8StringEncoding)) as text
asPrelude.applescript
else if c is date then
asPrelude.applescript
"\"" & ((x - (time to GMT)) as «class isot» as string) & ".000Z" & "\""
asPrelude.applescript
else if c is text then
asPrelude.applescript
"\"" & x & "\""
asPrelude.applescript
else if (c is integer or c is real) then
asPrelude.applescript
x as text
asPrelude.applescript
else if c is class then
asPrelude.applescript
end showJSON
asPrelude.applescript
on showLR(lr)
asPrelude.applescript
if isRight(lr) then
asPrelude.applescript
"Right(" & unQuoted(show(|Right| of lr)) & ")"
asPrelude.applescript
"Left(" & unQuoted(show(|Left| of lr)) & ")"
asPrelude.applescript
end showLR
asPrelude.applescript
on showList(xs)
asPrelude.applescript
"[" & intercalateS(", ", map(my show, xs)) & "]"
asPrelude.applescript
end showList
asPrelude.applescript
on showLog(e)
asPrelude.applescript
log show(e)
asPrelude.applescript
end showLog
asPrelude.applescript
on showMatrix(rows)
asPrelude.applescript
script showRow
asPrelude.applescript
on |λ|(a, row)
asPrelude.applescript
set {maxWidth, prevRows} to a
asPrelude.applescript
script showCell
asPrelude.applescript
on |λ|(acc, cell)
asPrelude.applescript
set {w, xs} to acc
asPrelude.applescript
if missing value is cell then
asPrelude.applescript