Anyone know of a partial function application library for Delphi?
Anyone know of a partial function application library for Delphi?
Basically something like Boost.Bind:
function MakeStr(i: integer; s: string): string;
begin
result := IntToHex(i, 4) + '-' + s;
end;
var
f: TFunc;
g: TFunc;
begin
f := Functional.Bind(MakeStr, _1, 'foo');
WriteLn(f(42)); // output: 002A-foo
g := Functional.Bind(MakeStr, 42, _1);
WriteLn(g('bar')); // output: 002A-bar
end.
Just so I don't have ot reinvent the wheel :)
http://paste.ie/view/9aec29b5
Basically something like Boost.Bind:
function MakeStr(i: integer; s: string): string;
begin
result := IntToHex(i, 4) + '-' + s;
end;
var
f: TFunc
g: TFunc
begin
f := Functional.Bind
WriteLn(f(42)); // output: 002A-foo
g := Functional.Bind
WriteLn(g('bar')); // output: 002A-bar
end.
Just so I don't have ot reinvent the wheel :)
http://paste.ie/view/9aec29b5
Comments
Post a Comment