/usr/share/axiom-20170501/src/algebra/CLAGG.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | )abbrev category CLAGG Collection
++ Author: Michael Monagan; revised by Manuel Bronstein and Richard Jenks
++ Date Created: August 87 through August 88
++ Date Last Updated: April 1991
++ Description:
++ A collection is a homogeneous aggregate which can built from
++ list of members. The operation used to build the aggregate is
++ generically named construct. However, each collection
++ provides its own special function with the same name as the
++ data type, except with an initial lower case letter, For example,
++ list for List, flexibleArray for FlexibleArray, and so on.
Collection(S) : Category == SIG where
S : Type
SIG ==> HomogeneousAggregate(S) with
construct : List S -> %
++ \axiom{construct(x,y,...,z)} returns the collection of elements
++ \axiom{x,y,...,z} ordered as given. Equivalently written as
++ \axiom{[x,y,...,z]$D}, where
++ D is the domain. D may be omitted for those of type List.
find : (S->Boolean, %) -> Union(S, "failed")
++ \axiom{find(p,u)} returns the first x in u such that
++ \axiom{p(x)} is true, and "failed" otherwise.
if % has finiteAggregate then
reduce : ((S,S)->S,%) -> S
++reduce(f,u) reduces the binary operation f across u.
++For example, if u is \axiom{[x,y,...,z]} then \axiom{reduce(f,u)}
++returns \axiom{f(..f(f(x,y),...),z)}.
++Note that if u has one element x, \axiom{reduce(f,u)} returns x.
++Error: if u is empty.
++
++X )clear all
++X reduce(+,[C[i]*x**i for i in 1..5])
reduce : ((S,S)->S,%,S) -> S
++ reduce(f,u,x) reduces the binary operation f across u, where x is
++ the identity operation of f.
++ Same as \axiom{reduce(f,u)} if u has 2 or more elements.
++ Returns \axiom{f(x,y)} if u has one element y,
++ x if u is empty.
++ For example, \axiom{reduce(+,u,0)} returns the
++ sum of the elements of u.
remove : (S->Boolean,%) -> %
++ remove(p,u) returns a copy of u removing all elements x such that
++ \axiom{p(x)} is true.
++ Note that \axiom{remove(p,u) == [x for x in u | not p(x)]}.
select : (S->Boolean,%) -> %
++ select(p,u) returns a copy of u containing only those elements
++ such \axiom{p(x)} is true.
++ Note that \axiom{select(p,u) == [x for x in u | p(x)]}.
if S has SetCategory then
reduce : ((S,S)->S,%,S,S) -> S
++ reduce(f,u,x,z) reduces the binary operation f across u,
++ stopping when an "absorbing element" z is encountered.
++ As for \axiom{reduce(f,u,x)}, x is the identity operation of f.
++ Same as \axiom{reduce(f,u,x)} when u contains no element z.
++ Thus the third argument x is returned when u is empty.
remove : (S,%) -> %
++ remove(x,u) returns a copy of u with all
++ elements \axiom{y = x} removed.
++ Note that \axiom{remove(y,c) == [x for x in c | x ^= y]}.
removeDuplicates : % -> %
++ removeDuplicates(u) returns a copy of u with all duplicates
++ removed.
++
++X removeDuplicates [1,4,2,-6,0,3,5,4,2,3]
if S has ConvertibleTo InputForm then ConvertibleTo InputForm
add
if % has finiteAggregate then
#c == # parts c
count(f:S -> Boolean, c:%) == _+/[1 for x in parts c | f x]
any?(f, c) == _or/[f x for x in parts c]
every?(f, c) == _and/[f x for x in parts c]
find(f:S -> Boolean, c:%) == find(f, parts c)
reduce(f:(S,S)->S, x:%) == reduce(f, parts x)
reduce(f:(S,S)->S, x:%, s:S) == reduce(f, parts x, s)
remove(f:S->Boolean, x:%) ==
construct remove(f, parts x)
select(f:S->Boolean, x:%) ==
construct select(f, parts x)
if S has SetCategory then
remove(s:S, x:%) == remove(y +-> y = s, x)
reduce(f:(S,S)->S, x:%, s1:S, s2:S) == reduce(f, parts x, s1, s2)
removeDuplicates(x) == construct removeDuplicates parts x
|