Code Snippets Pascal

Short texts Pascal 🧑‍💻 Code snippets Pascal ✍️ Reading lists Pascal 👀

Another retro (16-bit) Pseudo Random Number Generators written in Pascal before. Do anything with it.

unit prngs; { Pseudo Random Number Generators written in Pascal } { http://wiki.freepascal.org/Generating_Random_Numbers } interface type algorithm = (rtl, lcg, pcg, xors, mt); dist = (uniform, normal, exponential, gamma, erlang, poisson); { Default uniform distribution random integer range in RTL } { Should be Linear congruential generator (LCG) algorithm } function rnd(const min, max: word): […]

test.pas

// Part of source code on eof IBX Time0 = 31.13ms 8.35ms 9.86ms 8.19ms 8.34ms IBX Time1 = 120.69ms 109.61ms 106.19ms 106.40ms 106.54ms IBX Time2 = 1.13s 1.92s 811.44ms 2.09s 827.45ms IBX Time3 = 5.35ms 13.48ms 5.33ms 14.50ms 6.64ms IBX Time4 = 2.65ms 6.93ms 2.78ms 7.56ms 3.11ms IBX Time5 = 4.43ms 11.53ms 5.27ms 12.84ms 5.07ms […]

dvga.pas

unit dvga; {$G+} { generate 286 instructions — needed for shl 6/8 } { for rect, should I inline the hline routine, and convert the rest to asm? } interface const maxx=319; maxy=199; maxcolors=256; procedure setmcga; procedure settext; procedure pset(x,y:word; col:byte); function pget(x,y:word):byte; function kbhit:boolean; function getkey:char; procedure waitretrace; procedure hline(x,y,len:word; col:byte); procedure vline(x,y,len:word; col:byte); […]

Delphi – Disable extended RTTI

{$IF CompilerVersion >= 21.0} {$WEAKLINKRTTI ON} {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} {$IFEND} {$SetPEFlags 1} // IMAGE_FILE_RELOCS_STRIPPED {$SetPEFlags $20} // IMAGE_FILE_LARGE_ADDRESS_AWARE

A polyglot summation challenge

The summation challenge, extended from the classical a-plus-b problem, is a programming challenge for beginners. A programmer is asked to write a program to read multiple integers separated by whitespace from a single line and then print out their sum. Although not difficult, different solutions to this problem can exhibit different characteristics of programming languages. […]