Hi, I've created a list and want to subtract all the values within it from another variable, and assign it to a new variable.
How do I do it?
Basically, I ask for ground level (assigned to variable G1), and then any number of depths beneath that (assign to list LVLLIST), and I want to return the value of the bottom point. So it's all the values in LVLLIST added together and subtracted from G1. And assign it to a new variable BASE.
Me thinks anyway.
For example,
G1 = 650.00
LVLLIST = (1.23 23.26 0.13 50.23)
(setq BASE (- G1 LVLLLIST))
Thanks
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
@borderliner wrote:
.... I ask for ground level (assigned to variable G1), and then any number of depths beneath that (assign to list LVLLIST), and I want to return the value of the bottom point. So it's all the values in LVLLIST added together and subtracted from G1. And assign it to a new variable BASE.
....
G1 = 650.00
LVLLIST = (1.23 23.26 0.13 50.23)
(setq BASE (- G1 LVLLLIST))
....
This is an application for the (apply) function:
(setq BASE (- G1 (apply '+ LVLLLIST)))
Spot on.
Thanks.
First ever LISP routine - and feelin' quite good about it...