On Fri, 02 Aug 2013 13:18:53 +0200 Sven Barth <pascaldra...@googlemail.com> wrote:
>[...] > === source begin === > > program tgenfuncs; > > {$modeswitch result} > > generic function IsIn<T>(aElement: T; const aArray: array of T): Boolean; > var > elem: T; > begin > for elem in aArray do > if elem = aElement then > Exit(True); > Result := False; > end; > > begin > Writeln(specialize IsIn<LongInt>(42, [21, 42, 84])); > Writeln(specialize IsIn<LongInt>(5, [21, 42, 84])); What is the speed? Is it much slower compared to a line of "if (aElement=val) or (..)... then" or a "case" statement? What about code size? > Writeln(specialize IsIn<String>('Foobar', ['Foo', 'Bar', 'Blubber'])); > end. Mattias _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel