Created
May 1, 2011 09:57
-
-
Save kaareal/950383 to your computer and use it in GitHub Desktop.
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
var index = 0; | |
results = [], | |
prevLen; | |
while(true) { | |
r.albums[index] && results.push(r.albums[index]); | |
r.tracks[index] && results.push(r.tracks[index]); | |
r.artists[index] && results.push(r.artists[index]); | |
if(prevLen == results.length || results.length >= 9) { | |
break; | |
} | |
prevLen = results.length; | |
index++; | |
} | |
results = results.splice(0,9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C++0x version, not completely sure about correctness, but just to show use of initializer lists, auto typing and move semantics, renamed vars for better comparison with js version, and really, save for a few parentheses and types it's the same. I'm likely the only one of us who cares about this ;)