Sha256: 5c9b12d33b612bc179a8dc65c3cf7b3d2cb9efd1968f438dc72b5b480feb8815

Contents?: true

Size: 446 Bytes

Versions: 185

Compression:

Stored size: 446 Bytes

Contents

(defpackage #:pascal
  (:use #:common-lisp)
  (:export #:rows))

(in-package #:pascal)

(defun fact (n)
  (loop for i from 0 to n
        for fact = 1 then (* fact i)
        finally (return fact)))

(defun choose (n r)
  (/ (fact n)
     (* (fact r) (fact (- n r)))))

(defun rows (n)
  (if (> n 0)
      (loop for i from 0 to (1- n)
               collect (loop for j from 0 to i
                             collect (choose i j)))
      '()))

Version data entries

185 entries across 185 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.138 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.137 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.136 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.135 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.134 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.133 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.132 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.131 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.130 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.129 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.128 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.127 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.126 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.125 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.124 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.123 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.122 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.121 tracks/common-lisp/exercises/pascals-triangle/example.lisp
trackler-2.2.1.120 tracks/common-lisp/exercises/pascals-triangle/example.lisp