Map, Filter, Reduce in Common Lisp

preview_player
Показать описание
In this video, Andre and Chris discuss some list transformations in Common Lisp. We cover the functions `maplist`, `mapcar`, `remove-if-not`, and more.

Have a question? Leave a comment below
Рекомендации по теме
Комментарии
Автор

Good video. I’ll need to watch it a few more times, as it is a bit above my level. But i will def do that.

fetchmasters
Автор

Nice one! In your first examples, you don't need #' (sharp-sign quote) before the lambda, and indeed your following examples don't have it. (readers: #'fn is a shortcut to reference a function by its name, similar to (function fn) as we'll see right now).

The example that removes negative numbers can be shortened with the function PLUSP:

(remove-if-not #'plusp (list -1 1 -2 2))

;; => 1 2

or equivalent:

(remove-if #'minusp (list -1 1 -2 2))

also (+ x 1) can be shortened to (1+ 1) (with the function called 1+).

cheers

vindarel