Searching through lists with Scheme (DrRacket)
So here's my code:
(define *graph* (read(open-input-file "开发者_开发技巧starbucks4.sxml")))
(define get-artifacts
(lambda (l)
(member (list 'opm:artifact) l)))
When I type get-artifacts(*graph*)
I get an error saying procedure application: expected procedure, given:...(the whole of my file contents)
Anyone see what I'm doing wrong? Thanks guys :)
PS: I'm really new to Scheme so it's probably some stupid syntax I'm forgetting!
The syntax for calling a function in scheme is (function-name arguments)
, not function-name(arguments)
.
When you write get-artifacts(*graph*)
, racket first evaluates get-artifacts
which evaluates to itself.
Then it tries to evaluate (*graph*)
, which it takes to be a function call with no arguments. That does not work because *graph*
is a list and not a function. So you get the error.
See my answer to your other question; it looks like you're in search of sxpath, here.
精彩评论