aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2013-05-13 11:03:30 +0000
committerdos-reis <gdr@axiomatics.org>2013-05-13 11:03:30 +0000
commit67f8ca75d03aad7f041d8650ddca4d4cd0b71371 (patch)
treea9a394463fbfdaec39687dfde20b3eb09883e16a /src
parent79e0bdea715eea9bbbe308777a1a7a8b1d8c72f4 (diff)
downloadopen-axiom-67f8ca75d03aad7f041d8650ddca4d4cd0b71371.tar.gz
* algebra/array1.spad.pamphlet (IndexedOneDimensionalArray): Tidy.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/algebra/array1.spad.pamphlet45
2 files changed, 9 insertions, 40 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 02579bae..9e2f0283 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
2013-05-13 Gabriel Dos Reis <gdr@integrable-solutions.net>
+ * algebra/array1.spad.pamphlet (IndexedOneDimensionalArray): Tidy.
+
+2013-05-13 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
* interp/g-opt.boot (%array2list): New side-effect free opcode.
* interp/lisp-backend.boot: Expand it.
* algebra/array1.spad.pamphlet (PrimitiveArray): Implement
diff --git a/src/algebra/array1.spad.pamphlet b/src/algebra/array1.spad.pamphlet
index ee4b913b..b941d84e 100644
--- a/src/algebra/array1.spad.pamphlet
+++ b/src/algebra/array1.spad.pamphlet
@@ -364,9 +364,7 @@ FlexibleArray(S: Type) == Implementation where
++ This is the basic one dimensional array data type.
IndexedOneDimensionalArray(S:Type, mn:Integer):
- OneDimensionalArrayAggregate S == add
- macro Qmax == maxIndexOfSimpleArray$Foreign(Builtin)
- macro Qsetelt == setSimpleArrayEntry$Foreign(Builtin)
+ OneDimensionalArrayAggregate S == PrimitiveArray S add
macro I == Integer
import %icst0: I from Foreign Builtin
@@ -375,44 +373,11 @@ IndexedOneDimensionalArray(S:Type, mn:Integer):
import %vlength: % -> NonNegativeInteger from Foreign Builtin
import %aref: (%,Integer) -> S from Foreign Builtin
- Rep == PrimitiveArray S
-
- newArray(n: Integer): % ==
- makeSimpleArray(getVMType(S)$Foreign(Builtin),n)$Foreign(Builtin)
-
- #x == # rep x
- copy x == per copy rep x
- fill!(x, s) == per fill!(rep x, s)
minIndex x == mn
- empty() == per empty()$Rep
- new(n, s) == per new(n,s)$Rep
- construct l == per construct(l)$Rep
-
- map!(f, s1) ==
- n: Integer := Qmax(s1)
- negative? n => s1
- for i in %icst0..n repeat Qsetelt(s1,i,f %aref(s1,i))
- s1
-
- map(f, s1) ==
- n:Integer := Qmax(s1)
- negative? n => s1
- ss2:% := newArray(n+1)
- for i in %icst0..n repeat Qsetelt(ss2,i,f %aref(s1,i))
- ss2
-
- map(f, a, b) ==
- maxind:Integer := min(Qmax a, Qmax b)
- negative? maxind => empty()
- c:% := newArray(maxind + %icst1)
- for i in %icst0..maxind repeat
- Qsetelt(c,i,f(%aref(a,i),%aref(b,i)))
- c
-
if zero? mn then
qelt(x, i) == %aref(x, i)
- qsetelt!(x, i, s) == Qsetelt(x, i, s)
+ qsetelt!(x, i, s) == %store(%aref(x, i), s)$Foreign(Builtin)
elt(x:%, i:I) ==
negative? i or i > maxIndex(x) => error "index out of range"
@@ -425,7 +390,7 @@ IndexedOneDimensionalArray(S:Type, mn:Integer):
else if one? mn then
maxIndex x == %vlength x
qelt(x, i) == %aref(x, i - %icst1)
- qsetelt!(x, i, s) == Qsetelt(x, i - %icst1, s)
+ qsetelt!(x, i, s) == %store(%aref(x, i - %icst1), s)$Foreign(Builtin)
elt(x:%, i:I) ==
%ilt(i,%icst1) or %ilt(%vlength x,i) =>
@@ -435,11 +400,11 @@ IndexedOneDimensionalArray(S:Type, mn:Integer):
setelt(x:%, i:I, s:S) ==
%ilt(i,%icst1) or %ilt(%vlength x,i) =>
error "index out of range"
- Qsetelt(x, i - %icst1, s)
+ qsetelt!(x,i,s)
else
qelt(x, i) == %aref(x, i - mn)
- qsetelt!(x, i, s) == Qsetelt(x, i - mn, s)
+ qsetelt!(x, i, s) == %store(%aref(x, i - mn), s)$Foreign(Builtin)
elt(x:%, i:I) ==
i < mn or i > maxIndex(x) => error "index out of range"