Jump to content

Recommended Posts

Posted

Hi all,

I want to append an item to last item in a list, like this :

lst ((x1 y1) (x2 y2) (x3 y3))

and after appending z3 to last list in lst >> lst ((x1 y1) (x2 y2) (x3 y3 z3))

 

Can someone tell me how I can perform it?

Posted (edited)
(subst (append (last lst) (list 'z3)) (last lst) lst)
(reverse (cons (append (car (reverse lst)) (list 'z3)) (cdr (reverse lst))))

 

Edited by rlx
  • Like 1
Posted

One more for fun -

(reverse (cons (reverse (cons 'z3 (reverse (last lst)))) (cdr (reverse lst))))

 

  • Like 1
Posted


Lee, you remind me Steve Wozniak: his greatest gift has always been to be able to create electronic circuits (Apple), with the n. minimum of components! 

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...