[fpc-devel] Little feature teaser
Dmitry Boyarintsev
skalogryz.lists at gmail.com
Tue Aug 6 04:24:03 CEST 2013
Does a debugger understands that?
On Friday, August 2, 2013, Sven Barth wrote:
> Hello together!
>
> Just a little feature teaser what I'm currently working on when I find the
> time. :)
>
> === 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]));
> Writeln(specialize IsIn<String>('Foobar', ['Foo', 'Bar', 'Blubber']));
> end.
>
> === source end ===
>
> === console begin ===
>
> PS D:\svn\fpc> .\compiler\i386\pp.exe -n -Furtl\units\i386-win32
> -FEtestoutput -viwn .\fpctests\tgenfuncs.pas
> Target OS: Win32 for i386
> Compiling .\fpctests\tgenfuncs.pas
> Linking testoutput\tgenfuncs.exe
> 19 lines compiled, 0.3 sec, 32224 bytes code, 1204 bytes data
> PS D:\svn\fpc> .\testoutput\tgenfuncs.exe
> TRUE
> FALSE
> FALSE
>
> === console end ===
>
> Regards,
> Sven
> ______________________________**_________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/**mailman/listinfo/fpc-devel<http://lists.freepascal.org/mailman/listinfo/fpc-devel>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130805/90098d99/attachment.html>
More information about the fpc-devel
mailing list