Snippets tagged Sequence
Fibonacci sequence
Cached fib sequence
10 people like this
Posted: 1 years ago by Dmitri PavlenkovAsynchronous sequences
An asynchronous sequence is similar to the seq<T> type, but the elements of the sequence are generated asynchronously without blocking the caller as in Async<T>. This snippet declares asynchronous sequence and uses it to compare two files in 1k blocks.
36 people like this
Posted: 1 years ago by Tomas PetricekFunction to generate circular infinite sequence from a list
Function to generate circular infinite sequence from a list
12 people like this
Posted: 1 years ago by Ankur DhamaTake every Nth element of sequence
A function that takes every Nth element of a sequence where N is passed as an argument. The snippet shows a naive function and a function using IEnumerator directly to provide an efficient implementation.
19 people like this
Posted: 1 years ago by Tomas PetricekChronological sequence window beginnings
An abstraction of the following use case: Given a sequence of dates and max temperatures for each date, extract out the initial dates on which the temp is greater than a given threshold for n consecutive days. (Originally posted as an answer to this StackOverflow question: http://stackoverflow.com/questions/5267055 )
10 people like this
Posted: 1 years ago by ildjarnGaussian Random Sequence
Normalized Random sequence generator conforming to the user supplied mean and sigma utilizing a "seed factory" instead of the default time of day. The Gaussian sequence is based on the central limit theory, averages together the flat distribution from the random generator built into .NET. Two examples of using normalRand are given to create infinite sequences of white and brown(ian) noise.
32 people like this
Posted: 1 years ago by Tony LeeSequence Random Permutation
A generic function that randomly permutes the elements of a sequence.
29 people like this
Posted: 1 years ago by Taha HachanaTree using sequences
Tree implementation using sequences.
2 people like this
Posted: 1 years ago by Ankur Dhamaexec with redirected io as sequences
Since F# is my new scripting language, I needed something like Perl's exec but with sequences for Std In and Out.
5 people like this
Posted: 1 years ago by Tony LeeSelect n elements in group from seq
Select n elements in group from seq
1 people like this
Posted: 12 months ago by Ankur Dhama
Incremental (Functional) QuickSort
Functional quicksort inspired by the Haskell Quick Sort at http://www.haskell.org/haskellwiki/Introduction. Since F# lists aren't lazy, uses sequences instead of lists to be haskell like. Roughly O(n) if you Seq.take 1, full on QS if you enumerate the whole thing.
2 people like this
Posted: 11 months ago by Tony LeeRepeat until
Repeatedly call a function until it returns a positive result. Implemented using sequences.
2 people like this
Posted: 10 months ago by Johann DeneuxSeq group continuous matching elements
Seq group continuous matching elements [1;1;1;2;2;2] will become [ [1;1;1] ; [2;2;2] ]
2 people like this
Posted: 10 months ago by Ankur DhamaSplice sequence into other sequence
Splices a sequence into another sequence at a specified index n. Can replace the existing element at n or keep it.
3 people like this
Posted: 9 months ago by Henrik RavnSeq.reduceBallanced function
The function has the same type as Seq.reduce. Instead of reducing elements from the left to the right, it splits the input into two halves, reduces each half separately and then aggregates the results using the given function. This means that the values are aggregated into a ballanced tree, which can save stack space.
2 people like this
Posted: 9 months ago by Tomas PetricekByteString
An initial attempt at creating a ByteString type based on the Haskell version.
1 people like this
Posted: 10 months ago by Ryan RileyLargest Palindrome Number from Product of Two Three Digit Numbers
Here is an improved version twice shorter, than original
35 people like this
Posted: 1 years ago by Nick CanzoneriEnumerableStream
A lazy enumerable/stream of bytes.
8 people like this
Posted: 1 years ago by Ryan RileyNest 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