我不理解以下的面试实战问题:
这个有什么实际应用呢?
cons(a, b)
constructs a pair, andcar(pair)
andcdr(pair)
return the first and last element of that pair. For example,car(cons(3, 4))
returns3
, andcdr(cons(3, 4))
returns4
.Given this implementation of cons:
def cons(a, b): def pair(f): return f(a, b) return pair
Implement car and cdr.
cons
**是一个接受两个参数的函数…” - Felix Kling