So i've been working on this, and it's close... i know it is...<br />if i was to pass in say: <span class="inlinecode">(permute 'a 'b 'c)</span> i would get <span class="inlinecode">((a b c) (b c a) (c a b ))</span> which is the first 3 i need, but i've messed something up here because everytime i modify it to call permute or each-start with <span class="inlinecode">(cdr x)</span> it just goes all wrong.<br /><br />At one point i had an output of:<br /><span class="inlinecode">((a b c) (a (b c) (c b )) (b c a) (b (c a) (a c)) (c a b ) (c (a b ) (b a)))</span><br />which is getting closer, but not what i need...<br /><br />even if anyone just has an idea on the algorithm, or even a brand new one, i would appreciate the insight at this moment <br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><br />(define (show str) (display str))<br /><br />(define (permute x)<br />Â Â (cond ((= (length x) 0)<br />Â Â Â Â Â Â Â Â (list'()))<br />Â Â ((null? (cdr x));make sure list is more than 1 element<br />Â Â Â Â Â Â (car x))<br />Â Â (else (each-start x (length x) '()))))<br /><br />(define (each-start x len c)<br />Â Â (cond((= len 1)Â Â (list x))<br />Â Â Â Â Â Â (else (append (cons x (each-start (insert-at (cdr x) (car x) (- (length x) 1)) (- len 1) (car x)))))))<br />Â Â <br />;insert-at: x = list to insert into, y = element to insert, v = position base of 0<br />(define (insert-at x y v)<br />Â Â (cond ((= v 0)<br />Â Â Â Â Â Â Â Â (cons y x))<br />Â Â Â Â Â Â Â Â (else(cons (car x) (insert-at (cdr x) y (- v 1))))))<br /><br /><!--c2--></div><!--ec2--><br /><br /><span class='edit'>This post has been edited by <b>skyhawk133</b>: 21 Oct, 2006 - 08:36 AM</span>
</div>
</div>