adjust HtDP teaching languages' first and rest so that they accept circular lists.

This commit fix an unintentional change introduced by this commit:
  c7d67f9bab
(and it also adds in test cases for what that commit appears to have
been doing)

Assuming everyone agrees that the behavior for first rest from back
in 2010 is the behavior we still want (and the lack of release notes
on the subject makes me believe that we do), then:

Please include in 5.2.
(cherry picked from commit 7acc5b7852)
This commit is contained in:
Robby Findler 2011-10-21 07:26:55 -05:00 committed by Eli Barzilay
parent c6e1796afa
commit 564f9d0062
2 changed files with 13 additions and 1 deletions

View File

@ -5,7 +5,7 @@
(require scheme/promise
mzlib/struct
(only-in racket/list first rest)
(only-in mzlib/list first rest)
(for-syntax scheme/base)
(for-syntax stepper/private/shared))

View File

@ -174,6 +174,14 @@
(htdp-test 1 car (shared ([x (cons 1 x)]) x))
(htdp-test 1 cadr (shared ([x (cons 1 x)][y (cons 2 x)]) y))
(htdp-test 1 cadddr (shared ([x (cons 1 x)][y (cons 2 x)]) y))
(htdp-test 1 first (shared ([x (cons 1 x)]) x))
(htdp-test 1 second (shared ([x (cons 1 x)]) x))
(htdp-test 1 third (shared ([x (cons 1 x)]) x))
(htdp-test 1 fourth (shared ([x (cons 1 x)]) x))
(htdp-test 1 fifth (shared ([x (cons 1 x)]) x))
(htdp-test 1 sixth (shared ([x (cons 1 x)]) x))
(htdp-test 1 seventh (shared ([x (cons 1 x)]) x))
(htdp-test 1 eighth (shared ([x (cons 1 x)]) x))
(htdp-test #t (lambda (l) (eq? l (cdr l))) (shared ([x (cons 1 x)]) x))
(htdp-test #t (lambda (l) (eq? l (car l))) (shared ([x (list x x)]) x))
(htdp-test #t (lambda (l) (eq? l (cadr l))) (shared ([x (list x x)]) x))
@ -200,6 +208,10 @@
(htdp-err/rt-test (cons 1 2) "cons: second argument must be a list or cyclic list, but received 1 and 2")
(htdp-err/rt-test (append (list 1) 2) "append: last argument must be a list or cyclic list, but received 2")
(htdp-err/rt-test (first 1) "first: expected argument of type <non-empty list>; given 1")
(htdp-err/rt-test (rest 1) "rest: expected argument of type <non-empty list>; given 1")
(htdp-test #t 'equal? (equal? (vector (list 10) 'apple) (vector (list 10) 'apple)))
(htdp-test #t 'equal? (equal? (shared ([x (cons 10 x)]) x) (shared ([x (cons 10 x)]) x)))
(htdp-test #t 'equal? (equal? (shared ([x (cons (vector x) x)]) x) (shared ([x (cons (vector x) x)]) x)))