Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Vienna Development Method
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Sequences ==== The finite sequence type constructor (written <code>seq of T</code> where <code>T</code> is a predefined type) constructs the type composed of all finite lists of values drawn from the type <code>T</code>. For example, the type definition <syntaxhighlight lang="rsl"> String = seq of char </syntaxhighlight> Defines a type <code>String</code> composed of all finite strings of characters. Various operators are defined on sequences for constructing concatenation, selection of elements and subsequences etc. Many of these operators are partial in the sense that they are not defined for certain applications. For example, selecting the 5th element of a sequence that contains only three elements is undefined. The order and repetition of items in a sequence is significant, so <code>[a, b]</code> is not equal to <code>[b, a]</code>, and <code>[a]</code> is not equal to <code>[a, a]</code>. {| border="1" class="wikitable" |+ style="background:#ffdead;" |Main operators on sequences (s, s1,s2 are sequences) |- | <code>[a, b, c]</code> || Sequence enumeration: the sequence of elements <code>a</code>, <code>b</code> and <code>c</code> |- | <code><nowiki>[f(x) | x:T & P(x)]</nowiki></code> || Sequence comprehension: sequence of expressions <code>f(x)</code> for each <code>x</code> of (numeric) type <code>T</code> such that <code>P(x)</code> holds <br />(<code>x</code> values taken in numeric order) |- | <code>hd s</code> || The head (first element) of <code>s</code> |- | <code>tl s</code> || The tail (remaining sequence after head is removed) of <code>s</code> |- | <code>len s</code> || The length of <code>s</code> |- | <code>elems s</code> || The set of elements of <code>s</code> |- | <code>s(i)</code> || The <code>i</code><sup>th</sup> element of <code>s</code> |- | <code>inds s</code> || the set of indices for the sequence <code>s</code> |- | <code>s1^s2</code> || the sequence formed by concatenating sequences <code>s1</code> and <code>s2</code> |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)