Last active
June 20, 2018 17:41
-
-
Save jumpingrivers/a8b4c8400cb718a53a0ddb2f01c5278d to your computer and use it in GitHub Desktop.
This file contains 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
clock = function(max_laps=100) { | |
laps = numeric(max_laps) | |
laps[1] = Sys.time() | |
no_of_laps = 2 | |
reset = function() { | |
no_of_laps = 1 | |
laps <<- numeric(max_laps) | |
laps[no_of_laps] = Sys.time() | |
no_of_laps <<- 2 | |
} | |
lap = function() { | |
laps[no_of_laps] <<- Sys.time() | |
no_of_laps <<- no_of_laps + 1 | |
} | |
get_laps = function() { | |
laps[1:(no_of_laps-1)] - laps[1] | |
} | |
list(reset = reset, | |
lap = lap, | |
get_laps = get_laps) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment