Skip to content

Instantly share code, notes, and snippets.

@Quby
Created April 3, 2011 17:43
Show Gist options
  • Save Quby/900605 to your computer and use it in GitHub Desktop.
Save Quby/900605 to your computer and use it in GitHub Desktop.
function Sequence(init,n,iter){
return {
take:function(x){
var list=init.slice(0);
while(x>list.length){
list.push(iter.apply(null,(n!=Infinity?list.slice(list.length-n):list).concat(list.length)));
}
return list
},
read:function(x){
return this.take(x).pop();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment