2021年2月9日星期二

How to output an empty tuple as part of a function in OCaml?

I'm quite new to OCaml, so I apologise for the basic nature of my question. I've written code to output the head of a list of boolean tuples, as below:

let head (lst : (bool * bool) list) : (bool * bool) =      match lst with      | (h1, h2) :: tl -> (h1, h2)      | [] -> ();;  

However, I get a typing error when handling the case of the empty list, because the empty tuple is of type unit. Is there anyway I can output an empty tuple as part of the pattern-matching of my function? I would dislike outputting actual boolean values, since those mean something in the context of my function. Thanks for the assistance.

Sincerely, Charles

https://stackoverflow.com/questions/66131201/how-to-output-an-empty-tuple-as-part-of-a-function-in-ocaml February 10, 2021 at 01:08PM

没有评论:

发表评论