Last active
September 26, 2019 16:33
-
-
Save iamandrewluca/ac3d7c68433394aca514bb1462888adc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(DEFUN numar(L) | |
(COND | |
((NULL L) NIL) | |
((NUMBERP (CAR L)) | |
(PRINT (CAR L)) | |
(numar (CDR L)) | |
) | |
(T (numar (CDR L))) | |
) | |
) | |
;; (SETQ L `(a 5 b c 7)) | |
;; (numar L) ; 5 7 | |
(DEFUN rev (L) | |
(COND | |
((NULL L) NIL) | |
(T (APPEND | |
(rev (CDR L)) | |
(CONS (CAR L) NIL) | |
)) | |
) | |
) | |
;; (SETQ L `(a 5 b c 7)) | |
;; (setq LREV (rev L)) | |
;; (write LREV) ; (7 C B 5 A) | |
(DEFUN egal (L1 L2) | |
(COND | |
((AND (ATOM L1) (ATOM L2)) (EQ L1 L2)) | |
((OR (ATOM L1) (ATOM L2)) NIL) | |
((egal (CAR L1) (CAR L2)) (egal (CDR L1) (CDR L2))) | |
) | |
) | |
;; (SETQ L1 `(a 5 b c 7)) | |
;; (SETQ L2 `(a 5 b c 7)) | |
;; (SETQ L3 `(b 3 8 1 3)) | |
;; (print (egal L1 L2)) ; T | |
;; (print (egal L1 L3)) ; NIL | |
(DEFUN revc (L1 &OPTIONAL REZ) | |
(COND | |
((NULL L1) REZ) | |
(T (revc | |
(CDR L1) | |
(CONS (CAR L1) REZ) | |
)) | |
) | |
) | |
;; (SETQ L `(a 5 b c 7)) | |
;; (setq LREV (revc L)) | |
;; (write LREV) ; (7 C B 5 A) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment