1[[bbv2.reference.modules.sequence]] 2= sequence 3 4Various useful list functions. Note that algorithms in this module 5execute largely in the caller's module namespace, so that local rules 6can be used as function objects. Also note that most predicates can be 7multi-element lists. In that case, all but the first element are 8prepended to the first argument which is passed to the rule named by the 9first element. 10 111. `rule filter ( predicate + : sequence * )` 12+ 13Return the elements `e` of `$(sequence)` for which `[ $(predicate) e ]` 14has a non-null value. 15 162. `rule transform ( function + : sequence * )` 17+ 18Return a new sequence consisting of `[ $(function) $(e) ]` for each 19element `e` of `$(sequence)`. 20 213. `rule reverse ( s * )` 22+ 23Returns the elements of `s` in reverse order. 24 254. `rule insertion-sort ( s * : ordered * )` 26+ 27Insertion-sort `s` using the BinaryPredicate `ordered`. 28 295. `rule merge ( s1 * : s2 * : ordered * )` 30+ 31Merge two ordered sequences using the BinaryPredicate `ordered`. 32 336. `rule join ( s * : joint ? )` 34+ 35Join the elements of `s` into one long string. If `joint` is supplied, 36it is used as a separator. 37 387. `rule length ( s * )` 39+ 40Find the length of any sequence. 41 428. `rule unique ( list * : stable ? )` 43+ 44Removes duplicates from `list`. If `stable` is passed, then the order of 45the elements will be unchanged. 46 479. `rule max-element ( elements + : ordered ? )` 48+ 49Returns the maximum number in `elements`. Uses `ordered` for comparisons 50or `numbers.less` if none is provided. 51 5210. `rule select-highest-ranked ( elements * : ranks * )` 53+ 54Returns all of `elements` for which the corresponding element in the 55parallel list `rank` is equal to the maximum value in `rank`. 56