Array module
This module contains functions for manipulating and inspecting arrays. All of the functions will work on arrays of any type.
It is automatically imported (via the Prelude module) unless
the -noprelude compiler option is used. Almost all programs
and modules will need to import this module.
Exceptions
- OutOfBounds - Attempt to access an out-of-bounds element.
- ZeroStep - The step in a range may not be zero
Functions
- Void addAt(var [a] array,a elem,Int idx) - Add an element to an array
- Bool all(Bool(a) pred,[a] xs) - Check if all elements satisfy a predicate
- Bool any(Bool(a) pred,[a] xs) - Check if any elements satisfy a predicate
- Void concat(var [a] xs,[a] ys) - Concatenate two arrays.
- [a] createArray(Int size) - Create an array
- Bool elem(a val,[a] list,Bool(a, a) eq=equal) - Check whether a value is in a list.
- [a] filter(Bool(a) p,[a] xs) - Filter a list according to a predicate.
- b fold(b(a, b) f,[a] xs,b acc) - Fold an array.
- [a] intersperse(a sep,[a] xs) - Place a separator between each element of an array
- [a] join([[a]] lists) - Concatentate a list of lists
- [b] map(b(a) f,[a] xs) - Map a function across an array.
- Void nub(var [a] xs,Bool(a, a) eq=equal) - Remove repeated elements from a list.
- Void pop(var [a] array) - Remove a value from the end of an array
- Void push(var [a] array,a v) - Push a value onto the end of an array.
- [Int] range(Int first,Int last,Int step=1) - Get a range of integers
- [a] remove([a] array,Int pos,Int n) - Return the array created by removing a subarray.
- Void removeAt(var [a] array,Int idx) - Remove an element from an array
- Void resize(var [a] xs,Int i) - Resize an array.
- Void reverse(var [a] xs) - Reverse an array in-place.
- a shift(var [a] array) - Get the first item off an array, and remove it from the array.
- Void shuffle(var [a] xs) - Randomly reorder an array.
- Void sort(var [a] xs,Int(a, a) sortfn=compare) - Sort an array.
- [a] sorted([a] xs,Int(a, a) sortfn=compare) - Return a sorted array.
- [a] subarray([a] array,Int pos,Int n) - Return a subarray
- Void t_addAt_allowed() -
- Void t_addAt_illegal() -
- Void t_all_empty() -
- Void t_all_int() -
- Void t_any_empty() -
- Void t_any_int() -
- Void t_concat_empty_xs() -
- Void t_concat_empty_ys() -
- Void t_concat_refs() -
- Void t_concat_simple() -
- Void t_elem_custom_false() -
- Void t_elem_custom_true() -
- Void t_elem_empty() -
- Void t_elem_first() -
- Void t_elem_last() -
- Void t_elem_missing() -
- Void t_elem_only() -
- Void t_elem_there() -
- Void t_filter_empty() -
- Void t_filter_false() -
- Void t_filter_odd() -
- Void t_filter_true() -
- Void t_fold_ab() -
- Void t_fold_empty() -
- Void t_fold_sum() -
- Void t_intersperse_empty() -
- Void t_intersperse_int() -
- Void t_intersperse_one() -
- Void t_join_empty() -
- Void t_join_int() -
- Void t_map_aa() -
- Void t_map_ba() -
- Void t_map_empty() -
- Void t_nub_empty() -
- Void t_nub_repeated() -
- Void t_nub_repeated2() -
- Void t_nub_unique() -
- Void t_pop_empty() -
- Void t_pop_val() -
- Void t_push_val() -
- Void t_range_default() -
- Void t_range_exact() -
- Void t_range_inexact() -
- Void t_range_negative() -
- Void t_removeAt_allowed() -
- Void t_removeAt_illegal() -
- Void t_remove_allowed() -
- Void t_remove_illegal() -
- Void t_reverse_empty() -
- Void t_reverse_even() -
- Void t_reverse_odd() -
- Void t_shift_empty() -
- Void t_shift_val() -
- Void t_shuffle_empty() -
- Void t_shuffle_int() -
- Void t_sort_custom() -
- Void t_sort_empty() -
- Void t_sort_normal_int() -
- Void t_sort_normal_str() -
- Void t_sorted_custom() -
- Void t_sorted_default() -
- Void t_subarray_allowed() -
- Void t_subarray_illegal() -
- Void t_take_all() -
- Void t_take_illegal() -
- Void t_take_sub() -
- Void t_top_empty() -
- Void t_top_val() -
- Void t_unshift_val() -
- Void t_zip_1() -
- Void t_zipwith_aaa() -
- Void t_zipwith_abb() -
- Void t_zipwith_abc() -
- Void t_zipwith_empty_x() -
- Void t_zipwith_empty_xy() -
- Void t_zipwith_empty_y() -
- [a] take(Int x,[a] xs) - Take the first x elements from an array.
- a top([a] array) - Return the last value in an array
- Void unshift(a val,var [a] array) - Add a value onto the start of an array.
- [Pair<a, b> ] zip([a] xs,[b] ys) - Turn a pair of lists into a list of pairs.
- [c] zipWith(c(a, b) f,[a] xs,[b] ys) - Map a function across two arrays.