Reputation: 879
I made this function in Common Lisp
(defun f (&key n p x)
(* (combinacion n x) (expt p x) (expt (- 1 p) (- n x))))
and it works fine. The thing is that I want to make a function in Common Lisp lake the following Haskell function
ff n p x = sum . map (f n p) $ [0 .. x]
namley, map the function f
partially applied to a list.
I made the following function to create the lists
(defun range (&key max (min 0) (step 1))
(loop for n from min to max by step
collect n))
and works fine too, I only need to know how to make the mapping.
Upvotes: 2
Views: 1258
Reputation: 781310
Common Lisp doesn't have partial applications built in, you just have to write a lambda expression to do what you want.
(defun map-f (n p limit)
(let ((x-list (range :max limit)))
(mapcar #'(lambda (x) (f :n n :p p :x x)) x-list)))
Upvotes: 7