; your code goes here
(defun all-indexes-1 (len numbers pattern)
(if (null numbers)
(list pattern)
(mapcan (lambda (n)
(all-indexes-1 len
(remove n numbers)
(cons n pattern)))
numbers)))
(defun all-indexes (len)
(all-indexes-1 len
(loop for n below len collect n)
nil))
(defun all-patterns (seq)
(mapcar (lambda (indexes)
(coerce (mapcar (lambda (i) (aref seq i))
indexes)
(type-of seq)))
(all-indexes (length seq))))
(mapc #'print (all-patterns "abcd"))
OyB5b3VyIGNvZGUgZ29lcyBoZXJlCgooZGVmdW4gYWxsLWluZGV4ZXMtMSAobGVuIG51bWJlcnMgcGF0dGVybikKICAoaWYgKG51bGwgbnVtYmVycykKICAgICAgKGxpc3QgcGF0dGVybikKICAgICAgKG1hcGNhbiAobGFtYmRhIChuKQogICAgICAgICAgICAgICAgKGFsbC1pbmRleGVzLTEgbGVuCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAocmVtb3ZlIG4gbnVtYmVycykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChjb25zIG4gcGF0dGVybikpKQogICAgICAgICAgICAgIG51bWJlcnMpKSkKCihkZWZ1biBhbGwtaW5kZXhlcyAobGVuKQogIChhbGwtaW5kZXhlcy0xIGxlbgogICAgICAgICAgICAgICAgIChsb29wIGZvciBuIGJlbG93IGxlbiBjb2xsZWN0IG4pCiAgICAgICAgICAgICAgICAgbmlsKSkKCihkZWZ1biBhbGwtcGF0dGVybnMgKHNlcSkKICAobWFwY2FyIChsYW1iZGEgKGluZGV4ZXMpCiAgICAgICAgICAgIChjb2VyY2UgKG1hcGNhciAobGFtYmRhIChpKSAoYXJlZiBzZXEgaSkpCiAgICAgICAgICAgIAkJCQlpbmRleGVzKQogICAgICAgICAgICAgICAgICAgICh0eXBlLW9mIHNlcSkpKQogICAgICAgICAgKGFsbC1pbmRleGVzIChsZW5ndGggc2VxKSkpKQoKKG1hcGMgIydwcmludCAoYWxsLXBhdHRlcm5zICJhYmNkIikpCg==