Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8096621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:30:36+00:00 2026-06-05T21:30:36+00:00

I have this association-list in Common Lisp: (defvar base-list (list (cons ‘a 0) (cons

  • 0

I have this association-list in Common Lisp:

(defvar base-list (list (cons 'a 0) (cons 2 'c)))

I have to call assoc when my argument is of type string.

For the pair (A . 0) I have to convert “a” to a symbol, and for the pair (2 . C) I have to convert “2” to a symbol. How can I do that?

This should work like this:

CL-USER 28 : 1 > (assoc (convert-string-to-symbol "a") base-list)
(A . 0)
CL-USER 28 : 1 > (assoc (convert-number-to-symbol "2") base-list)
(2 . C)

I tried using intern but got NIL:

CL-USER 29 : 1 > (assoc (intern "a") base-list)
NIL
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:30:38+00:00Added an answer on June 5, 2026 at 9:30 pm

    You were close with intern; you just had the case wrong. Try this:

    > (assoc (intern "A") base-list)
    (A . 0)
    

    Note that here the name-as-string is capitalized.

    Alternately, you could use find-symbol to look for an existing symbol by name:

    > (assoc (find-symbol "A") base-list)
    (A . 0)
    

    The key here is that when you wrote your original defvar form, the reader read the string “a” and—by virtue of the current readtable case—converted the symbol name to be uppercase. Symbols with names of different case are not equal. It just so happens that at read time the reader is projecting what you wrote (lowercase) to something else (uppercase).

    You can inspect the current case conversion policy for the current reader using the readtable-case function:

    > (readtable-case *readtable*)
    :UPCASE
    

    To learn more about how the readtable case and the reader interact, see the discussion in section 23.1.2 of the Hyperspec.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question concerning active record association, referring to this part of the
I have a collection of entities with an any-association, like this: public class CreatedLog
I have a accepts_nested_attributes_for association between timesheet and timesheetlines. This works great, but when
my issue lokks similar to this one: (link) but i have one-to-many association: <set
I have a simple has_one/belongs_to relationship between two models. This is a new association
I have this type of associative array. Array ( [0] => Array ( [bookedArea]
I am loading a list of many entities. These entities have a one-to-many association
So I have this form which requests a JS call when a comment is
I have a class and inside it, a string and a list of enumerators.
Possible Duplicate: php loop through associative arrays i have this piece of code which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.