Home Explore Blog CI



nushell

book/nushell_map_imperative.md
86475b37b75b6d074b3681a46117f98809fab3672d1166af00000003000058f2
# Nu Map from Imperative Languages

The idea behind this table is to help you understand how Nu built-ins and plugins relate to imperative languages. We've tried to produce a map of programming-relevant Nu commands and what their equivalents are in other languages. Contributions are welcome.

Note: this table assumes Nu 0.94 or later.

| Nushell                                                                                                                                | Python                               | Kotlin (Java)                                               | C++                         | Rust                                                 |
| -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | ----------------------------------------------------------- | --------------------------- | ---------------------------------------------------- |
| [`append`](/commands/docs/append.md)                                                                                                   | `list.append`, `set.add`             | `add`                                                       | `push_back`, `emplace_back` | `push`, `push_back`                                  |
| [`math avg`](/commands/docs/math_avg.md)                                                                                               | `statistics.mean`                    |                                                             |                             |                                                      |
| [`math`](/commands/docs/math.md), [Math Operators](nushell_operator_map.md)                                                            | Math operators                       | Math operators                                              | Math operators              | Math operators                                       |
| [`cp`](/commands/docs/cp.md)                                                                                                           | `shutil.copy`                        |                                                             |                             | `fs::copy`                                           |
| [`date`](/commands/docs/date.md)                                                                                                       | `datetime.date.today`                | `java.time.LocalDate.now`                                   |                             |                                                      |
| [`drop`](/commands/docs/drop.md)                                                                                                       | `list[:-3]`                          |                                                             |                             |                                                      |
| [`du`](/commands/docs/du.md), [`ls --du`](/commands/docs/ls.md)                                                                        | `shutil.disk_usage`                  |                                                             |                             |                                                      |
| [`each`](/commands/docs/each.md)<br />[`for`](/commands/docs/for.md)                                                                   | `for`                                | `for`                                                       | `for`                       | `for`                                                |
| [`exit`](/commands/docs/exit.md)                                                                                                       | `exit()`                             | `System.exit`, `kotlin.system.exitProcess`                  | `exit`                      | `exit`                                               |
| [`http get`](/commands/docs/http_get.md)                                                                                               | `urllib.request.urlopen`             |                                                             |                             |                                                      |
| [`first`](/commands/docs/first.md)                                                                                                     | `list[:x]`                           | `List[0]`, `peek`                                           | `vector[0]`, `top`          | `Vec[0]`                                             |
| [`format`](/commands/docs/format.md)                                                                                                   | `format`                             | `format`                                                    | `format`                    | `format!`                                            |
| [`from`](/commands/docs/from.md)                                                                                                       | `csv`, `json`, `sqlite3`             |                                                             |                             |                                                      |
| [`get`](/commands/docs/get.md)                                                                                                         | `dict[\"key\"]`                      | `Map[\"key\"]`                                              | `map[\"key\"]`              | `HashMap["key"]`, `get`, `entry`                     |
| [`group-by`](/commands/docs/group-by.md)                                                                                               | `itertools.groupby`                  | `groupBy`                                                   |                             | `group_by`                                           |
| [`headers`](/commands/docs/headers.md)                                                                                                 | `keys`                               |                                                             |                             |                                                      |
| [`help`](/commands/docs/help.md)                                                                                                       | `help()`                             |                                                             |                             |                                                      |
| [`insert`](/commands/docs/insert.md)                                                                                                   | `dict[\"key\"] = val`                |                                                             | `map.insert({ 20, 130 })`   | `map.insert(\"key\", val)`                           |
| [`is-empty`](/commands/docs/is-empty.md)                                                                                               | `is None`, `is []`                   | `isEmpty`                                                   | `empty`                     | `is_empty`                                           |
| [`take`](/commands/docs/take.md)                                                                                                       | `list[:x]`                           |                                                             |                             | `&amp;Vec[..x]`                                          |
| [`take until`](/commands/docs/take_until.md)                                                                                           | `itertools.takewhile`                |                                                             |                             |                                                      |
| [`take while`](/commands/docs/take_while.md)                                                                                           | `itertools.takewhile`                |                                                             |                             |                                                      |
| [`kill`](/commands/docs/kill.md)                                                                                                       | `os.kill`                            |                                                             |                             |                                                      |
| [`last`](/commands/docs/last.md)                                                                                                       | `list[-x:]`                          |                                                             |                             | `&amp;Vec[Vec.len()-1]`                                  |
| [`length`](/commands/docs/length.md)                                                                                                   | `len`                                | `size`, `length`                                            | `length`                    | `len`                                                |
| [`lines`](/commands/docs/lines.md)                                                                                                     | `split`, `splitlines`                | `split`                                                     | `views::split`              | `split`, `split_whitespace`, `rsplit`, `lines`       |
| [`ls`](/commands/docs/ls.md)                                                                                                           | `os.listdir`                         |                                                             |                             | `fs::read_dir`                                       |
| [`match`](/commands/docs/match.md)                                                                                                     | `match`                              | `when`                                                      |                             | `match`                                              |
| [`merge`](/commands/docs/merge.md)                                                                                                     | `dict.append`                        |                                                             |                             | `map.extend`                                         |
| [`mkdir`](/commands/docs/mkdir.md)                                                                                                     | `os.mkdir`                           |                                                             |                             | `fs::create_dir`                                     |
| [`mv`](/commands/docs/mv.md)                                                                                                           | `shutil.move`                        |                                                             |                             | `fs::rename`                                         |
| [`get`](/commands/docs/get.md)                                                                                                         | `list[x]`                            | `List[x]`                                                   | `vector[x]`                 | `Vec[x]`                                             |
| [`open`](/commands/docs/open.md)                                                                                                       | `open`                               |                                                             |                             |                                                      |
| [`transpose`](/commands/docs/transpose.md)                                                                                             | `zip(\*matrix)`                      |                                                             |                             |                                                      |
| [`http post`](/commands/docs/http_post.md)                                                                                             | `urllib.request.urlopen`             |                                                             |                             |                                                      |
| [`prepend`](/commands/docs/prepend.md)                                                                                                 | `deque.appendleft`                   |                                                             |                             |                                                      |
| [`print`](/commands/docs/print.md)                                                                                                     | `print`                              | `println`                                                   | `printf`                    | `println!`                                           |
| [`ps`](/commands/docs/ps.md)                                                                                                           | `os.listdir('/proc')`                |                                                             |                             |                                                      |
| [`pwd`](/commands/docs/pwd.md)                                                                                                         | `os.getcwd`                          |                                                             |                             | `env::current_dir`                                   |
| [`range`](types_of_data.html#ranges) type                                                                                              | `range`                              | `..`, `until`, `downTo`, `step`                             | `iota`                      | `..`                                                 |
| [`reduce`](/commands/docs/reduce.md)                                                                                                   | `functools.reduce`                   | `reduce`                                                    | `reduce`                    | `fold`, `rfold`, `scan`                              |
| [`reject`](/commands/docs/reject.md)                                                                                                   | `del`                                |                                                             |                             |                                                      |
| [`rename`](/commands/docs/rename.md)                                                                                                   | `dict[\"key2\"] = dict.pop(\"key\")` |                                                             |                             | `map.insert(\"key2\", map.remove(\"key\").unwrap())` |
| [`reverse`](/commands/docs/reverse.md)                                                                                                 | `reversed`, `list.reverse`           | `reverse`, `reversed`, `asReversed`                         | `reverse`                   | `rev`                                                |
| [`rm`](/commands/docs/rm.md)                                                                                                           | `os.remove`                          |                                                             |                             |                                                      |
| [`save`](/commands/docs/save.md)                                                                                                       | `io.TextIOWrapper.write`             |                                                             |                             |                                                      |
| [`select`](/commands/docs/select.md)                                                                                                   | `{k:dict[k] for k in keys}`          |                                                             |                             |                                                      |
| [`shuffle`](/commands/docs/shuffle.md)                                                                                                 | `random.shuffle`                     |                                                             |                             |                                                      |
| [`str stats`](/commands/docs/str_stats.md)<br />[`str length`](/commands/docs/str_length.md)<br />[`length`](/commands/docs/length.md) | `len`                                |                                                             |                             | `len`                                                |
| [`skip`](/commands/docs/skip.md)                                                                                                       | `list[x:]`                           |                                                             |                             | `&amp;Vec[x..]`, `skip`                                  |
| [`skip until`](/commands/docs/skip_until.md)                                                                                           | `itertools.dropwhile`                |                                                             |                             |                                                      |
| [`skip while`](/commands/docs/skip_while.md)                                                                                           | `itertools.dropwhile`                |                                                             |                             | `skip_while`                                         |
| [`sort-by`](/commands/docs/sort-by.md)                                                                                                 | `sorted`, `list.sort`                | `sortedBy`, `sortedWith`, `Arrays.sort`, `Collections.sort` | `sort`                      | `sort`                                               |
| [`split row`](/commands/docs/split_row.md)                                                                                             | `str.split{,lines}`, `re.split`      | `split`                                                     | `views::split`              | `split`                                              |
| [`str`](/commands/docs/str.md)                                                                                                         | `str` functions                      | String functions                                            | String functions            | `&amp;str`, String functions                             |
| [`str join`](/commands/docs/str_join.md)                                                                                               | `str.join`                           | `joinToString`                                              |                             | `join`                                               |
| [`str trim`](/commands/docs/str_trim.md)                                                                                               | `strip`, `rstrip`, `lstrip`          | `trim`, `trimStart`, `trimEnd`                              | Regex                       | `trim`, `trim*{start,end}`, `strip*{suffix,prefix}`  |
| [`math sum`](/commands/docs/math_sum.md)                                                                                               | `sum`                                | `sum`                                                       | `reduce`                    | `sum`                                                |
| [`to`](/commands/docs/to.md)                                                                                                           | `import csv`, `json`, `sqlite3`      |                                                             |                             |                                                      |
| [`touch`](/commands/docs/touch.md)                                                                                                     | `open(path, 'a').close()`            |                                                             |                             |                                                      |
| [`uniq`](/commands/docs/uniq.md)                                                                                                       | `set`                                | Set                                                         | `set`                       | `HashSet`                                            |
| [`upsert`](/commands/docs/upsert.md)                                                                                                   | `dict[\"key\"] = val`                |                                                             |                             |                                                      |
| [`version`](/commands/docs/version.md)                                                                                                 | `sys.version`, `sys.version_info`    |                                                             |                             |                                                      |
| [`with-env`](/commands/docs/with-env.md)<br />`$env.FOO = "bar"`                                                                       | `os.environ`                         |                                                             |                             |                                                      |
| [`where`](/commands/docs/where.md)                                                                                                     | `filter`                             | `filter`                                                    | `filter`                    | `filter`                                             |
| [`which`](/commands/docs/which.md)                                                                                                     | `shutil.which`                       |                                                             |                             |                                                      |
| [`wrap`](/commands/docs/wrap.md)                                                                                                       | `{ "key" : val }`                    |                                                             |                             |                                                      |

Chunks
1be324d3 (1st chunk of `book/nushell_map_imperative.md`)
2a2e8c50 (2nd chunk of `book/nushell_map_imperative.md`)
5bac103e (3rd chunk of `book/nushell_map_imperative.md`)
1a233f03 (4th chunk of `book/nushell_map_imperative.md`)
6c751694 (5th chunk of `book/nushell_map_imperative.md`)
1707391f (6th chunk of `book/nushell_map_imperative.md`)
386f4663 (7th chunk of `book/nushell_map_imperative.md`)
2f12ea5c (8th chunk of `book/nushell_map_imperative.md`)