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->list
list->lambda-formals
pair->list
list->pair
lambda->exp
if->condition
@ -395,14 +394,6 @@
(car args)))
(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
(define (list->pair l)
(let loop ((lst l))

View file

@ -16,6 +16,7 @@
if?
begin?
lambda?
pair->list
;; Environments
env:enclosing-environment
env:first-frame
@ -66,6 +67,14 @@
(define (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
(define (char->natural c)
(let ((i (char->integer c)))