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.

Assorted minor changes

+8 -12
+1 -1
DESCRIPTION
··· 2 2 Title: An S7 Showcase 3 3 Version: 0.0.0.9000 4 4 Authors@R: 5 - person("Visruth", "Srimath Kandali", , "visruth@gmail.com", role = c("aut", "cre"), 5 + person("Visruth", "Srimath Kandali", , "public@visruth.com", role = c("aut", "cre"), 6 6 comment = c(ORCID = "0009-0005-9097-0688")) 7 7 Description: A toy package designed to showcase and serve as a 8 8 reference/tutorial for S7 development. To be used in conjunction with
+2 -2
R/big_num.R
··· 50 50 getter = function(self) self@state$head, 51 51 setter = function(self, value) { 52 52 # TODO: kick up to error? 53 - warning("@head should not be set manually. Maybe you meant to use `append_to_start()`?", call. = FALSE) 53 + warning("@head should not be set manually. Did you mean to use `append_to_start()`?", call. = FALSE) 54 54 55 55 my_env <- self@state 56 56 my_env$head <- value ··· 125 125 is_even <- new_generic("is_even", c("x")) 126 126 method(is_even, big_num) <- function(x) x@head@VALUE %% 2 == 0 127 127 128 - # TODO: rewrite to be external generic? 128 + # TODO: rewrite to be external generic? `base::append()` 129 129 bn_append <- new_generic("bn_append", c("x", "ll")) 130 130 method(bn_append, list(node, linked_list)) <- function(x, ll) { 131 131 suppressWarnings({
+1 -5
R/big_num_S4.R
··· 34 34 stop("Can't set read-only property VALUE ") 35 35 }) 36 36 37 - setClass("big_num_linked_list_s4", 38 - slots = c( 39 - state = "environment" 40 - ) 41 - ) 37 + setClass("big_num_linked_list_s4", slots = c(state = "environment")) 42 38 43 39 linked_list_s4 <- function(num = NULL) { 44 40 force(num)
+3 -3
README.md
··· 276 276 277 277 I wrote the S7 implementation first, and have since expanded to a S3 and S4 implementation (and might add a rough R6 one too?). These three versions (S3, S4, S7) have rough feature parity, but part of this project is to highlight the benefits of S7 so there are things you can't do (or at least, can't do as easily) in the other OOP structures. 278 278 279 - So why BigNum specifically? Well, mostly because it's easy to implement. The BigNum project is taken from my CSC 203 class, a OOP course at Cal Poly. I already had all the methods implemented (in Java) and a clear idea of what I needed to do and how, with the main work being in porting design to R as opposed to novel thought. This greatly simplified dev time since I had a reference implementation to use. **Importantly,** **this (along with my lack of experience) could lead to unidiomatic R/S7 code and design patterns.** **If you notice anything strange, please open an issue/PR!** 279 + So why BigNum specifically? Well, mostly because it's easy to implement. The BigNum project is taken from my CSC 203 class, an OOP course at Cal Poly. I already had all the methods implemented (in Java) and a clear idea of what I needed to do and how, with the main work being in porting design to R as opposed to novel thought. This greatly simplified dev time since I had a reference implementation to use. **Importantly,** **this (along with my lack of experience) could lead to unidiomatic R/S7 code and design patterns.** **If you notice anything strange, please open an issue/PR!** 280 280 281 - I haven't developed an R package before, and so that provided additional motivation for me to create this project. That also means that this package is certainly written sub-optimally. Additionally, my experience with S7 is extremely limited–I would be extremely grateful for any and all R sourcerers who can rain issues and pull requests down from the heavens fixing all my mistakes :) 281 + I haven't developed an R package before, and so that provided additional motivation for me to create this project. That also means that this package is certainly written sub-optimally. Additionally, my experience with S7 is extremely limited--I would be extremely grateful for any and all R sourcerers who can rain issues and pull requests down from the heavens fixing all my mistakes :) 282 282 283 283 ## Acknowledgements 284 284 285 - Thank you Dr T and Dr Bodwin for helping with this project! 285 + Thank you Dr Theobold and Dr Bodwin for helping with this project! 286 286 287 287 ## References 288 288
+1 -1
tests/testthat/test-big_num.R
··· 1 1 rmpfr_test_multiplication <- function(string_num_1, string_num_2) { 2 - # using Rmpfr to check big_num's accuracy 2 + # using Rmpfr to verify big_num's accuracy 3 3 num <- Rmpfr::mpfr(string_num_1, 200) * Rmpfr::mpfr(string_num_2, 200) 4 4 string_num_solution <- as(num, "character") 5 5