Share Pastebin
Guest
Public paste!

Common Lisp version of the MaxParts function

By: a guest | Mar 19th, 2010 | Syntax: Lisp | Size: 0.40 KB | Hits: 84 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. ;;; The mp function will calculate the maximal number of pieces resulting from C planar cuts through a D-dimensional object.
  2. ;;; An example of this in 3-space are the cake numbers, described here: http://www.research.att.com/njas/sequences/A000125
  3. (defun mp (D C)
  4.   (if (>= D C)
  5.     (expt 2 C)
  6.     (if (= D 0)
  7.       1
  8.       (if (= C 0)
  9.         1
  10.         (+ (mp (- D 1) (- C 1)) (mp D (- C 1)))))))