Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type GenTree<'data> =
- |Leaf of 'data
- |SubTree of GenTree<'data> * 'data * GenTree<'data>
- type Calc =
- |Operator of (float->float->float)
- |Operand of float
- let IsOperator (str:string) =
- match str with
- | "+" | "-" | "x" | "/" -> true
- |_ -> false
- let parseToFloat (str:string list) =
- System.Single.Parse <| System.String.Concat((List.toSeq str))
- let SwapValue (str:string) =
- match str with
- |"+" -> (+)
- |"-" -> (-)
- |"x" -> (*)
- |"/" -> (/)
- |_ -> failwith "Not valid operator"
- let rec ConvertValueTree (list:string list) =
- match list with
- |x::x2::x3::xs when (not (IsOperator x2)) && (not (IsOperator x)) -> x::x2::(ConvertValueTree xs)
- |_ -> failwith "Please insert more information"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement