PasteRack.org
Paste # 75965
2023-11-13 21:36:45

Fork as a new paste.

Paste viewed 437 times.


Embed:

  1. #lang racket
  2.  
  3. (require racket/generator)
  4.  
  5. (define constrain-cell
  6.   (generator ()
  7.     (let loop ([invalid (yield)]
  8.                [content '(1 2 3 4 5 6 7 8 9)])
  9.       (loop (yield content) (remove invalid content)))))
  10.  
  11. ; it works, but I'm not sure how
  12. (constrain-cell)
  13. (constrain-cell 4)
  14. (constrain-cell 5)
  15. (constrain-cell 6)
  16. (constrain-cell 1)
  17. (constrain-cell 'show) ; isn't in the defined content, does nothing

=>

'(1 2 3 4 5 6 7 8 9)

'(1 2 3 5 6 7 8 9)

'(1 2 3 6 7 8 9)

'(1 2 3 7 8 9)

'(2 3 7 8 9)