text
stringlengths
0
15.7k
source
stringlengths
6
112
end asinh
lns3.scpt
to acosh x
lns3.scpt
return 0.5 * (__e__ ^ x + __e__ ^ -x)
lns3.scpt
_error("acosh", eText, eNumber, eFrom, eTo)
lns3.scpt
end acosh
lns3.scpt
to atanh x
lns3.scpt
return (__e__ ^ x - __e__ ^ -x) / (__e__ ^ x + __e__ ^ -x)
lns3.scpt
_error("atanh", eText, eNumber, eFrom, eTo)
lns3.scpt
end atanh
lns3.scpt
to _frexp(m)
lns3.scpt
if m is 0 then return {0.0, 0}
lns3.scpt
set isNeg to m < 0
lns3.scpt
if isNeg then set m to -m
lns3.scpt
set e to 0
lns3.scpt
repeat until m ≥ 0.5 and m < 1
lns3.scpt
if m ≥ 1 then
lns3.scpt
set m to m / 2
lns3.scpt
set e to e + 1
lns3.scpt
set m to m * 2
lns3.scpt
set e to e - 1
lns3.scpt
return {m, e}
lns3.scpt
end _frexp
lns3.scpt
to _logn(x)
lns3.scpt
if x ≤ 0 then error "Invalid number (must be >0)." number -1703
lns3.scpt
set {x, e} to _frexp(x)
lns3.scpt
if e < -2 or e > 2 then
lns3.scpt
if x < 0.707106781187 then -- (2 ^ 0.5) / 2
lns3.scpt
set z to x - 0.5
lns3.scpt
set y to 0.5 * z + 0.5
lns3.scpt
set z to x - 1
lns3.scpt
set y to 0.5 * x + 0.5
lns3.scpt
set x to z / y
lns3.scpt
set z to x * x
lns3.scpt
set z to x * z * ((-0.789580278885 * z + 16.386664569956) * z - 64.140995295872) / (((z - 35.672279825632) * z + 312.093766372244) * z - 769.69194355046)
lns3.scpt
set y to e
lns3.scpt
set z to z - y * 2.12194440054691E-4 + x + e * 0.693359375
lns3.scpt
set x to 2 * x - 1
lns3.scpt
set y to x * z * (((((1.01875663804581E-4 * x + 0.497494994977) * x + 4.705791198789) * x + 14.498922534161) * x + 17.936867850782) * x + 7.708387337559) / (((((x + 11.287358718917) * x + 45.227914583753) * x + 82.987526691278) * x + 71.154475061856) * x + 23.125162012677)
lns3.scpt
if e ≠ 0 then
lns3.scpt
set y to y - e * 2.12194440054691E-4
lns3.scpt
set y to y - (z / 2)
lns3.scpt
set z to x + y
lns3.scpt
if e ≠ 0 then set z to z + e * 0.693359375
lns3.scpt
return z
lns3.scpt
end _logn
lns3.scpt
to logn x
lns3.scpt
return _logn(x as number)
lns3.scpt
_error("logn", eText, eNumber, eFrom, eTo)
lns3.scpt
end logn
lns3.scpt
to log10 x
lns3.scpt
return (_logn(x as number) / 2.302585092994) * 300.0 / 300.000000000006 -- correct for minor drift
lns3.scpt
_error("log10", eText, eNumber, eFrom, eTo)
lns3.scpt
end log10
lns3.scpt
to logb x base b
lns3.scpt
return _logn(x as number) / (_logn(b as number))
lns3.scpt
_error("logb", eText, eNumber, eFrom, eTo)
lns3.scpt
end logb
lns3.scpt
_errorWithPartialResult(handlerName, eText, eNumber, eFrom, eTo, missing value)
lns3.scpt
to _errorWithPartialResult(handlerName, eText, eNumber, eFrom, eTo, ePartial)
lns3.scpt
_support's rethrowError("List", handlerName, eText, eNumber, eFrom, eTo, missing value, ePartial)
lns3.scpt
end _errorWithPartialResult
lns3.scpt
to _makeListObject(len, padValue) -- make a new list of specified length using the supplied value as padding; caution: padValue will not be copied, so should be an immutable type (e.g. number, string, constant; not date/list/record/script/reference)
lns3.scpt
if len > 0 then
lns3.scpt
set listObject's _list_ to {padValue, padValue, padValue, padValue}
lns3.scpt
repeat while listObject's _list_'s length < len
lns3.scpt
set listObject's _list_ to listObject's _list_ & listObject's _list_
lns3.scpt
if listObject's _list_'s length > len then set listObject's _list_ to items 1 thru len of listObject's _list_
lns3.scpt
end _makeListObject
lns3.scpt
to insert into list theList value theValue before item beforeIndex : (missing value) after item afterIndex : (missing value) concatenation isJoin : (false)
lns3.scpt
if not isJoin or (count {theValue} each list) = 0 then set theValue to {theValue}
lns3.scpt
if afterIndex is not missing value then -- insert after specified index
lns3.scpt
if beforeIndex is not missing value then error "Expected ‘before item’ OR ‘after item’ parameter, but received both." number -1703
lns3.scpt
set afterIndex to _support's asIntegerParameter(afterIndex, "after item")
lns3.scpt
set isJoin to _support's asBooleanParameter(isJoin, "concatenation")
lns3.scpt
if afterIndex < 0 then set afterIndex to (listObject's _list_'s length) + afterIndex + 1
lns3.scpt
if afterIndex > (listObject's _list_'s length) then
lns3.scpt
_support's throwInvalidParameterIndex(a reference to after item afterIndex of (get listObject's _list_), "after item")
lns3.scpt
else if beforeIndex is not missing value then -- insert before specified index
lns3.scpt
set beforeIndex to _support's asIntegerParameter(beforeIndex, "before item")
lns3.scpt
if beforeIndex > 0 then
lns3.scpt
set afterIndex to beforeIndex - 1
lns3.scpt
else if beforeIndex < 0 then
lns3.scpt
set afterIndex to (listObject's _list_'s length) + beforeIndex
lns3.scpt
else -- `before item 0`
lns3.scpt
set afterIndex to listObject's _list_'s length
lns3.scpt
if afterIndex > (listObject's _list_'s length) or afterIndex < 0 then
lns3.scpt
_support's throwInvalidParameterIndex(a reference to before item beforeIndex of (get listObject's _list_), "before item")
lns3.scpt
else -- if no insertion index is specified, the default behavior is to append to list
lns3.scpt
return theList & theValue
lns3.scpt
if afterIndex = 0 then
lns3.scpt
return theValue & listObject's _list_
lns3.scpt
else if afterIndex = listObject's _list_'s length then
lns3.scpt
return listObject's _list_ & theValue
lns3.scpt
return (items 1 thru afterIndex of listObject's _list_) & theValue & (items (afterIndex + 1) thru -1 of listObject's _list_)
lns3.scpt
_error("insert into list", eText, eNumber, eFrom, eTo)
lns3.scpt
end insert into list
lns3.scpt
to delete from list theList item theIndex : (-1) from item startIndex : (missing value) to item endIndex : (missing value)
lns3.scpt
set listLength to listObject's _list_'s length
lns3.scpt
if startIndex is not missing value then set startIndex to _support's asIntegerParameter(startIndex, "from item")
lns3.scpt
if endIndex is not missing value then set endIndex to _support's asIntegerParameter(endIndex, "to item")
lns3.scpt