[PATCH] Move first and rest to racket/base.

From: Vincent St-Amour (stamourv at racket-lang.org)
Date: Thu Dec 13 12:40:52 EST 2012

---
 collects/racket/list.rkt                      |   16 +++-----------
 collects/racket/private/list.rkt              |   15 +++++++++++++-
 collects/scheme/base.rkt                      |    3 +-
 collects/scribblings/reference/pairs.scrbl    |   26 ++++++++++++------------
 collects/slideshow/code-pict.rkt              |    2 +-
 collects/string-constants/string-constant.rkt |    2 +-
 6 files changed, 35 insertions(+), 29 deletions(-)

diff --git a/collects/racket/list.rkt b/collects/racket/list.rkt
index fe32f68..4d5852f 100644
--- a/collects/racket/list.rkt
+++ b/collects/racket/list.rkt
@@ -1,8 +1,10 @@
 #lang racket/base
 
-(provide first second third fourth fifth sixth seventh eighth ninth tenth
+(provide first rest ; re-exported from racket/base
 
-         last-pair last rest
+         second third fourth fifth sixth seventh eighth ninth tenth
+
+         last-pair last
 
          cons?
          empty
@@ -34,11 +36,6 @@
          shuffle
          range)
 
-(define (first x)
-  (if (and (pair? x) (list? x))
-    (car x)
-    (raise-argument-error 'first "(and/c list? (not/c empty?))" x)))
-
 (define-syntax define-lgetter
   (syntax-rules ()
     [(_ name npos)
@@ -77,11 +74,6 @@
         (car l)))
     (raise-argument-error 'last "(and/c list? (not/c empty?))" l)))
 
-(define (rest l)
-  (if (and (pair? l) (list? l))
-    (cdr l)
-    (raise-argument-error 'rest "(and/c list? (not/c empty?))" l)))
-
 (define cons? (lambda (l) (pair? l)))
 (define empty? (lambda (l) (null? l)))
 (define empty '())
diff --git a/collects/racket/private/list.rkt b/collects/racket/private/list.rkt
index 0985f3f..67149f9 100644
--- a/collects/racket/private/list.rkt
+++ b/collects/racket/private/list.rkt
@@ -33,7 +33,10 @@
                        [alt-member member])
 
            compose
-           compose1)
+           compose1
+
+           first
+           rest)
 
   (#%require (rename "sort.rkt" raw-sort sort)
              (for-syntax "stxcase-scheme.rkt")
@@ -432,4 +435,14 @@
                   (mk member equal?)))
         (values memq memv member)))
 
+  (define (first x)
+    (if (and (pair? x) (list? x))
+        (car x)
+        (raise-argument-error 'first "(and/c list? (not/c empty?))" x)))
+
+  (define (rest l)
+    (if (and (pair? l) (list? l))
+        (cdr l)
+        (raise-argument-error 'rest "(and/c list? (not/c empty?))" l)))
+
   )
diff --git a/collects/scheme/base.rkt b/collects/scheme/base.rkt
index 12e1409..75fb5f2 100644
--- a/collects/scheme/base.rkt
+++ b/collects/scheme/base.rkt
@@ -5,6 +5,7 @@
                      struct
                      hash hasheq hasheqv
                      in-directory
-                     local-require)
+                     local-require
+                     first rest)
          make-base-empty-namespace
          make-base-namespace)
diff --git a/collects/scribblings/reference/pairs.scrbl b/collects/scribblings/reference/pairs.scrbl
index afa2d49..02258aa 100644
--- a/collects/scribblings/reference/pairs.scrbl
+++ b/collects/scribblings/reference/pairs.scrbl
@@ -142,6 +142,19 @@ pair @racket[p].
 (cdr '(1))
 ]}
 
+ at defproc[(first [lst list?]) any/c]{
+The same as @racket[(car lst)], but only for lists (that are not empty).
+ at mz-examples[#:eval list-eval
+(first '(1 2 3 4 5 6 7 8 9 10))
+]}
+
+ at defproc[(rest [lst list?]) list?]{
+The same as @racket[(cdr lst)], but only for lists (that are not empty).
+
+ at mz-examples[#:eval list-eval
+(rest '(1 2 3 4 5 6 7 8 9 10))
+]}
+
 @defthing[null null?]{The empty list.
 @mz-examples[
 null
@@ -721,19 +734,6 @@ The same as @racket[(null? v)].
 (empty? '())
 ]}
 
- at defproc[(first [lst list?]) any/c]{
-The same as @racket[(car lst)], but only for lists (that are not empty).
- at mz-examples[#:eval list-eval
-(first '(1 2 3 4 5 6 7 8 9 10))
-]}
-
- at defproc[(rest [lst list?]) list?]{
-The same as @racket[(cdr lst)], but only for lists (that are not empty).
-
- at mz-examples[#:eval list-eval
-(rest '(1 2 3 4 5 6 7 8 9 10))
-]}
-
 @defproc[(second [lst list?]) any]{Returns the second element of the list.
 @mz-examples[#:eval list-eval
 (second '(1 2 3 4 5 6 7 8 9 10))
diff --git a/collects/slideshow/code-pict.rkt b/collects/slideshow/code-pict.rkt
index 51e2f62..213ec56 100644
--- a/collects/slideshow/code-pict.rkt
+++ b/collects/slideshow/code-pict.rkt
@@ -2,7 +2,7 @@
 (require slideshow/pict
          texpict/code
          mzlib/unit
-         (for-syntax racket/base
+         (for-syntax (except-in racket/base first rest)
                      syntax/to-string
                      mzlib/list))
 
diff --git a/collects/string-constants/string-constant.rkt b/collects/string-constants/string-constant.rkt
index 2e9597e..bf61aec 100644
--- a/collects/string-constants/string-constant.rkt
+++ b/collects/string-constants/string-constant.rkt
@@ -1,5 +1,5 @@
 #lang racket/base
-(require (for-syntax racket/base)
+(require (for-syntax (except-in racket/base first rest))
 	 (for-syntax mzlib/etc)
 	 (for-syntax mzlib/list)
 	 (for-syntax (prefix-in english: "private/english-string-constants.rkt"))
-- 
1.7.1


--Multipart_Thu_Dec_13_12:44:38_2012-1--

Posted on the dev mailing list.