PasteRack.org
Paste # 39465
2025-09-29 16:08:35

Fork as a new paste.

Paste viewed 218 times.


Embed:

  1. #lang racket
  2.  
  3. (define (interleave l1 l2)
  4.      (match* (l1 l2)
  5.           [(list () ()) (list)]
  6.           [((cons h1 t1) ()) l1]
  7.           [(() (cons h2 t2)) l2]
  8.           [((cons h1 t1) (cons h2 t2)) (cons (cons h1 h2)(interleave t1 t2))]))
  9.  
  10. (define l1 (list 1 2 3))
  11. (define l2 (list 4 5 6))

=>

eval:2:0: match: wrong number of match clauses, expected 2

and got 5

  in: (list ‘ () ‘ ())