Lazy evaluation

Input: 100
Output: 100 101 102 103 104 105 ...

Any help will be highly appreciated
Thanks

Please familiarise yourself with the forums FAQ: Homework Policy

That said, I believe its as simple as this.

make_inf_list_from <- function(startnum,indexnum){
 function(indexnum) {
   startnum+indexnum - 1
 }
}

list_from_3 <- make_inf_list_from(3,1) 

list_from_3(1)
list_from_3(2)

library(purrr)
(map_dbl(1:6,
    list_from_3))

list_from_100 <- make_inf_list_from(100,1) 

list_from_100(1)
list_from_100(2)

(map_dbl(1:6,
         list_from_100))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.