Open juangomezduaso opened 5 years ago
An interesting (but perhaps too weird) alternative to these functions would be to have an S3 class of "virtual rrays", consisting of just the function and probaby the dimensionality , but not any concrete dimension. These "vrrays" would operate between themselves (virtually, to yield another vrray having , for example , (A+B)$fun = function(v) A$fun(v) +B$fun(v). And would operate with (a)rrays instantiating a compatible rray with the functions above (with broadcasting included) and yielding a rray as the result. Other functions like reshape, transpose, etc would also be easy to define, returning modified virtual rrays . OTOH, subseting would return a "real" rray. Functions like rray_yank(), rray_sum() etc would have no sense in these "infinite rrays" . Not the case of dim(x) which could, obviously, return: rep(Inf, rray_dims(x) ) ;)
I think it could be useful to generate rrays from a function over its indexes. To illustrate and brainstorm this idea I have made some alternatives for you to taste it.
Created on 2019-06-12 by the reprex package (v0.2.1)