Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,321
Issues
4,321
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
359
Merge Requests
359
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
59ecd68d
Commit
59ecd68d
authored
Nov 14, 2011
by
Simon Marlow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add "dropWhileEnd", as discussed on the libraries list
parent
53be8c84
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
libraries/base/Data/List.hs
libraries/base/Data/List.hs
+11
-0
No files found.
libraries/base/Data/List.hs
View file @
59ecd68d
...
...
@@ -95,6 +95,7 @@ module Data.List
,
takeWhile
-- :: (a -> Bool) -> [a] -> [a]
,
dropWhile
-- :: (a -> Bool) -> [a] -> [a]
,
dropWhileEnd
-- :: (a -> Bool) -> [a] -> [a]
,
span
-- :: (a -> Bool) -> [a] -> ([a], [a])
,
break
-- :: (a -> Bool) -> [a] -> ([a], [a])
...
...
@@ -228,6 +229,16 @@ infix 5 \\ -- comment to fool cpp
-- -----------------------------------------------------------------------------
-- List functions
-- | The 'dropWhileEnd' function drops the largest suffix of a list
-- in which the given predicate holds for all elements. For example:
--
-- > dropWhileEnd isSpace "foo\n" == "foo"
-- > dropWhileEnd isSpace "foo bar" == "foo bar"
-- > dropWhileEnd isSpace ("foo\n" ++ undefined) == "foo" ++ undefined
dropWhileEnd
::
(
a
->
Bool
)
->
[
a
]
->
[
a
]
dropWhileEnd
p
=
foldr
(
\
x
xs
->
if
p
x
&&
null
xs
then
[]
else
x
:
xs
)
[]
-- | The 'stripPrefix' function drops the given prefix from a list.
-- It returns 'Nothing' if the list did not start with the prefix
-- given, or 'Just' the list after the prefix, if it does.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment