PasteRack.org
Paste # 47476
2019-01-01 20:45:15

Forked from paste # 87651.

Fork as a new paste.

Paste viewed 597 times.


Embed:

  1. #lang racket/base
  2.  
  3. (require syntax/parse)
  4.  
  5. (define (compile-num-list nums)
  6.   (define-splicing-syntax-class ssc
  7.     (pattern (~seq (~optional ",") number:number)))
  8.   (syntax-parse nums
  9.     [(n:ssc ...) (syntax->datum #'(n.number ...))]))
  10.  
  11. (module+ test
  12.   (require rackunit)
  13.   (check-equal? (compile-num-list #'(1 "," 2 "," 3)) '(1 2 3)))

=>