You're very, very close to a correct solution! in the code in the question just do this:
- The outermost
lambda
is erroneous, delete that line and the corresponding closing parenthesis - The innermost
lambda
is the one that will eventually get passed to themap
procedure, so it needs to receive a parameter (even though it's not actually used) - Delete the outermost parenthesis surrounding the
let
form
It all boils down to this: the lambda
that gets passed to map
receives a parameter, but also encloses the P
variable. The let
form defines P
only once in the context of the passed lambda
, and from that point on the lambda
"remembers" the value of P
, because for each of the elements in the list the same P
is used.