2010-10-26 52 views
1

因此,這裏是我的代碼:通過搜索列表和計劃(DrRacket)

(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:我真的是新的計劃,所以這可能是一些愚蠢的語法,我忘了!

+1

你的意思是(get-artifacts \ * graph \ *)? – 2010-10-26 18:50:22

+0

謝謝保羅,我認爲這是問題所在。我現在有其他問題,但我會嘗試自己整理:) – Alex 2010-10-26 18:53:33

回答

2

在方案中調用函數的語法是(function-name arguments),而不是function-name(arguments)

當你寫get-artifacts(*graph*),球拍首先評估get-artifacts評估自己。

然後它試圖評估(*graph*),它需要一個沒有參數的函數調用。這是行不通的,因爲*graph*是一個列表而不是函數。所以你得到錯誤。

0

請參閱我對您的其他問題的回答;它看起來像你在尋找sxpath,在這裏。