Changes between Initial Version and Version 1 of Sequences


Ignore:
Timestamp:
09/10/13 13:55:40 (13 years ago)
Author:
zirkel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Sequences

    v1 v1  
     1= Sequences =
     2
     3It would be convenient for CIVL-C to have a sequence type.  This avoids the array/pointer conversions in C, allows sequences to be passed around by value, and allows for standard sequence operations.
     4
     5* `$seq<T>`
     6 * a sequence of elements of type T
     7* `int $seq_length($seq<T>)`
     8 * returns the number of elements in this sequence
     9* `$seq<T> $seq_concat($seq<T>, $seq<T>)`
     10 * returns the concatenation of two sequences
     11* `$seq<T> $seq_add($seq<T> a, T x)`
     12 * returns the result of adding the element `x` to the sequence `a`
     13* `$seq<T> $seq_remove($seq<T> a, int i)`
     14 * returns the result of removing the element at index `i` from the sequence `a`
     15* `$seq<T> $seq_subseq($seq<T> a, int start, int end)`
     16 * returns the subsequence of `a` starting at index `start` and ending at index `end`
     17* `$seq<T> $seq_write($seq<T> a, int i, T x)`
     18 * returns the sequence obtained by replacing the element of `a` at index `i` with `x`
     19* `T $seq_read($seq<T> a, int i)`
     20 * returns the element of `a` at index `i`