[Question]
  [
Given a nonempty list of nonempty rows of numbers, compute the *column wise sum*, which is another list that has the length of the longest input row. The first entry of the output list is the sum of all the first entires of the input rows, the second one is the sum of all the second elements (if available) etc. I think following example will explain it way better:
```
Input:      {[1,2,3,4],[1],[5,2,3],[6,1]}
Computation: [1,2,3,4]
              + . . .
             [1]. . .
              + + + .
             [5,2,3].
              + + . .
             [6,1]. .
              = = = =
    Output: [13,5,6,4]
```
### Test Cases
```
{[0]}                         -> 0
{[1],[1,1,1,1]}               -> [2,1,1,1]
{[1],[1,2],[1,2,3],[1,2,3,4]} -> [4,6,6,4]
{[1,6,2,-6],[-1,2,3,5]}       -> [0,8,5,-1]
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 1 byte
```
S
```
[Try it online!](https://tio.run/nexus/jelly#@x/8////6GjDWJ1oQx0jCKljDKN1TGJjAQ "Jelly – TIO Nexus") or [verify all test cases](https://tio.run/nexus/jelly#@x/8/@HuLWGH2x81rXH//z862iA2lis62jBWJ9pQBwyR@EYQUscYRuuYQGR1zIA8XTOgsC5E3DQ2FgA "Jelly – TIO Nexus").
### How it works
The sum atom `S` is a shorthand for `+/`, which performs reduction by addition.
The quick `/` reduces along the outmost dimension, so it calls its link for the elements of the input. Here, the elements are the rows.
The addition atom `+` vectorizes, so adding two row vectors perform element-by-element addition. When the arguments have different lengths, the elements of the longer argument that have no counterpart in the shorter one are left unaltered.
All in all, with an irregular matrix as argument, `S` computes the column-wise sum, skipping missing entries in the shorter rows.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~47~~ 45 bytes
```
lambda x:map(lambda*y:sum(filter(None,y)),*x)
```
*Thanks to @vaultah for golfing off 2 bytes!*
[Try it online!](https://tio.run/nexus/python2#TYnRCoIwGIWv6ynOzXCTf5CZEkI9Qi@wdmHkQHBTNoP59EuyIA6cw/cdgwvuaWjt49kiNrad@Ab50oSX5aYf5s7z2@g6WoSgPIpkRo@I3oErddCaoFShSRX0yb84bk3lb@n0valeUdarl9tRaS2a/W7yvZuRMVmeA@QVLGRg4JFgeBQivQE "Python 2 – TIO Nexus")
[Answer]
# [Perl 6](http://perl6.org/), 23 bytes
```
{roundrobin(|$_)».sum}
```
[Answer]
# Mathematica, 15 bytes
```
Total@*PadRight
```
[Answer]
# Haskell, 34 bytes
```
import Data.List
map sum.transpose
```
[Try it online!](https://tio.run/nexus/haskell#@5@ZW5BfVKLgkliSqOeTWVzClZuYmadgq1BQWhJcUqSgp1CckV8OpHITCxSKS3P1SooS84oL8otTFVQUoqMNdYx0jHVMYnWiDYHYFMQD0mY6hrGx//8DAA "Haskell – TIO Nexus") Usage:
```
Prelude Data.List> map sum.transpose $ [[1,2,3,4],[1],[5,2,3],[6,1]]
[13,5,6,4]
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~7~~ 5 bytes
*2 bytes off thanks to Dennis!*
```
{:.+}
```
This defines an anonymous block that takes a list of lists, such as `[[1 2 3 4] [1] [5 2 3] [6 1]]`, and replaces it by a list, `[13 5 6 4]`.
[Try it online!](https://tio.run/nexus/cjam#y6n7X22lp137v67gf3S0oYKRgrGCSaxCtCEQm4J4QNpMwTA2FgA) Or [verify all test cases](https://tio.run/nexus/cjam#y6n7X22lp137X7Xgf7SCQnS0QWwsiDKMVYg2VABDZAEjCKlgDKMVTKDSCmZArq4ZUFwXImEKkogFAA).
### Explanation
```
{   }   e# Define block
 :      e# Fold over the following dyadic function
  .+    e# Vectorized addition
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 3 bytes
```
oXs
```
(*MATL doesn't know that the plural of "ox" is "oxen"...*)
Input is a cell array of numeric row vectors, in the same format as in the challenge text:
```
{[1,2,3,4],[1],[5,2,3],[6,1]}
```
[Try it online!](https://tio.run/nexus/matl#@58fUfz/f3W0oY6RjrGOSaxOtCEQm4J4QNpMxzC2FgA "MATL – TIO Nexus") Or [verify all test cases](https://tio.run/nexus/matl#S/ifH1H83yXkf3W0QWwtV3W0YaxOtKEOGCLxjSCkjjGM1jGByOqYAXm6ZkBhXYi4aWwtAA).
```
     % Implicit input
o    % Convert cell array to a matrix, right-padding with zeros each row
Xs   % Sum of each column
     % Implicit display
```
[Answer]
## JavaScript (ES6), ~~51~~ 48 bytes
*Saved 3 bytes, thanks to ETHproductions*
```
a=>a.map(b=>b.map((v,i)=>r[i]=~~r[i]+v),r=[])&&r
```
### Test cases
```
let f =
a=>a.map(b=>b.map((v,i)=>r[i]=~~r[i]+v),r=[])&&r
console.log(f([[1,2,3,4],[1],[5,2,3],[6,1]])); // -> [13,5,6,4]
console.log(f([[0]]));                         // -> [0]
console.log(f([[1],[1,1,1,1]]));               // -> [2,1,1,1]
console.log(f([[1],[1,2],[1,2,3],[1,2,3,4]])); // -> [4,6,6,4]
console.log(f([[1,6,2,-6],[-1,2,3,5]]));       // -> [0,8,5,-1]
```
[Answer]
# [Wonder](https://github.com/wonderlang/wonder), 11 bytes
```
@->#sum '#0
```
Transpose and map with sum function. Usage:
```
(@->#sum '#0)[[1 2 3 4];[1];[5 2 3];[6 1]]
```
[Answer]
# C++14, 130 bytes
As unnamed generic lambda:
```
[](auto C,auto&r){r.clear();int i=0,b=1;while(b--){r.push_back(0);for(auto c:C)r.back()+=i<c.size()?c[b=1,i]:0;++i;}r.pop_back();}
```
Requires `C` to be like `vector<vector<int>>` and return value `r` to be like `vector<int>` (should be okay according to [meta](https://codegolf.meta.stackexchange.com/a/4942/53667)).
Ungolfed & usage:
```
#include<vector>
#include<iostream>
auto f=
[](auto C, auto&r){
 r.clear();         //clearing r just to be sure
 int i=0,b=1;       //i is the position in the row, b is a boolean
 while(b--){        //while something was added
  r.push_back(0);   //add zero
  for(auto c:C)     //for each container
   r.back() += i<c.size() ?   //add to the last element 
    c[b=1,i] : 0;             //set b and get the element or zero 
  ++i;              
 }
 r.pop_back();      //remove last unnecessary zero
}
;
using namespace std;
int main(){
 vector<vector<int> > C = { {1,2,3,4}, {1}, {5,2,3}, {6,1} };
 vector<int> r; 
 f(C,r);
 for (int i: r)
  cout << i << ", ";
 cout << endl;
}
```
[Answer]
# Pyth - 4 bytes
```
sM.T
```
[Try it online here](http://pyth.herokuapp.com/?code=sM.T&input=%5B1%2C2%2C3%2C4%5D%2C%5B1%5D%2C%5B5%2C2%2C3%5D%2C%5B6%2C1%5D&debug=0).
[Answer]
# Haskell, ~~61 41~~ 40 bytes
Thanks @Laikoni for -20 bytes, @nimi for -1 byte!
```
f[]=[]
f l=sum[h|h:_<-l]:f[t:u|_:t:u<-l]
```
**Explanation:** It is just a recursive summation of the first elements of the list, also dealing with discarding empty lists in every intermediate step:
```
    sum[h|h:_<-l]                    -- sums up all the first elemetns of the list
                    [t:u|_:t:u<-l]   -- removes the first element of all the list, and removes empty lists
                   f                 -- applies f to the remaining list
                 :                   -- prepends the sum to the rest
```
[Answer]
# J, 5 bytes
```
+/@:>
```
Takes input as a boxed list of lists.
## Test cases
```
   1 ; 1 1 1 1
+-+-------+
|1|1 1 1 1|
+-+-------+
   (+/@:>) 1 ; 1 1 1 1
2 1 1 1
   1 ; 1 2 ; 1 2 3 ; 1 2 3 4
+-+---+-----+-------+
|1|1 2|1 2 3|1 2 3 4|
+-+---+-----+-------+
   (+/@:>) 1 ; 1 2 ; 1 2 3 ; 1 2 3 4
4 6 6 4
```
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 3 [bytes](http://meta.codegolf.stackexchange.com/a/9429/43319)
```
+⌿↑
```
`+⌿` sum column-wise
`↑` the mixed (list of list, stacked into matrix, padding with zeros) argument
[TryAPL online!](http://tryapl.org/?a=f%u2190+%u233F%u2191%20%u22C4%20f%281%202%203%204%29%281%29%285%202%203%29%286%201%29&run)
[Answer]
# [R](https://www.r-project.org), ~~53~~ ~~52~~ 51 bytes
```
\(x){for(i in x)F=F+i*!seq(!i)-1:max(lengths(x));F}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGiNNulpSVpuhY3jWM0KjSr0_KLNDIVMvMUKjTdbN20M7UUi1MLNRQzNXUNrXITKzRyUvPSSzKKgUo1rd1qoVrL0zRyMotLNAw0NbmgTEOdZCAGQ01kUUMrIyA2BmIThDBIqZmOkY6umSZQm64hkGmsY4qsz8pEB2SiKUgGpMYMbCzE-gULIDQA)
Thanks to Giuseppe for a byte saved.
[Answer]
# Octave, 69 bytes
```
@(a){g=1:max(s=cellfun(@numel,a))<=s';f=g'+0;f(g')=[a{:}];sum(f')}{4}
```
[Answer]
# Japt, 5 bytes
```
Uz mx
```
[Test it online!](http://ethproductions.github.io/japt/?v=master&code=VXogbXg=&input=W1sxLDIsMyw0XSxbMV0sWzUsMiwzXSxbNiwxXV0=)
`U` is the input array, and `z` on arrays rotates the array clockwise by 90 degrees. Therefore,
```
[
 [1,2,3,4],
 [1      ],
 [5,2,3  ],
 [6,1    ]
]
```
becomes
```
[
 [6,5,1,1],
 [1,2,  2],
 [  3,  3],
 [      4]
]
```
(Spacing added only for display purposes.)
`mx` then `m`aps by summation (`x`), which gives the desired result: `[13,5,6,4]`.
[Answer]
# [Uiua](https://uiua.org), 4 [bytes](https://codegolf.stackexchange.com/a/265917/97916)
```
⬚0/+
```
[Try it!](https://uiua.org/pad?src=ZiDihpAg4qyaMC8rCgpmIHtbMSAyIDMgNF0gWzFdIFs1IDIgM10gWzYgMV19Cg==)
```
⬚0/+
  /+  # sum columns
⬚0    # filling needed nonexistent elements with zero
```
[Answer]
# [R](https://www.r-project.org), 52 bytes
```
\(x)colSums(t(sapply(x,\(v)v[1:max(lengths(x))])),T)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGiNNulpSVpuhY3TWI0KjST83OCS3OLNUo0ihMLCnIqNSp0YjTKNMuiDa1yEys0clLz0ksyioEKNWM1NXVCNKF6y9M0cjKLSzQMNDW5oExDnWQgBkNNZFFDKyMgNgZiE4QwSKmZjpGOrpkmUJuuIZBprGOKrM_KRAdkoilIBqTGDGwsxPoFCyA0AA)
Only one byte longer than [Kirill L.'s answer](https://codegolf.stackexchange.com/a/266570/55372), so I thought it's worth posting as well.
[Answer]
## Pyke, 4 bytes
```
.,ms
```
[Try it here!](http://pyke.catbus.co.uk/?code=.%2Cms&input=%5B%5B1%2C2%2C3%2C4%5D%2C%5B1%5D%2C%5B5%2C2%2C3%5D%2C%5B6%2C1%5D%5D)
[Answer]
# Java 8, 124 bytes
this is a lambda expression for a `Function< int[ ][ ], int[ ] >`
```
i->{int L=0,t,r[];for(int[]a:i)L=(t=a.length)>L?t:L;r=new int[L];for(;0>L--;)for(int[]a:i)r[L]+=a.length>L?a[L]:0;return r;}
```
it takes the largest array length from the input, creates a new array of that size, and then writes the sums of each column to the array.
[Answer]
## R, ~~105~~ 97 bytes
```
a=c();l=length;for(i in 1:l(w)){length(w[[i]])=max(sapply(w,l));a=rbind(a,w[[i]])};colSums(a,n=T)
```
This takes in input a `list` object called `w` in the form :
```
w=list(c(1,2,3,4),c(1),c(1,2))
```
It outputs the column-wise sum : `[1] 3 4 3 4`
This solution is quite long to me. **R** has the particularity to recycle when you try to bind vectors of different length. For example :
```
a=c(1,2,3,4)
b=c(1,2)
cbind(a,b)
     a b
[1,] 1 1
[2,] 2 2
[3,] 3 1
[4,] 4 2
```
`b` is re-used once to fit, which is why I begin with a list.
The program adjusts the length of all the elements of the list as the one of the longest, binds the elements and computs the column-wise sum.
The length adjusting produces `NA`'s, that are ignored by the `sum`.
*-8 bytes* thanks to @Jarko Dubbeldam !
[Answer]
**Clojure, 70 bytes**
```
#(for[i(range(apply max(map count %)))](apply +(for[v %](get v i 0))))
```
A basic nested loop.
[Answer]
# PHP, 63 bytes
```
<?foreach($_GETas$a)foreach($a as$i=>$x)$r[$i]+=$x;print_r($r);
```
call in browser with GET parameters as list of inputs.
Example:  
`script.php?a[]=1&a[]=2&a[]=3&a[]=4&b[]=1&c[]=5&c[]=2&c[]=3&d[]=6&d[]=1`  
(Array names are ignored, so you can name them any way you want.)
Try this function for testing:
```
function s($a){foreach($a as$b)foreach($b as$i=>$x)$r[$i]+=$x;return$r;}
```
or use `http_build_query($array,a)` to convert a given array of arrays to GET parameters.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 bytes
```
mΣT0
```
[Try it online!](https://tio.run/##yygtzv7/P/fc4hCD////R0cb6hjpGOuYxOpEGwKxKYgHpM10DGNjAQ "Husk – Try It Online")
## Explanation
```
mΣT0
  T0 Transpose matrix, padding with 0's where needed
mΣ   map each column to its sum
```
[Answer]
# [Scala](http://www.scala-lang.org/), 64 bytes
Golfed version. [Try it online!](https://tio.run/##lVDBaoQwEL37FXM0MLrqqhRBocdCSw@7PS1SUjddLDGKicVW/HabjXXbg7DtJAwzk8mb90YWlNOpfnljhYIHWgoYLAveKYei5l0ldl0FCdj3pVQH4@6EynNIM7hkBFKYeJoN3K1oY/dp1rsNPe5rey48u7L8ZETHPXqEuKqlQja1ZMtrV5FxAjiyV6g0A5u2J5nAbdvSj8NOtaU45SSBJ1EqPWmwQNtmA3smFRRUMmkqje5TXNgX2obz7HwMcIshQZjTJYjO9SWJ0SfaztCPnWo6lXx3bxEihBghJFcneasQ3vWPF04@mrOKEyD48/0XYPAr/NG7LGVtUGj0/k2yj7FGcuIF15mBo/VNINyYdTpGwmiN0xc)
```
l=>{l.map(x=>x.padTo(l.map(_.size).max,0)).transpose.map(_.sum)}
```
Ungolfed version. [Try it online!](https://tio.run/##lVFda8IwFH33V5zHBmJt/ShDcLCHPQwce9A9yRhZTbWjTUqSTsfwt7s0adUHwa0t6b2Xc8@950SnrGDHo/z45KnBM8sFfno9YM0zpLKoS7Goy6DItdFTzO1v5Y4nYd7eSFtpEsxsH@wzGOBR6FpxmC2HawSzmcxQizyTqkTBxcZsYWMYxYSupM7FhiLLiwJ6K5XhClJwjV1ucZF2xF@sQMn2c98889RhyargPfSMxGb7E7adNncbXMKbCLN7Vwkrtl7K4MRLERHS64Qs2@3OWhoZXlNgaiV065FGLoyEkjtNwMQaui7BWbptSo7tcpuwU83b9S2aWNShM7601xAwtbGWPyjFvlcLo6xDjeGvIjeXXi@5XSplmnuTKoszhQjOV9dM9EdMh3REx4TCp10waepdktCY2KehfqlNVZtpix5RTCgSijG5OSm6ShHdbjztFFP3XuUZUsT@@xfh8CI86@1MuTZo7PT@TXJME8vUTzrevieeXHeC4s7Z2Y/9vR@Ox18)
```
object Main {
  def columnSum(lists: List[List[Int]]): List[Int] = {
    // Ensure the lists are of uniform length for transposing, fill shorter ones with 0s
    val maxLength = lists.map(_.length).max
    val uniformLists = lists.map(list => list.padTo(maxLength, 0))
    // Transpose the list of lists (turns columns into rows) and sum each row
    uniformLists.transpose.map(_.sum)
  }
  def main(args: Array[String]): Unit = {
    // Test cases
    println(columnSum(List(List(1,2,3,4), List(1), List(5,2,3), List(6,1)))) // Output: List(13, 5, 6, 4)
    println(columnSum(List(List(0)))) // Output: List(0)
    println(columnSum(List(List(1), List(1,1,1,1)))) // Output: List(2, 1, 1, 1)
    println(columnSum(List(List(1), List(1,2), List(1,2,3), List(1,2,3,4)))) // Output: List(4, 6, 6, 4)
    println(columnSum(List(List(1,6,2,-6), List(-1,2,3,5)))) // Output: List(0, 8, 5, -1)
  }
}
```
]