Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun izvadizagradi (lista noval)
- (if (null lista)
- noval
- (if (atom (car lista))
- (izvadizagradi (cdr lista) (append noval (list (car lista))))
- (izvadizagradi (cdr lista) (append noval (izvadizagradi (car lista) '())))
- )
- )
- )
- (defun reverse (lista noval)
- (if (null lista)
- noval
- (reverse (cdr lista) (append (list (car lista)) noval))
- )
- )
- (defun pomosna (lista obratno)
- (if(null lista)
- T
- (if (equal (car lista) (car obratno))
- (pomosna (cdr lista) (cdr obratno))
- NIL
- )
- )
- )
- (defun vtorpalindrom (lista)
- (if (pomosna lista (reverse lista '()))
- T
- NIL
- )
- )
- (defun ostatok (sozagradi staral lista noval)
- (if (vtorpalindrom (append staral noval))
- (append sozagradi noval)
- (ostatok sozagradi staral (cdr lista) (append (list (car lista)) noval))
- )
- )
- (defun palindrom (lista)
- (if (pomosna (izvadizagradi lista '()) (reverse (izvadizagradi lista '()) '()))
- T
- (ostatok lista (izvadizagradi lista '()) (izvadizagradi lista '()) '())
- )
- )
- (palindrom '(1 (2 2 (3) 4) 5 ((4 (3)) 2)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement