【问题标题】:Scheme: define-syntax-rule pattern matching syntaxScheme:define-syntax-rule 模式匹配语法
【发布时间】:2011-03-14 00:36:10
【问题描述】:

我想重写这个:

(define-syntax match-rewriter
  (syntax-rules ()
    ((_ (patt body) ...)
      (λ (x) (match x (patt body) ... (_ x))))))

使用 (define-syntax-rule 模式模板) 但我似乎无法正确使用语法。任何建议表示赞赏。

谢谢。

【问题讨论】:

    标签: scheme syntax-error racket


    【解决方案1】:

    试试:

    (define-syntax-rule (match-rewriter (patt body) ...)
      (lambda (x) (match x (patt body) ... (_ x))))
    

    【讨论】:

    • 谢谢!这几乎正​​是我使用的,但我现在看到我有一对额外的括号抛出了模式。
    猜你喜欢
    • 2011-07-05
    • 1970-01-01
    • 1970-01-01
    • 2018-03-30
    • 2020-08-16
    • 2016-07-21
    相关资源
    最近更新 更多