Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- divalg a b = if a < b then (0,a)
- else
- let (q,r) = divalg (a-b) b
- in (q+1,r)
- divalg a b | a < b = (0,a)
- otherwise = let (q,r) = divalg (a-b) b
- in (q+1,r)
- divalg a b | a < b = (0,a)
- | otherwise = (q+1,r) where
- (q,r) = divalg (a-b) b
- -- Function trace (example)
- divalg 14 6 = if 14 < 6 then (0,14) else let(q,r) = divalg 8 6 in (q+1,r) -- False, so do the else statement
- = let (q,r) = divalg 8 6 in (q+1,r) -- This is the else statement
- = let (q,r) = if 8 < 6 then (0,8) else let (q,r) = divalg 2 6 in (q+1,r) -- False again, do the else statement...
- = let (q,r) = let(q,r) = divalg 2 6 in (q+1,r) -- Else statement here :trololo:
- = let (q,r) = let(q,r) = if 2 < 6 then 0,2) else let (q,r) = divalg (-4) 6 in (q+1+r) in (q+1+r) -- Condition met, do the true statement now
- = let (q,r) = let(q,r) = (0,2) in (q+1,r) in (q+1,r) -- We got the info! Let's pass it back.
- = let (q,r) = (1,2) in (q+1,r) -- Passing it back,
- = (2,2) -- Done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement