Skip to content

Commit

Permalink
evaluate measure lazily for deep
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Sep 8, 2015
1 parent 6df0e18 commit fecaaa8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
10 changes: 9 additions & 1 deletion js/dist/fingertree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
this.left = left;
this.middle = middle;
this.right = right;
this.v = M.plus(this.left.measure(M), M.plus(this.middle.measure(), this.right.measure(M)));
this.v = null;
}

/* js/src/3-tree/2-api */
Expand All @@ -1113,6 +1113,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
_createClass(Deep, [{
key: 'measure',
value: function measure() {

if (this.v === null) {

var M = this.M;

this.v = M.plus(this.left.measure(M), M.plus(this.middle.measure(), this.right.measure(M)));
}

return this.v;
}
}, {
Expand Down
Loading

0 comments on commit fecaaa8

Please sign in to comment.