Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Sep 8, 2015
1 parent 07f847a commit 6df0e18
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 64 deletions.
38 changes: 4 additions & 34 deletions js/dist/fingertree.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
value: function splitDigit(p, i, M) {
return new Split([], this.a, []);
}
}, {
key: 'length',
get: function get() {
return 1;
}
}]);

return One;
Expand Down Expand Up @@ -521,11 +516,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
if (p(i)) return new Split([], this.a, [this.b]);
return new Split([this.a], this.b, []);
}
}, {
key: 'length',
get: function get() {
return 2;
}
}]);

return Two;
Expand Down Expand Up @@ -618,11 +608,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
if (p(i)) return new Split([this.a], this.b, [this.c]);
return new Split([this.a, this.b], this.c, []);
}
}, {
key: 'length',
get: function get() {
return 3;
}
}]);

return Three;
Expand Down Expand Up @@ -723,11 +708,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
if (p(i)) return new Split([this.a, this.b], this.c, [this.d]);
return new Split([this.a, this.b, this.c], this.d, []);
}
}, {
key: 'length',
get: function get() {
return 4;
}
}]);

return Four;
Expand Down Expand Up @@ -801,11 +781,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
value: function cons(value) {
throw new Error("trying to call cons of Node2");
}
}, {
key: 'length',
get: function get() {
throw new Error("trying to call length of Node2");
}
}]);

return Node2;
Expand Down Expand Up @@ -891,11 +866,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
value: function cons(value) {
throw new Error("trying to call cons of Node3");
}
}, {
key: 'length',
get: function get() {
throw new Error("trying to call length of Node3");
}
}]);

return Node3;
Expand Down Expand Up @@ -1165,7 +1135,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
value: function tail() {
var _this = this;

if (this.left.length === 1) {
if (this.left instanceof One) {

if (this.middle.empty()) {
return from_iterable(this.M, this.right);
Expand All @@ -1183,7 +1153,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
value: function init() {
var _this2 = this;

if (this.right.length === 1) {
if (this.right instanceof One) {

if (this.middle.empty()) {
return from_iterable(this.M, this.left);
Expand All @@ -1200,7 +1170,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
key: 'cons',
value: function cons(value) {

if (this.left.length === 4) {
if (this.left instanceof Four) {

return new Deep(this.M, new Two(value, this.left.head()), this.middle.cons(this.left.tail().node(this.M)), this.right);
}
Expand All @@ -1211,7 +1181,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
key: 'push',
value: function push(value) {

if (this.right.length === 4) {
if (this.right instanceof Four) {

return new Deep(this.M, this.left, this.middle.push(this.right.init().node(this.M)), new Two(this.right.last(), value));
}
Expand Down
2 changes: 1 addition & 1 deletion js/dist/fingertree.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/fingertree.min.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions js/src/1-digit/1-One.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ class One {
return M.measure( this.a ) ;
}

get length ( ) {
return 1 ;
}

head ( ) {
return this.a ;
}
Expand Down
4 changes: 0 additions & 4 deletions js/src/1-digit/2-Two.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ class Two {
return M.plus( M.measure( this.a ) , M.measure( this.b ) ) ;
}

get length ( ) {
return 2 ;
}

head ( ) {
return this.a ;
}
Expand Down
4 changes: 0 additions & 4 deletions js/src/1-digit/3-Three.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class Three {
) ;
}

get length ( ) {
return 3 ;
}

head ( ) {
return this.a ;
}
Expand Down
4 changes: 0 additions & 4 deletions js/src/1-digit/4-Four.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ class Four {
) ;
}

get length ( ) {
return 4 ;
}

head ( ) {
return this.a ;
}
Expand Down
4 changes: 0 additions & 4 deletions js/src/2-node/Node2.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class Node2 {
return new Two( this.a , this.b ) ;
}

get length ( ) {
throw new Error( "trying to call length of Node2" ) ;
}

head ( ) {
throw new Error( "trying to call head of Node2" ) ;
}
Expand Down
4 changes: 0 additions & 4 deletions js/src/2-node/Node3.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class Node3 {
return new Three( this.a , this.b , this.c ) ;
}

get length ( ) {
throw new Error( "trying to call length of Node3" ) ;
}

head ( ) {
throw new Error( "trying to call head of Node3" ) ;
}
Expand Down
8 changes: 4 additions & 4 deletions js/src/3-tree/1-base/2-Deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Deep extends Tree {

tail ( ) {

if ( this.left.length === 1 ) {
if ( this.left instanceof One ) {

if ( this.middle.empty( ) ) {
return from_iterable( this.M , this.right ) ;
Expand All @@ -49,7 +49,7 @@ class Deep extends Tree {

init ( ) {

if ( this.right.length === 1 ) {
if ( this.right instanceof One ) {

if ( this.middle.empty( ) ) {
return from_iterable( this.M , this.left ) ;
Expand All @@ -65,7 +65,7 @@ class Deep extends Tree {

cons ( value ) {

if ( this.left.length === 4 ) {
if ( this.left instanceof Four ) {

return new Deep(
this.M ,
Expand All @@ -82,7 +82,7 @@ class Deep extends Tree {

push ( value ) {

if ( this.right.length === 4 ) {
if ( this.right instanceof Four ) {

return new Deep(
this.M ,
Expand Down

0 comments on commit 6df0e18

Please sign in to comment.