| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
MCSP.Data.String.Extra
Description
Custom operations for String.
Synopsis
- type Partition a = [String a]
- chars :: String a -> Partition a
- alphabet :: Ord a => String a -> Set a
- occurrences :: Ord a => String a -> Map a Int
- singletons :: Ord a => String a -> Set a
- repeated :: Ord a => String a -> Set a
- hasOneOf :: Ord a => String a -> Set a -> Bool
- module MCSP.Data.String.Extra.Radix
- longestCommonSubstring :: Ord a => String a -> String a -> Maybe (String a)
Partition operations
chars :: String a -> Partition a Source #
O(n) Split the string in substrings of 1 char each.
>>>chars "abcd"[a,b,c,d]
Character set analysis
alphabet :: Ord a => String a -> Set a Source #
O(n lg n) The set of all characters in a string.
>>>alphabet "aabacabd"fromList "abcd"
occurrences :: Ord a => String a -> Map a Int Source #
O(n lg n) The frequency count of each character in a string.
>>>occurrences "aabacabd"fromList [('a',4),('b',2),('c',1),('d',1)]
singletons :: Ord a => String a -> Set a Source #
O(n lg n) The set of singleton characters in a string.
>>>singletons "aabacabd"fromList "cd"
repeated :: Ord a => String a -> Set a Source #
O(n lg n) The set of repeated characters in a string.
>>>repeated "aabacabd"fromList "ab"
hasOneOf :: Ord a => String a -> Set a -> Bool Source #
O(n lg m) Check if at least one of the character of string is present in the given set.
>>>import Data.Set (fromList)>>>hasOneOf "abca" (fromList "bdf")True
>>>import Data.Set (fromList)>>>hasOneOf "xxx" (fromList "bdf")False
Substring analysis
module MCSP.Data.String.Extra.Radix