0 people like it.
Like the snippet!
Formula Calculator
Simple formula calculator including dynamic unit of measure support. Run as a script in Try F#, and try formula with units like 3m * 3m.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
|
#if INTERACTIVE
#else
namespace global
#endif
type UnitType =
| Empty
| Unit of string * int
| CompositeUnit of UnitType list
static member Create(s,n) =
if n = 0 then Empty else Unit(s,n)
override this.ToString() =
let exponent = function
| Empty -> 0
| Unit(_,n) -> n
| CompositeUnit(_) -> invalidOp ""
let rec toString = function
| Empty -> ""
| Unit(s,n) when n=0 -> ""
| Unit(s,n) when n=1 -> s
| Unit(s,n) -> s + " ^ " + n.ToString()
| CompositeUnit(us) ->
let ps, ns =
us |> List.partition (fun u -> exponent u >= 0)
let join xs =
let s = xs |> List.map toString |> List.toArray
System.String.Join(" ",s)
match ps,ns with
| ps, [] -> join ps
| ps, ns ->
let ns = ns |> List.map UnitType.Reciprocal
join ps + " / " + join ns
match this with
| Unit(_,n) when n < 0 -> " / " + (this |> UnitType.Reciprocal |> toString)
| _ -> toString this
static member ( * ) (v:ValueType,u:UnitType) = UnitValue(v,u)
static member ( * ) (lhs:UnitType,rhs:UnitType) =
let text = function
| Empty -> ""
| Unit(s,n) -> s
| CompositeUnit(us) -> us.ToString()
let normalize us u =
let t = text u
match us |> List.tryFind (fun x -> text x = t), u with
| Some(Unit(s,n) as v), Unit(_,n') ->
us |> List.map (fun x -> if x = v then UnitType.Create(s,n+n') else x)
| Some(_), _ -> raise (new System.NotImplementedException())
| None, _ -> us@[u]
let normalize' us us' =
us' |> List.fold (fun (acc) x -> normalize acc x) us
match lhs,rhs with
| Unit(u1,p1), Unit(u2,p2) when u1 = u2 ->
UnitType.Create(u1,p1+p2)
| Empty, _ -> rhs
| _, Empty -> lhs
| Unit(u1,p1), Unit(u2,p2) ->
CompositeUnit([lhs;rhs])
| CompositeUnit(us), Unit(_,_) ->
CompositeUnit(normalize us rhs)
| Unit(_,_), CompositeUnit(us) ->
CompositeUnit(normalize' [lhs] us)
| CompositeUnit(us), CompositeUnit(us') ->
CompositeUnit(normalize' us us')
| _,_ -> raise (new System.NotImplementedException())
static member Reciprocal x =
let rec reciprocal = function
| Empty -> Empty
| Unit(s,n) -> Unit(s,-n)
| CompositeUnit(us) -> CompositeUnit(us |> List.map reciprocal)
reciprocal x
static member ( / ) (lhs:UnitType,rhs:UnitType) =
lhs * (UnitType.Reciprocal rhs)
static member ( + ) (lhs:UnitType,rhs:UnitType) =
if lhs = rhs then lhs
else invalidOp "Unit mismatch"
and ValueType = decimal
and UnitValue (v:ValueType,u:UnitType) =
new(v:ValueType) = UnitValue(v,Empty)
new(v:ValueType,s:string) = UnitValue(v,Unit(s,1))
member this.Value = v
member this.Unit = u
override this.ToString() = sprintf "%O %O" v u
static member (~-) (v:UnitValue) =
UnitValue(-v.Value,v.Unit)
static member (+) (lhs:UnitValue,rhs:UnitValue) =
UnitValue(lhs.Value+rhs.Value, lhs.Unit+rhs.Unit)
static member (-) (lhs:UnitValue,rhs:UnitValue) =
UnitValue(lhs.Value-rhs.Value, lhs.Unit+rhs.Unit)
static member (*) (lhs:UnitValue,rhs:UnitValue) =
UnitValue(lhs.Value*rhs.Value,lhs.Unit*rhs.Unit)
static member (*) (lhs:UnitValue,rhs:ValueType) =
UnitValue(lhs.Value*rhs,lhs.Unit)
static member (*) (v:UnitValue,u:UnitType) =
UnitValue(v.Value,v.Unit*u)
static member (/) (lhs:UnitValue,rhs:UnitValue) =
UnitValue(lhs.Value/rhs.Value,lhs.Unit/rhs.Unit)
static member (/) (lhs:UnitValue,rhs:ValueType) =
UnitValue(lhs.Value/rhs,lhs.Unit)
static member (/) (v:UnitValue,u:UnitType) =
UnitValue(v.Value,v.Unit/u)
static member Pow (lhs:UnitValue,rhs:UnitValue) =
let isInt x = 0.0M = x - (x |> int |> decimal)
let areAllInts =
List.forall (function (Unit(_,p)) -> isInt (decimal p*rhs.Value) | _ -> false)
let toInts =
List.map (function (Unit(s,p)) -> Unit(s, int (decimal p * rhs.Value)) | _ -> invalidOp "" )
match lhs.Unit, rhs.Unit with
| Empty, Empty ->
let x = (float lhs.Value) ** (float rhs.Value)
UnitValue(decimal x)
| _, Empty when isInt rhs.Value ->
pown lhs (int rhs.Value)
| Unit(s,p1), Empty when isInt (decimal p1*rhs.Value) ->
let x = (float lhs.Value) ** (float rhs.Value)
UnitValue(x |> decimal, Unit(s,int (decimal p1*rhs.Value)))
| CompositeUnit us, Empty when areAllInts us ->
let x = (float lhs.Value) ** (float rhs.Value)
UnitValue(x |> decimal, CompositeUnit(toInts us))
| _ -> invalidOp "Unit mismatch"
static member One = UnitValue(1.0M,Empty)
override this.Equals(that) =
let that = that :?> UnitValue
this.Unit = that.Unit && this.Value = that.Value
override this.GetHashCode() = hash this
interface System.IComparable with
member this.CompareTo(that) =
let that = that :?> UnitValue
if this.Unit = that.Unit then
if this.Value < that.Value then -1
elif this.Value > that.Value then 1
else 0
else invalidOp "Unit mismatch"
[<AutoOpen>]
module Tokenizer =
type token =
| WhiteSpace
| Symbol of char
| OpToken of string
| StrToken of string
| NumToken of string
let (|Match|_|) pattern input =
let m = System.Text.RegularExpressions.Regex.Match(input, pattern)
if m.Success then Some m.Value else None
let matchToken = function
| Match @"^\s+" s -> s, WhiteSpace
| Match @"^\+|^\-|^\*|^\/|^\^" s -> s, OpToken s
| Match @"^=|^<>|^<=|^>=|^>|^<" s -> s, OpToken s
| Match @"^\(|^\)|^\,|^\:" s -> s, Symbol s.[0]
| Match @"^[A-Za-z]+" s -> s, StrToken s
| Match @"^\d+(\.\d+)?|\.\d+" s -> s, s |> NumToken
| _ -> invalidOp "Failed to match token"
let tokenize s =
let rec tokenize' index (s:string) =
if index = s.Length then []
else
let next = s.Substring index
let text, token = matchToken next
token :: tokenize' (index + text.Length) s
tokenize' 0 s
|> List.choose (function WhiteSpace -> None | t -> Some t)
[<AutoOpen>]
module Parser =
type arithmeticOp = Add | Sub | Mul | Div
type formula =
| Neg of formula
| Exp of formula * formula
| ArithmeticOp of formula * arithmeticOp * formula
| Num of UnitValue
let rec (|Term|_|) = function
| Exponent(f1, t) ->
let rec aux f1 = function
| SumOp op::Exponent(f2, t) -> aux (ArithmeticOp(f1,op,f2)) t
| t -> Some(f1, t)
aux f1 t
| _ -> None
and (|SumOp|_|) = function
| OpToken "+" -> Some Add | OpToken "-" -> Some Sub
| _ -> None
and (|Exponent|_|) = function
| Factor(b, OpToken "^"::Exponent(e,t)) -> Some(Exp(b,e),t)
| Factor(f,t) -> Some (f,t)
| _ -> None
and (|Factor|_|) = function
| OpToken "-"::Factor(f, t) -> Some(Neg f, t)
| Atom(f1, ProductOp op::Factor(f2, t)) ->
Some(ArithmeticOp(f1,op,f2), t)
| Atom(f, t) -> Some(f, t)
| _ -> None
and (|ProductOp|_|) = function
| OpToken "*" -> Some Mul | OpToken "/" -> Some Div
| _ -> None
and (|Atom|_|) = function
| Symbol '('::Term(f, Symbol ')'::t) -> Some(f, t)
| Number(n,t) -> Some(n,t)
| Units(u,t) -> Some(Num u,t)
| _ -> None
and (|Number|_|) = function
| NumToken n::Units(u,t) -> Some(Num(u * decimal n),t)
| NumToken n::t -> Some(Num(UnitValue(decimal n)), t)
| _ -> None
and (|Units|_|) = function
| Unit'(u,t) ->
let rec aux u1 = function
| OpToken "/"::Unit'(u2,t) -> aux (u1 / u2) t
| Unit'(u2,t) -> aux (u1 * u2) t
| t -> Some(u1,t)
aux u t
| _ -> None
and (|Int|_|) s =
match System.Int32.TryParse(s) with
| true, n -> Some n
| false,_ -> None
and (|Unit'|_|) = function
| StrToken u::OpToken "^"::OpToken "-"::NumToken(Int p)::t ->
Some(UnitValue(1.0M,UnitType.Create(u,-p)),t)
| StrToken u::OpToken "^"::NumToken(Int p)::t ->
Some(UnitValue(1.0M,UnitType.Create(u,p)),t)
| StrToken u::t ->
Some(UnitValue(1.0M,u), t)
| _ -> None
let parse s =
match tokenize s with
| Term(f,[]) -> f
| _ -> failwith "Failed to parse formula"
let evaluate formula =
let rec eval = function
| Neg f -> - (eval f)
| Exp(b,e) -> (eval b) ** (eval e)
| ArithmeticOp(f1,op,f2) -> arithmetic op (eval f1) (eval f2)
| Num d -> d
and arithmetic = function
| Add -> (+) | Sub -> (-) | Mul -> (*) | Div -> (/)
eval formula
open System.Windows
open System.Windows.Controls
open System.Windows.Input
open System.Windows.Media
[<AutoOpen>]
module Collection =
let toDoubleCollection xs =
let collection = DoubleCollection()
xs |> Seq.iter collection.Add
collection
[<AutoOpen>]
module Resources =
open System.Windows.Shapes
let createBorder color =
Rectangle(
Stretch=Stretch.Fill,
RadiusX=6.0,
RadiusY=6.0,
Stroke=SolidColorBrush(color),
StrokeThickness=6.0,
StrokeLineJoin=PenLineJoin.Round
)
let createDashedBorder color =
let border = createBorder color
border.StrokeDashCap <- PenLineCap.Round
border.StrokeDashArray <- [4.0;3.0] |> toDoubleCollection
border
type Calculator () as this =
inherit UserControl ()
let label =
TextBlock(
Text="Formula Calculator",
Foreground=SolidColorBrush(Colors.Purple),
FontWeight=FontWeights.Bold,
FontSize=18.0,
Margin=Thickness(8.0,8.0,8.0,0.0),
HorizontalAlignment=HorizontalAlignment.Center
)
let formulaText =
TextBox(Text="Enter Formula Here",
BorderThickness=Thickness(0.0),
Margin=Thickness(8.0),
SelectionBackground=SolidColorBrush(Colors.Gray),
SelectionForeground=SolidColorBrush(Colors.White)
)
let makeBorder parent child =
let border = Grid()
do border.Children.Add parent
do border.Children.Add child
border
let (+.) (panel:#Panel) (item) =
panel.Children.Add item |> ignore; panel
let (+@) (grid:Grid) (item,col,row) =
grid.Children.Add item
Grid.SetColumn(item,col)
Grid.SetRow(item,row)
grid
let computeButton =
Button(Content=" = ",
Margin=Thickness(8.0),
HorizontalAlignment=HorizontalAlignment.Right
)
let formulaPanel =
Grid()
+@ (formulaText,0,0)
+@ (computeButton,1,0)
do [GridLength(); GridLength(1.0,GridUnitType.Star)]
|> List.iter (fun x ->
ColumnDefinition(Width=x)
|> formulaPanel.ColumnDefinitions.Add
)
let dashedBorder = createDashedBorder Colors.Red
let formulaPanel = makeBorder dashedBorder formulaPanel
do formulaPanel.Margin <- Thickness(8.0)
let resultBlock =
TextBlock(Text="Result",Margin=Thickness(12.0))
let resultPanel =
resultBlock |> makeBorder (createBorder Colors.Blue)
do resultPanel.Margin <- Thickness(8.0)
let solidBorder = createBorder Colors.Magenta
let layout =
StackPanel()
+. label
+. formulaPanel
+. resultPanel
|> makeBorder solidBorder
let compute _ =
try
parse formulaText.Text
|> evaluate
|> sprintf "%O"
with e -> e.Message
|> (fun s -> resultBlock.Text <- s)
do formulaText.KeyDown.Add (fun e ->
if e.Key = Key.Enter
then compute ()
)
do computeButton.Click.Add compute
do this.Content <- layout
#if INTERACTIVE
open Microsoft.TryFSharp
App.Dispatch (fun() ->
App.Console.ClearCanvas()
Calculator() |> App.Console.Canvas.Children.Add
App.Console.CanvasPosition <- CanvasPosition.Right
)
#endif
|
union case UnitType.Empty: UnitType
union case UnitType.Unit: string * int -> UnitType
Multiple items
val string : value:'T -> string
Full name: Microsoft.FSharp.Core.Operators.string
--------------------
type string = System.String
Full name: Microsoft.FSharp.Core.string
Multiple items
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
union case UnitType.CompositeUnit: UnitType list -> UnitType
type UnitType =
| Empty
| Unit of string * int
| CompositeUnit of UnitType list
override ToString : unit -> string
static member Create : s:string * n:int -> UnitType
static member Reciprocal : x:UnitType -> UnitType
static member ( + ) : lhs:UnitType * rhs:UnitType -> UnitType
static member ( / ) : lhs:UnitType * rhs:UnitType -> UnitType
static member ( * ) : v:ValueType * u:UnitType -> UnitValue
static member ( * ) : lhs:UnitType * rhs:UnitType -> UnitType
Full name: Script.UnitType
type 'T list = List<'T>
Full name: Microsoft.FSharp.Collections.list<_>
static member UnitType.Create : s:string * n:int -> UnitType
Full name: Script.UnitType.Create
val s : string
val n : int
val this : UnitType
override UnitType.ToString : unit -> string
Full name: Script.UnitType.ToString
val exponent : (UnitType -> int)
val invalidOp : message:string -> 'T
Full name: Microsoft.FSharp.Core.Operators.invalidOp
val toString : (UnitType -> string)
System.Int32.ToString() : string
System.Int32.ToString(provider: System.IFormatProvider) : string
System.Int32.ToString(format: string) : string
System.Int32.ToString(format: string, provider: System.IFormatProvider) : string
val us : UnitType list
val ps : UnitType list
val ns : UnitType list
Multiple items
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IEnumerable
interface IEnumerable<'T>
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
member Tail : 'T list
static member Cons : head:'T * tail:'T list -> 'T list
static member Empty : 'T list
Full name: Microsoft.FSharp.Collections.List<_>
val partition : predicate:('T -> bool) -> list:'T list -> 'T list * 'T list
Full name: Microsoft.FSharp.Collections.List.partition
val u : UnitType
val join : (UnitType list -> string)
val xs : UnitType list
val s : string []
val map : mapping:('T -> 'U) -> list:'T list -> 'U list
Full name: Microsoft.FSharp.Collections.List.map
val toArray : list:'T list -> 'T []
Full name: Microsoft.FSharp.Collections.List.toArray
namespace System
Multiple items
type String =
new : value:char -> string + 7 overloads
member Chars : int -> char
member Clone : unit -> obj
member CompareTo : value:obj -> int + 1 overload
member Contains : value:string -> bool
member CopyTo : sourceIndex:int * destination:char[] * destinationIndex:int * count:int -> unit
member EndsWith : value:string -> bool + 2 overloads
member Equals : obj:obj -> bool + 2 overloads
member GetEnumerator : unit -> CharEnumerator
member GetHashCode : unit -> int
...
Full name: System.String
--------------------
System.String(value: nativeptr<char>) : unit
System.String(value: nativeptr<sbyte>) : unit
System.String(value: char []) : unit
System.String(c: char, count: int) : unit
System.String(value: nativeptr<char>, startIndex: int, length: int) : unit
System.String(value: nativeptr<sbyte>, startIndex: int, length: int) : unit
System.String(value: char [], startIndex: int, length: int) : unit
System.String(value: nativeptr<sbyte>, startIndex: int, length: int, enc: System.Text.Encoding) : unit
System.String.Join(separator: string, values: System.Collections.Generic.IEnumerable<string>) : string
System.String.Join<'T>(separator: string, values: System.Collections.Generic.IEnumerable<'T>) : string
System.String.Join(separator: string, [<System.ParamArray>] values: obj []) : string
System.String.Join(separator: string, [<System.ParamArray>] value: string []) : string
System.String.Join(separator: string, value: string [], startIndex: int, count: int) : string
static member UnitType.Reciprocal : x:UnitType -> UnitType
val v : ValueType
type ValueType = decimal
Full name: Script.ValueType
Multiple items
type UnitValue =
interface IComparable
new : v:ValueType -> UnitValue
new : v:ValueType * u:UnitType -> UnitValue
new : v:ValueType * s:string -> UnitValue
override Equals : that:obj -> bool
override GetHashCode : unit -> int
override ToString : unit -> string
member Unit : UnitType
member Value : ValueType
static member Pow : lhs:UnitValue * rhs:UnitValue -> UnitValue
...
Full name: Script.UnitValue
--------------------
new : v:ValueType -> UnitValue
new : v:ValueType * s:string -> UnitValue
new : v:ValueType * u:UnitType -> UnitValue
val lhs : UnitType
val rhs : UnitType
val text : (UnitType -> string)
System.Object.ToString() : string
val normalize : (UnitType list -> UnitType -> UnitType list)
val t : string
val tryFind : predicate:('T -> bool) -> list:'T list -> 'T option
Full name: Microsoft.FSharp.Collections.List.tryFind
val x : UnitType
union case Option.Some: Value: 'T -> Option<'T>
val v : UnitType
val n' : int
static member UnitType.Create : s:string * n:int -> UnitType
val raise : exn:System.Exception -> 'T
Full name: Microsoft.FSharp.Core.Operators.raise
Multiple items
type NotImplementedException =
inherit SystemException
new : unit -> NotImplementedException + 2 overloads
Full name: System.NotImplementedException
--------------------
System.NotImplementedException() : unit
System.NotImplementedException(message: string) : unit
System.NotImplementedException(message: string, inner: exn) : unit
union case Option.None: Option<'T>
val normalize' : (UnitType list -> UnitType list -> UnitType list)
val us' : UnitType list
val fold : folder:('State -> 'T -> 'State) -> state:'State -> list:'T list -> 'State
Full name: Microsoft.FSharp.Collections.List.fold
val acc : UnitType list
val u1 : string
val p1 : int
val u2 : string
val p2 : int
static member UnitType.Reciprocal : x:UnitType -> UnitType
Full name: Script.UnitType.Reciprocal
val reciprocal : (UnitType -> UnitType)
Multiple items
val decimal : value:'T -> decimal (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.decimal
--------------------
type decimal = System.Decimal
Full name: Microsoft.FSharp.Core.decimal
--------------------
type decimal<'Measure> = decimal
Full name: Microsoft.FSharp.Core.decimal<_>
val this : UnitValue
member UnitValue.Value : ValueType
Full name: Script.UnitValue.Value
member UnitValue.Unit : UnitType
Full name: Script.UnitValue.Unit
override UnitValue.ToString : unit -> string
Full name: Script.UnitValue.ToString
val sprintf : format:Printf.StringFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf
val v : UnitValue
property UnitValue.Value: ValueType
property UnitValue.Unit: UnitType
val lhs : UnitValue
val rhs : UnitValue
val rhs : ValueType
static member UnitValue.Pow : lhs:UnitValue * rhs:UnitValue -> UnitValue
Full name: Script.UnitValue.Pow
val isInt : (decimal -> bool)
val x : decimal
val areAllInts : (UnitType list -> bool)
val forall : predicate:('T -> bool) -> list:'T list -> bool
Full name: Microsoft.FSharp.Collections.List.forall
val p : int
val toInts : (UnitType list -> UnitType list)
val x : float
Multiple items
val float : value:'T -> float (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.float
--------------------
type float = System.Double
Full name: Microsoft.FSharp.Core.float
--------------------
type float<'Measure> = float
Full name: Microsoft.FSharp.Core.float<_>
val pown : x:'T -> n:int -> 'T (requires member get_One and member ( * ) and member ( / ))
Full name: Microsoft.FSharp.Core.Operators.pown
static member UnitValue.One : UnitValue
Full name: Script.UnitValue.One
override UnitValue.Equals : that:obj -> bool
Full name: Script.UnitValue.Equals
val that : obj
val that : UnitValue
override UnitValue.GetHashCode : unit -> int
Full name: Script.UnitValue.GetHashCode
val hash : obj:'T -> int (requires equality)
Full name: Microsoft.FSharp.Core.Operators.hash
Multiple items
type IComparable<'T> =
member CompareTo : other:'T -> int
Full name: System.IComparable<_>
--------------------
type IComparable =
member CompareTo : obj:obj -> int
Full name: System.IComparable
override UnitValue.CompareTo : that:obj -> int
Full name: Script.UnitValue.CompareTo
Multiple items
type AutoOpenAttribute =
inherit Attribute
new : unit -> AutoOpenAttribute
new : path:string -> AutoOpenAttribute
member Path : string
Full name: Microsoft.FSharp.Core.AutoOpenAttribute
--------------------
new : unit -> AutoOpenAttribute
new : path:string -> AutoOpenAttribute
type token =
| WhiteSpace
| Symbol of char
| OpToken of string
| StrToken of string
| NumToken of string
Full name: Script.Tokenizer.token
union case token.WhiteSpace: token
union case token.Symbol: char -> token
Multiple items
val char : value:'T -> char (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.char
--------------------
type char = System.Char
Full name: Microsoft.FSharp.Core.char
union case token.OpToken: string -> token
union case token.StrToken: string -> token
union case token.NumToken: string -> token
val pattern : string
val input : string
val m : System.Text.RegularExpressions.Match
namespace System.Text
namespace System.Text.RegularExpressions
Multiple items
type Regex =
new : pattern:string -> Regex + 1 overload
member GetGroupNames : unit -> string[]
member GetGroupNumbers : unit -> int[]
member GroupNameFromNumber : i:int -> string
member GroupNumberFromName : name:string -> int
member IsMatch : input:string -> bool + 1 overload
member Match : input:string -> Match + 2 overloads
member Matches : input:string -> MatchCollection + 1 overload
member Options : RegexOptions
member Replace : input:string * replacement:string -> string + 5 overloads
...
Full name: System.Text.RegularExpressions.Regex
--------------------
System.Text.RegularExpressions.Regex(pattern: string) : unit
System.Text.RegularExpressions.Regex(pattern: string, options: System.Text.RegularExpressions.RegexOptions) : unit
System.Text.RegularExpressions.Regex.Match(input: string, pattern: string) : System.Text.RegularExpressions.Match
System.Text.RegularExpressions.Regex.Match(input: string, pattern: string, options: System.Text.RegularExpressions.RegexOptions) : System.Text.RegularExpressions.Match
property System.Text.RegularExpressions.Group.Success: bool
property System.Text.RegularExpressions.Capture.Value: string
val matchToken : _arg1:string -> string * token
Full name: Script.Tokenizer.matchToken
active recognizer Match: string -> string -> string option
Full name: Script.Tokenizer.( |Match|_| )
val tokenize : s:string -> token list
Full name: Script.Tokenizer.tokenize
val tokenize' : (int -> string -> token list)
val index : int
property System.String.Length: int
val next : string
System.String.Substring(startIndex: int) : string
System.String.Substring(startIndex: int, length: int) : string
val text : string
Multiple items
val token : token
--------------------
type token =
| WhiteSpace
| Symbol of char
| OpToken of string
| StrToken of string
| NumToken of string
Full name: Script.Tokenizer.token
val choose : chooser:('T -> 'U option) -> list:'T list -> 'U list
Full name: Microsoft.FSharp.Collections.List.choose
val t : token
type arithmeticOp =
| Add
| Sub
| Mul
| Div
Full name: Script.Parser.arithmeticOp
union case arithmeticOp.Add: arithmeticOp
union case arithmeticOp.Sub: arithmeticOp
union case arithmeticOp.Mul: arithmeticOp
union case arithmeticOp.Div: arithmeticOp
type formula =
| Neg of formula
| Exp of formula * formula
| ArithmeticOp of formula * arithmeticOp * formula
| Num of UnitValue
Full name: Script.Parser.formula
union case formula.Neg: formula -> formula
union case formula.Exp: formula * formula -> formula
union case formula.ArithmeticOp: formula * arithmeticOp * formula -> formula
union case formula.Num: UnitValue -> formula
active recognizer Exponent: token list -> (formula * token list) option
Full name: Script.Parser.( |Exponent|_| )
val f1 : formula
val t : token list
val aux : (formula -> token list -> (formula * token list) option)
active recognizer SumOp: token -> arithmeticOp option
Full name: Script.Parser.( |SumOp|_| )
val op : arithmeticOp
val f2 : formula
active recognizer Factor: token list -> (formula * token list) option
Full name: Script.Parser.( |Factor|_| )
val b : formula
val e : formula
val f : formula
active recognizer Atom: token list -> (formula * token list) option
Full name: Script.Parser.( |Atom|_| )
active recognizer ProductOp: token -> arithmeticOp option
Full name: Script.Parser.( |ProductOp|_| )
active recognizer Term: token list -> (formula * token list) option
Full name: Script.Parser.( |Term|_| )
active recognizer Number: token list -> (formula * token list) option
Full name: Script.Parser.( |Number|_| )
val n : formula
active recognizer Units: token list -> (UnitValue * token list) option
Full name: Script.Parser.( |Units|_| )
val u : UnitValue
val n : string
active recognizer Unit': token list -> (UnitValue * token list) option
Full name: Script.Parser.( |Unit'|_| )
val aux : (UnitValue -> token list -> (UnitValue * token list) option)
val u1 : UnitValue
val u2 : UnitValue
type Int32 =
struct
member CompareTo : value:obj -> int + 1 overload
member Equals : obj:obj -> bool + 1 overload
member GetHashCode : unit -> int
member GetTypeCode : unit -> TypeCode
member ToString : unit -> string + 3 overloads
static val MaxValue : int
static val MinValue : int
static member Parse : s:string -> int + 3 overloads
static member TryParse : s:string * result:int -> bool + 1 overload
end
Full name: System.Int32
System.Int32.TryParse(s: string, result: byref<int>) : bool
System.Int32.TryParse(s: string, style: System.Globalization.NumberStyles, provider: System.IFormatProvider, result: byref<int>) : bool
val u : string
active recognizer Int: string -> int option
Full name: Script.Parser.( |Int|_| )
val parse : s:string -> formula
Full name: Script.Parser.parse
val failwith : message:string -> 'T
Full name: Microsoft.FSharp.Core.Operators.failwith
val evaluate : formula:formula -> UnitValue
Full name: Script.Parser.evaluate
Multiple items
val formula : formula
--------------------
type formula =
| Neg of formula
| Exp of formula * formula
| ArithmeticOp of formula * arithmeticOp * formula
| Num of UnitValue
Full name: Script.Parser.formula
val eval : (formula -> UnitValue)
val arithmetic : (arithmeticOp -> UnitValue -> UnitValue -> UnitValue)
val d : UnitValue
namespace System.Windows
val toDoubleCollection : xs:seq<'a> -> 'b
Full name: Script.Collection.toDoubleCollection
val xs : seq<'a>
val collection : 'b
module Seq
from Microsoft.FSharp.Collections
val iter : action:('T -> unit) -> source:seq<'T> -> unit
Full name: Microsoft.FSharp.Collections.Seq.iter
val createBorder : color:'a -> 'b
Full name: Script.Resources.createBorder
val color : 'a
val createDashedBorder : color:'a -> 'b
Full name: Script.Resources.createDashedBorder
val border : 'b
Multiple items
type Calculator =
inherit obj
new : unit -> Calculator
Full name: Script.Calculator
--------------------
new : unit -> Calculator
val this : Calculator
val ignore : value:'T -> unit
Full name: Microsoft.FSharp.Core.Operators.ignore
val iter : action:('T -> unit) -> list:'T list -> unit
Full name: Microsoft.FSharp.Collections.List.iter
More information