[ 
https://issues.apache.org/jira/browse/SYSTEMML-296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mike Dusenberry updated SYSTEMML-296:
-------------------------------------
    Assignee: Tatsuya Nishiyama  (was: Mike Dusenberry)

> Add elif (else if) to PyDML
> ---------------------------
>
>                 Key: SYSTEMML-296
>                 URL: https://issues.apache.org/jira/browse/SYSTEMML-296
>             Project: SystemML
>          Issue Type: Improvement
>          Components: Parser, PyDML
>            Reporter: Deron Eriksson
>            Assignee: Tatsuya Nishiyama
>            Priority: Minor
>
> "Else if" (elif) statements are useful since they avoid the need for nested 
> if/else statements.  Currently, DML has "else if" but PyDML does not have an 
> equivalent "elif".
> As an example, here is DML containing "else if" statements:
> {code}
> x = 6
> if (x == 1) {
>       print('A')
> } else if (x == 2) {
>       print('B')
> } else if (x == 3) {
>       print('C')
> } else if (x == 4) {
>       print('D')
> } else if (x == 5) {
>       print('E')
> } else {
>       print('F')
> }
> {code}
> Here is the logical equivalent in PyDML using nested "if else" statements:
> {code}
> x = 6
> if (x == 1):
>     print('A')
> else:
>     if (x == 2):
>         print('B')
>     else:
>         if (x == 3):
>             print('C')
>         else:
>             if (x == 4):
>                 print('D')
>             else:
>                 if (x == 5):
>                     print('E')
>                 else:
>                     print('F')
> {code}
> The nesting becomes especially challenging in a Python-like language as the 
> number of nested "if else" statements increases due to the use of whitespace 
> indentations to specify blocks of code.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to