Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

ericrost

  • 2 years ago

For Problem Lec.5.3.3: Functions on Lists Part 2 question 12, I don't understand why (length (cons y y)) is 4. For reference y => (1 2 3)

  • This Question is Open
  1. teal
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    The list is ((1 2 3) 1 2 3), which is 4 items. The first list is only a single item, because it's in car.

  2. dbastos
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Like our friend above says, the first element is a single item. In Lisp, lists can contain any kind of elements. (Even other lists.) In that list of yours, the first element is a list (with 3 elements), but that list with 3 elements is /the first/ element of the list (cons y y). Does that clarify?

  3. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy