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
{ Table data structure, adapted from an example
in "Multiparadigm Data Structures in Leda"
by Tim Budd, 1993
Assumes the list data structure is already defined. }
class Association [X, Y : equality] of equality[Association];
var
key : X;
value : Y;
function equals(argValue : Association[X, Y])->boolean;
begin
return key = argValue.key;
end;
end;
class Table [X, Y : equality] { of equality[Association] };
var
data : List[Association[X, Y]];
function add (newKey : X, newValue : Y);
begin
if ~ defined(data) then
data := List[Association[X, Y]]();
data.add(Association[X, Y](newKey, newValue));
end;
function onEach (theFun : function(X, Y));
begin
if defined(data) then
data.onEach(function (item : Association[X, Y]);
begin
theFun(item.key, item.value);
end);
end;
function items (byRef key : X, byRef value : Y)->relation;
var
element : Association[X, Y];
begin
return defined(data)
& data.items(element)
& unify[X](key, element.key)
& unify[Y](value, element.value);
end;
function includesKey (key : X)->boolean;
var
value : Y;
begin
if items(key, value) then
return true;
return false;
end;
function at (key : X)->Y;
var
value : Y;
begin
if items(key, value) then
return value;
return NIL;
end;
function atPut (key : X, value : Y);
var
element : Association[X, Y];
begin
if defined(data) & data.items(element) & element.key = key then
element.value := value
else
add(key, value);
end;
end;
global(sieve)?
global(limit)?
main :-
write("N=?"), read_token(limit & int),
next_prime(2), nl.
remove_multiples(P,M) :-
cond(M < limit,
(sieve.M <-multiple_of(P),remove_multiples(P,M+P))
).
next_prime(P) :- P < limit, !, SP=sieve.P,
( SP=prime(P),
!,
write(P,' '),
remove_multiples(P,2*P)
;
succeed
),
next_prime(P+1).
next_prime(P).
# A simple program to sum up some numbers
# presented on the command line, from
# Bob Pike's forthcoming book on Limbo.
implement Sum;
include "sys.m";
sys: Sys;
include "draw.m";
Sum: module
{
init: fn(context: ref Draw->Context, argl: list of string);
};
init(context: ref Draw->Context, argl: list of string)
{
sys = load Sys Sys->PATH;
argl = tl argl; # ignore command name
if(len argl == 0){
sys->print("usage: sum numbers....\n");
return;
}
sum := 0.0;
while(argl != nil){
arg := hd argl;
sys->print("%s", arg);
sum += real arg;
argl = tl argl;
if(argl != nil)
sys->print(" + ");
}
sys->print(" = %g\n", sum);
}
;; Simple factorial routine
;; (until I get a better example written)
(defun fact1 (num)
(cond ((not (integerp num)) nil)
((<= num 1) 1)
(t (* num (fact1 (- num 1)))))
)
; Recursive procedure to line, fractalized
to DrawFractalLine :level :length
ifelse :level < 1 [
fd :length] [
DrawFractalLine (sum -1 :level) (quotient :length 3.00)
left 60
DrawFractalLine (sum -1 :level) (quotient :length 3.00)
right 120
DrawFractalLine (sum -1 :level) (quotient :length 3.00)
left 60
DrawFractalLine (sum -1 :level) (quotient :length 3.00)
]
end
; procedure to clear screen and position turtle
to SetupTurtle
cs setpos [-160 -10] right 60 clean
end
; setup turtle then draw Koch's snowflake(5)
SetupTurtle
setpensize [2 2]
repeat 3 [DrawFractalLine 5 330 right 120]
' Find agents owned by the current user
' and remove them (Adapted from examples at
' www.lotus.com)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim agentArray(1 To 10) As NotesAgent
Dim count as Integer
Dim answer as string
count = 0
Set db = session.CurrentDatabase
Forall a In db.Agents
If ( a.Owner = session.UserName ) Then
Set agentArray(count) = a
count = count + 1
If (count > 10) Then
Exit Forall
End If
End If
End Forall
answer = Inputbox$( "You have " & count & " agents. Delete them?" )
If (answer = "y") Or (answer = "yes") Then
Forall a in agentArray
Call a.Remove
End Foreall
End If
-- Simple Lua program that implements the
-- bisection method for solving non-linear equations
function bisect(f,a,b,fa,fb)
write(n," a=",a," fa=",fa," b=",b," fb=",fb,"\n")
local c=(a+b)/2
if abs(a-b) < delta then return c end
n=n+1
local fc=f(c)
if fa*fc < 0 then
return bisect(f,a,c,fa,fc)
else
return bisect(f,c,b,fc,fb)
end
end
-- find root of f in the inverval [a,b].
-- bisection requires that f(a)*f(b) < 0
function solve(f,a,b)
delta=1e-6 -- tolerance
n=0
local z=bisect(f,a,b,f(a),f(b))
write(format("after %d steps, root is %.10g\n",n,z))
end
-- test the bisection code with
-- a function: x^3 - x - 1
function f(x)
return x*x*x - x - 1
end
solve(f,1,2)
h
where
h = 1 fby merge(merge(2 * h, 3 * h), 5 * h);
merge(x,y) = if xx <= yy then xx else yy fi
where
xx = x upon xx <= yy;
yy = y upon yy <= xx;
end;
end;
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.