Created
November 27, 2011 16:36
-
-
Save owskio/1397775 to your computer and use it in GitHub Desktop.
FunctionalEuler
This file contains 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
#!/sw/bin/js | |
function euler(firstPoint) { | |
print("Curr is:" + firstPoint) | |
function inner(passedPoint) { | |
var prevAsOuter = passedPoint | |
return function(currInner) { | |
print("\nPrev was:" + prevAsOuter) | |
print("Curr is:" + currInner) | |
//Rewrite the fn yet again so prev will be stored 4 next time | |
euler = inner(currInner); | |
} | |
} | |
//Rewrite the fn so that initial conditions are not repeated again | |
euler = inner(firstPoint) | |
} | |
//Test Suite | |
euler(1); //Output --> "Curr is:1" | |
euler(2); //Output --> "Prev was:1" | |
// "Curr is:2" | |
euler(3); //Output --> "Prev was:2" | |
// "Curr is:3" | |
euler(4); //Output --> "Prev was:3" | |
// "Curr is:4" | |
euler(5); //Output --> "Prev was:4" | |
// "Curr is:5" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you wanted to make a nice curve between a series of points on an svg canvas, you could do a piece-wise continuous regression based upon the last 2 or 3 datums, instead of storing them all and doing a regression on all the points at the end.