mardi 5 février 2019

ocaml boolean define a function that contains an element return true if so or else false

I am not sure why this is throwing me an error. Any help is appreciated thank you! The question is: "Define a function contains taking an element and a list and returning true if the element is in the list, and false otherwise."

My answer is:

let contains elt l = 
    if l = l
      then true
    else
      false;;

It is saying that everything is true when I test it.

Aucun commentaire:

Enregistrer un commentaire