mercredi 10 octobre 2018

Making my function return an error message

I'm trying to make my function return "invalid Input" when it finds an empty sublist.

let func (lst: 'a list list) =
    if List.contains [] lst then
        printfn "%s" "Invalid Input"
    else
        List.map List.head lst

This is what I've tried but this of course doesn't work since my if/else returns two different types.

Aucun commentaire:

Enregistrer un commentaire