[CM] dopairs
Orm Finnendahl
finnendahl@folkwang-hochschule.de
Tue, 1 Jul 2003 12:58:24 +0200
Hi Rick,
using your dopairs macro I noticed the following behaviour:
(dopairs (x y '(1 2 3 4 5))
(begin
(display (list x y))
(newline)))
guile> (1 2)
(3 4)
<unnamed port>: In procedure cadr in expression (cadr #{\ g75}#):
<unnamed port>: Wrong type argument in position 1: ()
ABORT: (wrong-type-arg)
Type "(backtrace)" to get more information or "(debug)" to enter the debugger.
I think, the error of an uneven pair list should get caught and assume
it's due to a typo in the fourth last line of the dopairs definition.
To fix this, change that line:
- (if (null? ,a)
into
+ (if (null? (cdr ,a))
After replacement:
(dopairs (x y '(1 2 3 4 5))
(begin
(display (list x y))
(newline)))
guile> (1 2)
(3 4)
<unnamed port>: In procedure error in expression (error str):
<unnamed port>: Uneven pair list: (1 2 3 4 5)
ABORT: (misc-error)
guile>
--
Orm