Common Lisp Package: GMAP

README:

FUNCTION

Private

Undocumented

GMAP>ARG-SPEC-LOOKUP (RAW-ARG-SPEC)

GMAP>EXPAND (FN RES-SPECS ARG-SPECS)

GMAP>FUNCALL (FUNCTION &REST ARGS)

GMAP>LET-SPECS (ARG-SPECS RES-SPECS)

GMAP>PARAM (ARG-SPEC)

GMAP>PARAM>ARG (PARAM ARG-SPEC MULTI-VARS)

GMAP>PARAM>EXIT-TEST (PARAM ARG-SPEC)

GMAP>PARAM>MULTI-LET-SPECS (PARAM ARG-SPEC MULTI-VARS)

GMAP>PARAM>MULTI-VARS (ARG-SPEC)

GMAP>RES-SPEC-LOOKUP (RAW-RES-SPEC)

GMAP>RES-SPEC-LOOKUP-1 (RAW-RES-SPEC)

GMAP>RES>CLEANUP (RES-SPECS RESULT-LIST ONE-VALUE-P)

GMAP>RES>INIT-CLAUSES (RES-SPECS)

GMAP>RES>NEXT (RES-SPEC RESULT FNVALS)

MACRO

Public

DEF-GMAP-ARG-TYPE (NAME ARGS &BODY BODY)

Defines a GMap arg-type. Syntax is identical to `defun'. The body should return a list of 1 to 5 elements: (0, "init") the initial value of the state variable; (1, "exitp"), if non-nil, a function of one argument which is called on the state variable, a true result causing the iteration to exit; (2, "argfn"), if non-nil, a function of one argument which is called on the state variable to get the value to be used on this iteration; (3, "nextfn"), if non-nil, a function of one argument which is called on the state variable to get the new value of same; and (4, "let-specs") a list of clauses for an `nlet' that will wrapped around the entire expansion. It is also possible for an arg-type to generate multiple arguments. If element 2, "argfn", is of the form `(:values N FN)', FN should be a function returning N values, which will be passed as separate arguments to the function being mapped.

DEF-GMAP-RES-TYPE (NAME ARGS &BODY BODY)

Defines a GMap result-type. Syntax is identical to `defun'. The body should return a list of 2 to 5 elements: (0, "init") the initial value of the state variable; (1, "resfn") a function of two arguments which is called on the state variable and the current value of the function being mapped, returning the new value of the state variable; (2, "cleanup"), if non-nil, a function of one argument which is called on the final value of the state variable to get the value of the `gmap' form; (3, "filterp"), if non-nil, a predicate of one argument which is called on the current value of the function being mapped, a false value causing "resfn" not to be called on this iteration (and the state variable to be unchanged); and (4, "let-specs") a list of clauses for an `nlet' that will wrapped around the entire expansion. It is also possible for a result-type to consume more than one value of the function being mapped. If element 1, "resfn", is of the form `(:consume N FN)', FN should be a function of N + 1 arguments, and will receive N values from the function being mapped.

GMAP (RES-SPEC FN &REST ARG-SPECS)

A generalized mapping macro. Applies `fn' to the successive values generated by the `arg-specs', analagously to `mapcar'; that is, on each iteration, each arg-spec yields one value, and `fn' is called with these values as arguments. The values returned by `fn' are accumulated into a result according to `res-spec'. The `res-spec' is either a list whose car is a predefined result type, or a list whose car is `nil' and whose cdr has the same form as the value of a result type expander (see `def-gmap-res-type'); or, the `res-spec' can be a symbol, which is shorthand for a list of that symbol; or, it can be a list whose car is `:values' and whose cdr is a list of result-specs. Similarly, each of the `arg-specs' is either a list whose car is a predefined arg type, or a list whose car is `nil' and whose cdr has the same form as the value of an arg type expander (see `def-gmap-arg-type').

Private

COND (&REST CLAUSES)

A generalization of CL:COND that makes it convenient to compute a value in the predicate expression of a clause and then use that value in the consequent. If the predicate expression is a LET form, then the scope of the variables bound by the LET is extended to include the consequent expressions. For example: (cond ((let ((x (foo))) (bar x)) (baz x))) Here the X in (BAZ X) is the one bound to the result of (FOO).

LET (CLAUSES &BODY BODY)

A generalization of CL:LET that better supports nested bindings and multiple values. Syntax: (let (<clause>*) <body>). The <clause> syntax is more general than for CL:LET: <clause> ::= <symbol> ; binds to NIL | ( <symbol> ) ; likewise | <clause1> <clause1> ::= ( <symbol>+ <form> ) ; binding | ( <clause1>+ ) ; nesting When a clause begins with more than one variable name, they are to be bound to successive values of the form. The nesting of clauses indicates sequencing of bindings; more deeply nested clauses may reference bindings of shallower clauses. All bindings at a given depth are done in parallel. This allows arbitrary combinations of parallel and sequential binding. Standard declarations at the head of BODY are handled correctly, though nonstandard ones may not be. If two variables of the same name are bound at different levels, any declaration applies to the inner one.

VARIABLE

Private

*GMAP-ARG-TYPE-LIST*

A list of all GMAP arg types that have been defined.

*GMAP-RES-TYPE-LIST*

A list of all GMAP result types that have been defined.