Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scheme list equivalence comparison

Hello I need to check if two lists have same elements in same order but I wasn't able to achieve as it seems like scheme eq? and eqv? checks by reference so giving false to such:

> (eq? (list 1 2 3) (list 1 2 3))
#f
> (eqv? (list 1 2 3) (list 1 2 3))
#f

How to achieve this ?

like image 455
Hellnar Avatar asked Sep 20 '09 10:09

Hellnar


2 Answers

This site explains the difference between those operators. But essentially, you want to use equal? when you want to compare the contents of two objects.

like image 64
João Silva Avatar answered Sep 21 '22 14:09

João Silva


seems like equal? and eq? are seperate procedures where equal checks as I needed:

> (equal? (list 1 2 3) (list 1 2 3))
#t
like image 20
Hellnar Avatar answered Sep 19 '22 14:09

Hellnar