Skip to content

Commit

Permalink
rejig rrejig
Browse files Browse the repository at this point in the history
  • Loading branch information
pearsonca committed Aug 28, 2024
1 parent 07eb9c7 commit 1263ca4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/rrejig.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@
#'
#' @export
rrejig <- function(rFUN) {
.FUN <- rFUN # make a duplicate of FUN
.FUN <- function() {}
formals(.FUN) <- c(formals(rFUN), alist(hash = ))
dispatch <- as.character(substitute(rFUN))
hashc <- str2lang("set.hash(hash, get('.hash.salt', envir = parent.frame()))")
origc <- body(rFUN)
origc <- str2lang(sprintf("%s%s%s(%s)",dispatch[2],dispatch[1],dispatch[3],toString(names(formals(rFUN)))))

Check warning on line 21 in R/rrejig.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/rrejig.R,line=21,col=42,[commas_linter] Commas should always have a space after.

Check warning on line 21 in R/rrejig.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/rrejig.R,line=21,col=54,[commas_linter] Commas should always have a space after.

Check warning on line 21 in R/rrejig.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/rrejig.R,line=21,col=66,[commas_linter] Commas should always have a space after.

Check warning on line 21 in R/rrejig.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/rrejig.R,line=21,col=78,[commas_linter] Commas should always have a space after.

Check warning on line 21 in R/rrejig.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/rrejig.R,line=21,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 109 characters.
body(.FUN) <- substitute({
hashc
origc
})
environment(.FUN) <- parent.frame()
return(.FUN)
}

#' @export
sample <- rrejig(sample)
sample <- rrejig(base::sample)

#' @export
sample.int <- rrejig(sample.int)
sample.int <- rrejig(base::sample.int)

0 comments on commit 1263ca4

Please sign in to comment.