This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun hd xs = | |
case xs of | |
[] => raise List.empty | |
| x::_ => x | |
exception MyUndesirableCondition | |
exception MyOtherException of int * int | |
fun mydiv (x,y) = | |
if y=0 | |
then raise MyUndesirableCondition | |
else x div y | |
fun maxlist (xs,ex) = | |
case xs of | |
[] => raise ex | |
| x::[] => x | |
| x::xs' => Int.max(x, maxlist(xs',ex)) | |
(* val y = maxlist ([], MyUndesirableCondition) *) | |
val z = maxlist([], MyUndesirableCondition) handle MyUndesirableCondition => 42 |
No comments:
Post a Comment