Skip to content

Instantly share code, notes, and snippets.

View jmbarbone's full-sized avatar

Jordan Mark Barbone jmbarbone

View GitHub Profile
@jmbarbone
jmbarbone / global-calling-handlers.R
Created October 1, 2025 01:06
R environment/class for handling handlers
global_calling_handlers <- local({
. <- environment()
class(.) <- c("cnd:global_calling_handlers", "environment")
.handlers <- NULL
handlers <- NULL
add <- function(...) {
"Adds calling handlers
If handlers with the same name already exist, they are replaced.
@jmbarbone
jmbarbone / iterators.md
Created October 2, 2025 05:55
just some iterations in R
enumerate <- function(x, i = "i", v = "v") {
  lapply(
    seq_along(x),
    function(iteration) {
      structure(
        list(iteration, x[[iteration]]),
        class = c("enumeration", "list"),
        names = c(i, v)
      )
@jmbarbone
jmbarbone / another-version.md
Last active October 18, 2025 23:31
typed functions in R
arg <- function(sym, type, default) {
  sym <- substitute(sym)
  spec <- structure(
    list(
      sym = as.character(sym),
      type = type
    ),
    class = "arg"
  )
@jmbarbone
jmbarbone / fibonocci.md
Created October 9, 2025 04:20
'fib'-o-nocci; or
.fibs <- new.env()

.fib <- function(n) {
  name <- as.character(n)
  get0(name, envir = .fibs) %||% assign(name, fibonocci(n), envir = .fibs)
}

fibonocci <- function(n = 0) {
 n &lt;- floor(n)