Skip to content

Instantly share code, notes, and snippets.

@ktakashi
Created January 24, 2014 08:19
Show Gist options
  • Save ktakashi/8593835 to your computer and use it in GitHub Desktop.
Save ktakashi/8593835 to your computer and use it in GitHub Desktop.
Cyclic list's equal?
;; For R6RS
(import (rnrs) (rnrs mutable-pairs))
;; For R7RS
;;(import (scheme base) (scheme cxr) (scheme write))
(define a (list 1 2))
(define b (list 1 2 1 2))
(set-cdr! (cdr a) a) ;; #0=(1 2 . #0#)
(set-cdr! (cdddr b) b) ;; #0=(1 2 1 2 . #0#)
(display (equal? a b)) (newline)
(display (equal? b a)) (newline)
#|
;; results
;; Sagittarius (0.5.0)
#t
#t
;; Mosh (0.2.7)
#t
#t
;; Ypsilon (0.9.6-update3)
#t
#t
;; Chibi (0.6 "carbon")
#t
#t
;; Gauche (0.9.4_pre3)
infinite loop...
|#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment