PasteRack.org
Paste # 84179
2017-09-12 09:04:23

Fork as a new paste.

Paste viewed 78 times.


Embed:

  1. #lang racket
  2.  
  3. ;; Create a struct with an initial value with everything null
  4. (define-syntax (skeltal stx)
  5.   (syntax-parse stx
  6.     [(_ structure-name:id initializer-name:id (name:id ...))
  7.      (with-syntax ([(nulls ...) (make-list (length (syntax-e #'(name ...))) 'null)])
  8.        #'(begin
  9.          (struct/lens structure-name (name ...) #:prefab)
  10.          (define initializer-name (structure-name nulls ...))))]))

=>