Created
December 10, 2017 08:26
-
-
Save christlc/30237941afa727867d6dea4789ec9132 to your computer and use it in GitHub Desktop.
Token cache closure
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
tokens_pool <- function(tokens){ | |
current_count <- 1 | |
list(get_next_token = function(){ | |
current_count <<- current_count +1 | |
if(current_count>length(tokens)){ | |
current_count <<- 1 | |
} | |
return(tokens[[current_count]]) | |
}, | |
get_current_token = function(){ | |
return(tokens[[current_count]]) | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment