I'm learning Ocaml and having hard time understanding how to use first function as argument of another.
For example, I created a function bigger
# let bigger (a,b) = match (a,b) with
(a,b) -> if a > b then true else false;;
val bigger : 'a * 'a -> bool = <fun>
# bigger (2,3);;
- : bool = false
# bigger (3,2);;
- : bool = true
Now I'm struggling to use this function as an argument in function sortPair - it sorts both elements: - if bigger = true then (a,b) - if bigger = false then (b,a)
I'm sure it's a very simple solution, but I really want to understand this basic problem before moving on further.
This is what I tried:
# let sortPair (a,b) = match (a,b) with
bigger (a,b) -> if true then (a,b) else (b,a);;