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

assoc mapcar and strcase

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
507 Views, 5 Replies

assoc mapcar and strcase

Having a Monday on a Wednesday....

I am trying to get the assoc value of a list. The problem is sometimes the value I am looking for is upper case and other times not, while the list is upper/lower case.  I am wanting to use mapcar to convert the 1st value in each part of the list to uppercase during the assoc.

 

Example -

(setq Value "TEXT2")

(setq Mylist (list (list "Text1" "Line 1") (list "Text2" "Line 2") (list "Text3" "Line 3")))

(assoc Value Mylist)

;returns nil

 

I can't figure out the rest of the following -

(setq ValueFound (assoc (strcase Value) (mapcar .........

 

Hope this is clearer than mud.

5 REPLIES 5
Message 2 of 6
dbroad
in reply to: Anonymous


@Anonymous wrote:

Having a Monday on a Wednesday....

I am trying to get the assoc value of a list. The problem is sometimes the value I am looking for is upper case and other times not, while the list is upper/lower case.  I am wanting to use mapcar to convert the 1st value in each part of the list to uppercase during the assoc.

 

Example -

(setq Value "TEXT2")

(setq Mylist (list (list "Text1" "Line 1") (list "Text2" "Line 2") (list "Text3" "Line 3")))

(assoc Value Mylist)

;returns nil

 

I can't figure out the rest of the following -

(setq ValueFound (assoc (strcase Value) (mapcar .........

 

Hope this is clearer than mud.


Something like this:

 

(assoc (strcase value) (mapcar '(lambda (x)(cons (strcase car x)(cdr x))) mylist))

Architect, Registered NC, VA, SC, & GA.
Message 3 of 6
pbejse
in reply to: dbroad


@Anonymous wrote:
Something like this:

 

(assoc (strcase value) (mapcar '(lambda (x)(cons (strcase car x)(cdr x))) mylist))


(assoc (strcase value) (mapcar '(lambda (x)(cons (strcase (car x))(cdr x))) mylist))

 

 

Message 4 of 6
dbroad
in reply to: Anonymous

Thanks for the correction. Wasn't at AutoCAD when posted.

Architect, Registered NC, VA, SC, & GA.
Message 5 of 6
Anonymous
in reply to: Anonymous

Thanks guys....

Message 6 of 6
dbroad
in reply to: Anonymous

Probably should give  pbejse the credit for the solution instead of yourself.  Otherwise others reading the thread will be confused.

 

 
Architect, Registered NC, VA, SC, & GA.

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

Post to forums  

Autodesk Design & Make Report

”Boost