From: Jérôme Benoit Date: Mon, 1 May 2017 20:17:22 +0000 (+0200) Subject: Implement a better filter function X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d4b2508d9663596624e7f44c701147c27c6cceb2;p=TD_LISP.git Implement a better filter function Signed-off-by: Jérôme Benoit --- diff --git a/exercices/lists.lsp b/exercices/lists.lsp index 1facea2..e97d747 100755 --- a/exercices/lists.lsp +++ b/exercices/lists.lsp @@ -180,23 +180,27 @@ (setq L1 '(A ? ? B C D ?)) (setq L2 '(? A B ? C ? ? D)) -(define (removeC C L) - (cond - ((null? L) '()) - ((= C (first L))) (removeC C (rest L)) - (((cons (first L) (removeC C (rest L))))))) -(println "removeC") -(println (removeC A L1)) -;escape character in newLISP? -(println (removeC \? L1)) +;(println "replace") +;(println L1) +;(println L2) +;the replace function modify the passed argument +;(println (replace 'B L1)) +;(println (replace '? L1)) +;(println (replace '? L2)) +;(println L1) +;(println L2) (define (filtre L1 L2 C) + ;the replace function modify the passed argument + ;FIXME: use the function argument C + (replace '? L1) + (replace '? L2) (cond ((and (null? L1) (null? L2)) true) ((and (not (null? L1)) (null? L2)) nil) ((and (null? L1) (not (null? L2))) nil) ((and (inclu L1 L2) (inclu L2 L1) true)))) (println "filtre") -;(println (filtre L1 L2 ?)) +(println (filtre L1 L2 ?)) (exit)