Here is the code of the functions that I have:
(setq list ' ((((Ш К Э Ы О) (( )) (Ы)) ((Ш Ы Ж ((( ))) Т Ы) (З М Т Э ( ) К) (Щ Й У O)) (( )) ((Д У З И Э) ( ((( ))) Ш С Э П П) (Ш) ( ) ) ((Г Щ Щ У Т) ( ) )) (((Ъ З С П ( ) Ь) (Ь)) ((Л Р (( )) П )) ((С Щ Ь Х ( ) Р) (Ч Е Ш П Д) ( ) ) ((Ы И О Ф Е) ((( ))) (Ы К)) ((Ш М) ( ) ) ((Ф Ш С Э Ъ) ( ) (Ф Э К))) ((( ((( ))) Х Л Ш О А) (Й) (( )) ) ((М Р О А Ш) ( ) (П Д))))) (defun badp (Z) (cond ((null Z) T) ((atom Z) nil) ((and (null (cdr Z)) (listp (car Z))) (badp (car Z))) ((atom (car Z)) nil) (t nil) )) (defun clear (Y) (cond ((null Y) nil) ((badp (car Y)) (clear (cdr Y))) ((listp (car Y)) (cons (clear (car Y)) (clear (cdr Y)))) (t (cons (car Y) (clear (cdr Y)))) )) (clear list) (defun OneList (X) (cond ((null X) nil) ((listp (car X)) (append (oneList (car X)) (OneList (cdr X)))) (T (cons (car X) (OneList (cdr X)))) )) (onelist list) (defun alfavit (d) (let ((result nil)) (loop for l from 0 to 31 do (setq result (cons (list-to-delimited-string (list (+ l (- d 1)) - (int-char (+ 192 l))) " ") result)) ) (list-to-delimited-string (reverse result) ", ") )) (alfavit 1) (defun preGamm (text key ngamma) (LET* ( (spisok (coerce text 'list)) (keyspisok (coerce text 'list)) (j 0) (n (- (length keyspisok) 1)) (result nil)) (for i from 0 to (- (length spisok) 1) do (if (= ngamma 1) (PROGN (setq result (cons (nth j keyspisok) result)) (if (< jn) (setq j (+ j 1)) (setq j 0)) ) (if (OR (equal (nth i spisok) #\space) (equal (nth i spisok) #\.)) (setq result (cons (nth i spisok) result)) (PROGN (setq result (cons (nth j keyspisok) result)) (if (< jn) (setq j (+ j 1)) (setq j 0)) )) )) (list-to-delimited-string (reverse result) ""))) (defun Vigener-MG (text key ngamma) (LET ( (source (coerce text 'list)) (keygamma (coerce (pregamm text key ngamma) 'list)) (kriptogramma nil)) (for i from 0 to (- (length source) 1) do (if (OR (equal (nth i source) #\space) (equal (nth i source) #\.)) (setq kriptogramma (cons (nth i source) kriptogramma)) (setq kriptogramma (cons (int-char (+ 192 (mod (- (+ 32 (- (char-int (nth i source)) 192)) (- (char-int (nth i keygamma)) 192)) 32))) kriptogramma))) ) (list-to-delimited-string (reverse kriptogramma) ""))) Functions Vigener-MG and preGamm from the manual, there is also a function of the frequency of the appearance of letters in the cryptogram and that's it. As I understood, Vigener-MG and preGamm are for encrypting the text, but I need to decipher the cryptogram, that is, vice versa. Task: Cipher Vizhener-mg, the key "MIRROR", the number of gamming is 1 (without a gap to the space and the end of the sentence, that is, the key MIRROR to repeat also where there are dots and spaces), Predicate error: if the sublist without elements is I am made by the Clear function, which removes these "bulbs". OneList function said to write to remove all internal brackets
Lisp is for the first time in our country, so I don’t understand how to remake Vigener-MG and preGamm to decrypt my cryptogram