next up previous contents index
Next: Simple Sequence Manipulation Up: Sequence Functions Previous: Scans and Reduces

Sequence Reordering Functions

values -> indices {([a], [int]) tex2html_wrap_inline10157 [a] :: (a in any)}
  Given a sequence of values on the left and a sequence of indices on the right, which can be of different lengths, -> returns a sequence which is the same length as the indices sequence and the same type as the values sequence. For each position in the indices sequence, it reads the value at that index of the values sequence. For example:

4pt

tabular7794

permute(v, i) {([a], [int]) tex2html_wrap_inline10183 [a] :: (a in any)}
  Given a sequence v and a sequence of indices i, which must be of the same length, permute permutes the values to the given indices. The permutation must be one-to-one.

d <- ivpairs {([a], [(int, a)]) tex2html_wrap_inline10185 [a] :: (a in any)}
  This operator, called write, is used to write multiple elements into a sequence. Its left argument is the sequence to write into (the destination sequence) and its right argument is a sequence of integer-value pairs. For each element (i,v) in the sequence of integer-value pairs, the value v is written into position i of the destination sequence.

rotate(a, i) {([a], int) tex2html_wrap_inline10187 [a] :: (a in any)}
  Given a sequence and an integer, rotate rotates the sequence around by i positions to the right. If the integer is negative, then the sequence is rotated to the left. For example:

4pt

tabular7814

reverse(a) {[a] tex2html_wrap_inline10221 [a] :: (a in any)}
  Reverses the order of the elements in a sequence.



Jonathan Hardwick
Tue Nov 28 13:57:00 EST 1995