Jump to content

LdBeth

Members
  • Content Count

    3
  • Joined

  • Last visited

About LdBeth

  • Rank
    Junior Member

Contact Methods

Profile Information

  • Gender
    Male
  • Location
    US

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I guess it is because combinations like (a3 b3 c3 b3) are acceptable but won't be available with combination
  2. There's a count-repeat function. ? (count-repeat '(a3 b3 b3 b3)) count-repeat (1 3) Thus (let ((*do-verbose* nil)) (remove-if (lambda (x) (> (apply #'max (count-repeat x)) 1)) ;; or replace apply with (reduce #'max (count-repeat x)), essentially does the same (combination2 4 '(c3 d3 e3 f3 g3 a3 b3)))) ((a3 b3 a3 b3) (g3 b3 a3 b3) (f3 b3 a3 b3) (e3 b3 a3 b3) (d3 b3 a3 b3) (c3 b3 a3 b3) (b3 g3 a3 b3) (a3 g3 a3 b3) (f3 g3 a3 b3) (e3 g3 a3 b3) (d3 g3 a3 b3) (c3 g3 a3 b3) (b3 f3 a3 b3) (a3 f3 a3 b3) (g3 f3 a3 b3) (e3 f3 a3 b3) (d3 f3 a3 b3) (c3 f3 a3 b3) (b3 e
  3. LdBeth

    LdBeth

  4. you can work with Common Lisp arrays to reduce memory usage. Here's a very direct translation of Algorithm T from http://www.kcats.org/csci/464/doc/knuth/fascicles/fasc2b.pdf which precomputes the permutation table of n distinct elements. ;; We needs to use the factorial function (defun factorial (x) ...) (defun algorithm-t (n &aux (num (factorial n))) ;; The `(integer 1 ,n) declaration will make sure CCL allocates far less memory ;; then using 'integer or 'fixnum. (let ((table (make-array num :element-type `(integer 1 ,n) :initial-element 0)) (m 2)
×
×
  • Create New...

Important Information

Terms of Use Privacy Policy