PasteRack.org
Paste # 82127
2020-08-08 15:58:06

Fork as a new paste.

Paste viewed 304 times.


Embed:

Omit certain values in list from expansion

  1. #lang racket
  2. (require (for-syntax threading))
  3. (require (for-syntax racket/match))
  4.  
  5. (define-for-syntax (every-other lst)
  6.                    (match lst
  7.                           ['() '()]
  8.                           [(list* a b others) (cons b (every-other others))]
  9.                           [(list a) (list a)]))
  10.  
  11. (define-syntax (score stx)
  12.                (define vals (~>> stx
  13.                                  syntax->datum
  14.                                  cdr
  15.                                  every-other))
  16.                (datum->syntax stx (cons '+ vals)))
  17.  
  18. (score coding 2
  19.        architecture 3
  20.        data 2
  21.        communication 3
  22.        leadership 3)

=>