Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Look for "A" value in list

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
DRossger
308 Views, 4 Replies

Look for "A" value in list

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

 

4 REPLIES 4
Message 2 of 5
martti.halminen
in reply to: DRossger


@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))

 

--

 

--

Message 3 of 5
DRossger
in reply to: martti.halminen

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 ?

Message 4 of 5
pbejse
in reply to: DRossger


@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 

 

 

Message 5 of 5
DRossger
in reply to: pbejse

Thanks for explanantion, it´s clear now

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost