PasteRack.org
Paste # 74811
2020-02-07 14:58:53

Fork as a new paste.

Paste viewed 318 times.


Embed:

  1. #lang racket/base
  2.  
  3. (require racket/match)
  4.  
  5. (define (first-item xs)
  6.   (match xs
  7.     [(list) "oh no empty"]
  8.     [(cons this more) this]))
  9.  
  10. (first-item (list))
  11. (first-item (list 1))
  12. (first-item (list 1 2))

=>

"oh no empty"

1

1