Just as exercise I want to transform:
(alist "foo" 1 "bar" 2 "baz" 3)
into
(("foo" . 1) ("bar" . 2) ("baz" . 3))
is this possible with syntax-rules?
My attempt:
(define-syntax alist
(syntax-rules ()
((_ a b) (cons a b))
((_ x y ...)
(list (alist x y) ...))))
the problem that it expand into:
(("foo" . 2) ("foo" . "bar") ("foo" . 4) ("foo" . "baz") ("foo" . 6))
is macro alist possible with syntax-rules? How it should look like?
EDIT:
Another attempt
(define-syntax alist
(syntax-rules ()
((_ a b) (cons a b))
((_ x y z ...)
(list (alist x y) (alist z ...)))))
it returns (("foo" . 2) (("bar" . 4) ("baz" . 6))).