Data & text · BUILT-IN MODULE
collections
List, Map, Set, sorting, mapping, and filtering helpers.
Quick start
use collections
nums = [3, 1, 3, 2]
say collections.sort nums
say collections.unique nums
say collections.first numsAPI reference
collections.reverse valuesReverse a collection.
反轉集合。
collections.contains values valueCheck membership.
檢查成員是否存在。
collections.first valuesReturn the first value.
回傳第一個值。
collections.last valuesReturn the last value.
回傳最後一個值。
collections.unique valuesRemove duplicate values.
移除重複值。
collections.sort valuesSort values.
排序值。
collections.keys mapReturn Map keys.
回傳 Map 的 keys。
collections.values mapReturn Map values.
回傳 Map 的 values。
collections.filter list predicateReturn values for which predicate is true.
回傳 values for which predicate is true.
collections.map list functionTransform every value into a new List.
Transform every value into a new List.
collections.reduce list initial functionReduce a List into one value.
歸約 a List into one value.
collections.slice list start endReturn a List slice.
回傳 a List slice.
collections.take list countTake the first count values.
Take the first count values.
collections.drop list countDrop the first count values.
Drop the first count values.
collections.sort_by list fieldSort by a field/key.
排序 by a field/key.
collections.sort_by_desc list fieldSort descending by field/key.
排序 descending by field/key.
collections.sort_with list comparatorSort using a comparator function.
排序 using a comparator function.