home *** CD-ROM | disk | FTP | other *** search
- /* 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("]");
- }
-