Skip to content

Commit

Permalink
refactor: use modulo
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Feb 24, 2025
1 parent 48b44af commit 37aa592
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/mock2-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ mock_output_sequence <- function(values, recycle = FALSE) {
i = "You can set {.arg recycle} to {.code TRUE}."
))
}
value <- rep_len(values, length.out = i)[[i]]
remainder <- i %% length(values)
if (remainder == 0) {
index <- length(values)
} else {
index <- remainder
}
value <- rep_len(values, length.out = index)[[index]]
i <<- i + 1
value
}
Expand Down

0 comments on commit 37aa592

Please sign in to comment.