| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.PrimitiveArray.Index.Subword
Description
Index structure for context-free grammars on strings. A Subword captures
a pair (i,j) with i<=j.
Documentation
A subword wraps a pair of Int indices i,j with i<=j.
Subwords always yield the upper-triangular part of a rect-angular array.
This gives the quite curious effect that (0,N) points to the
``largest'' index, while (0,0) ... (1,1) ... (k,k) ... (N,N) point to
the smallest. We do, however, use (0,0) as the smallest as (0,k) gives
successively smaller upper triangular parts.
Constructors
| Subword | |
Fields
| |
Instances
| Eq Subword | |
| Ord Subword | |
| Read Subword | |
| Show Subword | |
| Generic Subword | |
| Arbitrary Subword | |
| ToJSON Subword | |
| FromJSON Subword | |
| Binary Subword | |
| Serialize Subword | |
| NFData Subword | |
| Unbox Subword | |
| IndexStream Subword | |
| Index Subword | |
| Vector Vector Subword | |
| MVector MVector Subword | |
| IndexStream z => IndexStream ((:.) z Subword) | |
| type Rep Subword | |
| data Vector Subword = V_Subword (Vector (Int, Int)) | |
| data MVector s0 Subword = MV_Subword (MVector s (Int, Int)) |
triangularNumber :: Int -> Int Source
triangular numbers
A000217
upperTri :: Subword -> Int Source
Size of an upper triangle starting at i and ending at j. "(0,N)" what
be the normal thing to use.
subwordIndex :: Subword -> Subword -> Int Source
Subword indexing. Given the longest subword and the current subword, calculate a linear index "[0,..]". "(l,n)" in this case means "l"ower bound, length "n". And "(i,j)" is the normal index.
TODO probably doesn't work right with non-zero base ?!
subwordFromIndex :: Subword -> Int -> Subword Source