Writing eval functions for boolean formula datatypes in SML

  • Thread starter Thread starter Monsu
  • Start date Start date
  • Tags Tags
    Programming
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 3K views
Monsu
Messages
38
Reaction score
1
hi, pleaaaaaaaaaase! i need help urgently! I am completely stuck! I have no idea what to do on this question, it reads thus:





Given the following datatypes for boolean formulae and the truth values

datatype boolexp = bez | beo (*0 and 1*)
| bep of boolexp * boolexp (*plus*)
| bet of boolexp * boolexp (*times*)
| bec of boolexp (*complement*)
| bev of int (*variables*)
datatype mybool = mytrue | myfalse

write a cascading evaluation function eval : (int -> mybool) -> boolexp -> mybool
that takes an assignment $ and a boolean formula & and returns I$(&) as a value .
write a simplified version of the function evalbib : (int -> bool) -> boolexp -> bool. (without using "if" constructs)




I'm clueless as to how to begin this, and I am a novice in all languages, any acclaration and explanations will be highly appreciated, thanks in advance!


:rolleyes: :rolleyes: :rolleyes:
 
Physics news on Phys.org
read the slides


philipp