Subject: question regarding maphash

From: [email-masked] (Dan Stanger)
Date: Wed, 28 Jun 1995 17:43:26 -0600

when i execute the following

(defun mapx (f s) (mapcar f s))
(defun maph (f s) (maphash f s))
(mapx #'(lambda (a) (print a)) '(1 2 3))
 
(setf h (make-hash-table))
(setf (gethash 1 h) 'a)
(setf (gethash 2 h) 'b)
(print h)
 
(maph #'(lambda (a) (print a)) h)

i get this output

;; Loading file /home/dxs/gmgr/x.lsp ...
1 
2 
3 
#S(HASH-TABLE EQL (2 . B) (1 . A)) 
*** - EVAL/APPLY: too many arguments given to :LAMBDA
1. Break> where
 
APPLY frame for call (:LAMBDA '2 'B)

shouldnt mapx and maph work the same way in that i could pass a
lambda expression to either of them?  could someone explain what
my mistake is?
thanks,
dan stanger

---

From: [email-masked] (Joerg-Cyril Hoehle)
Date: Thu, 29 Jun 95 08:48:22 +0200

> *** - EVAL/APPLY: too many arguments given to :LAMBDA

Maphash uses a function with two arguments, the first being the hash
key, the second the value. Your lambda only has one parameter.

(maph #'(lambda (k v) (format t "~&~S ~S~%" k v)) h) should work.

	Joerg Hoehle
[email-masked]