[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- To: SHRAGE at WHARTON-10
- From: Jon L White <JONL at MIT-MC>
- Date: Tue ,11 Nov 80 13:32:00 EDT
- Cc: LISP-FORUM at MIT-MC, LISP-DISCUSSION at MIT-MC
Date: 9 Nov 1980 (Sunday) 0116-EDT
From: SHRAGE at WHARTON (Jeffrey Shrager)
Subject: A suggested enhanced naming convention
How about addiing functions to replace (eventually) the MAPCAR, MAPCAN...
. . .
NIL has the special form "MAPF", which even works in MacLISP; it isn't
"autoloadable" in maclisp, but comes defined as a macro in the file
LISP:DRAMMP.FASL (several other NIL facilities are in that file).
There may be some more general extension beyond MAPF, but for those
of you who weren't in on the discussion of two years ago, the definition
of MAPF follows, lifted from the file MC:NIL;NEWFUN >
MAPF - (MAPF <result-kind> <source-kinds> <function> <as1> <as2> ... <asn>)
This is an attempt to generalize all the various mappers by having
the first two arguments specify the various options. *** These first
two items are not evaluated, but the remaining arguments are evaluated
just as in MACLISP.
<result-kind> must be among
{LIST, NCONC, PROJ1, VECTOR, STRING, BITS, +, +$}
<source-kinds> is a list of symbols which are source-descriptors; a
single symbol is treated like an infinite list of that symbol. The
descriptors are among
{LIST, CAR, VECTOR, STRING, BITS, 1+, 1-, 1+$, 1-$, CONSTANT}
<function> should evaluate to a function of n arguments, and
<as1> ... <asn> evaluate to the argument sources for <function>
The meaning of the <result-kind> is:
LIST Return a LIST of all the successive results of the
application of <function>
NCONC Same as LIST, but as if NCONC were applied to the
result, flattening it by one level.
PROJ1 Return the value of <as1>, as MAPC would.
VECTOR Return a VECTOR of all the successive results of the
application of <function>
STRING The result of each application must be a CHARACTER -
Return, then, the STRING of all those CHARACTERs.
BITS The result of each application must be either 0 or 1 -
the resultant 0's and 1's are packed into a BITS.
+, +$ Return the numerical sum of all outputs. "+" specifies
that they will all be FIXNUMs, "+" for FLONUMs.
The meaning of the <source-kinds> is:
LIST The argument source is a list, which is successivly
CDR'd after successive applications.
CAR Same as LIST, except CAR of the list is given as
the argument to <function>
VECTOR The successive items of a VECTOR are given
STRING The successive characters of a STRING are given
BITS The successive bits (0's or 1's) of a BITS are given
1+, 1+$ The argument source is a FIXNUM (or FLONUM in the
"1+$" case) which is successively incremented by 1.
1-, 1-$ Same as "1+" case, but is decremented by 1.
CONSTANT The argument source is repeatedly given, unmodified
as the corresponding argument to <function>; it
** DOES NOT ** mean that the type of the source is
a constant, but only that it is not "stepped".
Right now, not all the combinations are worked out, but these will
certainly be installed initially:
(MAP FOO . rst) ==> (MAPF 'PROJ1 'LIST FOO . rst)
(MAPLIST FOO . rst) ==> (MAPF 'LIST 'LIST FOO . rst)
(MAPC FOO . rst) ==> (MAPF 'PROJ1 'CAR FOO . rst)
(MAPCAR FOO . rst) ==> (MAPF 'LIST 'CAR FOO . rst)
(MAPCON FOO . rst) ==> (MAPF 'NCONC 'LIST FOO . rst)
(MAPCAN FOO . rst) ==> (MAPF 'NCONC 'CAR FOO . rst)
(MAPVECTOR FOO . rst) ==> (MAPF 'VECTOR 'VECTOR FOO . rst)