···11-node_or_na_s4 <- function(value) is.na(value) || is(value, "big_num_node_s4")
11+node_or_na_s4 <- function(value) is(value, "big_num_node_s4") || is.na(value)
2233setClass("big_num_node_s4",
44 slots = c(
···1616 new("big_num_node_s4", VALUE = VALUE, state = rlang::new_environment(list(nxt = nxt)))
1717}
18181919-# TODO: copy this in S3 to approximate read only properties
1919+# TODO: copy this in S3 to approximate read only properties?
2020setGeneric("nxt", function(x) standardGeneric("nxt"))
2121setMethod("nxt", "big_num_node_s4", function(x) x@state$nxt)
2222···7272big_num_s4 <- function(num = "") {
7373 as(linked_list_s4(num), "big_num_s4")
7474}
7575+7676+setMethod("show", "big_num_linked_list_s4", function(object) {
7777+ current <- object@state$head
7878+ while (is(current, "big_num_node_s4")) {
7979+ cat(current@VALUE, "-> ")
8080+ current <- current@state$nxt
8181+ }
8282+ cat("NA\n")
8383+})
8484+8585+setMethod("show", "big_num_s4", function(object) {
8686+ len <- object@state$length
8787+8888+ if (len == 0) {
8989+ return(cat("NA\n"))
9090+ }
9191+9292+ stack <- character(len)
9393+ current <- object@state$head
9494+9595+ for (i in len:1) {
9696+ stack[i] <- current@VALUE
9797+ current <- current@state$nxt
9898+ }
9999+100100+ string <- paste0(stack, collapse = "")
101101+ cat(string, "\n")
102102+})
+1-3
man/big_num.Rd
···1010\item{num}{A string representation of a num.}
1111}
1212\description{
1313-BigNum exposes three S7 objects, which are all closely related,
1414-i.e. they are all tightly coupled--which isn't great OOP design
1515-but will suffice.
1313+TODO: WRITE THIS
16141715The \code{big_num} class is essentially a wrapper around \link{linked_list}
1816with a custom print method as well as some defined operators such as