您的位置:首页 > 产品设计 > UI/UE

June 11th Monday (六月 十一日 月曜日)

2007-07-14 11:21 447 查看
(rule (append-to-form () ?y ?y))
(rule (append-to-form (?u . ?v) ?y (?u . ?z))
      (append-to-form ?v ?y ?z))

;;; Query input:
(append-to-form (a b) (c d) ?z)
;;; Query results:
(append-to-form (a b) (c d) (a b c d))

  This rule had puzzled me.  Now I known what happen?  Firstly, (append-to-form ?a ?b ?c) means
the result ?c is ?a + ?b.  (rule (append-to-form () ?y ?y)) is easy to understand.  A empty list
is appended to a list.  Let's look at the second sub rule.

(rule (append-to-form (?u . ?v) ?y (?u . ?z))
      (append-to-form ?v ?y ?z))

  A list can be considered as the 'car' and 'cdr' parts.  So, the (?u . ?v) represented that two
parts in a list.  The '?u' is the 'car' part and the '?z' is the rest of a new list appended.  How
to get the '?z'?  Append the 'cdr' part of the first list and a list -- ?y.

  It is so easy and intuitive. 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  list query rest input c