home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
a
/
armbob
/
!ArmBob
/
progs
/
h
/
list
< prev
next >
Wrap
Text File
|
1994-06-06
|
560b
|
44 lines
/* GCW 06/06/94 */
/* lists */
cons(x,list)
{
local node;
node = newvector(2);
node[0] = x;
node[1] = list;
return node;
}
head(list)
{
return ((typeof(list)==VECTOR)?(list[0]):nil);
}
tail(list)
{
return ((typeof(list)==VECTOR)?(list[1]):nil);
}
map(f,l)
{
return ((typeof(l)==VECTOR)?(cons(f(head(l)),map(f,tail(l)))):nil);
}
printlist(l)
{
print("[");
if (typeof(l)==VECTOR)
{
print(head(l));
l = tail(l);
while (typeof(l)==VECTOR)
{
print(",");
print(head(l));
l = tail(l);
}
}
print("]");
}