🎲 R HARUSPEX DIFFICULTY: Adept Creational

The Prototype: Cloning the Prophecy

Duplicating arcane statistical objects without re-initializing them.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Divination // Cloning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// R PATTERN //
library(R6)

# Prototype
ProphecyDraft <- R6Class("ProphecyDraft",
  public = list(
    prediction = NULL,
    confidence = NULL,
    initialize = function(prediction, confidence) {
      self$prediction <- prediction
      self$confidence <- confidence
    },
    clone_prophecy = function() {
      # R6 environments are by reference, clone(deep=TRUE) handles nested
      self$clone(deep = TRUE)
    },
    show = function() {
      paste("Prophecy:", self$prediction, "| Confidence:", self$confidence)
    }
  )
)

Sometimes constructing a prophecy is computationally expensive. We clone an existing baseline and tweak it, saving valuable compute cycles in the astral plane.

Runic Tags: #R6 #Divination #Creational #Prototype