Relocated pair->list

This commit is contained in:
Justin Ethier 2016-08-13 23:14:12 -04:00
parent d322ccea65
commit d0d889f594
2 changed files with 9 additions and 9 deletions

View file

@ -71,7 +71,6 @@
ast:lambda-formals-type ast:lambda-formals-type
ast:lambda-formals->list ast:lambda-formals->list
list->lambda-formals list->lambda-formals
pair->list
list->pair list->pair
lambda->exp lambda->exp
if->condition if->condition
@ -395,14 +394,6 @@
(car args))) (car args)))
(else (error `(Unexpected type ,type))))) (else (error `(Unexpected type ,type)))))
;; Create a proper copy of an improper list
;; EG: (1 2 . 3) ==> (1 2 3)
(define (pair->list p)
(let loop ((lst p))
(if (not (pair? lst))
(cons lst '())
(cons (car lst) (loop (cdr lst))))))
;; Create an improper copy of a proper list ;; Create an improper copy of a proper list
(define (list->pair l) (define (list->pair l)
(let loop ((lst l)) (let loop ((lst l))

View file

@ -16,6 +16,7 @@
if? if?
begin? begin?
lambda? lambda?
pair->list
;; Environments ;; Environments
env:enclosing-environment env:enclosing-environment
env:first-frame env:first-frame
@ -66,6 +67,14 @@
(define (lambda? exp) (define (lambda? exp)
(tagged-list? 'lambda exp)) (tagged-list? 'lambda exp))
;; Create a proper copy of an improper list
;; EG: (1 2 . 3) ==> (1 2 3)
(define (pair->list p)
(let loop ((lst p))
(if (not (pair? lst))
(cons lst '())
(cons (car lst) (loop (cdr lst))))))
; char->natural : char -> natural ; char->natural : char -> natural
(define (char->natural c) (define (char->natural c)
(let ((i (char->integer c))) (let ((i (char->integer c)))