source: trunk/source/tests/ansi-tests/rctest/rctest-util.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 590 bytes
RevLine 
[8991]1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Jun  7 21:42:23 2003
4;;;; Contains: Utility functions for RCTEST
5
6(in-package :rctest)
7
8(defun randomly-partition (size &optional (limit 1))
9  "Return a randomly generated list of positive integers whose
10   sum is SIZE.  Try to make no element be < LIMIT."
11  (declare (type unsigned-byte size limit))
12  (let ((result nil))
13    (loop
14     while (> size 0)
15     do
16     (let* ((e0 (min size (max limit (1+ (min (random size) (random size)))))))
17       (push e0 result)
18       (decf size e0)))
19    (random-permute result)))
Note: See TracBrowser for help on using the repository browser.