[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]

	MDL has had a similar construct for quite some time (five years?).
There are two SUBRs, MAPF (MAP-First) and MAPR (MAP-Rest), which map over
successive elements and successive RESTs (CDRs) of structures.  The syntax
	<MAPF	;"or MAPR"
	  struc1 ... strucN >

The way it works is that the loopf (usually an imbedded FUNCTION but also
permitted to be an externally defined function or a SUBR) is applied to
successive elements (or RESTs) of the strucs.  This continues until one
of the strucs "runs out" (becomes empty), or the loopf performs a MAPLEAVE

	If the finalf is a FALSE (NIL in conventional Lisps), MAPF/R is
thus just a FOR-EACH style loop.  If the finalf is applicable, it is
applied to the accumulated values of the applications of the loopf.  The
loopf may control the accumulation of values itself by performing MAPRETs
inside itself.  The arguments of MAPRET (any number) become the values from
that application of the loopf.  MAPSTOP is like MAPRET except that it says,
after accumulating these arguments, apply the finalf and return.

	MAPLEAVE says "return my argument as the value of the MAPF/R".

	Note also that if no strucs are supplied, MAPF becomes a sort of
generator function to build structures.


	      <FUNCTION (X)
		<COND (<WIN? .X> <MAPRET .X>)
		      (ELSE <MAPRET>)>>

returns a list of the members of CANDIDATES that pass a certain test.

	<MAPR <>
	      <FUNCTION (X)
		<COND (<==? <1 .X> .Y> <MAPLEAVE .X>)>>

is precisely <MEMQ .Y .X>.


returns a list of the elements in a hash-table.  (! is the MDL construct
that means "take my elements instead of me")

	MDL, of course, is coming soon to a machine near you...


		Marc Blank
		Dave Lebling