Skip to content

Commit 3226654

Browse files
authored
Merge pull request #257 from rgwood/math-mode
Remove math mode mentions, move short hand syntax documentation
2 parents d9839a5 + c151cac commit 3226654

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

book/math.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,3 @@ Math operations are evaluated in the follow order (from highest precedence to lo
7070
> 3 * (1 + 2)
7171
9
7272
```
73-
74-
## Short-hand math mode
75-
76-
A variation of math mode that Nushell supports is called "short-hand" math mode. This is because it gives you a way of accessing columns using a simple short-hand.
77-
78-
You may have already used this functionality before. If, for example, we wanted to only see rows from `ls` where the entry is at least ten kilobytes, we can write:
79-
80-
```
81-
> ls | where size > 10kb
82-
```
83-
84-
The `where size > 10kb` is a command with two parts: the command name `where` and the short-hand math expression `size > 10kb`. We say short-hand because `size` here is the shortened version of writing `$it.size`. If we look at the fully expanded form, we would see:
85-
86-
```
87-
> ls | where {|$it| $it.size > 10kb }
88-
```
89-
90-
Rather than having to type all this out every time a command needs to work with column data, we use this short-hand mode to access column data.
91-
92-
For the expansion to work, the column name must appear on the left-hand side of the operation. Above, `size` appears on the left-hand side of the comparison, which allows the expression to expand into the full math mode block.

book/variables_and_subexpressions.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,21 @@ We can do a very similar action in a single step using a subexpression path:
6363
```
6464

6565
It depends on the needs of the code and your particular style which form works best for you.
66+
67+
## Short-hand subexpressions (row conditions)
68+
69+
Nushell supports accessing columns in a subexpression using a simple short-hand. You may have already used this functionality before. If, for example, we wanted to only see rows from `ls` where the entry is at least ten kilobytes we can write:
70+
71+
```
72+
> ls | where size > 10kb
73+
```
74+
75+
The `where size > 10kb` is a command with two parts: the command name `where` and the short-hand expression `size > 10kb`. We say short-hand because `size` here is the shortened version of writing `$it.size`. This could also be written in any of the following ways:
76+
77+
```
78+
> ls | where $it.size > 10kb
79+
> ls | where ($it.size > 10kb)
80+
> ls | where {|$it| $it.size > 10kb }
81+
```
82+
83+
For short-hand syntax to work, the column name must appear on the left-hand side of the operation (like `size` in `size > 10kb`).

book/working_with_lists.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ let colors = []
4343
= $colors | empty? # true
4444
```
4545
46-
The `in` and `not in` operators are used to test whether a value is in a list.
47-
Operators can only be used in "math mode".
48-
One way to enter math mode is to begin an expression with `=`.
49-
For example:
46+
The `in` and `not-in` operators are used to test whether a value is in a list. For example:
5047
5148
```bash
5249
let colors = [red green blue]

0 commit comments

Comments
 (0)