Post History
Reorder expressions in order to save whitespace Consider the following code: if c=='U':c='X' The space between if and c obviously cannot be removed, as that would merge them to the identifier ...
Answer
#3: Post edited
- # Reorder expressions in order to save whitespace
- Consider the following code:
- ```
- if c=='U':c='X'
- ```
- The space between `if` and `c` obviously cannot be removed, as that would merge them to the identifier `ifc`. However by reversing the order of the arguments to `==`, the space becomes removable:
- ```
- if'U'==c:c='X'
- ```
- # Reorder expressions in order to save whitespace
- Consider the following code:
- ```
- if c=='U':c='X'
- ```
- The space between `if` and `c` obviously cannot be removed, as that would merge them to the identifier `ifc`. However by reversing the order of the arguments to `==`, the space becomes removable:
- ```
- if'U'==c:c='X'
- ```
- As [user](https://codegolf.codidact.com/users/53837) noted [in the comments](https://codegolf.codidact.com/comments/thread/4477#comment-13560), another place where whitespace can be saved is between a number and a following keyword. For example, in
- ```
- if 2+x in{a,b,c}:x=0
- ```
- the space between `x` and `in` cannot be simply removed. However reordering the sum allows to remove it anyway:
- ```
- if x+2in{a,b,c}:x=0
- ```
#2: Post edited
- # Reorder expressions in order to save whitespace
- Consider the following code:
- ```
- if c=='U':c='X'
- ```
- The space between `if` and `c` obviously cannot be removed, as that would merge them to the identifier `ifc`. However by reversing the order of the arguments to `==`, the space becomes removable:
- ```
if'U'==C:c='X'- ```
- # Reorder expressions in order to save whitespace
- Consider the following code:
- ```
- if c=='U':c='X'
- ```
- The space between `if` and `c` obviously cannot be removed, as that would merge them to the identifier `ifc`. However by reversing the order of the arguments to `==`, the space becomes removable:
- ```
- if'U'==c:c='X'
- ```
#1: Initial revision
# Reorder expressions in order to save whitespace Consider the following code: ``` if c=='U':c='X' ``` The space between `if` and `c` obviously cannot be removed, as that would merge them to the identifier `ifc`. However by reversing the order of the arguments to `==`, the space becomes removable: ``` if'U'==C:c='X' ```