Task

Pass a function     as an argument     to another function.



Related task

   First-class functions


go => 
  % ...
  L = 1..10,
  L2 = 1..3,
  % ...
 
f1(X) = X**2.
f2(X,A) = X**A + A**X.
 
%
% qsort(List, SortFunction)
% returns a sorted list according to the sort function SortFunction
%
qsort([],_F)   = [].
qsort([H|T],F) = qsort([E : E in T, call(F,E,H)], F) 
                 ++ [H] ++
                 qsort([E : E in T, not call(F,E,H)],F).
 
% sort on length 
sortf(F1,F2) => 
  F1.length < F2.length.