Skip to content

Commit 51aac60

Browse files
Copy the rest of the comment over
1 parent 268ecda commit 51aac60

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Data/String/CodePoints.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ singletonFallback (CodePoint cp) =
217217
-- | Splits a string into two substrings, where `before` contains the code
218218
-- | points up to (but not including) the given index, and `after` contains the
219219
-- | rest of the string, from that index on.
220+
-- |
221+
-- | Thus the length of `(splitAt i s).before` will equal either `i` or
222+
-- | `length s`, if that is shorter. (Or if `i` is negative the length will be
223+
-- | 0.)
224+
-- |
225+
-- | In code:
226+
-- | ```purescript
227+
-- | length (splitAt i s).before == min (max i 0) (length s)
228+
-- | (splitAt i s).before <> (splitAt i s).after == s
229+
-- | splitAt i s == {before: take i s, after: drop i s}
230+
-- | ```
220231
splitAt :: Int -> String -> { before :: String, after :: String }
221232
splitAt i s =
222233
let before = take i s in

0 commit comments

Comments
 (0)