OpenMath Content Dictionary: list3
Canonical URL:
http://www.openmath.org/cd/list3.ocd
CD Base:
http://www.openmath.org/cd
CD File:
list3.ocd
CD as XML Encoded OpenMath:
list3.omcd
Defines:
difference , entry , length , list_of_lengthn , select
Date:
2004-11-02
Version:
3
(Revision 1)
Review Date:
2004-11-01
Status:
experimental
Several standard operations on lists, such as length and append, are given in
this CD.
Initiated by Arjeh M. Cohen 2004-03-02
Role:
application
Description:
This symbol represents a function whose argument should be a list.
It returns the length of
its argument.
Example:
The length of the list [1,2,3] is 3.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
<OMA><OMS cd="relation1" name="eq"/>
<OMA><OMS cd="list3" name="length"/>
<OMA><OMS cd="list1" name="list"/>
<OMI> 1 </OMI>
<OMI> 2 </OMI>
<OMI> 3 </OMI>
</OMA>
</OMA>
<OMI> 3 </OMI>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="relation1">eq</csymbol>
<apply><csymbol cd="list3">length</csymbol>
<apply><csymbol cd="list1">list</csymbol>
<cn type="integer">1</cn>
<cn type="integer">2</cn>
<cn type="integer">3</cn>
</apply>
</apply>
<cn type="integer">3</cn>
</apply>
</math>
Prefix
Popcorn
list3.length([1 , 2 , 3]) = 3
Rendered Presentation MathML
length
(
(
1
,
2
,
3
)
)
=
3
Signatures:
sts
Description:
This symbol represents a function with two arguments,
the first of which is a natural number and the second of which is a list.
The first argument is the length of the list.
Example:
A list L of length 3:
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
<OMA><OMS cd="list3" name="list_of_lengthn"/>
<OMI> 3 </OMI>
<OMA><OMS cd="list1" name="list"/>
<OMV name="L"/>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="list3">list_of_lengthn</csymbol>
<cn type="integer">3</cn>
<apply><csymbol cd="list1">list</csymbol><ci>L</ci></apply>
</apply>
</math>
Prefix
Popcorn
list3.list_of_lengthn(3, [$L])
Rendered Presentation MathML
list_of_lengthn
(
3
,
(
L
)
)
Signatures:
sts
Description:
This symbol represents a binary function whose first argument should be a list
L and whose second argument should be a positive integer i such that
the absolute value of i is in the interval [1..n], where n is the length of L.
If i is positive, it returns the i-th entry L[i] of L, if i is negative it
returns
the (n+1-i)-th entry of L.
Example:
The second entry of the list [1,2,3] is 2.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
<OMA><OMS cd="relation1" name="eq"/>
<OMA><OMS cd="list3" name="entry"/>
<OMA><OMS cd="list1" name="list"/>
<OMI> 1 </OMI>
<OMI> 2 </OMI>
<OMI> 3 </OMI>
</OMA>
<OMI> 2 </OMI>
</OMA>
<OMI> 2 </OMI>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="relation1">eq</csymbol>
<apply><csymbol cd="list3">entry</csymbol>
<apply><csymbol cd="list1">list</csymbol>
<cn type="integer">1</cn>
<cn type="integer">2</cn>
<cn type="integer">3</cn>
</apply>
<cn type="integer">2</cn>
</apply>
<cn type="integer">2</cn>
</apply>
</math>
Prefix
Popcorn
list3.entry([1 , 2 , 3], 2) = 2
Rendered Presentation MathML
entry
(
(
1
,
2
,
3
)
,
2
)
=
2
Example:
Specification of the second element of the list [1,..,6]
counted from the end.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
<OMA><OMS cd="relation1" name="eq"/>
<OMA><OMS cd="list3" name="entry"/>
<OMA><OMS cd="list1" name="list"/>
<OMI> 1 </OMI> <OMI> 2 </OMI> <OMI> 3 </OMI>
<OMI> 4 </OMI> <OMI> 5 </OMI> <OMI> 6 </OMI>
</OMA>
<OMI>-2</OMI>
</OMA>
<OMI>5</OMI>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="relation1">eq</csymbol>
<apply><csymbol cd="list3">entry</csymbol>
<apply><csymbol cd="list1">list</csymbol>
<cn type="integer">1</cn>
<cn type="integer">2</cn>
<cn type="integer">3</cn>
<cn type="integer">4</cn>
<cn type="integer">5</cn>
<cn type="integer">6</cn>
</apply>
<cn type="integer">-2</cn>
</apply>
<cn type="integer">5</cn>
</apply>
</math>
Prefix
Popcorn
list3.entry([1 , 2 , 3 , 4 , 5 , 6], -2) = 5
Rendered Presentation MathML
entry
(
(
1
,
2
,
3
,
4
,
5
,
6
)
,
-2
)
=
5
Signatures:
sts
Description:
This symbol takes two arguments both a list. It represents a function which returns a list made up of all
the elements of the first list which are not in the second.
Example:
Specification of the list [1,..,6], apart from the first 3 elements.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
<OMA><OMS cd="relation1" name="eq"/>
<OMA><OMS cd="list3" name="difference"/>
<OMA><OMS cd="list1" name="list"/>
<OMI> 1 </OMI> <OMI> 2 </OMI> <OMI> 3 </OMI>
<OMI> 4 </OMI> <OMI> 5 </OMI> <OMI> 6 </OMI>
</OMA>
<OMA><OMS cd="list1" name="list"/>
<OMI> 1 </OMI> <OMI> 2 </OMI> <OMI> 3 </OMI>
</OMA>
</OMA>
<OMA><OMS cd="list1" name="list"/>
<OMI> 4 </OMI> <OMI> 5 </OMI> <OMI> 6 </OMI>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="relation1">eq</csymbol>
<apply><csymbol cd="list3">difference</csymbol>
<apply><csymbol cd="list1">list</csymbol>
<cn type="integer">1</cn>
<cn type="integer">2</cn>
<cn type="integer">3</cn>
<cn type="integer">4</cn>
<cn type="integer">5</cn>
<cn type="integer">6</cn>
</apply>
<apply><csymbol cd="list1">list</csymbol>
<cn type="integer">1</cn>
<cn type="integer">2</cn>
<cn type="integer">3</cn>
</apply>
</apply>
<apply><csymbol cd="list1">list</csymbol>
<cn type="integer">4</cn>
<cn type="integer">5</cn>
<cn type="integer">6</cn>
</apply>
</apply>
</math>
Prefix
eq
(
difference
(
list
( 1 , 2 , 3 , 4 , 5 , 6 )
,
list
( 1 , 2 , 3 )
)
,
list
( 4 , 5 , 6 )
)
Popcorn
list3.difference([1 , 2 , 3 , 4 , 5 , 6], [1 , 2 , 3]) = [4 , 5 , 6]
Rendered Presentation MathML
difference
(
(
1
,
2
,
3
,
4
,
5
,
6
)
,
(
1
,
2
,
3
)
)
=
(
4
,
5
,
6
)
Signatures:
sts
Description:
This symbol takes two lists as arguments, L and M say. The second argument is a
list containing only entries from [1..n], where n is the length of
L. The symbol represents the
function which returns a list whose length is equal to the length of
M, and having at position k the value of L at position M_k.
Example:
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
<OMA><OMS name="eq" cd="relation1"/>
<OMA><OMS cd="list3" name="select"/>
<OMA><OMS cd="list1" name="list"/>
<OMI> 4 </OMI> <OMI> 5 </OMI> <OMI> 6 </OMI>
<OMI> 7 </OMI> <OMI> 8 </OMI> <OMI> 9 </OMI>
</OMA>
<OMA><OMS cd="list1" name="list"/>
<OMI> 3 </OMI> <OMI> 5 </OMI>
<OMI> 2 </OMI> <OMI> 2 </OMI>
</OMA>
</OMA>
<OMA><OMS cd="list1" name="list"/>
<OMI> 6 </OMI> <OMI> 8 </OMI>
<OMI> 5 </OMI> <OMI> 5 </OMI>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="relation1">eq</csymbol>
<apply><csymbol cd="list3">select</csymbol>
<apply><csymbol cd="list1">list</csymbol>
<cn type="integer">4</cn>
<cn type="integer">5</cn>
<cn type="integer">6</cn>
<cn type="integer">7</cn>
<cn type="integer">8</cn>
<cn type="integer">9</cn>
</apply>
<apply><csymbol cd="list1">list</csymbol>
<cn type="integer">3</cn>
<cn type="integer">5</cn>
<cn type="integer">2</cn>
<cn type="integer">2</cn>
</apply>
</apply>
<apply><csymbol cd="list1">list</csymbol>
<cn type="integer">6</cn>
<cn type="integer">8</cn>
<cn type="integer">5</cn>
<cn type="integer">5</cn>
</apply>
</apply>
</math>
Prefix
eq
(
select
(
list
( 4 , 5 , 6 , 7 , 8 , 9 )
,
list
( 3 , 5 , 2 , 2 )
)
,
list
( 6 , 8 , 5 , 5 )
)
Popcorn
list3.select([4 , 5 , 6 , 7 , 8 , 9], [3 , 5 , 2 , 2]) = [6 , 8 , 5 , 5]
Rendered Presentation MathML
select
(
(
4
,
5
,
6
,
7
,
8
,
9
)
,
(
3
,
5
,
2
,
2
)
)
=
(
6
,
8
,
5
,
5
)
Signatures:
sts