I'm writing a function that takes a single list of knights that fight. The code running their fights is working(jousting-game), now I'm writing a tournament system and I can't get my tournament round to work. As I said, it takes a list of knights and has them fight recursively until everyone has fought, and returns two lists, one of winners, one of losers. I've tried everything I know and no matter what I do I get an error and the code refuses to work, and I don't understand why. Here's what I've written so far:
(define (playTourneyRound knightList)
(
(cond
((> (length knightList) 1)
(let (
(winner (jousting-game (car knightList) (cadr knightList)))
(winners (list))
(losers (list))
(results (playTourneyRound (cddr knightList)))
)
(if (= winner 1) (winners (append winners (list (car knightList)))) (winners (append winners (list (cadr knightList)))))
(winners (append (car results)))
(losers (list (cadr knightList) (cadr results)))
(list winners losers)
)
)
((= (length knightList) 1)
(list knightList)
)
)
(list '() '())
)
)
Can someone please explain to me why I'm getting the error "Call of non-procedure: #", and how can I avoid this error in future? I'm sure I just don't understand something about scheme/lisp that's important, and I could really use an explanation.
Thanks for all the help, problem has been solved