I can map a function with multiple arguments in this way:
Code: Select all
(map pow '(2 1) '(3 4))
;-> (8 1)
But, if the list of arguments are within a list:
Code: Select all
(setq lst '((2 1) (3 4)))
Code: Select all
(map pow lst)
ERR: value expected in function pow : '(2 1)
Code: Select all
(map (curry apply pow) lst)
;-> (2 81)
Ok, transpose the list of arguments:
Code: Select all
(map (curry apply pow) (transpose lst))
;-> (8 1)
Code: Select all
(map (lambda(x) (apply pow x)) (transpose lst))
;-> (8 1)
Code: Select all
(define (mypow lst)
(if (null? lst) '()
(cons (pow (nth '(0 0) lst) (nth '(0 1) lst)) (mypow (rest lst)))
)
)
Code: Select all
(setq lst '((2 1) (3 4)))
(mypow (transpose lst))
;-> (8 1)
Code: Select all
(map max '(3 5) '(2 7))
;-> (3 7)
(map (curry apply max) '((3 5) (2 7)))
;-> (5 7)
(map (curry apply max) (transpose '((3 5) (2 7))))
;-> (3 7)
cameyo
p.s. sorry for poor english...