1

I am trying to write a decoder which uses 26 english letters. But since 26! is too much to calculate, My Permutation function cannot return the overall list so I want to return those elements one by one to evaluate them seperately. If someone help me It would be awesome. Below is the permutation function.

(defun permutations (coll) (if (not (cdr coll)) (list (first coll)) (loop for el in coll nconc (mapcar #'(lambda (combos) (cons el combos)) (permutations (remove el coll))) ) ) ) 

1 Answer 1

2

You can use map-permutations from the library alexandria for that.

Sign up to request clarification or add additional context in comments.

2 Comments

I cant use any library. Is there another alternative?
Yes, you can copy the function from the library. It is open source. It also seems that you do not need the more complicated code path there, so you might prune it down.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.