Re: Where is the syntax error

"Dario Teixeira [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <[email protected]>
Hi,


> As a exercise of Ocaml from the very beginning I have to write
> a function which display true if both are non zero .> 
> So I tried this : 
> 
> let both_zero a b = a != 0 || b !=0   ;;


Besides the problems with using the wrong intepreter and using
physical inequality (!=) instead of structural inequality (<>),
there's also another problem with your code: why is the function
called "both_zero" when its semantics imply that "both_non_zero"
should actually be its name?

Btw, regarding the physical/structural equality/inequality operators:
as a beginner, you should never come across a situation where you
actually need the physical eq/neq operators.  Try to get them out
of your mind for now, and always use the structural eq/neq operators
until your mastery of the language reaches a point where you really
grok the difference between them.


Best regards,
Dario Teixeira
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.