/usr/share/axiom-20170501/src/algebra/PMLSAGG.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 | )abbrev package PMLSAGG PatternMatchListAggregate
++ Author: Manuel Bronstein
++ Date Created: 4 Dec 1989
++ Date Last Updated: 29 Jun 1990
++ Description:
++ This package provides pattern matching functions on lists.
PatternMatchListAggregate(S, R, L) : SIG == CODE where
S : SetCategory
R : PatternMatchable S
L : ListAggregate R
PLR ==> PatternMatchListResult(S, R, L)
SIG ==> with
patternMatch : (L, Pattern S, PLR) -> PLR
++ patternMatch(l, pat, res) matches the pattern pat to the
++ list l; res contains the variables of pat which
++ are already matched and their matches.
CODE ==> add
match: (L, List Pattern S, PLR, Boolean) -> PLR
patternMatch(l, p, r) ==
(u := isList p) case "failed" => failed()
match(l, u::List Pattern S, r, true)
match(l, lp, r, new?) ==
empty? lp =>
empty? l => r
failed()
multiple?(p0 := first lp) =>
empty? rest lp =>
if not new? then l := reverse_! l
makeResult(atoms r, addMatchRestricted(p0,l,lists r,empty()))
new? => match(reverse l, reverse lp, r, false)
error "Only one multiple pattern allowed in list"
empty? l => failed()
failed?(r := makeResult(patternMatch(first l,p0,atoms r),lists r))
=> failed()
match(rest l, rest lp, r, new?)
|