-
Notifications
You must be signed in to change notification settings - Fork 0
New List Functions
These functions extend from the current List object/class from greyscript.
The following are a list of new functions that can be utilized.
Will return the largest value in the list.
print([1, 3, 8, 5, 1, 5, 0].max)
-- 8Will return the smallest value in the list.
print([1, 3, 8, 5, 1, 5, 0].min)
-- 0Will return the index of the largest value in the list.
print([1, 3, 8, 5, 1, 5, 0].maxIndex)
-- 2Will return the index of the smallest value in the list.
print([1, 3, 8, 5, 1, 5, 0].minIndex)
-- 6Will return true if the list contains the item provided, false if otherwise.
print([1, 3, 8, 5, 1, 5, 0].hasItem(8))
-- 1(true)Will delete the first instance of the given item from list and will also return said list.
newlist = [1, 2, 2, 1, 3]
newlist.delete(1)
print(newlist)
-- [2, 2, 1, 3]
print([1, 2, 2, 1, 3].delete(1))
-- [2, 2, 1, 3]Will delete the all instances of the given item from list and will also return said list.
newlist = [1, 2, 2, 1, 3]
newlist.deleteAll(1)
print(newlist)
-- [2, 2, 3]
print([1, 2, 2, 1, 3].deleteAll(1))
-- [2, 2, 3]Will delete all duplicates from list and will also return said list.
newlist = [1, 2, 2, 1, 3]
newlist.set
print(newlist)
-- [1, 2, 3]
print([1, 2, 2, 1, 3].set)
-- [1, 2, 3]Will return how many times the given item appears in said list.
print([1, 2, 2, 1, 3].count(2))
-- 2Will return the mean (average) of the said list.
print([1, 3, 8, 5, 1, 5, 0].mean)
-- 3.28571...Will return the smallest value in the list.
print([1, 3, 8, 5, 1, 5, 0].median)
-- 3Will return the most common value in the list.
print([1, 3, 8, 5, 1, 5, 0].mode)
-- 1Will return true if all values in said list are true.
print([true, true, false].all)
-- 0(false)Will return true if at least one values in said list are true.
print([true, true, false].any)
-- 1(true)Will apply the given function func onto all items in the given list.
print([1.32, 124.234, 423.3, 32.24545].applyFunction(@floor))
-- [1, 124, 423, 32]