Skip to content

Commit

Permalink
Don't use flip, instead just cap one of the vector(slice)s.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfl committed May 20, 2012
1 parent 721887d commit 6c12e2e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions AmrPut.sml
Expand Up @@ -4,16 +4,16 @@ struct
structure V = Vector
structure VS = VectorSlice

fun flip f (x, y) = f (y, x)

val i2s = Int.toString

fun zipWith opr v1 v2 =
let val (x, y, f) = if VS.length v2 < VS.length v1 then (v2, v1, flip opr)
else (v1, v2, opr)
in VS.full(VS.mapi (fn (i,a) => f(a, VS.sub(y, i))) x)
let val (x, y) = if VS.length v2 < VS.length v1
then (VS.subslice(v1, 0, SOME(VS.length v2)), v2)
else (v1, v2)
in VS.full(VS.mapi (fn (i,a) => opr(a, VS.sub(y, i))) x)
end


(* Pointwise manipulation of vectors-slices and scalars *)
infix ^*^ ^+^ -^ *^

Expand Down

0 comments on commit 6c12e2e

Please sign in to comment.