表示する1つの文字列の代わりに文字列のリストを表示するこれは5に設定された回転キーでちょうどCommon Lispではシーザー暗号をある
私はいくつかの制限が
入力がなければなりません持っています再帰的にリストとして読み込み、処理されます。
変数、配列、ループ、prognは許可されていません。
出力はリストではなく文字列でなければなりません。
プログラムは再帰のみを使用する必要があります。
(defun encode (expr) ; define function funcName (argument)
; Out case when the list is empty
(cond ((null expr) nil) ; conditional (test1 action1)
; Checking if the expression is an atom only then to go encryption
((atom expr) (encrot expr)) ; test2 see if one or less atom
; Adding the result of encrot to the list and
(t(cons (encode(car expr)) (encode(cdr expr)))))) ; will run if all others fail
(defun encrot (expr)
; casts the object and then shifts the char by 5
(string (int-char(encrot2 (+ 5 (char-int(char (string expr) 0)))))))
(defun encrot2 (x)
; Checking to see if the atom is a letter
(cond ((> x 90) (+ 64 (mod x 90)))
((< x 91) x)))
私の理解では、関数の短所は、文字列としてリストの要素が表示されていることです。たとえば、( "A" "B" "C")
文字列としては、理論的には"A B C"
のようになります。
GNU CLISP 2.49(2010-07-07)http://clisp.cons.org/を使用してコンパイルします。
あなたは(入力+出力)を例を挙げてもらえますか? – coredump
'cons'は何も表示していません。それは何も出力されていません。 'cons'はコンスセルを構築するだけです。 –