I'm programming binary arithmetic program using F#. I don't think my code was wrong but type error occurred.
Please examine my code and tell me what is wrong.
let carry a b c = if a then b||c else b&&c
let sum a b c = (if c then (a=b) else not (a=b))
let rec addc cin (l1:bool list) (l2:bool list) =
if l2.Length>0 then sum(cin,l1.Head,l2.Head)::addc(carry cin,l1.Head,l2.Head), l1.Tail, l2.Tail) else l1
The error message:
if l2.Length>0 then sum(cin,l1.Head,l2.Head)::addc(carry(cin,l1.Head,l2.Head),l1.Tail,l2.Tail) else l1
--------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^stdin(173,51): error FS0001: This expression was expected to have type ('a * bool * bool -> bool -> bool) list but here has type bool list -> bool list -> ('a * bool * bool -> bool -> bool) list