正在加载图片...
6.001, Spring Semester, 2005--Quiz I Question 11: Assume that the procedure one-of has the following behavior. It takes two argu- ments, an element and a list. It successively test s for equality of t he element to entries in the list using string=?, unt il it eit her reaches the end of the list(in which case it ret urns false)or until it finds an element of the list that mat ches(in which case it ret urns true). Using this, supply an expression for INSErT1 in the expression below. (define (has-name name) IN SERT1) (filter(has-name "marie") samp ledata) Value: ((("jones""anne""marie""heather")60000"hacker") (("roe""marie""jane")29000"vice-president")) Question 12: Recall the pro cedure (define(map proc lst (if (null? lst nil (cons (proc (car lst))(map proc (cdr lst))))) Provide an expression for INSERT2 so that evaluating(map INSERT2 sampledat a) would ret urn a list of the number of names(bot h family and given names) for each entry, e. g (map IN SERT 2 samp ledata) Value:(34233) You may assume that length is a procedure t hat ret urns the number of elements(or lengt h) of a￾        6 ￾   &&  * *     *& * - 1*."  0& -  9 &'     &"  & &&./ &&  + /  *   &  * &' &  '   * *& *   * & @ -** &   & &C    ?&    * & * *& @ -** &   &  C" E& *&' & /  >&&    * >&& 1-"  "   ./0123  "  !!  )*+, !#! !! !! !""! $$$$ !"! !! !! !#! '$$$ !( ! ￾   5 *  3      +-           %.  >&&   & * .  ￾  ￾  -     &  *  1  & @1* /  . &C  * /' ""  ./0123  )*+,       / &&  *   &    *  & *  1  & @ *C   &"
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有