Last active
January 12, 2018 18:30
-
-
Save ruliana/7842dd555e0a674b0281c3f7fea64d73 to your computer and use it in GitHub Desktop.
Example of "define-pattern" use
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-pattern (inner a) (list a (... ...))) ; This line defines a new pattern | |
(define inner-lists (list (list 1 2) (list 3 4))) ; Same as (define inner-lists '((1 2) (3 4))) | |
(match inner-lists | |
[(inner (list _ x _ ...)) (printf "x = ~a\n" x)]) ; Matches inner lists, returns (2 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment