Dear Forum, is there a canonical way in gap to generate lexical closures for functions? The best I could come up with is something like
MakeF:=function () local q; q := ValueGlobal( "q" ); return function(x) return x+q; end; end; which captures the value of the global value of q, so that q:=10; f0:=MakeF(); q:=20 f1:=MakeF(); gives f0(0)=10 and f1(0)=20 and it "sort of works" (and, at least for the cases I have in mind it might be enough) Still, I am asking if there might a better (or canonical) way to implement this? Regards, luca _______________________________________________ Forum mailing list Forum@mail.gap-system.org http://mail.gap-system.org/mailman/listinfo/forum