正在加载图片...
Tree-ref 入 (define( tree-ref index tree); index is a list of indices (if (=0(car index) at the right index (if(null?(cdr index)) and were done nesting return element at this point ( tree-ref (cdr index) (car tree)); otherwise go to next level keep indexing at current level (tree-ref (cons((car index)1)(cdr index))(cdr tree)) pt.24,2003 6410/16413 Even More scheme Mapping (map function list) (map f(e1 e2.e3)) >(fe1)(fe2) 5e3 pt.24,2003 16410/16413 Even more schemeSept. 24, 2003 16.410/16.413 Even More Scheme 11 Tree-ref (define (tree-ref index tree) ; index is a list of indices (if ;; keep indexing at current level (= 0 (car index)) ; at the right index ; and we're done nesting (car tree) ; return element at this point Sept. 24, 2003 16.410/16.413 Even More Scheme 12 Mapping • (map function list) • (if (null? (cdr index)) (tree-ref (cdr index) (car tree))) ; otherwise go to next level (tree-ref (cons (- (car index) 1) (cdr index)) (cdr tree)))) (map f ‘(e1 e2 … e3)) => ((f e1) (f e2) … (f e3))
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有