HELP PDTOLIST updated Mark Rubinstein November 1985
pdtolist(procedure) -> dynamic list
This procedure takes a procedure as argument and returns a dynamic list
made from the procedure. A dynamic list is a PAIR whose FRONT is TRUE and
whose BACK is the procedure given to PDTOLIST.
HD and TL etc recognize such PAIRs. The procedure should be a generator,
which, each time it is called, returns a new result, and returns *TERMIN
when it is finished. The advantage of a dynamic list is that its elements
are computed only as they are required, which can save space and time.
PROGLIST, which plays a crucial role in the compiler is a dynamic list.
ISDYNAMIC recognises dynamic lists, returning the generator procedure.
EXPANDLIST expands dynamic lists and makes them static lists.
See HELP * ATOM, *FRONT, *BACK, *DESTPAIR, *HD, *TL, *ISDYNAMIC,
*EXPANDLIST
For technical details see REF * LISTS
--- Example ------------------------------------------------------------
By partially applying GENSYM to the word "CAT" we create a generator
which returns, on succcessive calls, the words CAT1, CAT2, CAT3, etc. We
can make a dynamic list from this procedure.
vars catlist;
pdtolist(gensym(%"cat"%)) -> catlist;
CATLIST is now a dynamic list, represented by a PAIR, whose front is TRUE
and whose back is the generator procedure
front(catlist) =>
** <true>
back(catlist)=>
** <procedure gensym>
The procedures HD and TL, unlike FRONT and BACK, make it look like an
ordinary list.
hd(catlist)=>
** cat1
catlist =>
** [cat1 ...] ;;; printing does not expand dynamic lists
repeat 20 times tl(catlist) -> catlist endrepeat;
hd(catlist) =>
** cat21
CATLIST is, in effect, an infinite (or very very long) list, bits of which
come into existence as needed.
--- C.all/help/pdtolist
--- Copyright University of Sussex 1992. All rights reserved. ----------Author: updated Mark Rubinstein November 1985