HMWK3
Due: 3 Apr 2023, by end of class
Given the following signature:
signature SLORP = sig
datatype ('a,'b) slorp = zip |
zap of 'a * 'b * ('a, 'b) slorp
val sameslorp : ('a,'b) slorp * ('a,'b) slorp -> bool
val taz : ('a,'b) slorp -> ('a * 'b)
val tiz : ('a,'b) slorp -> ('a,'b) slorp
val check: (('a * 'b) -> ('a * 'b) -> bool) -> ('a,'b) slorp -> bool
val twiddle: (('a * 'b) -> ('a * 'b) -> bool) -> ('a,'b) slorp -> ('a,'b) slorp
end;
and the following specifications:
taz (zap (x,y,z)) = (x,y)
tiz (zap (x,y,z)) = z
taz (zip) = raise error
tiz (zip) = zip
check f (twiddle f l) = true
check f zip = true |
check f zap(x,y,zip) = true |
check f zap(x,y,zap(r,s,l)) = (f (x,y) (r,s)) andalso (check f zap(r,s,l))
Create a structure which implements the signature.
Think carefully about what it means for this stuff to work correctly; create test cases which correctly assess whether your code works. Actually test your code.
Hand in:
a) the code
b) your test cases (sufficient to cover each code path)