just the behavior we were hoping for. But we want to be able to use
the output of the safe-division function as input for further division
operations. So we have to jack up the types of the inputs:
<pre>
just the behavior we were hoping for. But we want to be able to use
the output of the safe-division function as input for further division
operations. So we have to jack up the types of the inputs:
<pre>
</pre>
So far so good. But what if we want to combine division with
other arithmetic operations? We need to make those other operations
</pre>
So far so good. But what if we want to combine division with
other arithmetic operations? We need to make those other operations
well chosen to resonate with linguists, but what can you do). To continue our mnemonic association, we'll put a `'` after the name "bind" as well.
<pre>
well chosen to resonate with linguists, but what can you do). To continue our mnemonic association, we'll put a `'` after the name "bind" as well.
<pre>
-let div' (x: int option) (y: int option) =
- bind' x (fun x -> bind' y (fun y -> if (0 = y) then None else Some (x / y)));;
+let div' (u: int option) (v: int option) =
+ bind' u (fun x -> bind' v (fun y -> if (0 = y) then None else Some (x / y)));;