/usr/share/axiom-20170501/src/algebra/DBASE.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 | )abbrev domain DBASE Database
++ Author: Mark Botch
++ Description:
++ This domain implements a simple view of a database whose fields are
++ indexed by symbols
Database(S) : SIG == CODE where
S: OrderedSet with
elt : (%,Symbol) -> String
++ elt(x,s) returns an element of x indexed by s
display : % -> Void
++ display(x) displays x in some form
fullDisplay : % -> Void
++ fullDisplay(x) displays x in detail
SIG ==> SetCategory with
elt : (%,QueryEquation) -> %
++ elt(db,q) returns all elements of \axiom{db} which satisfy \axiom{q}.
elt : (%,Symbol) -> DataList String
++ elt(db,s) returns the \axiom{s} field of each element of \axiom{db}.
_+ : (%,%) -> %
++ db1+db2 returns the merge of databases db1 and db2
_- : (%,%) -> %
++ db1-db2 returns the difference of databases db1 and db2
++ consisting of elements in db1 but not in db2
coerce : List S -> %
++ coerce(l) makes a database out of a list
display : % -> Void
++ display(db) prints a summary line for each entry in \axiom{db}.
fullDisplay : % -> Void
++ fullDisplay(db) prints full details of each entry in \axiom{db}.
fullDisplay : (%,PositiveInteger,PositiveInteger) -> Void
++ fullDisplay(db,start,end ) prints full details of entries in the range
++ \axiom{start..end} in \axiom{db}.
CODE ==> List S add
s: Symbol
Rep := List S
coerce(u: List S):% == u@%
elt(data: %,s: Symbol) == [x.s for x in data] :: DataList(String)
elt(data: %,eq: QueryEquation) ==
field := variable eq
val := value eq
[x for x in data | stringMatches?(val,x.field)$Lisp]
x+y==removeDuplicates_! merge(x,y)
x-y==mergeDifference(copy(x::Rep),y::Rep)$MergeThing(S)
coerce(data): OutputForm == (#data):: OutputForm
display(data) == for x in data repeat display x
fullDisplay(data) == for x in data repeat fullDisplay x
fullDisplay(data,n,m) == for x in data for i in 1..m repeat
if i >= n then fullDisplay x
|