Arc Forumnew | comments | leaders | submitlogin
as-expressions in wart
2 points by akkartik 2147 days ago | discuss
You wouldn't write it like this, but you could:

  def (pair? (x | (first ... (rest | (second ... rest2)))))
    (and list?.x
I'm currently not using as-patterns for pattern matching, just destructuring:

  def (copy (x | (head ... tail)))
    if (~bound? 'head)   # enter even if x is not a list
      (cons copy.head copy.tail)
I'm not sure how useful this is; every use case I've seen for it seems worse than just using car and cdr. Thoughts?

P.S. Building this feature turned out to be shockingly easy: