github.com/nevalang/neva@v0.23.1-0.20240507185603-7696a9bb8dda/std/builtin/collections.neva (about) 1 component { 2 // Len returns the length of the given sequence: list, map, or string: 3 // for lists it returns number of elements, 4 // for maps it returns number of keys, 5 // for for strings it returns number of utf-8 characters. 6 #extern(list list_len, map map_len) 7 pub Len<T list<any> | map<any> | string>(data T) (res int) 8 9 // List receives stream and sends list with all elements from the stream. 10 #extern(stream_to_list) 11 pub List<T>(seq stream<T>) (res list<T>) 12 13 // Index returns the element at the given index in the ordered collection. 14 // If the index is out of bounds, it returns an error. 15 // The index is zero-based. 16 #extern(index) 17 pub Index<T list<any> | string>(data T, idx int) (res T, err error) 18 19 // Push creates new list with appended element. 20 #extern(list_push) 21 pub Push<T> (lst list<T>, data T) (res list<T>) 22 23 // Sort creates sorted version of the given list. 24 #extern(int int_sort, float float_sort, string string_sort) 25 pub Sort<T int | float | string>(data list<T>) (res T) 26 27 #extern(slice) 28 pub Slice<T string | list<any>>(data T, from int, to int) (res T, err error) 29 30 #extern(list_to_stream) 31 pub Iter<T>(data list<T>) (seq stream<T>) 32 }