Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. (match/debug 'two
  2. ['one 1]
  3. ['two 2])
  4.  
  5. Case 2 <-- Printed
  6. 2 <-- Returned value
  7.  
  8. (match 'two
  9. ['one (displayln "Case 1") 1]
  10. ['two (displayln "Case 2") 2])
  11.  
  12. (define-syntax-rule (match-debug id [pattern value] ...)
  13. (let ([index 0])
  14. (match id
  15. [(begin
  16. (set! index (add1 index))
  17. pattern)
  18. (printf "Case ~an" index)
  19. value] ...)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement