You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@systemml.apache.org by "Mike Dusenberry (JIRA)" <ji...@apache.org> on 2016/05/13 18:28:12 UTC

[jira] [Assigned] (SYSTEMML-296) Add elif (else if) to PyDML

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

Mike Dusenberry reassigned SYSTEMML-296:
----------------------------------------

    Assignee: 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: Mike Dusenberry
>            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)