Snippets tagged sequence

  • Asynchronous sequences

    An asynchronous sequence is similar to the seq type, but the elements of the sequence are generated asynchronously without blocking the caller as in Async. This snippet declares asynchronous sequence and uses it to compare two files in 1k blocks.

    109 people like this

    Posted: 14 years ago by Tomas Petricek

  • Fibonacci sequence

    Cached fib sequence

    16 people like this

    Posted: 13 years ago by Dmitri Pavlenkov

  • Take 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.

    36 people like this

    Posted: 13 years ago by Tomas Petricek

  • Chronological 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 )

    13 people like this

    Posted: 13 years ago by ildjarn

  • exec 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.

    7 people like this

    Posted: 13 years ago by Tony Lee

  • 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.

    3 people like this

    Posted: 13 years ago by Tony Lee

  • Seq group continuous matching elements

    Seq group continuous matching elements [1;1;1;2;2;2] will become [ [1;1;1] ; [2;2;2] ]

    3 people like this

    Posted: 13 years ago by Ankur Dhama

  • Splice 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: 13 years ago by Henrik Ravn

  • Nest 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: 12 years ago by Tomas Petricek

  • Enumerable extraction in query expressions

    Adds "enumerable extraction" support to query expressions

    7 people like this

    Posted: 12 years ago by kvb

  • The Dominator of Array

    The dominator of array A is the value that occurs in more than half of the elements of A. It is a zero-indexed based array consisting of N integers (A [] with N length). To find the index array of the dominator from a A [], we can use a helpful function from Seq module call 'Seq.groupBy' to mitigate the implementation of a solution.

    4 people like this

    Posted: 12 years ago by Joel Huang

  • Convert list of sequences to sequence of lists

    Function to combine the values of a list of sequences into a sequence of lists where each list contains the nth element of the different sequences. It works like zip but for an arbitrary number of sequences and it returns lists instead of tuples. As with zip when one sequence is exhausted any remaining elements in the other sequences are ignored.

    5 people like this

    Posted: 11 years ago by Samuel Bosch

  • Decoder for Google API polylines

    Full source code for my blog entry on this subject - http://chrsb.co/BNqAbM

    1 people like this

    Posted: 10 years ago by Chris Ballard

  • Sequence Random Permutation

    A generic function that randomly permutes the elements of a sequence.

    0 people like this

    Posted: 7 years ago by Taha Hachana

  • Exponentiation by squaring

    Function, what calculates x^n by non-recursive basic exponentiation squaring algorithm. This method uses the bits of the exponent to determine computing powers. Generic parameter x suitable for any type what supports multiplication. I do not suppose existence of inverse operator like "/", thus parameter n must be a positive integer only. It is not difficult to define an extended variant for a type what supports division.

    3 people like this

    Posted: 4 years ago by Pavel Tatarintsev

  • groupAdjacent

    A variation of another snippet "Seq.groupWhen". This one groups adjacent elements based on a predicate that accepts two arguments - the previous and current elements

    2 people like this

    Posted: 1 year ago by Faisal Waris