Hacker News new | past | comments | ask | show | jobs | submit login

K handles the general case:

    1 1 1 + 2 2 2
  3 3 3
  
    (1 1 1; 2 2 2; 3 3 3) + (4 4 4; 5 5 5; 6 6 6)
  (5 5 5
   7 7 7
   9 9 9)



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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: