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
# Some S code to plot concentric convex hulls
# around some data, from the documentation for
# the chull function.
drawhull <- function(xvec, yvec, ltype)
{
polygon(xvec, yvec, density=0, lty=ltype)
}
p <- chull(corn.rain, corn.yield, peel=T)
which <- rep(seq(p$count), p$count)
s <- split(p$hull, which)
plot(corn.rain, corn.yield, pch="X")
for(i in seq(s)) {
j <- s[[i]]
if (length(j) > 2)
drawhull(corn.rain[j], corn.yield[j], i)
}
-- Still working on a good code example here...
-- A simple class from the Sather Essential manual
class POINT is
attr x,y:INT;
create(x,y:INT):POINT is
res:POINT := new; res.x := x; res.y := y; return res;
end;
add(xval,yval:INT):POINT is
xsum:INT := x xval;
ysum:INT := y yval;
res:POINT := #POINT(xsum, ysum);
return res;
end;
offset_by(val:INT):POINT is
return add(val,val);
end;
end;
;;; takes two sorted lists merges them
(define (merge! a b less?)
(define (loop r a b)
(if (less? (car b) (car a))
(begin
(set-cdr! r b)
(if (null? (cdr b))
(set-cdr! b a)
(loop b a (cdr b)) ))
;; (car a) <= (car b)
(begin
(set-cdr! r a)
(if (null? (cdr a))
(set-cdr! a b)
(loop a (cdr a) b)) )) )
(cond
((null? a) b)
((null? b) a)
((less? (car b) (car a))
(if (null? (cdr b))
(set-cdr! b a)
(loop b a (cdr b)))
b)
(else ; (car a) <= (car b)
(if (null? (cdr a))
(set-cdr! a b)
(loop a (cdr a) b))
a)))
$ A SETL program to do the sieve of
$ Erastothenes (probably badly, but its my first
$ SETL program)
program sieve;
read(mx);
primes := {};
(for x in [3..mx] | odd x)
primes with:= x;
end;
(for x in [3..ceil(mx / 2)] | odd x)
primes := sieve1(x, primes);
end;
print(primes);
proc sieve1(rd n, rd pset);
(for x in pset | n < x and x mod n = 0)
pset less:= x;
end;
return pset;
end proc sieve1;
end program sieve;
#!/bin/sh
# Simple shell script to count files of size
# greater than 1k
if [ -z "$1" ]
then
pat="*"
else
pat="$1"
fi
cnt=0
for fname in $pat
do
if [ -r $fname -a ! -d $fname ]
then
size=`cat $fname | wc -c`
if [ $size -gt 1024 ]
then
echo $fname ' ' $size
cnt=`expr $cnt 1`
fi
fi
done
echo "${pat}: Files bigger than 1K: $cnt"
exit
Preamble
'' A simple telephone system model - CACI Products Company
'' files: TELPHN1.SRC
Normally mode is integer
Processes include
GENERATOR
Every INCOMING.CALL has
a CALL.ID
Define NUMBER.BUSY and
LOST.CALLS
as integer variables
End ''Preamble
Main
Activate a GENERATOR now
Start simulation
Print 1 line with LOST.CALLS thus
15 phone calls were made and ** were lost due to busy lines
End ''Main
Process GENERATOR
For I = 1 to 15 do
Activate a INCOMING.CALL now
Let CALL.ID(INCOMING.CALL) = I
Wait uniform.f (2.0, 6.0, 1) minutes
Loop
End ''GENERATOR
Process INCOMING.CALL
If NUMBER.BUSY < 2
Add 1 to NUMBER.BUSY
Wait uniform.f(6.0, 10.0, 2) minutes
Subtract 1 from NUMBER.BUSY
Else
Add 1 to LOST.CALLS
Endif
End ''INCOMING.CALL
Class Line(a,b,c); real a,b,c;
begin
boolean procedure parallelto(l); ref(Line) l;
if l =/= none then
parallelto := abs(a*l.b - b* l.a) < 0.00001;
ref(Point) procedure meets(l); ref(Line) l;
begin real t;
if l =/= none and ~parallelto(l) then
begin
t := 1/(l.a * b - l.b * a);
*** complicated expressions omitted below ***
meets :- new Point(..., ...);
end;
end; ***meets***
real d;
d := sqrt(a**2 b**2);
if d = 0.0 then error else
begin
d := 1/d;
a := a * d; b := b * d; c := c * d;
end;
end *** Line***
// an example from the Sina/st 3.1 distribution
main
comment '
Bring a salute to our globe';
temps
hello: HelloWorld;
begin
hello.show
end // main
#Category 'Sina-Hello world';
class HelloWorld interface
methods
show returns nil;
inputfilters
disp: Dispatch = {inner.*};
end; // interface HelloWorld
class HelloWorld implementation
methods
show
begin
self.printLine('Hello, world!');
return
end; // show
end; // implementation HelloWorld
% A simple example of using SISAL arrays,
% adapted from various sample exercises in the
% SISAL tutorial by John Feo.
define main
type Matrix = array [ array [ real ] ]
% generate a square matrix where element [n,m]
% is set to n m
function gensquare(siz : integer
returns Matrix )
for i in 1,siz cross j in 1,siz
returns array of real(i) real(j)
end for
end function
% perform one step of a relaxation, average each
% element with its eight nearest neighbors
function relax ( a : Matrix returns Matrix )
for row in a at i cross elt in row at j
avg := (elt a[i, j-1] a[i, j 1]
a[i 1, j-1] a[i 1, j] a[i 1, j 1]
a[i-1, j-1] a[i-1, j] a[i-1, j 1]) / 9.0
returns array of avg
end for
end function
% test the generator and relax function
function main(returns Matrix)
let a1 := gensquare(5) in a1
end let
end function
GEN, PEGDEN, SERIAL WORK AREAS QUEUE MODEL, 7/14/77, 1;
LIMITS,2,1,50;
NETWORK;
CREATE, EXPON(.4), , 1;
QUEUE(1), 0, 4, BALK(SUB);
ACT/1,EXPON(0.25);
QUEUE(2), 0, 2, BLOCK;
ACT/2,EXPON(0.50);
COLCT, INT(1), TIME IN SYSTEM, 20/0/.25
TERM;
SUB COLCT,BET,TIME BETWEEN BALKS;
TERM;
INIT,0,300;
FIN;
' Smalltalk class to constraint a 2D point to a fixed grid
' (from Horan & Hopkins, Smalltalk: An Introduction...)
Point subclass: #GriddedPoint
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Exercise11.5'!
!GriddedPoint methodsFor: 'accessing'!
x: xInteger
"Set the x coordinate gridded to 10 (using rounding, alternatively I could
use truncating)."
super x: (xInteger roundTo: 10)!
y: yInteger
"Set the y coordinate gridded to 10 (using rounding, alternatively I could
use truncating)."
super y: (yInteger roundTo: 10)! !
!GriddedPoint methodsFor: 'private'!
setX: xPoint setY: yPoint
"Initialize the instance variables rounding to 10."
super setX: (xPoint roundTo: 10) setY: (yPoint roundTo: 10)! !
* Find biggest words and numbers in a test string
* (from Griswold,Poage,& Polonsky, 1971)
BIGP = (*P $ TRY *GT(SIZE(TRY,SIZE(BIG))) $ BIG FAIL
STR = 'IN 1964 NFL ATTENDANCE JUMPED TO 4,807884; '
'AN INCREASE OF 401,810.'
P = SPAN('0123456789,')
BIG =
STR BIGP
OUTPUT = 'LONGEST NUMBER IS ' BIG
P = SPAN('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
BIG =
STR BIGP
OUTPUT = 'LONGEST WORD IS ' BIG
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.