File tree 3 files changed +11
-2
lines changed
3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,8 @@ Returns the string without the first `n` characters.
178
178
count :: (Char -> Boolean) -> String -> Int
179
179
```
180
180
181
- Returns the number of characters in the string for which the predicate holds.
181
+ Returns the number of contiguous characters at the beginning
182
+ of the string for which the predicate holds.
182
183
183
184
#### ` split `
184
185
Original file line number Diff line number Diff line change @@ -120,6 +120,13 @@ exports.drop = function (n) {
120
120
} ;
121
121
} ;
122
122
123
+ exports . count = function ( p ) {
124
+ return function ( s ) {
125
+ for ( var i = 0 ; i < s . length && p ( s . charAt ( i ) ) ; i ++ ) ; { }
126
+ return i ;
127
+ } ;
128
+ } ;
129
+
123
130
exports . split = function ( sep ) {
124
131
return function ( s ) {
125
132
return s . split ( sep ) ;
Original file line number Diff line number Diff line change @@ -172,7 +172,8 @@ foreign import take :: Int -> String -> String
172
172
-- | Returns the string without the first `n` characters.
173
173
foreign import drop :: Int -> String -> String
174
174
175
- -- | Returns the number of characters in the string for which the predicate holds.
175
+ -- | Returns the number of contiguous characters at the beginning
176
+ -- | of the string for which the predicate holds.
176
177
foreign import count :: (Char -> Boolean ) -> String -> Int
177
178
178
179
-- | Returns the substrings of the first string separated along occurences
You can’t perform that action at this time.
0 commit comments