<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Thanks, re the first example.  I had an if statement solution, but I
    was under the impression that ifs were frowned upon.<br>
    <br>
    Re the second example, each atom in fact represents a possible
    musical fork.  So, to create a bit of an odd but useful example:<br>
    <br>
    case SoundType of:<br>
    <br>
        ostinato                                             -> some
    action;<br>
        melisma or melody or ornament  -> some action common to all
    three atoms;<br>
       _                                                           ->
    error_message()    % i.e., an unrecognized SoundType<br>
    end,<br>
    <br>
    I was trying to understand how to do the 'or' part (the second guard
    statement) without repeating the code 3 times.<br>
    <br>
    <div class="moz-cite-prefix">On 2/10/2019 7.17 PM, Richard O'Keefe
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CABcYAd+UEDsNvPn7JonDFQFPhpbPhbCofqjRQ7iY_zueCPt1AQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:monospace,monospace">The first example
          would probably be better as</div>
        <div class="gmail_default"
          style="font-family:monospace,monospace">   if X =:= 4       
          -> first case</div>
        <div class="gmail_default"
          style="font-family:monospace,monospace">    ; X >= 2, X
          =< 6 -> third case</div>
        <div class="gmail_default"
          style="font-family:monospace,monospace">    ; true         
           -> second case</div>
        <div class="gmail_default"
          style="font-family:monospace,monospace">   end</div>
        <div class="gmail_default"
          style="font-family:monospace,monospace"><br>
        </div>
        <div class="gmail_default"
          style="font-family:monospace,monospace">The second example
          makes me unhappy.  We are so far in the misty clouds of</div>
        <div class="gmail_default"
          style="font-family:monospace,monospace">abstraction here that
          we can't see the ground with a telescope.  And the</div>
        <div class="gmail_default"
          style="font-family:monospace,monospace">thing that makes me
          unhappy is the "_" case.  This is a maintenance bug</div>
        <div class="gmail_default"
          style="font-family:monospace,monospace">waiting to happen, and
          it does not matter what your programming language is.</div>
        <div class="gmail_default"
          style="font-family:monospace,monospace">This is the ML
          lesson.  A concrete example would be a big help.</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Mon, 11 Feb 2019 at 08:43,
          Hugo Mills <<a href="mailto:hugo@carfax.org.uk"
            moz-do-not-send="true">hugo@carfax.org.uk</a>> wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On
          Sun, Feb 10, 2019 at 02:33:36PM -0500, Donald Steven wrote:<br>
          > Newbie question regarding best practices (including a
          string of nested ifs):<br>
          > <br>
          > How do you code the following:<br>
          <br>
             Guards:<br>
          <br>
          > case X of<br>
          >     4             -> something;<br>
          >     <2 or >6 -> something else;<br>
          >     _             -> something else again<br>
          > end,<br>
          <br>
          case X of<br>
              4 -><br>
                  something;<br>
              Y when Y < 2; Y > 6 -><br>
                  something else;<br>
              _ -><br>
                  something else again<br>
          end,<br>
          <br>
          Note that >=2 and =<6 would be written with "when Y
          >= 2, Y =< 6" --<br>
          use comma for "and", semicolon for "or", with "or" being at
          the higher<br>
          level:<br>
          <br>
             Y when Y >= 2, Y =< 6; Y >= 8, Y =< 10 -><br>
                 Y is either between 2 and 6 or between 8 and 10
          inclusive;<br>
          <br>
          > and<br>
          > <br>
          > case X of<br>
          >     atom1 or atom2 or atom3 -> something;<br>
          >     atom4                                    ->
          something else;<br>
          >     _ ->                                         ->
          something else again<br>
          > end,<br>
          <br>
          case X of<br>
              Y when Y =:= atom1; Y =:= atom2; Y =:= atom3 -><br>
                  something;<br>
              atom4 -><br>
                  something else;<br>
              _ -><br>
                  something else again<br>
          end,<br>
          <br>
             Hugo.<br>
          <br>
          -- <br>
          Hugo Mills             | I have a step-ladder. My real ladder
          left when I was<br>
          hugo@... <a href="http://carfax.org.uk" rel="noreferrer"
            target="_blank" moz-do-not-send="true">carfax.org.uk</a> | a
          child.<br>
          <a href="http://carfax.org.uk/" rel="noreferrer"
            target="_blank" moz-do-not-send="true">http://carfax.org.uk/</a> 
          |<br>
          PGP: E2AB1DE4          |<br>
          _______________________________________________<br>
          erlang-questions mailing list<br>
          <a href="mailto:erlang-questions@erlang.org" target="_blank"
            moz-do-not-send="true">erlang-questions@erlang.org</a><br>
          <a href="http://erlang.org/mailman/listinfo/erlang-questions"
            rel="noreferrer" target="_blank" moz-do-not-send="true">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>