Say I wanted to find the highest square of a bunch of numbers:
(max (map (lambda (x) (* x x)) (range -4 1))) ; I want 16
This doesn't work: max
expects to be called like (max 16 9 4 1 0)
and I'm calling it like (max '(16 9 4 1 0))
.
The operation I want to apply here is the same as Python's asterisk or Javascript's spread operator, but it's neither quoting, unquoting or quasi-quoting...
What is it called in lisp (or Scheme) (or Racket) and how do I perform it? This seems like such a basic operation I'm struggling to find appropriate search terms on Google.
So far the best I've got is a really sad
(argmax (lambda (x) x) (map (lambda (x) (* x x)) (range -4 1))) ; 16 but really sadly so