Scion
A function ancestrally dependent on apply$
The function fn is a scion of apply$ or simply a
scion if the function is ancestrally dependent on apply$. That
is, fn is apply$, or fn calls apply$, or calls a function
that calls apply$, or calls a function that calls a function that calls
apply$, etc.
Meriam-Webster defines scion as ``a descendant of a wealthy,
aristocratic, or influential family.''
Examples of scions include apply$, collect$ and foldr, where
the last two are defined as shown below.
(defun$ collect$ (fn lst)
(if (endp lst)
nil
(cons (apply$ fn (list (car lst)))
(collect$ fn (cdr lst)))))
(defun$ foldr (lst fn init)
(if (endp lst)
init
(apply$ fn
(list (car lst)
(foldr (cdr lst) fn init)))))
Note: Collect$, which is part of the support for the loop$
statement, is pre-defined in ACL2 but foldr is not.
Most often, scions treat one or more of their arguments as ``functions,''
i.e., have at least one formal of ilk :FN. But that is not necessarily
the case. Collect$-squares, as defined below,
(defun$ collect$-squares (lst)
(collect$ (lambda$ (x) (* x x)) lst))
is a scion even though it does not have a formal of ilk :FN.
However, it calls the scion collect$.
The function defined by
(defun$ collect$-expr (x lst alist)
(if (endp lst)
nil
(cons (ev$ x (cons (cons 'v (car lst)) alist))
(collect$-expr x (cdr lst) alist))))
is a scion because it calls ev$ which calls apply$ in the
mutually recursive clique that defines them both. Note that the ilks of the
formals of collect$-expr are :EXPR, NIL and NIL,
respectively. The function collects the successive values of the expression
x under extensions of alist binding the variable symbol v to
successive elements of lst.
In the early days of apply$ we used the term ``mapping function'' to
refer to scions. But that nomenclature was misleading because in the Lisp
culture ``mapping'' tends to be understood as a kind of linear iteration.
Fans of higher order logic have suggested we use the term ``functional''
for our scions, or at least for those scions having at least one formal of
ilk :FN. However, we have resisted that suggestion because a functional
takes a function as an argument and is thus a higher-order entity, but ACL2
is first-order, functions are never objects in ACL2, and the values of our
:FN formals are ordinary objects like symbols and lists that are
interpreted as functions.