transform method should be static, and you should implement toString methods as necessary so that it's possible to display your edit sequences as shown below (copied and pasted from the DrJava interactions pane). Note: An enumerated type is almost enough to represent the edits, but can't capture the Change and Insert operations since they need to "remember" the character associated with the operation.
> EditDistance.transform("brad", "")
[Kill]
> EditDistance.transform("recursion", "cursin")
[Delete, Delete, Copy, Copy, Copy, Copy, Copy, Delete, Copy]
> EditDistance.transform("brad", "richards")
[Delete, Copy, Insert i, Insert c, Insert h, Copy, Insert r, Copy, Insert s]
Once you're done, tell me two things you like better about the Haskell version, and two things you like better about the Java version.
Main> pairSatisfies (==) ["ab", "ba", "ba"] "ba" Main> pairSatisfies (>) [1,2,3,2,1] 3 Main> pairSatisfies (\n m -> (n*m) > 0) [-1,2,-3,-4] -3
new guess = (guess + N/guess) / 2Sample runs:
Main> take 5 (sqrtApprox 1.5 10) [1.5,4.08333,3.26616,3.16393,3.16228] Main> take 10 (sqrtApprox 1.5 25346) [1.5,8449.42,4226.21,2116.1,1064.04,543.93,295.264,190.553,161.783,159.225]
join f (n:ns) (m:ms) = (f n m) : (join f ns ms) ones = 1 : ones increasing = join (+) ones (0:increasing)