aboutsummaryrefslogtreecommitdiff
path: root/src/algebra
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2013-05-09 01:34:59 +0000
committerdos-reis <gdr@axiomatics.org>2013-05-09 01:34:59 +0000
commite688a0421303fb51afe31bb4b36774011bfac76d (patch)
tree03deb19a4aedeefea11f2f257f042ae972449b86 /src/algebra
parent146c880a873a04fc433125646dd998882354f1c5 (diff)
downloadopen-axiom-e688a0421303fb51afe31bb4b36774011bfac76d.tar.gz
Simplify copy
Diffstat (limited to 'src/algebra')
-rw-r--r--src/algebra/list.spad.pamphlet17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/algebra/list.spad.pamphlet b/src/algebra/list.spad.pamphlet
index ea7960fb..9f0cc282 100644
--- a/src/algebra/list.spad.pamphlet
+++ b/src/algebra/list.spad.pamphlet
@@ -72,19 +72,18 @@ List(S:Type): Exports == Implementation where
import %tail: % -> % from Foreign Builtin
import %lreverse: % -> % from Foreign Builtin
import %lreverse!: % -> % from Foreign Builtin
+ import %lcopy: % -> % from Foreign Builtin
import %llength: % -> NonNegativeInteger from Foreign Builtin
import %icst0: NonNegativeInteger from Foreign Builtin
import %icst1: NonNegativeInteger from Foreign Builtin
import %idec: Integer -> Integer from Foreign Builtin
Qpush ==> PUSH$Lisp
- cycleMax ==> 1000 -- value used in checking for cycles
nil == %nil
null l == %peq(l,%nil)
cons(s, l) == %pair(s,l)
append(l:%, t:%) == %lconcat(l,t)
-
#x == %llength x
concat(s:S,x:%) == %pair(s,x)
eq?(x,y) == %peq(x,y)
@@ -110,11 +109,11 @@ List(S:Type): Exports == Implementation where
empty? x => error "Cannot update an empty list"
%store(%tail x,y)$Foreign(Builtin)
%tail x
- construct l == l pretend %
- parts s == s pretend List S
+ construct l == l
+ parts s == s
reverse! x == %lreverse! x
reverse x == %lreverse x
- minIndex x == 1
+ minIndex x == %icst1
rest(x, n) ==
for i in %icst1..n repeat
@@ -122,13 +121,7 @@ List(S:Type): Exports == Implementation where
x := %tail x
x
- copy x ==
- y := empty()
- for i in %icst0.. while not empty? x repeat
- if i = cycleMax and cyclic? x then error "cyclic list"
- y := %pair(%head x,y)
- x := %tail x
- %lreverse! y
+ copy x == %lcopy x
if S has CoercibleTo(OutputForm) then
coerce(x):OutputForm ==