Skip to content

Instantly share code, notes, and snippets.

@Wilfred
Created December 14, 2018 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wilfred/ad0978bc894201b21ce823bad60a207a to your computer and use it in GitHub Desktop.
Save Wilfred/ad0978bc894201b21ce823bad60a207a to your computer and use it in GitHub Desktop.
type fruit =
| Banana of int
| Apple of int
let fruit_value include_banana f =
match f with
(* Error: The value include_banana is not an instance variable *)
| Banana x when include_banana
| Apple x ->
x
| _ -> 0
let rec sum_fruit include_banana vals =
List.fold_left (fun x f -> x + fruit_value include_banana f) vals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment