在DrScheme中,如何从2个列表创建关联列表?
例如,我有,
y = ( 1 2 3 )
x = ( a b c )
Run Code Online (Sandbox Code Playgroud)
而且我要
z = ((a 1) (b 2) (c 3))
Run Code Online (Sandbox Code Playgroud)
假设方案(因为你的最后两个问题是关于方案):
(define x '(1 2 3))
(define y '(4 5 6))
(define (zip p q) (map list p q)) ;; <----
(display (zip x y))
;; ((1 4) (2 5) (3 6))
Run Code Online (Sandbox Code Playgroud)
结果:http://www.ideone.com/DPjeM