I need to write my own datatypes - either, and eitherTree, which have their own types. With these, I need to create a function, that takes an int, and an eitherTree as parameters, that searches through the tree, and returns true if the value exists in the tree. the type needs to be: eitherTree -> int -> bool
So far I have :
datatype either = ImAString of string | ImAnInt of int
datatype eitherTree = eLEAF of either | eINTERIOR of (either*eitherTree*eitherTree)
fun eitherSearch v1 (eLEAF((v2)) = if v1 = v2 then true
else false
| eitherSearch v1 (eINTERIOR(e1, et1, et2)) = if v1 = e1 then true
else if (eitherSearch v1 et1) = true
then true
else if (eitherSearch v1 et1) = true
then true else false
The "trick" seems to be casting ImAnInt / int to one another so I can compare them. Anyone have any ideas? Thank you.