What are the alternatives to using 'apply(f, [k])' in the
following function?
(C1) xsum(f, n) := block([s : 0],
for k : 1 thru n do (s : s + apply(f, [k])), s)$
For a toy function, it's a minor inconvenience, but 'apply(f, [k])'
might be wearisome in a lengthy function. Is the need for
'apply(f,[k])' instead of 'f(k)' documented?
I understand what happens when 'apply(f, [k])' is replaced
by 'f(k),' but look what the translator does to ysum:
(C6) ysum(f, n) := block([s : 0],
for k : 1 thru n do (s : s + f(k)), s)$
(C7) ysum(f,2);
(D7) 3
(C8) ysum(g,2);
(D8) 3
(C9) translate(ysum)$
(C10) ysum(f,2);
(D10) 3
(C11) ysum(g,2);
(D11) 5
(C12)
Is this feature documented? If the translation is done by
translate_file, the UNLISP file does have warning:
This is the unlisp file for trap.mac
Translating: xsum
Translating: ysum
f
in the form f(k)
has been used as a function, yet is a bound variable
in this context. This code being translated as :APPLY(f,[k])
Who reads the UNLISP file?
Barton