Questions tagged [quotations]

Code quotations, a language feature that enables you to generate and work with F# code expressions programmatically. This feature lets you generate an abstract syntax tree that represents F# code.

Code quotations, a language feature that enables you to generate and work with F# code expressions programmatically. This feature lets you generate an abstract syntax tree that represents F# code.

For more information about F# quotations, please visit its MSDN page.

190 questions
7
votes
1 answer

What is the difference between single, double, and triple quotes in Python?

In other words, how do I know which one to use? I know when I use strings. I would do string = "This is a string" When would I use ' ' or """ """?
7
votes
1 answer

What is the most up to date way to compile code quotations in F#

I'm building a symbolic derivative engine. For example let f = <@ fun x:double -> x * x @> let df = der f and the resulting expression will be <@ 2 * x @> The actual equations could be arbitrarily complex. The generation of the derivatives are not…
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
6
votes
2 answers

Partial applications of F# Quotations

Let's say I have this Quotation of type Quotations.Expr<(int -> int -> int)> <@ fun x y -> x + y @> I want to create a function fun reduce x expr that when called as reduce 1 expr would essentially yield <@ fun y -> 1 + y @> i.e. I want to…
tejas
  • 607
  • 6
  • 11
6
votes
3 answers

What are F# quotations?

What are "quotations" in F#, and what are they used for?
6
votes
1 answer

Generating parameterized F# quotations

Let's say we have a simple F# quotation: type Pet = { Name : string } let exprNonGeneric = <@@ System.Func(fun (x : Pet) -> x.Name) @@> The resulting quotation is like: val exprNonGeneri : Expr = NewDelegate (System.Func`2[[FSI_0152+Pet,…
Vagif Abilov
  • 9,835
  • 8
  • 55
  • 100
6
votes
1 answer

Composing quoted functions using computation expressions

I've looked around and struggled to get an answer to this; I'm sure there's an obvious answer but I just can't seem to find it; or I've hit a limitation of quotations that I can't pass when used with computation expressions. Basically I want to work…
akara
  • 396
  • 2
  • 7
6
votes
3 answers

How to get a name of a variable coming into a function as a parameter using F#?

Is there any way in F# how to get a name of a variable passed into a function? Example: let velocity = 5 let fn v = v.ParentName let name = fn velocity // this would return "velocity" as a string Thank you in advance EDIT: Why this code does not…
Oldrich Svec
  • 4,191
  • 2
  • 28
  • 54
5
votes
1 answer

How to use escape character in replace function when replacing quotations in VB

Here is my code snippet: Public Function convert(ByVal robert As String) Try robert = Replace(robert, "U", "A") robert = Replace(robert, "\"", "A") I want to actually replace the "quotations" with the A but the…
Robert
  • 83
  • 1
  • 1
  • 5
5
votes
3 answers

What is the best way to markup a testimonial in XHTML?

I used to just use p and span elements for this... but I'm always pushing to use the right elements, and this is something I haven't really thought about before with regard to testimonials. This is what I had in mind...
alex
  • 479,566
  • 201
  • 878
  • 984
5
votes
3 answers

Call a function from its name as a string in f#

I thought that I might be able to do this with quotations - but I can't see how. Should I just use a table of the functions with their names - or is their a way of doing this? Thanks. For more info...... I'm calling a lot of f# functions from excel…
b1g3ar5
  • 335
  • 2
  • 9
5
votes
1 answer

How to Get the F# Name of a Module, Function, etc. From Quoted Expression Match

I continue to work on a printer for F# quoted expressions, it doesn't have to be perfect, but I'd like to see what is possible. The active patterns in Microsoft.FSharp.Quotations.Patterns and Microsoft.FSharp.Quotations.DerivedPatterns used for…
Stephen Swensen
  • 22,107
  • 9
  • 81
  • 136
5
votes
1 answer

Parametric LINQ query

This is another take on accessing dynamic objects in F# There I'm using let y = x.Where(fun x -> x.City ="London").Select("new(City,Zip)") to parametrize the query and extract the necessary items. These would correspond to columns in an SQL query,…
s952163
  • 6,276
  • 4
  • 23
  • 47
5
votes
4 answers

How can I extract all quotations in a text?

I'm looking for a SimpleGrepSedPerlOrPythonOneLiner that outputs all quotations in a text. Example 1: echo “HAL,” noted Frank, “said that everything was going extremely well.” | SimpleGrepSedPerlOrPythonOneLiner stdout: "HAL," "said that…
secr
  • 2,743
  • 3
  • 20
  • 20
5
votes
1 answer

Is this an F# quotations bug?

[] let rec x = (fun() -> x + "abc") () The sample code with the recursive value above produces the following F# compiler error: error FS0432: [] terms cannot contain uses of the prefix splice operator…
controlflow
  • 6,667
  • 1
  • 31
  • 55
5
votes
3 answers

How to implement null-safe operator in F#

I was wondering if you can add something like a "null-safe"-operator in F#. I know that there might be plans for such an operator in C# for the next bigger release. If there is no way to achieve such a behaviour, is there a way to wrap a statement…
1
2
3
12 13