updating the last element in a skill list

N

nour

Guest
hello,

I have a problem:

I want to update the last element in a skill list by incrementing it ,
for example I have the following list: list='(4 6) and I want to
transform it to this one list='(4 7).

There is a skill fonction which can do it: rplacd(name_liste
new_value) but it works only when I give the exact new_value, for
example i must tape
rplacd( list '(7))

Please help me because i must use it in a "for" fonction so the
incrementation must happen automatically ....

I've tried this but it didn't work:

y=nth( 1 list)+1
rplacd( list '(y))

it generate the following list: (4 y)

thanks a lot for the one who will help me
 
nour <nour.laouini@gmail.com> writes:

hello,

I have a problem:

I want to update the last element in a skill list by incrementing it ,
for example I have the following list: list='(4 6) and I want to
transform it to this one list='(4 7).

There is a skill fonction which can do it: rplacd(name_liste
new_value) but it works only when I give the exact new_value, for
example i must tape
rplacd( list '(7))

Please help me because i must use it in a "for" fonction so the
incrementation must happen automatically ....

I've tried this but it didn't work:

y=nth( 1 list)+1
rplacd( list '(y))

it generate the following list: (4 y)

thanks a lot for the one who will help me
(defun addtolast (l inc)
(setcar (last l) (plus (last l) inc)))

--
Jean-Marc
 
On Apr 25, 8:47 pm, Jean-Marc Bourguet <j...@bourguet.org> wrote:
nour <nour.laou...@gmail.com> writes:
hello,

I have a problem:

I want to update the last element in a skill list by incrementing it ,
for example I have the following list:    list='(4 6) and I want to
transform it to this one  list='(4 7).

There is a skill fonction which can do it: rplacd(name_liste
new_value) but it works only when I give the exact new_value, for
example i must tape
 rplacd( list '(7))

Please help me because i must use it in a "for" fonction so the
incrementation must happen automatically ....

I've tried this but it didn't work:

y=nth( 1 list)+1
rplacd( list  '(y))

it generate the following list:   (4 y)

thanks a lot for the one who will help me

(defun addtolast (l inc)
   (setcar (last l) (plus (last l) inc)))

--
Jean-Marc- Hide quoted text -

- Show quoted text -
thanks for everybody who had helped me.....
 

Welcome to EDABoard.com

Sponsor

Back
Top