----------------------------------------------------------------------------------
@MSGID:
fe9d7b71
@REPLYADDR none) (albert
@REPLYTO 2:5075/128 none) (albert
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID:
@TZUTC: 0200
@TID: FIDOGATE-5.12-ge4e8b94
Implementing mal according to
https://github.com/kanaka/mal
I have problems with the implementation of apply.
(apply symbol? (list two) )
should give true, but this test fails.
This is the description with MAL.
apply: takes at least two arguments. The first argument is a function
and the last argument is a list (or vector). The arguments
between the function and the last argument (if there are any) are
concatenated with the final argument to create the arguments that
are used to call the function. The apply function allows a
function to be called with arguments that are contained in a list
(or vector). In other words, (apply F A B [C D]) is equivalent to
(F A B C D).
There is no mention that it is a special function. So all the arguments
of apply are evaluated.
I imagine myself as a naive user.
A naive user would apply to a list with the non-interned symbol two.
(apply symbol? (two) )
This doesn`t work. (two) is not a list, but a call.
We must do.
(apply symbol? (list two) )
But again list is not a special function. It evaluates its arguments.
In order to have a list that contains the symbol `` two ``
we must do:
(apply symbol? (list (quote two))
We arrive at the list to be evaluated
(<#4623388>
) where #4623388 is the actual function symbol? refers to.
This is an abstract structure tree: a list consisting of a a function
and a symbol.
Now we are supposed to evaluate this list.
symbol? is not a special function. So we evaluate its arguments :
`` two ``.
Bang! ERROR 8010.
8010 : Symbol not in environment
My test succeeds if we
(def! two 2)
2
(apply number? (list two) )
true
I cannot reasonably interpret the specification such that the
given test succeeds.
(apply symbol? (list (quote(quote two)))
gives true if I test it.
Groetjes Albert
--
Don`t praise the day before the evening. One swallow doesn`t make spring.
You must not say "hey" before you have crossed the bridge. Don`t sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -
--- trn 4.0-test77 (Sep 1, 2010)
* Origin: KPN B.V. (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441