data-list-zigzag alternatives and similar packages
Based on the "Data" category.
Alternatively, view data-list-zigzag alternatives based on common mentions on social networks and blogs.
-
semantic-source
Parsing, analyzing, and comparing source code across many languages -
lens
Lenses, Folds, and Traversals - Join us on web.libera.chat #haskell-lens -
code-builder
Packages for defining APIs, running them, generating client code and documentation. -
text
Haskell library for space- and time-efficient operations over Unicode text. -
cassava
A CSV parsing and encoding library optimized for ease of use and high performance -
unordered-containers
Efficient hashing-based container types -
compendium-client
Mu (μ) is a purely functional framework for building micro services. -
hashable
A class for types that can be converted to a hash value -
holmes
A reference library for constraint-solving with propagators and CDCL. -
binary
Efficient, pure binary serialisation using ByteStrings in Haskell. -
resource-pool
A high-performance striped resource pooling implementation for Haskell -
primitive
This package provides various primitive memory-related operations. -
discrimination
Fast linear time sorting and discrimination for a large class of data types -
json-autotype
Automatic Haskell type inference from JSON input -
audiovisual
Extensible records, variants, structs, effects, tangles -
IORefCAS
A collection of different packages for CAS based data structures. -
dependent-sum
Dependent sums and supporting typeclasses for comparing and displaying them -
reflection
Reifies arbitrary Haskell terms into types that can be reflected back into terms -
dependent-map
Dependently-typed finite maps (partial dependent products) -
streaming
An optimized general monad transformer for streaming applications, with a simple prelude of functions -
orgmode-parse
Attoparsec parser combinators for parsing org-mode structured text! -
bifunctors
Haskell 98 bifunctors, bifoldables and bitraversables -
safecopy
An extension to Data.Serialize with built-in version control -
protobuf
An implementation of Google's Protocol Buffers in Haskell. -
text-icu
This package provides the Haskell Data.Text.ICU library, for performing complex manipulation of Unicode text. -
scientific
Arbitrary-precision floating-point numbers represented using scientific notation -
uuid-types
A Haskell library for creating, printing and parsing UUIDs
Static code analysis for 29 languages.
Do you think we are missing an alternative of data-list-zigzag or a related project?
README
Data.List.ZigZag
The feature of this module is ZigZag and its class instances. It is an abstract data type and can be constructed / deconstructed by fromList / toList or fromDiagonals / toDiagonals. See the associated documentation for more information.
diagonals :: [[a]] -> [[a]]
Finds the diagonals through a ragged list of lists.
For example, the diagonals of:
[ [0,1,2]
, []
, [3,4]
, [5,6,7]
]
Are:
[ [0]
, [1]
, [3,2]
, [5,4]
, [6]
, [7]
]
Which can be seen intuitively.
This algorithm works by storing a list of tails of rows already seen. To find the next diagonal we take the head of the next row plus the head of each stored tail. The tail remainders are stored plus the remainder of the new row.
If there are no more rows but some remaining tails we then iteratively form diagonals from the heads of each tail until there are no tails remaining.
Applied to the example:
Row | Output | Remaining |
---|---|---|
[0,1,2] |
[0] |
[[1,2]] |
[] |
[1] |
[[2]] |
[3,4] |
[3,2] |
[[4]] |
[5,6,7] |
[5,4] |
[[6,7]] |
x | [6] |
[[7]] |
x | [7] |
[] |
fromDiagonals :: [[a]] -> ZigZag a
Convert a list of diagonals to a ZigZag.
fromDiagonals . toDiagonals = id
toDiagonals . fromDiagonals = id
fromList :: [a] -> ZigZag a
Convert a list to a ZigZag.
fromList . toList = id
toList . fromList = id
toDiagonals :: ZigZag a -> [[a]]
Convert a ZigZag to a list of diagonals.
fromDiagonals . toDiagonals = id
toDiagonals . fromDiagonals = id
toList :: ZigZag a -> [a]
Convert a ZigZag to a list.
fromList . toList = id
toList . fromList = id
ZigZag
A list but with a balanced enumeration of Cartesian product such that
fmap sum (sequence (replicate n (fromList [0..])))
is monotonically increasing.
Example:
sequence [fromList [0,1], fromList [0,1,2]]
= fromDiagonals
[ [[0,0]]
, [[1,0],[0,1]]
, [[1,1],[0,2]]
, [[1,2]]
]
This variation is useful in at least two ways. One, it is not stuck on infinite factors. Two, if the factors are ordered then the product is similarly ordered; this can lend to efficient searching of product elements.
Note that this method fails for the infinitary product even if every factor is known to be non-empty. The first element is known but following it are infinite elements that each draw a second element from one of the infinite factors. A product element drawing a third factor element is never reached.