Assuming this is homework, I don't want to say too much. ->
in a type expression represents a function. 'a -> 'a -> ('a * 'a)
has two arrows, so 2 might be the answer for your first question, though I find that particular question obscure. An argument could be made that each fun
defines exactly one function, which might happen to return a function for its output. Also, you ask "how many functions are present in the expression ... " but then give a string which literally has 0 functions in it (type descriptions describe functions but don't contain functions), so maybe the answer is 0.
If you want a natural example of int -> int -> int * int
, you could implement the functiondivmod
where divmod x y
returns a tuple consisting of the quotient and remainder upon dividing x
by y
. For example, you would want divmod 17 5
to return (3,2)
. This is a built-in function in Python but not in SML, but is easily defined in SML using the built-in operators div
and mod
. The resulting function would have a type of the form 'a -> 'a -> 'a*'a
-- but for a specific type (namely int
). You would have to do something which is a bit less natural (such as what you did in your answer to your question) to come up with a polymorphic example.