Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor the generalize function.

  • Loading branch information...
commit 0551e42f56605b69aec44811c99abee622f7c4b3 1 parent 879d079
@arthurschreiber authored
Showing with 9 additions and 13 deletions.
  1. +9 −13 lisp/version_space.lisp
View
22 lisp/version_space.lisp
@@ -7,20 +7,16 @@
; generalize - a VS generalization for 2 hypotheses
; specialize - the set "G" is specialized, in this case: one element of g
-
(defun generalize (hyp1 hyp2)
- (cond ((null hyp1) nil)
- ((equal (car hyp1) "_")
- (cons (car hyp2)
- (generalize (cdr hyp1) (cdr hyp2))))
- ((equal (car hyp2) "_")
- (cons (car hyp1)
- (generalize (cdr hyp1) (cdr hyp2))))
- ((equal (car hyp1)(car hyp2))
- (cons (car hyp1)
- (generalize (cdr hyp1) (cdr hyp2))))
- (T (cons "*"
- (generalize (cdr hyp1) (cdr hyp2))))))
+ (mapcar #'(lambda (a b)
+ (cond
+ ((equal a "_") b)
+ ((equal b "_") a)
+ ((equal a b) a)
+ (T "*")
+ )
+ ) hyp1 hyp2)
+)
; --- some helpers ---
Please sign in to comment.
Something went wrong with that request. Please try again.