I have just started learning SML and still in the process of making sense of its error messages.
when trying to input the function definition below
val rec : real->real = fn 0.0 => 0.0 | n:real => 1.0/n;
i get the following error :
stdIn:25.9-25.17 Error: syntax error: deleting COLON ID ARROW
stdIn:25.24-25.33 Error: syntax error: deleting FN REAL DARROW
stdIn:25.38 Error: syntax error found at BAR
can someone point out what i am doing wrong ?
thank you.
You have two errors in your code:
val recand the type annotation there should be the name of the value you’re defining.reals. Sincereals are inexact, they aren’t equality types, so you can’t use=on them either. You need to useReal.==to compare reals for equality (or better: don’t compare them for equality, but compare them against some delta instead).