bugfixes to mapslices: work for dims = Integer and don't evaluate f twice

This patch fixes multiple failures that occur if you do `mapslices(f, A, dim)` where `dim` is a single `Integer` rather than an array.

It also fixes a problem in which the function `f` was being evaluated twice for the first slice, which is problematic if `f` has side effects (besides being suboptimal).