This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Your code here. | |
| function every(array,predicate){ | |
| for(var i = 0; i<array.length; i++){ | |
| if (!predicate(array[i])) | |
| return false; | |
| } | |
| return true; | |
| } | |
| function some(array,predicate){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Your code here. | |
| function Vector(x,y){ | |
| this.x=x; | |
| this.y=y; | |
| }; | |
| Vector.prototype.plus = function(vector){ | |
| return new Vector(this.x+vector.x, this.y+vector.y) | |
| } | |
| Vector.prototype.minus = function(vector){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Your code here. | |
| function StretchCell(inner, width, height){ | |
| this.inner = inner; | |
| this.width = width; | |
| this.height = height; | |
| }; | |
| StretchCell.prototype.minWidth = function(){ | |
| return Math.max(this.width, this.inner.minWidth()); | |
| } | |
| StretchCell.prototype.minHeight = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function logFive(sequence) { | |
| for (var i = 0; i < 5; i++) { | |
| if (!sequence.next()) | |
| break; | |
| console.log(sequence.current()); | |
| } | |
| } | |
| function ArraySeq(array) { | |
| this.pos = -1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function MultiplicatorUnitFailure() {} | |
| function primitiveMultiply(a, b) { | |
| if (Math.random() < 0.5) | |
| return a * b; | |
| else | |
| throw new MultiplicatorUnitFailure(); | |
| } | |
| function reliableMultiply(a, b) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function withBoxUnlocked(body) { | |
| var closed = box.locked; | |
| if (!closed) return body(); | |
| box.unlock(); | |
| try{ | |
| return body(); | |
| } finally{ | |
| box.lock(); | |
| } |
OlderNewer