Skip to content

Instantly share code, notes, and snippets.

@ruliana
Last active January 12, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruliana/7842dd555e0a674b0281c3f7fea64d73 to your computer and use it in GitHub Desktop.
Save ruliana/7842dd555e0a674b0281c3f7fea64d73 to your computer and use it in GitHub Desktop.
Example of "define-pattern" use
(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