From: Jérôme Benoit Date: Mon, 1 May 2017 19:11:46 +0000 (+0200) Subject: Some variables renaming for consitency X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9cd3ff4a71c79b2d15a160e014d3f40999630eb9;p=TD_LISP.git Some variables renaming for consitency Signed-off-by: Jérôme Benoit --- diff --git a/exercices/lists.lsp b/exercices/lists.lsp index 25360bc..1facea2 100755 --- a/exercices/lists.lsp +++ b/exercices/lists.lsp @@ -46,11 +46,11 @@ ;(trace true) -(define (rang x L) - (if (boolmemrec x L) +(define (rang E L) + (if (boolmemrec E L) (cond - ((= x (first L)) 0) - ((+ 1 (rang x (rest L))))) + ((= E (first L)) 0) + ((+ 1 (rang E (rest L))))) nil)) (println "rang/find") (println (rang 4 L)) @@ -60,11 +60,11 @@ ;(trace nil) -(define (tete n L) +(define (tete N L) (cond ((null? L) '()) - ((= n 0) '()) - ((cons (first L) (tete (- n 1) (rest L)))))) + ((= N 0) '()) + ((cons (first L) (tete (- N 1) (rest L)))))) (println "tete/slice") (println (tete 3 L)) (println (slice L 0 3)) @@ -144,20 +144,20 @@ (println (reverseL L)) (println (reverse L)) -(define (list< n L) +(define (list< N L) (cond ((null? L) '()) - ((>= (first L) n) (list< n (rest L))) - ((cons (first L) (list< n (rest L)))))) + ((>= (first L) N) (list< N (rest L))) + ((cons (first L) (list< N (rest L)))))) (println "list<") (println (list< 5 L)) (println (list< 5 C)) -(define (list>= n L) +(define (list>= N L) (cond ((null? L) '()) - ((< (first L) n) (list>= n (rest L))) - ((cons (first L) (list>= n (rest L)))))) + ((< (first L) N) (list>= N (rest L))) + ((cons (first L) (list>= N (rest L)))))) (println "list>=") (println (list>= 5 C)) @@ -180,12 +180,15 @@ (setq L1 '(A ? ? B C D ?)) (setq L2 '(? A B ? C ? ? D)) -(define (removeC c L) +(define (removeC C L) (cond ((null? L) '()) - ((= c (first L))) (removeC c (rest L)) - (((cons (first L) (removeC c (rest 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)) (define (filtre L1 L2 C) (cond @@ -193,7 +196,7 @@ ((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") ;(println (filtre L1 L2 ?)) (exit)