Re:2 is a code smell
by kevinlawler on Wednesday October 12, 2011 @03:47PM
(#3104245)
K handles the general case:
[ Parent
| on HN ]
As does R :)
> c(1, 1, 1) + c(2, 2, 2)
[1] 3 3 3
> matrix(c(1, 1, 1, 2, 2, 2, 3, 3, 3),
+ ncol = 3, byrow = TRUE) +
+ matrix(c(4, 4, 4, 5, 5, 5, 6, 6, 6),
+ ncol = 3, byrow = TRUE)
[,1] [,2] [,3]
[1,] 5 5 5
[2,] 7 7 7
[3,] 9 9 9
Not quite so concise and elegant but it's pretty straightforward stuff for most R users.