text stringlengths 0 15.7k | source stringlengths 6 112 |
|---|---|
if startIndex is missing value and endIndex is missing value then | lns3.scpt |
set startIndex to _support's asIntegerParameter(theIndex, "item") | lns3.scpt |
if startIndex < 0 then set startIndex to listLength + 1 + startIndex | lns3.scpt |
if startIndex = 0 or startIndex > listLength then | lns3.scpt |
_support's throwInvalidParameterIndex(a reference to item startIndex of (get listObject's _list_), "item") | lns3.scpt |
set endIndex to startIndex | lns3.scpt |
set endIndex to listLength | lns3.scpt |
if endIndex < 0 then set endIndex to listLength + 1 + endIndex | lns3.scpt |
_support's throwInvalidParameterIndex(a reference to item startIndex of (get listObject's _list_), "from item") | lns3.scpt |
else if endIndex = 0 or endIndex > listLength then | lns3.scpt |
_support's throwInvalidParameterIndex(a reference to item endIndex of (get listObject's _list_), "to item") | lns3.scpt |
if startIndex > endIndex then return listObject's _list_'s items | lns3.scpt |
if startIndex = 1 then | lns3.scpt |
if startIndex = listLength or endIndex = listLength then return {} | lns3.scpt |
set startList to {} | lns3.scpt |
set startList to listObject's _list_'s items 1 thru (startIndex - 1) | lns3.scpt |
if endIndex = listLength then | lns3.scpt |
set endList to {} | lns3.scpt |
set endList to listObject's _list_'s items (endIndex + 1) thru -1 | lns3.scpt |
return startList & endList | lns3.scpt |
_error("delete from list", eText, eNumber, eFrom, eTo) | lns3.scpt |
end delete from list | lns3.scpt |
to remove duplicates from list theList | lns3.scpt |
property _list_ : _support's asListParameter(theList, "")'s items | lns3.scpt |
set {i, u, listLength} to {2, 1, listObject's _list_'s length} | lns3.scpt |
if listLength = 0 then return {} | lns3.scpt |
repeat until i > listLength | lns3.scpt |
repeat while {listObject's _list_'s item i} is in listObject's _list_'s items 1 thru u | lns3.scpt |
if i > listLength then return listObject's _list_'s items 1 thru u | lns3.scpt |
set u to u + 1 | lns3.scpt |
set listObject's _list_'s item u to listObject's _list_'s item i | lns3.scpt |
return listObject's _list_'s items 1 thru u | lns3.scpt |
_error("remove duplicates from list", eText, eNumber, eFrom, eTo) | lns3.scpt |
end remove duplicates from list | lns3.scpt |
to slice list theList from item startIndex : (missing value) to item endIndex : (missing value) | lns3.scpt |
set theList to _support's asListParameter(theList, "") | lns3.scpt |
set theLength to theList's length | lns3.scpt |
set startIndex to _support's asIntegerParameter(startIndex, "from item") | lns3.scpt |
if startIndex = 0 then _support's throwInvalidParameterIndex(startIndex, "from item") | lns3.scpt |
return theList's items | lns3.scpt |
return theList's items startIndex thru -1 | lns3.scpt |
error "Expected ‘from item’ and/or ‘to item’ parameter but received neither." number -1701 | lns3.scpt |
set endIndex to _support's asIntegerParameter(endIndex, "to item") | lns3.scpt |
if endIndex = 0 then _support's throwInvalidParameterIndex(endIndex, "to item") | lns3.scpt |
return theList's items 1 thru endIndex | lns3.scpt |
or startIndex > theLength and endIndex > theLength then return {} | lns3.scpt |
return items startIndex thru endIndex of theList | lns3.scpt |
_error("slice list", eText, eNumber, eFrom, eTo) | lns3.scpt |
end slice list | lns3.scpt |
to transpose list theList by unevenOption : (rejecting uneven lists) padding with padValue : (missing value) | lns3.scpt |
if theList is {} then return {} | lns3.scpt |
if (count {theList} each list) = 0 or (count theList each list) ≠ (count theList) then | lns3.scpt |
_support's throwInvalidParameter(theList, "", list, "Not a list of lists.") | lns3.scpt |
property _list_ : theList | lns3.scpt |
property _resultList_ : {} | lns3.scpt |
set resultListLength to length of listObject's _list_'s item 1 | lns3.scpt |
if unevenOption is rejecting uneven lists then | lns3.scpt |
if aRef's length ≠ resultListLength then _support's throwInvalidParameter(theList, "", list, "Sublists are not all same length.") | lns3.scpt |
else if unevenOption is padding uneven lists then | lns3.scpt |
if aRef's length > resultListLength then set resultListLength to aRef's length | lns3.scpt |
else if unevenOption is trimming uneven lists then | lns3.scpt |
if aRef's length < resultListLength then set resultListLength to aRef's length | lns3.scpt |
_support's throwInvalidConstantParameter(unevenOption, "by") | lns3.scpt |
if resultListLength > 0 then | lns3.scpt |
set resultSubListLength to length of listObject's _list_ | lns3.scpt |
set resultSubList to _makeListObject(resultSubListLength, padValue) | lns3.scpt |
set end of listObject's _resultList_ to resultSubList | lns3.scpt |
repeat with i from 2 to resultListLength | lns3.scpt |
set end of listObject's _resultList_ to (get resultSubList's items) -- shallow copy | lns3.scpt |
if unevenOption is padding uneven lists then | lns3.scpt |
repeat with i from 1 to resultSubListLength | lns3.scpt |
repeat with j from 1 to length of listObject's _list_'s item i | lns3.scpt |
set item i of item j of listObject's _resultList_ to item j of item i of listObject's _list_ | lns3.scpt |
repeat with j from 1 to resultListLength | lns3.scpt |
return listObject's _resultList_ | lns3.scpt |
_error("transpose list", eText, eNumber, eFrom, eTo) | lns3.scpt |
end transpose list | lns3.scpt |
to unsort list theList | lns3.scpt |
script resultListObject | lns3.scpt |
property _list_ : items of _support's asListParameter(theList, "") | lns3.scpt |
set len to length of resultListObject's _list_ | lns3.scpt |
repeat with idx1 from 1 to len | lns3.scpt |
set idx2 to random number from 1 to len | lns3.scpt |
set {resultListObject's _list_'s item idx1, resultListObject's _list_'s item idx2} to {get resultListObject's _list_'s item idx2, get resultListObject's _list_'s item idx1} | lns3.scpt |
return resultListObject's _list_ | lns3.scpt |
_error("unsort list", eText, eNumber, eFrom, eTo) | lns3.scpt |
end unsort list | lns3.scpt |
to find in list theList value theItem : (missing value) using filterObject : (missing value) returning findingOccurrences : (all occurrences) | lns3.scpt |
property _result_ : {} | lns3.scpt |
if findingOccurrences is all occurrences then | lns3.scpt |
if filterObject is missing value then | lns3.scpt |
repeat with i from 1 to length of listObject's _list_ | lns3.scpt |
if item i of listObject's _list_ is theItem then | lns3.scpt |
set end of listObject's _result_ to i | lns3.scpt |
set filterObject to _support's asScriptParameter(filterObject, "using") | lns3.scpt |
if filterObject's filterItem(item i of listObject's _list_) then | lns3.scpt |
else if findingOccurrences is first occurrence then | lns3.scpt |
else if findingOccurrences is last occurrence then | lns3.scpt |
repeat with i from length of listObject's _list_ to 1 by -1 | lns3.scpt |
_support's throwInvalidConstantParameter(findingOccurrences, "returning") | lns3.scpt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.