A toy package designed to showcase and serve as a reference/tutorial for S7 development. To be used in conjunction with the S7 package webs
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Removed unnecessary external generics

+1 -5
+1 -5
R/big_num.R
··· 118 118 parent = linked_list, 119 119 package = "BigNum", 120 120 constructor = function(num = "") { 121 + if (!is.character(num)) warning("Use strings to make big_nums.", call. = FALSE) 121 122 new_object(linked_list(num)) 122 123 } 123 124 ) ··· 166 167 append_to_start(node(x), ll) 167 168 } 168 169 169 - print <- new_external_generic("base", "print", "x") 170 170 method(print, linked_list) <- function(x) { 171 171 current <- x@head 172 172 while (S7_inherits(current)) { ··· 199 199 invisible(x) 200 200 } 201 201 202 - `+` <- new_external_generic("base", "+", c("e1", "e2")) 203 202 add_helper <- function(node1, node2, carry, sum) { 204 203 digit <- node1@VALUE + node2@VALUE + carry 205 204 carry <- digit %/% 10 ··· 279 278 invisible(bn) 280 279 } 281 280 282 - `*` <- new_external_generic("base", "*", c("e1", "e2")) 283 281 method(`*`, list(big_num, big_num)) <- function(e1, e2) { 284 282 product <- big_num(0) 285 283 node2 <- e2@head ··· 307 305 big_num(e1) * e2 308 306 } 309 307 310 - `^` <- new_external_generic("base", "^", c("e1", "e2")) 311 308 method(`^`, list(big_num, class_numeric)) <- function(e1, e2) { 312 309 if (e2 == 0) { 313 310 return(big_num(1)) ··· 324 321 } 325 322 } 326 323 327 - `==` <- new_external_generic("base", "==", c("e1", "e2")) 328 324 method(`==`, list(linked_list, linked_list)) <- function(e1, e2) { 329 325 len <- e1@length 330 326 if (len != e2@length) {