Re: [Rd] List comprehensions for R

2007-12-15 Thread David C. Norris
Gabor, Thank you for drawing this previous work to my attention. I've attached below code that extends the list comprehension to include logical 'guard' expressions, as in > leap.years <- .[ x ~ x <- 1900:2100 | (x %% 400 == 0 || x %% 100 != 0 && x %% 4 == 0) ] > leap.years [1] 1904 1908 1

[Rd] List comprehensions for R

2007-12-09 Thread David C. Norris
Below is code that introduces a list comprehension syntax into R, allowing expressions like: > .[ sin(x) ~ x <- (0:11)/11 ] [1] 0. 0.09078392 0.18081808 0.26935891 0.35567516 0.43905397 [7] 0.51880673 0.59427479 0.66483486 0.72990422 0.78894546 0.84147098 > .[ .[x*y ~ x <- 0:3] ~ y <-