F
F
Filipp422021-06-05 16:47:07
Lisp
Filipp42, 2021-06-05 16:47:07

How to name the function?

I have a Common Lisp function that takes two lists (preferably equal) and a function name. Then it applies the resulting function in pairs to all the elements of the lists, and collects the returned values ​​into the resulting list. I can’t imagine what name, capacious and concise will suit her. Here is the function itself:

(defun pair-lists-fun (a-list b-list fun)
  (loop for a in a-list
     for b in b-list
     collect (funcall fun a b)))

It can be used, for example, to add pairs of elements of lists.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
Filipp42, 2021-06-05
@Filipp42

Sergey Gornostaev (many thanks to him) suggested the mapcar function, which provides much more opportunities. When creating my function, I did not know about that one, but now there is no need for mine. Use mapcar, very convenient.

S
Sergey Gornostaev, 2021-06-05
@sergey-gornostaev

pairwise

M
mlyamasov, 2021-06-05
@mlyamasov

https://zvon.org/other/haskell/Outputprelude/zipWi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question