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

Convert OCaml tuple to function arguments

$
0
0

If I have a function returning a tuple (a * b * c) and I want to immediately pass it into another function with type a -> b -> c -> T, is there a way to do it other than tediously expanding it like this:

let (a, b, c) = my_tuple inmy_function a b c

ChatGPT suggested I write a helper function:

let apply_tuple3 (f : 'a -> 'b -> 'c -> 'd) ((a, b, c) : 'a * 'b * 'c) : 'd =  f a b c

which is not variadic... It's fine I guess, but surely something like this exists already? It seems like an obvious task.


Viewing all articles
Browse latest Browse all 531

Trending Articles



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