XML technologies / MathML / Content markup / Constructor elements / Sets and lists

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

Sets and lists are represented using the set and list elements, respectively. Sets and lists are both used to represent a collection of elements that can be numbers, identifiers, or expressions. However, lists differ from sets in two important respects:

You can specify the elements of a set either by explicitly listing the elements or by using the bvar and condition elements to define a condition that elements of the set must satisfy. Here is an example of a set in which the elements are listed explicitly:

{0, 1, 2, 3}

<set>
  <cn>0</cn>
  <cn>1</cn>
  <cn>2</cn>
  <cn>3</cn>
</set> 

Here is an example of the same set defined using a condition:

Sets and lists: equation 2

<set>
  <bvar><ci>x</ci></bvar>
  <condition>
    <apply>
      <and/>
      <apply>
        <lt/>
        <ci>x</ci>
        <cn>4</cn>
      </apply>
      <apply>
        <in/>
        <ci>x</ci>
        <naturalnumbers/>
      </apply>
    </apply>
  </condition>
  <ci>x</ci>
</set>

As with sets, you can describe lists either by explicitly listing their elements or by using a condition. Here is an example of a list in which the elements are listed explicitly:

[0, 1, 2, 3]

<list>
  <cn>0</cn>
  <cn>1</cn>
  <cn>2</cn>
  <cn>3</cn>
</list>

Here is an example of the same list defined using a condition:

Sets and lists: equation 4

<list order="numeric">
  <bvar><ci> x </ci></bvar>
  <condition>
    <apply>
      <lt/>
      <ci>x</ci>
      <cn>5</cn>
    </apply>
  </condition>
  <ci>x</ci>
</list>

You specify the ordering of the list elements by using the order attribute. This can take two values: numeric (which orders the elements in increasing numeric order) and lexicographic (which corresponds to an alphabetic ordering).

   

 

 

 

 

back to top