When I run the code shown below I get an error that I have also shown below and i am unsure why this is happening
let average x y = ((x+y)/2);;
let rec average2 xs = function
| [x,y] -> average x y :: xs
| x :: y :: xs -> if xs = [] then average x y :: xs else average2 xs;;
Error: This expression has type int * int but an expression was expected of type int
The letter x in the last line is underlined by this error though when defining the average function it should be retruning just an int to add to the xs list
Thanks for any help
Aucun commentaire:
Enregistrer un commentaire