disjoin 코드

CL-USER> (defun disjoin (fn &rest fns)
           (if (null fns)
               fn
               (let ((disj (apply #'disjoin fns)))
                 #'(lambda (&rest args)
                     (or (apply fn args) (apply disj args))))))
DISJOIN
CL-USER> (funcall (disjoin #'< #'=) 3 5)
T
CL-USER> (funcall (disjoin #'< #'=) 5 3)
NIL
CL-USER> (funcall (disjoin #'< #'=) 3 3)
T

재귀적(recursive) 사고에 익숙하지 않다면 이해하는게 고역일 수도 있다.
당연히 conjoin은 or을 and로 바꾸기만 하면 된다.

트랙백

이 글과 관련된 글 쓰기 (트랙백 보내기)
TrackbackURL : http://www.xeraph.com/tb/1228776 [도움말]

덧글

댓글 입력 영역