Snippets tagged quotations

  • Traverse quotation

    Shows how to use the 'ExprShape' module to recursively traverse an entire quotation and how to write quotation transformations. As an example, the snippet replaces all numeric constants in the quotation and then runs the transformed code.

    24 people like this
    Posted: 3 years ago by Tomas Petricek

  • Supercompilation using quotations

    This code sample shows how to create a function that raises number to a given power using supercompilation with quotations. For any given power, the function returns quoted expression for calculating the power using explicit multiplications, which is then evaluated.

    19 people like this
    Posted: 3 years ago by Dmitry Soshnikov

  • Transform expressions into Excel formulae

    Sometimes it is extremely useful to check some calculations with Excel. The snippet shows how F# expressions can be transformed into Excel formulae. The data is exported together with the formulae, e.g. a, b and sum function as input sets A1's value to a, B1's to b and C1's formula to "=$A$1+$B$1"

    17 people like this
    Posted: 2 years ago by Natallie Baikevich

  • Clojure-like lambda function syntax

    This snippet implements a Clojure-like lambda function syntax using Code Quotations. However, this implementation is slow and, moreover, not type-safe. So I'm looking for a way to solve the issues.

    5 people like this
    Posted: 3 years ago by einblicker

  • Expanding quotations

    The snippet implements a function "expand" that takes a quotation and performs two operations. It replaces all calls to methods marked with ReflectedDefinition with the body of the method and it simplifies all expressions that can be reduced in call-by-name style (let binding & application of lambda).

    3 people like this
    Posted: 2 years ago by Tomas Petricek

  • Translating quotations to LINQ

    A sample that translates simple F# quotations (method calls, property getters) to stnadard C# LINQ expression trees.

    7 people like this
    Posted: 2 years ago by Tomas Petricek

  • Compiling quotations

    Demonstrates how to compose code at run time using F# quotations (both typed and untyped) and how to compile and run the quotation using F# PowerPack API.

    49 people like this
    Posted: 3 years ago by Tomas Petricek

  • Declarative validation

    Simple combinator library to declarative validation.

    6 people like this
    Posted: 2 years ago by Kaspar

  • Mocking library

    F# Mocking library with a fluent interface Moq users should find familiar. Generate mocks for interfaces and abstract types. Supports mocking methods, properties and events. Specify arguments as wildcards or values to match. Define results as values, computed values or exceptions.

    5 people like this
    Posted: 2 years ago by Phillip Trelford

  • Eval Quotations

    Evaluates a useful subset of F# quotations at run-time (without the F# PowerPack API).

    7 people like this
    Posted: 1 years ago by Phillip Trelford

  • In-list / contains expression

    Filter by list of properties when provider supports filter expressions but doesn't support Contains. Equivalent C# : https://gist.github.com/mausch/6893533

    2 people like this
    Posted: 1 years ago by Mauricio Scheffer

  • Using Expressions to Clone F# Values

    How to generate functions for copying F# record-array-union trees with Expr.

    0 people like this
    Posted: 5 months ago by Rick Minerich