Skip to content

Commit

Permalink
Added SC operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
dloscutoff committed Mar 20, 2018
1 parent 824e2bf commit f3178b2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Documentation/Operator list.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ Operators are listed in ASCII order. See also the [precedence table](https://git

<code>RVa</code> Reverse iterable

<code>SCa</code> Swap case: `Hello, World!` becomes `hELLO, wORLD!`

<code>SEa</code> Secant

<code>SGa</code> Sign of number (-1, 0, or 1)
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Precedence table.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Regex modifiers | Unary |
Remove | Binary | Left | `RM` <br> `DC` | Remove <br> Deletechars | `""` <br> `""` | No <br> Both | Yes <br> Yes
String repetition | Binary | Left | `X` | Strmul | `""` | Both | Yes
Strip and trim | Binary | Left | `\|\|` <br> `\|>` <br> `<\|` <br> `TM` | Strip <br> Lstrip <br> Rstrip <br> Trim | `""` <br> `""` <br> `""` <br> `""` | List <br> List <br> List <br> List | Yes <br> Yes <br> Yes <br> Yes
Strip and trim | Unary | – | `\|\|` <br> `\|>` <br> `<\|` <br> `TM` <br> `LC` <br> `UC` | Strip <br> Lstrip <br> Rstrip <br> Trim <br> Lowercase <br> Uppercase | None <br> None <br> None <br> None <br> None <br> None | List <br> List <br> List <br> List <br> List <br> List | Yes <br> Yes <br> Yes <br> Yes <br> Yes <br> Yes
Strip and trim | Unary | – | `\|\|` <br> `\|>` <br> `<\|` <br> `TM` <br> `LC` <br> `UC` <br> `SC` | Strip <br> Lstrip <br> Rstrip <br> Trim <br> Lowercase <br> Uppercase <br> Swapcase | None <br> None <br> None <br> None <br> None <br> None <br> None | List <br> List <br> List <br> List <br> List <br> List <br> List | Yes <br> Yes <br> Yes <br> Yes <br> Yes <br> Yes <br> Yes
Range and to-base | Binary | Left | `,` <br> `\,` <br> `RR` <br> `TB` | Range <br> Inclrange <br> Randrange <br> Tobase | None <br> None <br> `0` <br> `0` | Both <br> Both <br> Both <br> Both | Yes <br> Yes <br> Yes <br> Yes
Range and to-base | Unary | – | `,` <br> `\,` <br> `RR` <br> `TB` | Rangeto <br> Inclrangeto <br> Randrangeto <br> Tobase | None <br> None <br> None <br> None | Both <br> Both <br> Both <br> Both | Yes <br> Yes <br> Yes <br> Yes
Low-precedence numeric operators | Binary | Left | `BA` <br> `BO` <br> `BX` <br> `AT` <br> `CM` | Bitwiseand <br> Bitwiseor <br> Bitwisexor <br> Arctan <br> Numcmp | `-1` <br> `0` <br> `0` <br> None <br> `0` | Both <br> Both <br> Both <br> Both <br> No | Yes <br> Yes <br> Yes <br> Yes <br> Yes
Expand Down
9 changes: 9 additions & 0 deletions execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2889,6 +2889,15 @@ def SUB(self, lhs, rhs):
type(lhs), "and", type(rhs))
return nil

def SWAPCASE(self, rhs):
if type(rhs) is Scalar:
return Scalar(str(rhs).swapcase())
elif type(rhs) in (Range, Nil):
return rhs
else:
self.err.warn("Unimplemented argtype for SWAPCASE:", type(rhs))
return nil

def TANGENT(self, rhs):
if type(rhs) is Scalar:
return Scalar(math.tan(rhs.toNumber()))
Expand Down
1 change: 1 addition & 0 deletions operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def copy(self):
("TM", "TRIM", None, RVALS | IN_LAMBDA | LIST_EACH),
("LC", "LOWERCASE", None, RVALS | IN_LAMBDA | LIST_EACH),
("UC", "UPPERCASE", None, RVALS | IN_LAMBDA | LIST_EACH),
("SC", "SWAPCASE", None, RVALS | IN_LAMBDA | LIST_EACH),
],
[2, "L",
(",", "RANGE", None, RVALS | IN_LAMBDA | RANGE_EACH),
Expand Down
2 changes: 1 addition & 1 deletion pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from execution import ProgramState
from errors import FatalError

VERSION = "0.18.03.05"
VERSION = "0.18.03.20"

def pip(code=None, args=None, interactive=True):
if code or args:
Expand Down

0 comments on commit f3178b2

Please sign in to comment.