Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type LineItem = {Cost: decimal option; Price: decimal option; Qty: decimal option}
- let discount = 0.25M
- let createItem (c, p, q) =
- {Cost = c; Price = p; Qty = q}
- let items =
- [
- (Some 1M , None , Some 1M)
- (Some 3M , Some 2.0M , None)
- (Some 5M , Some 3.0M , Some 5M)
- (None , Some 1.0M , Some 2M)
- (Some 11M , Some 2.0M , None)
- ]
- |> List.map createItem
- items
- |> Seq.map (fun line -> line.Price
- |> Option.map (fun x -> discount * x))
- val it : seq<decimal option> =
- seq [null; Some 0.500M; Some 0.750M; Some 0.250M; ...]
- items
- |> Seq.map (fun line -> line.Price
- |> Option.map (fun x -> discount * x)
- |> Option.map (fun x -> x - (line.Cost
- |> Option.map (fun x -> x)))
- |> Option.map (fun x -> x * (line.Qty
- |> Option.map (fun x -> x))))
- error FS0001: Type constraint mismatch. The type
- 'a option
- is not compatible with type
- decimal
- The type ''a option' is not compatible with the type 'decimal'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement