Proposal: make first
and last
always return 1 element, let take
return from end of list
#7128
Labels
enhancement
New feature or request
inconsistent-behavior
Behavior between different commands or types inconsistent/unexpected
polish
this problem makes nu feel unpolished
Following some discussion on Discord and in this issue, I would like to propose the following changes:
first
andlast
so they always return a single itemtake
sotake -3
returns the last 3 elements.last n
functionality without adding a new commandExamples
Language Comparison
T
T
T
List<T>
List<T>
(more_)itertools
first
nth
last
take(n)
arr[-n:]
,tail(n)
lodash
)head()
nth
last()
take(n)
takeRight(n)
First()
ElementAt()
Last()
Take(n)
TakeLast(n)
,array[^n..]
first()
nth()
last()
take(n)
v[v.len()-3..]
?head
drop(n-1).next
last
take(n)
.takeRight(n)
first
get n
last
first n
,take n
last n
first
get n
last
take n
take -n
Next Steps
If this isn't too controversial I can implement it soon.
Additional context and details
No response
The text was updated successfully, but these errors were encountered: