/[meta-cvs]/meta-cvs/F-5AD8C72020BEB5748163790EE9832EC7.lisp
ViewVC logotype

Diff of /meta-cvs/F-5AD8C72020BEB5748163790EE9832EC7.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by kaz, Mon Mar 11 19:34:50 2002 UTC revision 1.2 by kaz, Mon Mar 11 23:09:09 2002 UTC
# Line 28  to lambda variables. Line 28  to lambda variables.
28  Syntax:  Syntax:
29    
30    find-bind ({:test test-func} {:key key-func} {:take take-func})    find-bind ({:test test-func} {:key key-func} {:take take-func})
31              (rem-var {(var key)}*)              (rem-var {(var key {default-value})}*)
32              alist {decl}* {form}*              alist {decl}* {form}*
33    
34    var               A symbol naming a variable to be bound.    var               A symbol naming a variable to be bound.
35    key               A value to be sought after in the input sequence.    key               A value to be sought after in the input sequence.
36      default-value     Optional value to bind to the variable if a match
37                        is not found.
38    rem-var           A symbol naming the variable to be bound to    rem-var           A symbol naming the variable to be bound to
39                      a sequence that has only the unmatched elements                      a sequence that has only the unmatched elements
40                      from the original sequence.                      from the original sequence.
# Line 49  Syntax: Line 51  Syntax:
51  Semantics:  Semantics:
52    
53    The specified keys are looked up in the sequence and their corresponding    The specified keys are looked up in the sequence and their corresponding
54    variables are bound to the values that are found, or else to NIL.    variables are bound to the values that are found, or else to their
55      default value, or NIL if there is no default value.
56    
57    The rem-var variable is bound to a new sequence that is stripped of    The rem-var variable is bound to a new sequence that is stripped of
58    these previously located elements. The declarations and forms are    these previously located elements. The declarations and forms are
# Line 61  Semantics: Line 64  Semantics:
64    matches a second occurence and so on."    matches a second occurence and so on."
65    (let ((vars (mapcar #'first var-specs))    (let ((vars (mapcar #'first var-specs))
66          (keys (mapcar #'second var-specs))          (keys (mapcar #'second var-specs))
67            (defaults (mapcar #'third var-specs))
68          (val-sym (gensym "VALS-"))          (val-sym (gensym "VALS-"))
69          (rem-sym (gensym "REM-")))          (rem-sym (gensym "REM-")))
70    
71      `(multiple-value-bind (,val-sym ,rem-sym)      `(multiple-value-bind (,val-sym ,rem-sym)
72                            (find-bind-extract-vals (list ,@keys) ,sequence                            (find-bind-extract-vals (list ,@keys) ,sequence
73                                                    ,test ,key ,take)                                                    ,test ,key ,take)
74           (setf ,val-sym (mapcar #'(lambda (x y) (if x x y))
75                                  ,val-sym (list ,@defaults)))
76         (destructuring-bind (,remainder ,@vars)         (destructuring-bind (,remainder ,@vars)
77                             (cons ,rem-sym ,val-sym)                             (cons ,rem-sym ,val-sym)
78           ,@forms))))           ,@forms))))

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.5