Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

port over the append command from nushell #345

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

stormasm
Copy link
Contributor

append a row or rows in a table...
append strings, ints, bools in a list...
reproduce functionality of the nushell append command...

@sophiajt
Copy link
Contributor

sophiajt commented Nov 18, 2021

This works a bit differently than the Nushell one. Not sure if we want to keep the Nushell approach or use this one. Here's the Nushell one:

> [1, 2, 3] | append [4, 5, 6]
───┬────────────────
 0 │              1 
 1 │              2 
 2 │              3 
 3 │ [table 3 rows] 
───┴────────────────

@fdncred
Copy link
Contributor

fdncred commented Nov 18, 2021

I personally like this better. in this statement, i read it like this; take the input list and append the items in the second list to it.

〉[1 2 3] | append [4 5 6]
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │ 3 │
│ 3 │ 4 │
│ 4 │ 5 │
│ 5 │ 6 │
╰───┴───╯

if i wanted to do it the nushell way, i can still do this, which makes the intent more explicit, which I like.

〉[1 2 3] | append [[4 5 6]]
╭───┬───────────╮
│ 0 │ 1         │
│ 1 │ 2         │
│ 2 │ 3         │
│ 3 │ [4, 5, 6] │
╰───┴───────────╯

@stormasm
Copy link
Contributor Author

stormasm commented Nov 18, 2021

[[name,age];[bill,20],[rick,21]] | append [[name,age]; [paul, 40], [hb,70], [sally, 333], [sam,46]]
╭───┬───────┬─────╮
│ # │ name  │ age │
├───┼───────┼─────┤
│ 0 │ bill  │ 20  │
│ 1 │ rick  │ 21  │
│ 2 │ paul  │ 40  │
│ 3 │ hb    │ 70  │
│ 4 │ sally │ 333 │
│ 5 │ sam   │ 46  │
╰───┴───────┴─────╯

@stormasm
Copy link
Contributor Author

This was the one that took me the most time to seem correct, so I liked this one better....

@sophiajt
Copy link
Contributor

Let's go for it

@sophiajt sophiajt merged commit adb7eeb into nushell:main Nov 18, 2021
@stormasm stormasm deleted the append_final branch November 18, 2021 22:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants