3 ms·
I wanted to implement the sleep sort algorithm, but I can't use VA = [4, 2, 5, 7]; for(x=0; x<VA.length; x++) { var y = VA[x]; setTimeout('cons
by y0ghur7_xxx 15y ago
I wanted to implement the sleep sort algorithm, but I can't use
VA = [4, 2, 5, 7];
for(x=0; x<VA.length; x++) {
var y = VA[x];
setTimeout('console.log(' + y + ')', y*1000);
}
it tells me I can't use "var". And when I remove that I get some syntax error.
Any nice alternative way to implement a sleep sort in coffescript?
- rlivsey 15y agoThis is the coffeescript equivalent, not sure how to get it working in the visualisation though as it doesn't involve swaps. VA = [4, 2, 5, 7] for y in VA setTimeout('console.log(' + y + ')', y*1000)
- tkahn6 15y agoTry this: VA = [4, 2, 5, 7] for y in VA setTimeout "console.log(#{y})", y*1000