プログラミング言語 Standard ML 入門 (問題の解答例)
4 MLの基本データ型

4.2 真理値型(eqtype bool

問 4.2

以下のそれぞれの式を評価した結果を予測せよ.

  • false andalso true before print "Is this printed?\n"

  • true andalso false before print "How about this one?\n"

  • false orelse true before print "Another one?\n"

  • false andalso true orelse true before print "One more?\n"

解答例  SML#での実行結果は以下の通り.

   # false andalso true before print "Is this printed?\n";
   val it = false : bool
   # true andalso false before print "How about this one?\n";
   How about this one?
   val it = false : bool
   # false orelse true before print "Another one?\n";
   Another one?
   val it = true : bool
   # false andalso true orelse true before print "One more?\n";
   One more?
   val it = true : bool