RM
Size: a a a
RM
оГ
VZ
R
AH
VZ
RM
AH
RM
AH
AH
RM
R
VK
type InvokeResult =
| Success of obj
| ObjectWasNotAFunction of Type
let dynamicFunction (fn: obj) (args: obj seq) =
let rec dynamicFunctionInternal (next: obj) (args: obj list): InvokeResult =
match args.IsEmpty with
| false ->
let fType = next.GetType()
if FSharpType.IsFunction fType then
let (head, tail) = (args.Head, args.Tail)
let methodInfo =
fType.GetMethods()
|> Seq.filter (fun x -> x.Name = "Invoke" && x.GetParameters().Length = 1)
|> Seq.head
let partialResult = methodInfo.Invoke(next, [| head |])
dynamicFunctionInternal partialResult tail
else
ObjectWasNotAFunction fType
| true ->
Success(next)
dynamicFunctionInternal fn (args |> List.ofSeq)
I
type InvokeResult =
| Success of obj
| ObjectWasNotAFunction of Type
let dynamicFunction (fn: obj) (args: obj seq) =
let rec dynamicFunctionInternal (next: obj) (args: obj list): InvokeResult =
match args.IsEmpty with
| false ->
let fType = next.GetType()
if FSharpType.IsFunction fType then
let (head, tail) = (args.Head, args.Tail)
let methodInfo =
fType.GetMethods()
|> Seq.filter (fun x -> x.Name = "Invoke" && x.GetParameters().Length = 1)
|> Seq.head
let partialResult = methodInfo.Invoke(next, [| head |])
dynamicFunctionInternal partialResult tail
else
ObjectWasNotAFunction fType
| true ->
Success(next)
dynamicFunctionInternal fn (args |> List.ofSeq)
I