Created
August 5, 2012 06:35
-
-
Save dinopetrone/3262368 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 fb = { | |
fbArr:['','','Fizz','','Buzz','Fizz','','','Fizz','Buzz','','Fizz','','','FizzBuzz'], | |
next:function(){ | |
var first_slot = this.fbArr.shift(); | |
this.fbArr.push(first_slot); | |
console.log(first_slot); | |
} | |
} | |
fb.next(); | |
while(true){ | |
fb.next(); | |
} |
theladyjaye
commented
Aug 5, 2012
Very clever use of shift and push.
Executing it the same way, take a look at python's:
collections.deque module.
Still doesn't satisfy all requirements. This only returns an infinite loop. How do you select a single iteration? i.e. what is 30?
Which one? The JS or the Haskell?
Which one? JS or Haskell?
:: mobile emails ::
…On Aug 5, 2012, at 11:30, Daniel Smith ***@***.*** wrote:
Still doesn't satisfy all requirements. This only returns an infinite loop. How do you select a single iteration? i.e. what is 30?
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/3262368
let r = take 30 fizzbuzz
^ first 30 results
last r
^ the last result in r
last (take 30 fizzbuzz)
the JS one
Simplified POC. Same functionality as Dino's with no numbers as well.
<?php
$fb = array('','','Fizz','','Buzz','Fizz','','','Fizz','Buzz','','Fizz','','','FizzBuzz');
$i = (int) null;
$i++;
while (true) {
print(sprintf('%d: %s', $i, current($fb))."\n");
if(next($fb) === false){
reset($fb);
}
$i++;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment