Ah, thanks guys! I should have stopped writing code an hour earlier and gone to bed, and I was too tired to think clearly (enough)!
I think the problem is indeed with the confusion between strings and symbols. As the 'fname' suggested, it's a function (symbol), also treated like a string.
The problem is clarified like this:
Code: Select all
(set 't '(
(sin 803)
(cos 811)
(sin 17)
(cos 28)
(sin 61)))
(set 'fname "cos")
(println " result " (find-all (list (sym fname) '+) t))
result ((cos 811) (cos 28)) ; that works!
(set 't '(
(Maths:sin 803)
(Maths:cos 811)
(Maths:sin 17)
(Maths:cos 28)
(Maths:sin 61) ))
(set 'fname "Math:cos")
(println " result " (find-all (list (sym fname) '+) t))
result () ; that doesn't...?
You can see why I was confused at midnight... I'm still confused... :)
One thing I noticed is that the manual often uses simple literal lists, without showing how expressions are introduced. For example:
find-all '(? 2) '((a 1) (b 2) (a 2) (c 4)))
is a useful indication of the function's behaviour, but doesn't show how to use existing symbols (and those quoted wild-card characters, which I learnt about first from this forum...).