functional programming - How to map a function in Common Lisp? -


i made function in common lisp

(defun f (&key n p x)     (* (combinacion n x) (expt p x) (expt (- 1 p) (- n x)))) 

and works fine. thing want make function in common lisp lake following haskell function

ff n p x = sum . map (f n p) $ [0 .. x] 

namley, map function f partially applied list.

i made following function create lists

(defun range (&key max (min 0) (step 1))     (loop n min max step         collect n)) 

and works fine too, need know how make mapping.

common lisp doesn't have partial applications built in, have write lambda expression 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))) 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -