1d and 2d are different.  This is short enough that I thought abstracting it would make things less clear, hence the two functions.