-
-
Save soswow/7c0793a79f18bdf3fe41 to your computer and use it in GitHub Desktop.
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
f = (n) -> | |
if n is 0 | |
0 | |
else if n is 1 | |
1 | |
else | |
f(n-1) + f(n-2) | |
process.on 'message', (input) -> | |
output = f(input) | |
process.send output | |
module.exports = f |
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
fork = require('child_process').fork | |
fibCp = fork(__dirname + '/fib') | |
fibCp.on 'message', (result) -> | |
console.log result | |
$ -> | |
$('#fib-start').click -> | |
fibCp.send 45 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment