active-pattern Questions

2

Solved

I tried googling this but I couldn't find a collection of words that guided me to what I am trying to do. I am trying to solve Project Euler Problem 54, and I have this rather ridiculous function:...
Kiss asked 1/9, 2016 at 3:2

1

Does F# support pattern matching of a discriminated union member instance by criteria other than the Identifier pattern? For example, imagine that I want to match on the underlying shape of the da...

1

Solved

I'm learning F# by writing a recursive descent parser using active patterns. Since all my rules or partial active patterns I need to combine them in different manners, but I'm getting really frust...
Frederiksen asked 25/3, 2014 at 13:14

3

Solved

I've defined an expression tree structure in F# as follows: type Num = int type Name = string type Expr = | Con of Num | Var of Name | Add of Expr * Expr | Sub of Expr * Expr | Mult of Expr ...
Motorbike asked 4/8, 2013 at 21:16

3

Is it possible to use active patterns within discrimated union type declarations? To be more precise, consider the following toy example: type T = | A of int | B let (|Negative|_|) t = matc...
Chapman asked 12/12, 2012 at 14:31

2

Solved

I have a Dictionary over which I initially iterated thusly: myDictionary |> Seq.iter (fun kvp -> doSomething kvp.Key kvp.Value) Later, I discovered that I could make use of the KeyValue act...
Follicle asked 27/11, 2012 at 18:12

4

Solved

This active pattern compiles with F# 2.0: let (|Value|_|) value = // 'a -> 'T option match box value with | :? 'T as x -> Some x | _ -> None but, in F# 3.0, emits the error: Activ...
Trail asked 15/8, 2012 at 22:26

2

Solved

The active pattern in this question fails to compile after upgrading to VS 2012 RTM. It provides a way to do a type test and match a literal within a single pattern. For example: let (|Value|_|) v...
Roseboro asked 16/8, 2012 at 14:28

2

Solved

For an inline function one could create a constraint like: let inline implicit arg = ( ^a : (static member op_Implicit : ^b -> ^a) arg) requiring the given operator or member on the argument...
Clad asked 3/9, 2011 at 10:59

2

Solved

Given the following contrived active pattern: let (|TypeDef|_|) (typeDef:Type) (value:obj) = if obj.ReferenceEquals(value, null) then None else let typ = value.GetType() if typ.IsGenericType &...
Ability asked 21/7, 2011 at 16:37

1

Solved

I defined the active pattern "Expression" as follows: let (|Expression|_|) expression _ = Some(expression) Now I'm trying to use it in this way: match () with | Expression((totalWidth - wLeft -...
Chartres asked 29/5, 2011 at 16:20

1

Solved

I found this useful article on using Active Patterns with Regular Expressions: http://www.markhneedham.com/blog/2009/05/10/f-regular-expressionsactive-patterns/ The original code snippet used in ...
Pose asked 16/4, 2011 at 2:7

3

Solved

I'm not sure if non-static public member active patterns are allowed but you can define them without the compiler complaining. If they are allowed what's the syntax for matching against one? The co...
Salomesalomi asked 2/12, 2009 at 3:52
1

© 2022 - 2024 — McMap. All rights reserved.