[erlang-questions] Best practices -- conditional statements

Donald Steven t6sn7gt@REDACTED
Wed Feb 13 13:40:59 CET 2019


The code excerpt below shows two alternate ways of branching. I'd be 
grateful for opinions on which represents best practices. Thanks.


Don


makePanPositionL(Notes, Mode, L),

     CurrentPanPosition = hd(L),

     case Mode of

         left2right ->
             if
                 Notes < 6 -> PanPosition = CurrentPanPosition + 8;
                 Notes < 12 -> PanPosition = CurrentPanPosition + 4;
                 true -> PanPosition = CurrentPanPosition + 2
             end;

         left2right ->
             case Notes of
                 Few  when Few  < 6 -> PanPosition = CurrentPanPosition + 8;
                 More when More < 12 -> PanPosition = CurrentPanPosition 
+ 4;
                 _Lots -> PanPosition = CurrentPanPosition + 2
             end;




More information about the erlang-questions mailing list