Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let predList =
- [(predicate1, Base.method1);
- (predicate2, method2);
- (predicate4; Derived.method4)
- ...
- ]
- while ... do
- let input = ReadInput
- if IsBase(input)
- then
- let method = List.Find matchingPredicate predList
- let baseObj = ChooseBaseObject(input)
- baseObj.method // ????
- else
- let method = List.Find matchingPredicate predList
- let derivedObj = ChooseDerivedObject(input)
- derivedObj.method // ????
- let wrap_method1 (x :Base) = x.method1()
- let wrap_method2 (x :Base) =
- match x with
- | :? Derived as xd -> xd.method2()
- | _ -> x.method2()
- let wrap_method4 (x :Base) =
- match x with
- | :? Derived as xd -> xd.method4()
- | _ -> ()
- // use
- let predList =
- [(predicate1, wrap_method1);
- (predicate2, wrap_method2);
- ... ]
- while ... do
- let input = ReadInput
- let method = List.Find matchingPredicate predList
- method input
Add Comment
Please, Sign In to add comment