代码之家  ›  专栏  ›  技术社区  ›  Alex

使用Scheme搜索列表(DrRacket)

  •  1
  • Alex  · 技术社区  · 15 年前

    我的代码是:

    (define *graph* (read(open-input-file "starbucks4.sxml")))
    
    (define get-artifacts
      (lambda (l)
       (member (list 'opm:artifact) l)))
    

    get-artifacts(*graph*) 我说错话了 procedure application: expected procedure, given:...(the whole of my file contents)

    PS:我对Scheme很陌生,所以我可能忘记了一些愚蠢的语法!

    2 回复  |  直到 15 年前
        1
  •  2
  •   sepp2k    15 年前

    scheme中调用函数的语法是 (function-name arguments) ,不是 function-name(arguments) .

    get-artifacts(*graph*) ,racket首先评估 get-artifacts 它会自我评估。

    (*graph*) ,它将成为没有参数的函数调用。那不行,因为 *graph* 是一个列表而不是函数。所以你得到了错误。

        2
  •  0
  •   John Clements    15 年前