declare
fun {Abs X}
case {Int.is X} of
true andthen X<0 then ~X
[]true then X
[]false andthen X<0.0 then ~X
[]false then X
end
end
Wednesday, January 28, 2009
Ch3, Ex1
Its wrong because there is no implicit type casting(that implicitly converts a float to int) in oz and given program will only work for integers. Correct Abs should check whether the input is an int or float and then do the appropriate check.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment