Jump to content

Palindrome


Recommended Posts

Hello,

 

I'd like to create a palindrome where I start with   ((s -) (e -) (3e = = -e))   and have the output be  ((s -) (e -) (3e = = -e) (e -) (s -)) .   But the gen-palindrome function doesn't quite do this.  Is there a general lisp way of doing this?

 

 

Link to comment
Share on other sites

  • eboats changed the title to Palindrome

This is one way.

(setf foo '((s -) (e -) (3e = = -e)))

(append foo (cdr (reverse foo))) 
 

Or as a function

 

(defun palindrome (lst)
  (append lst (cdr (reverse lst)))
)

(palindrome foo)

 

Jesper

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy