How would I go about writing my own eqv? or equal? in scheme? Would I just do a cond and look for symbol?, number?, etc and return the appropriate #t or #f?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As per R5RS, the minimum specifications for an implementation of
eqv?(when passed two argumentsobj1andobj2) to evaluate to#tare:obj1andobj2are both#tor both#f. (how two boolean literals evaluate to the same value is implementation dependent).obj1andobj2are both symbols and(string=?(symbol->string obj1)
(symbol->string obj2)) =)
=> #t
obj1andobj2are both numbers, are numerically equal (=), and are either both exact or both inexact.obj1andobj2are both characters and are the same character according to thechar=?procedure.obj1andobj2are the empty list.obj1andobj2are pairs, vectors, or strings that denote the same locations in the store (See section 3.4 of R5RS).obj1andobj2are procedures whose location tags are equal (Alambdaexpression is conceptually tagged with a storage location. What that means varies between Scheme implementations. Also see section 4.1.4 of R5RS).
equal?could be implemented in terms ofeqv?as it recursively compares the contents of pairs, vectors, and strings, applyingeqv?on other objects such as numbers and symbols.