简体   繁体   中英

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 ?

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.

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

> (equal? (list 1 2 3) (list 1 2 3))
#t

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM