灯下 登录
计算机科学 / SICP / 3.3.1 Mutable List Structure

Exercise 3.17 · 习题

Exercise 3.17: Devise a correct version of the

count-pairs procedure of Exercise 3.16 that returns the number of

distinct pairs in any structure. (Hint: Traverse the structure, maintaining an

auxiliary data structure that is used to keep track of which pairs have already

been counted.)

练习 3.17:为练习 3.16 中的 count-pairs 过程设计一个正确的版本,使其能返回任意结构中互不相同的序对的数量。(提示:遍历该结构,同时维护一个辅助数据结构,用于记录哪些序对已经被计入。)