Guest User

Untitled

a guest
Jan 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. let predList =
  2. [(predicate1, Base.method1);
  3. (predicate2, method2);
  4. (predicate4; Derived.method4)
  5. ...
  6. ]
  7.  
  8. while ... do
  9. let input = ReadInput
  10. if IsBase(input)
  11. then
  12. let method = List.Find matchingPredicate predList
  13. let baseObj = ChooseBaseObject(input)
  14. baseObj.method // ????
  15. else
  16. let method = List.Find matchingPredicate predList
  17. let derivedObj = ChooseDerivedObject(input)
  18. derivedObj.method // ????
  19.  
  20. let wrap_method1 (x :Base) = x.method1()
  21. let wrap_method2 (x :Base) =
  22. match x with
  23. | :? Derived as xd -> xd.method2()
  24. | _ -> x.method2()
  25. let wrap_method4 (x :Base) =
  26. match x with
  27. | :? Derived as xd -> xd.method4()
  28. | _ -> ()
  29.  
  30. // use
  31. let predList =
  32. [(predicate1, wrap_method1);
  33. (predicate2, wrap_method2);
  34. ... ]
  35.  
  36. while ... do
  37. let input = ReadInput
  38. let method = List.Find matchingPredicate predList
  39. method input
Add Comment
Please, Sign In to add comment