tabulators

Stephen Weeks MLton@sourcelight.com
Thu, 24 Jan 2002 13:04:58 -0800


> I don't think so; there is no Vector.rev in the basis library, so you'll
> end up needing to do a fold over the vector into a list and then
> Vector.fromList that.  (It's a different story with access to
> MLton.Vector.unfoldi.)

fun rev (v: 'a vector): 'a vector =
   let
      open Vector
      val n = length v
   in
      tabulate (n, fn i => sub (v, n - 1 - i))
   end