Snippets tagged collections
Convert a obj list to a typed list without generics
This is used for building things with reflection at runtime. As ConstructorInfo arguments require typed collections, it is necessary when parsing to reflected records to first build up contents and then afterward convert the collected obj[] to a 'a[]. This is finally cast back to obj so it can be used as a ConstructorInfo argument.
18 people like this
Posted: 1 years ago by Rick MinerichVery Fast Permutations
I spent a lot of time this week profiling different permutation functions from various places on the internet. The following was by far the fastest:
4 people like this
Posted: 1 years ago by Rick MinerichPartition a sequence into groups linearly by predicate
Partitions a sequence into groups linearly by predicate. I use this for breaking up my lazy record parsing with sequences into entity-sized chunks which are then easily digestible. Note: Edited back from the previous edit as these were heavily profiled and yield! tends to be slow. Edit #2: Now correctly using "use" instead of "let" for sequence.GetEnumerator () (Thanks Vladimir Matveev)
0 people like this
Posted: 1 years ago by Rick MinerichA failed attempt at evaluating sequence items in terms of a try-with block
A broken code example demonstrating how it's you can't catch a single throwing enumeration and continue with F#'s IEnumerable.
2 people like this
Posted: 1 years ago by Rick Minerich
JoinList
A JoinList is a variation on the list type that offers a constant time append operation.
5 people like this
Posted: 9 months ago by Ryan RileyCircular queue
A circular queue implemented over an array.
3 people like this
Posted: 8 months ago by Johann DeneuxRandom Subset
A function that takes a random subset from a seq<'T>.
0 people like this
Posted: 5 months ago by Taha HachanaNest items of a sequence
A function that nests items of a sequence that do not match a specified predicate under the last item that matches the predicate. The input is a sequence of values and the result is a sequence of pairs where the second element is a list of nested items.
3 people like this
Posted: 4 months ago by Tomas Petricek