jack
jack

Reputation: 313

what does ignore function do in SML

what does ignore function do in SML

fun prntlst f l =
      if NULL l then ()
      else (ignore(f (HD l)); prntlst f (TL(l)));

what does ignore do here

Upvotes: 0

Views: 441

Answers (1)

sepp2k
sepp2k

Reputation: 370455

The ignore function does nothing. It simply ignores its argument and returns ().

The point of the function is to avoid warnings about a return value not being used. That is if you have a function f whose return type is not unit, then calling f without using the return value will cause a warning. If you wrap ignore around it, it won't.

Upvotes: 2

Related Questions