home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d09xx / d0963.lha / SIOD / scm / reverse.scm < prev    next >
Text File  |  1992-12-09  |  685b  |  27 lines

  1. (define (append x y)
  2.         (if (null? x)
  3.             y
  4.             (cons (car x) (append (cdr x) y))))
  5.  
  6. (define (reverse x)
  7.         (define (reverse_it x y)
  8.                 (if (null? x)
  9.                     y
  10.                     (reverse_it (cdr x) (cons (car x) y))))
  11.         (reverse_it x nil))
  12.  
  13. (define (append_it x y res)
  14.         (if (null? x)
  15.             (if (null? y)
  16.                 (cons res nil)
  17.                 (append_it x (cdr y) (cons res (car y))))
  18.             (append_it (cdr x) y (cons res (car x)))))
  19.  
  20. (define (A x y)
  21.         (cond ((= y 0) 0)
  22.               ((= x 0) (* 2 y))
  23.               ((= y 1) 2)
  24.               (else (A (- x 1) (A x (- y 1))))))
  25.  
  26.              
  27.