Hello all!
I have a list, looks like this
(("S" 152747.0 6.4086e+006 72.3828 "A" -4.19779) ("S" 152752.0 6.4086e+006 72.3091 "A" -1.95332) ("S" 152770.0 6.40863e+006 72.1742 "A" 0.722905) ("S" 152774.0 6.40863e+006 72.1143 "A" -2.4611) ("S" 152786.0 6.40866e+006 71.9021 "A" 9.32426))
and I want have all value from "A" ... ("A" -4.19779) ("A" -1.95332) ("A" 0.722905)....
I was thinking and try it with lambda expressions but whtat is wrong?
((lambda (x)
(while
(not
(member "A" (nth (1- (length area_list)) area_list))
)
)
)
(princ x)
)
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
Solved by martti.halminen. Go to Solution.
@DRossger wrote:Hello all!
I have a list, looks like this
(("S" 152747.0 6.4086e+006 72.3828 "A" -4.19779) ("S" 152752.0 6.4086e+006 72.3091 "A" -1.95332) ("S" 152770.0 6.40863e+006 72.1742 "A" 0.722905) ("S" 152774.0 6.40863e+006 72.1143 "A" -2.4611) ("S" 152786.0 6.40866e+006 71.9021 "A" 9.32426))
and I want have all value from "A" ... ("A" -4.19779) ("A" -1.95332) ("A" 0.722905)....
Assuming your list is assigned into the variable data, and you want to have everything in the list after "A":
(mapcar '(lambda (x) (member "A" x)) data)
=> (("A" -4.19779) ("A" -1.95332) ("A" 0.722905) ("A" -2.4611) ("A" 9.32426))
--
--
Thanks a lot that was the answer I want have...
second questions:
If I program with lambda, there is a control what can be inside (x) ? I have not much expierence with lambda, how I can check as function works rigtht ?
@DRossger wrote:Thanks a lot that was the answer I want have...
second questions:
If I program with lambda, there is a control what can be inside (x) ? I have not much expierence with lambda, how I can check as function works rigtht ?
by using the expression on the first item of the list argument
(mapcar '(lambda (x) (member "A" x)) data)
(setq x (car data))<---
("S" 152747.0 6.4086e+006 72.3828 "A" -4.19779)
(member "A" x)<---
("A" -4.19779)
and on every subsequent item on the list