mootoh (owner)

Revisions

gist: 157850 Download_button fork
public
Public Clone URL: git://gist.github.com/157850.git
Embed All Files: show embed
pascal-fast.scm #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
; CTMCP 1.5
;
(define (pascal n)
  (if (eq? n 1)
    '(1)
    (let ((prev (pascal (- n 1))))
      (addlist (shiftleft prev) (shiftright prev)))))
 
(define (shiftleft lst)
  (if (null? lst)
    '(0)
    (cons (car lst) (shiftleft (cdr lst)))))
 
(define (shiftright lst)
  (cons 0 lst))
 
(define (addlist lst1 lst2)
  (if (null? lst1) '()
    (cons (+ (car lst1) (car lst2)) (addlist (cdr lst1) (cdr lst2)))))
 
(pascal 32)