File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -232,8 +232,19 @@ foreign import count :: (Char -> Boolean) -> String -> Int
232232foreign import split :: Pattern -> String -> Array String
233233
234234-- | Returns a string split into two substrings at the given index, where
235- -- | `before` includes all of the characters up to the given index, and `after`
236- -- | is the rest of the string, from the given index on.
235+ -- | `before` includes all of the characters up to (but not including) the
236+ -- | given index, and `after` is the rest of the string, from the given index
237+ -- | on.
238+ -- |
239+ -- | Thus the length of `(splitAt i s).before` will equal either `i` or
240+ -- | `length s`, if that is shorter. (Or if `i` is negative the length will be
241+ -- | 0.)
242+ -- |
243+ -- | In code:
244+ -- | ```purescript
245+ -- | length (splitAt i s).before == min (max i 0) (length s)
246+ -- | (splitAt i s).before <> (splitAt i s).after == s
247+ -- | ```
237248foreign import splitAt :: Int -> String -> { before :: String , after :: String }
238249
239250-- | Converts the string into an array of characters.
You can’t perform that action at this time.
0 commit comments