Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "apply" and "mapcar" in Lisp

Tags:

People also ask

What is Mapcar Lisp?

mapcar is a function that calls its first argument with each element of its second argument, in turn. The second argument must be a sequence. The ' map ' part of the name comes from the mathematical phrase, “mapping over a domain”, meaning to apply a function to each of the elements in a domain.

What is apply in Lisp?

In Common Lisp apply is a function that applies a function to a list of arguments (note here that "+" is a variadic function that takes any number of arguments): (apply #'+ (list 1 2)) Similarly in Scheme: (apply + (list 1 2))

What is funcall lisp?

Description: funcall applies function to args. If function is a symbol, it is coerced to a function as if by finding its functional value in the global environment. Examples: (funcall #'+ 1 2 3) => 6 (funcall 'car '(1 2 3)) => 1 (funcall 'position 1 '(1 2 3 2 1) :start 1) => 4 (cons 1 2) => (1 .


(defun describe-paths (location edges) 
(apply #'append (mapcar #'describe-path (cdr (assoc location edges)))))