zippoxer Posted October 21, 2011 Share Posted October 21, 2011 None of the examples here work in SCAR: http://rosettacode.org/wiki/Higher-order_functions#Pascal I tried changing assigns to function names to assign to "Result". The only language I ever met that doesn't support it, is Java. There are cases where passing a function as parameter can save blocks of code. I'm in such a case right now. Thanks. Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 21, 2011 Share Posted October 21, 2011 Try this: [scar]program Example; type FnType = function(x: Extended): Extended; function First(f: FnType): Extended; begin Result := f(1.0) + 2.0; end; function Second(x: Extended): Extended; begin Result := x / 2.0; end; begin WriteLn(First(@Second)); end.[/scar] Quote Link to comment Share on other sites More sharing options...
zippoxer Posted October 21, 2011 Author Share Posted October 21, 2011 Try this: [scar]program Example; type FnType = function(x: Extended): Extended; function First(f: FnType): Extended; begin Result := f(1.0) + 2.0; end; function Second(x: Extended): Extended; begin Result := x / 2.0; end; begin WriteLn(First(@Second)); end.[/scar] Pointers? That's great, thanks. Quote Link to comment Share on other sites More sharing options...
FHannes Posted October 21, 2011 Share Posted October 21, 2011 Divi does not support pointers, only function pointers. Pointer support will be in SCAR 4, but it is still in early development. Quote Link to comment Share on other sites More sharing options...