Welcome to the Dictionary of Programming Languages, a compendium
of computer coding methods assembled to provide information and
aid your appreciation for computer science history.
Browse the dictionary by clicking on a section:
A
B
C
D
E
F
G
H
I
JK
L
M
N
O
P
QR
S
T
UV
WXYZ+
Get a full dump of the dictionary:
List of Names
Short Form
Full Form
produce := procedure(); seq := ["S"]; rhs := ["(", "S", ")", "S"]; i := 1; repeat if Random(1, 10) gt 7 then Insert(~seq, i, i, rhs); else Remove(~seq, i); end if; print #seq gt 0 select &*seq else "eps"; i := Position(seq, "S"); until i eq 0; print "Length:", #seq; end procedure
(* RandomWalk example from Maeder, 1990 *) RandomWalk::usage = "RandomWalk[n] plots a random walk of length n" RandomWalk[n_Integer] := Block[{loc = {0.0, 0.0}, dir, points= Table[0, {n+1}], range = N[{0, 2 Pi}]}, points[[1]] = loc; Do[ dir = Random[Real, range]; loc += {Cos[dir], Sin[dir]}; points[[i]] = loc, {i, 2, n+1}]; Show[ Graphics[{Point[{0,0}], Line[points]}], Framed -> True, AspectRation -> Automatic] ]
/* the Voting example from the Mawl 2.1 Tutorial */ typedef { string name, int nVotes } vote; static [ vote ] tally = [ ]; static int total = 0; session vote { auto form { [ vote ] tally, int total, string castvote } showvote; showvote.put( { tally, total, "Vote" } ); } subsession void AddVote(string name) { ++total; auto int i; for (i = 0; i < tally.length(); ++i) if (tally[i].name == name) { tally[i].nVotes++; return; } tally.append( { name, 1 } ); } session Vote { auto form void -> { string name } getName; AddVote( getName.put().name ); }
% An example of finding primes using a sieve % (adapted from a logic programming benchmark in mercury) :- interface. :- import_module list, int. :- implementation. :- pred primes(int, list(int)). :- mode primes(in, out) is det. :- pred integers(int, int, list(int)). :- mode integers(in, in, out) is det. :- pred sift(list(int), list(int)). :- mode sift(in, out) is det. :- pred remove(int, list(int), list(int)). :- mode remove(in, in, out) is det. primes(Limit, Ps) :- integers(2, Limit, Is), sift(Is, Ps). integers(Low, High, Result) :- ( Low =< High -> M is Low + 1, Result = [Low | Rest], integers(M, High, Rest) ; Result = [] ). sift([], []). sift([I | Is], [I | Ps]) :- remove(I, Is, New), sift(New, Ps). remove(_P, [], []). remove(P, [I | Is], Result) :- M is I mod P, ( M = 0 -> Result = Nis, remove(P, Is, Nis) ; Result = [I | Nis], remove(P, Is, Nis) ).
|| Sorting with the comparison function as a parameter || (adapted from code example by Simon Thompson) sortG :: (* -> * -> bool) -> [*] -> [*] sortG comp (a:x) = sortG comp smaller ++ [a] ++ sortG comp larger where smaller = [ b | b<-x ; comp b a ] larger = [ b | b<-x ; comp a b ] || Example Use CompInt :: (* -> * -> bool) CompInt m n = (m < n) SortG CompInt [3,5,0,12,8,43,7]
fun sort nil = nil : int list | sort(h::t) = let fun insert(i,nil) = [i] | insert(i,h::t) = if i>h then i::h::t else h::insert(i,t) in insert(h, sort t) end; fun mean l = let fun sl(nil ,sum,len) = sum div len | sl(h::t,sum,len) = sl(t,sum+h,len+h) in sl(l,0,0) end; mean(sort [2,3,5,7,11,13] @ [6,14,28] )
MODULE Push EXPORTS Main; IMPORT Trestle, VBT, TextVBT, RigidVBT, ButtonVBT, BorderedVBT, HVSplit, Axis; action of button when pushed PROCEDURE QuitAction (self: ButtonVBT.T; READONLY cd: VBT.MouseRec) = BEGIN Trestle.Delete(main); (* NB. "main" is visible here. *) END QuitAction; CONST horz = 30.0; (* horizontal size "hello" window *) vert = 10.0; (* vertical size of "hello" window *) VAR hello := RigidVBT.FromHV(TextVBT.New("Hello World"), horz, vert); quit := ButtonVBT.New(ch := TextVBT.New("Quit"), action := QuitAction); main := HVSplit.Cons(Axis.T.Ver, hello, BorderedVBT.New(quit)); BEGIN Trestle.Install(main); Trestle.AwaitDelete(main); END Push.
MODULE AlphaRandom; (* Randomize the alphabet, and show how to use the module Shuffle *) (* John Andrea, 1992 *) FROM InOut IMPORT WriteLn, WriteString; FROM Shuffle IMPORT Deck, Create, Next, Reset; VAR d :Deck; i, j, min, max, n :CARDINAL; BEGIN min := ORD( 'a' ); max := ORD( 'z' ); n := max - min + 1; Create( d, min, max ); FOR i := 1 TO 10 DO WriteString( 'random alphabet = ' ); FOR j := 1 TO n DO WriteString( CHR( Next( d ) ) ); END; WriteLn; Reset( d ); END; END AlphaRandom.
; EXAMPLE FROM UC DAVIS LEXICON ;PROGRAM TO CREATE SORTED DICTIONARY READ !,"ENTER NEXT TERM (NULL TO QUIT): ",TERM GOTO:TERM="" LIST READ !,"ENTER ONE LINE DEFINITION: ",DEF SET ^WORD(TERM)=DEF GOTO LEXICON LIST READ !,"WOULD YOU LIKE TERMS LISTED (Y/N)?",YESNO QUIT:YESNO'?1"Y".E SET X="" ;TO GO TO PRINTER ADD 'OPEN 1 USE 1' FOR I=1:1 SET Y=$ORDER(^WORD(X)),X=Y QUIT:X="" WRITE !,Y,?15,^WORD(Y)
Descriptions in this dictionary are ©1997-99 Neal Ziring. Some examples copyright of their respective authors. Some technologies and languages are trademarked. Permission to copy descriptions is granted as long as authorship credit is preserved.
Comments on this dictionary, corrections and suggestions, are all welcome. Please use email, the address is ziring@home.com
[Ziring MicroWeb Home] [Dictionary Start] [Sign Guestbook]
Dictionary and script maintained by Neal Ziring, last major modifications 3/18/98. Most recent additions to dictionary and master list, 1/00.