Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,52 @@
(import (srfi 25))
(define-syntax dotimes
(syntax-rules ()
((_ (i n) body ...)
(do ((i 0 (+ i 1)))
((>= i n))
body ...))))
(define (pascal-upper n)
(let ((p (make-array (shape 0 n 0 n) 0)))
(dotimes (i n)
(array-set! p 0 i 1))
(dotimes (i (- n 1))
(dotimes (j (- n 1))
(array-set! p (+ 1 i) (+ 1 j)
(+ (array-ref p i j)
(array-ref p (+ 1 i) j)))))
p))
(define (pascal-lower n)
(let ((p (make-array (shape 0 n 0 n) 0)))
(dotimes (i n)
(array-set! p i 0 1))
(dotimes (i (- n 1))
(dotimes (j (- n 1))
(array-set! p (+ 1 i) (+ 1 j)
(+ (array-ref p i j)
(array-ref p i (+ 1 j))))))
p))
(define (pascal-symmetric n)
(let ((p (make-array (shape 0 n 0 n) 0)))
(dotimes (i n)
(array-set! p i 0 1)
(array-set! p 0 i 1))
(dotimes (i (- n 1))
(dotimes (j (- n 1))
(array-set! p (+ 1 i) (+ 1 j)
(+ (array-ref p (+ 1 i) j)
(array-ref p i (+ 1 j))))))
p))
(define (print-array a)
(let ((r (array-end a 0))
(c (array-end a 1)))
(dotimes (row (- r 1))
(dotimes (col (- c 1))
(display (array-ref a row col))
(display #\space))
(newline))))

View file

@ -0,0 +1 @@
(print-array (pascal-upper 6))

View file

@ -0,0 +1 @@
(print-array (pascal-lower 6))

View file

@ -0,0 +1 @@
(print-array (pascal-symmetric 6))