Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有列表操作之类的
'(xy) '(1 2)
(替换'(xy)'(1 2)(+'x'y))
-> (每个符号由数字列表相对匹配,并替换)
-> (x = 1, y = 2)
-> (+ 1 2)
-> 3
我无法从参考中找到任何想法。
http://docs.racket-lang.org/reference/pairs.html
您可以使用let:
let
(let ((x 1) (y 2)) (+ x y))
如果您试图表示名称和值之间的映射(“字典”),有几种方法可以做到这一点。Racket 提供了一种哈希类型,可以将名称与值相关联。您可以在指南中了解它们。有一种更通用的方法可以在 Racket 中使用类似字典的值(在球拍/字典库中描述),它适用于不同的数据类型,而不仅仅是散列。