Created
August 9, 2019 00:23
-
-
Save belmarca/f0e1625ce923b83d2219e0265d9ffd56 to your computer and use it in GitHub Desktop.
Exemple de macro scheme.
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
(define-syntax de | |
(syntax-rules (à) | |
((de x à y) (cond ((> x y) (let loop ((z y) (l '())) | |
(cond ((< z x) (loop (+ z 1) (cons z l))) | |
((= z x) (cons z l))))) | |
((= x y) x) | |
((< x y) (let loop ((z y) (l '())) | |
(cond ((> z x) (loop (- z 1) (cons z l))) | |
((= z x) (cons z l))))))))) | |
;; Exemple dans gxi: | |
;; | |
;; > (de 1 à 1) | |
;; 1 | |
;; > (de 2 à 9) | |
;; (2 3 4 5 6 7 8 9) | |
;; > (de 28 à 11) | |
;; (28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment