File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,14 @@ exports.drop = function (n) {
131131 } ;
132132} ;
133133
134+ exports . slice = function ( b ) {
135+ return function ( e ) {
136+ return function ( s ) {
137+ return s . slice ( b , e ) ;
138+ } ;
139+ } ;
140+ } ;
141+
134142exports . count = function ( p ) {
135143 return function ( s ) {
136144 var i = 0 ;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ module Data.String
2626 , drop
2727 , dropRight
2828 , dropWhile
29+ , slice
2930 , stripPrefix
3031 , stripSuffix
3132 , count
@@ -172,6 +173,17 @@ takeWhile p s = take (count p s) s
172173dropWhile :: (Char -> Boolean ) -> String -> String
173174dropWhile p s = drop (count p s) s
174175
176+ -- | Returns the substring at indices [begin, end).
177+ -- | If either index is negative, it is normalized to `length s - index`,
178+ -- | where `s` is the input string. An empty string is returned if either
179+ -- | index is out of bounds or if `begin > end`.
180+ -- |
181+ -- | ```purescript
182+ -- | slice 0 1 "purescript" == "p"
183+ -- | slice 3 6 "purescript" == "ecr"
184+ -- | slice -4 -1 "purescript" == "rip"
185+ foreign import slice :: Int -> Int -> String -> String
186+
175187-- | If the string starts with the given prefix, return the portion of the
176188-- | string left after removing it, as a Just value. Otherwise, return Nothing.
177189-- |
You can’t perform that action at this time.
0 commit comments