Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please I need help, with SML language write a function band of type bool list ->

ID: 674795 • Letter: P

Question

please I need help, with SML language

write a function band of type bool list -> bool that takes a list of boolean values and return the logical AND of all of them. if the list is empty, your function should return true.

the answer should be in one line please

Explanation / Answer

exception Err datatype ty = IntTy | BoolTy datatype exp = True | False | Int of int | Not of exp | Add of exp * exp | If of exp * exp * exp fun typeOf (True) = BoolTy | typeOf (False) = BoolTy | typeOf (Int _) = IntTy | typeOf (Not e) = if typeOf e = BoolTy then BoolTy else raise Err | typeOf (Add (e1, e2)) = if (typeOf e1 = IntTy) andalso (typeOf e2 = IntTy) then IntTy else raise Err | typeOf (If (e1, e2, e3)) = if typeOf e1 BoolTy then raise Err else if typeOf e2 typeOf e3 then raise Err else typeOf e2 fun eval (True) = True | eval (False) = False | eval (Int n) = Int n | eval (Not e) = (case eval e of True => False | False => True | _ => raise Fail "type-checking is broken") | eval (Add (e1, e2)) = let val (Int n1) = eval e1 val (Int n2) = eval e2 in Int (n1 + n2) end | eval (If (e1, e2, e3)) = if eval e1 = True then eval e2 else eval e3 fun chkEval e = (ignore (typeOf e); eval e) (* will raise Err on type error *)