[GHC] #10084: Data.List should have a takeLastN function

#10084: Data.List should have a takeLastN function -------------------------------------+------------------------------------- Reporter: leonbaum2 | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.4 Component: | Operating System: Unknown/Multiple libraries/base | Type of failure: None/Unknown Keywords: | Blocked By: Architecture: | Related Tickets: Unknown/Multiple | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- A natural compliment to the `take` function that instead takes `n` elements from the end of the list rather than from the start would be very useful. I'm surprised it's not defined in base because it seems to be a common operation that is not trivial to define in an efficient way. See http://www.joachim- breitner.de/blog/600-On_taking_the_last_n_elements_of_a_list -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10084 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10084: Data.List should have a takeLastN function -------------------------------------+------------------------------------- Reporter: leonbaum2 | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata): Heh, nice to see my blog cited here :-) One could argue that obviously, when you do `takeLastN` on a list, you are using the wrong data structure. But we also have `last` and `isSuffixOf` in `Data.List`, and maybe leaving it out for that reason is too much patronizing... In general, I’m in favor of adding that function. Did you have a real, practical need for the function, or are you bringing this up for other reasons? If you want this to become real, I suggest you follow the process in https://wiki.haskell.org/Library_submissions, i.e. send your proposal to the libraries mailing list. Possible issues to consider in the proposal and following discussion: * What is a good name for this? * If we have `takeLastN`, do we need `dropLastN`? How would that be implemented? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10084#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC