aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <holden.rohrer@gmail.com>2019-12-27 13:50:16 -0500
committerHolden Rohrer <holden.rohrer@gmail.com>2019-12-27 13:50:21 -0500
commit639ec59f1913a903dee3bb9068108b78c193d616 (patch)
treede66716ce7013c4a7fb94f7561350aa20a618912
parent283faa1479cb0a640ab7055bced6aafea0416835 (diff)
replaced space.subsection quadruplet with coord pair
-rw-r--r--space.js12
-rw-r--r--tests/space_subsection.js2
2 files changed, 7 insertions, 7 deletions
diff --git a/space.js b/space.js
index ae0ee50..50ae16c 100644
--- a/space.js
+++ b/space.js
@@ -111,14 +111,14 @@ function Space(){ // CLASS
} if (match) break;}
return loc;
}
- this.subsection = function(range){ // range is a standard quadruplet
+
+ this.subsection = function(range){ // range is a coordinate pair
+ // Similarly excludes this.loc
newspace = new Space();
- for (let line=0; line<=range[2]-range[0]; line++){
+ for (let line=range[0][0]; line<=range[1][0]; line++){
newspace.data.push([]);
- for (let chr=0; chr<=range[3]-range[1]; chr++){
- newspace.data[line].push(
- this.data[line+range[0]][chr+range[1]] || ''
- );
+ for (let chr=range[0][1]; chr<=range[1][1]; chr++){
+ newspace.data[line-range[0][0]].push(this.data[line][chr] || '');
}
}
return newspace;
diff --git a/tests/space_subsection.js b/tests/space_subsection.js
index b30b7e1..216b404 100644
--- a/tests/space_subsection.js
+++ b/tests/space_subsection.js
@@ -7,4 +7,4 @@ line\n\
\n\
long long long line\
');
-console.log(newspace.subsection([1,1,2,10]));
+console.log(newspace.subsection([[1,1],[2,10]]));