PasteRack.org
Paste # 615
2021-04-25 08:06:37

Fork as a new paste.

Paste viewed 380 times.


Embed:

hmm

  1. #lang racket/base
  2.  
  3. (require (for-syntax racket/base
  4.                      syntax/parse))
  5.  
  6. (define-syntax (example stx)
  7.   (syntax-parse stx
  8.     #:literals (unquote)
  9.     [(_ (~or (~and #:first-kw f-kw)
  10.              (~optional the-first:expr))
  11.         (~or (~and #:second-kw s-kw)
  12.              (~optional the-second:expr)))
  13.      #'(hash (~? (~@ 'first the-first)) (~? (~@ 'second the-second)))]))
  14.  
  15.  
  16. (example 5)

=>

'#hash((first . 5))