1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/input algaggr.input}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{License}
<<license>>=
--Copyright The Numerical Algorithms Group Limited 1991.
@
<<*>>=
<<license>>
)clear all
-- lists are constructed explicitly by using square brackets
l := [1,4,2,-6,0,3,5,4,2,3]
-- "listify" an element by using the "list" function
m := list 555555
-- use "concat" to add an item to the front of a list
concat(5,l)
-- "concat" concatenates 2 lists
concat(m,l)
-- to remove all duplicates, issue
removeDuplicates l
-- use "first" to get the first element, and "rest" to get the
-- list of remaining elements
first l
rest l
-- "last" extracts the last element
last l
-- to find the number of elements, use "#"
#l
-- "first" and "rest" extract or remove leading or trailing
-- parts of the list
l
first(l,3)
rest(l,3)
-- individual elements may be extracted as follows
-- notice that list indexing goes from 1 to the size of the list
l.1
l.2
l.(#l)
-- individual elements may be set (destructively) in a similar manner
l.1 := 1000000000
l
-- "insert" is used to add an element to a specific position in the list
insert(10,l,4)
insert(2,l,1)
-- "position" determines the first index of an element in a list
-- if the element is not in the list, 0 is returned.
position(-6,l)
-- to reverse a list
reverse l
-- the following functions demonstrate some functions on sets
l
m := [4,2,3,6,5,7,-9,1,2,3,2]
sl:SET(INT) := brace l
sm:SET(INT) := brace m
difference(sl, sm)
intersect(sl,sm)
union(sl,sm)
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}
|