Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 527

Composition of function pair

$
0
0

I am very new to OCaml and I am currently trying to solve some exercises. While doing so I stumbled over the following problem:

let compose_pair (p:(('b -> 'c) * ('a -> 'b))) : 'a -> 'c = 

The goal is to complete the function such that it composes the two functions of the pair in sequence.

My problem is that, as far as I understand, the return type of this function should again be a function and I don't really know how to achieve that.

My attempt would be something like

(fst p) (snd p)

which happens to just return something of type 'c if I understood this right.

Does anyone know how to solve this? i would be very thankful for some tips or hints.

My current try is this:

let compose_pair (p:(('b -> 'c) * ('a -> 'b))) : 'a -> 'c =   fun x -> fst p (snd p x)

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>