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

  • SEARCH
  • Home
  • 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 6978795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:48:09+00:00 2026-05-27T17:48:09+00:00

There is this procedure giving me trouble: (define (pro lst) (define (inner l) (if

  • 0

There is this procedure giving me trouble:

(define (pro lst)
  (define (inner l)
    (if (null? (mcdr l))
        (set-mcdr! l lst)
        (inner (mcdr l))))
  (inner lst)
  lst)

Using (mlist 1 2 3) as parameter I get #0={1 2 3 . #0#} returned.
(mcdr (pro (mlist 1 2 3))) returns #0={2 3 1 . #0#},
(mcdr (mcdr (pro (mlist 1 2 3)))) returns #0={3 1 2 . #0#} and so on.

So obviously this is for cycling through lists by returning a pair of a list and another procedure. But how does this work? I only see that it replaces the final'() with the parameter lst but not with any obscure lambda function …
What do #0 and #0# mean anyway?

  • 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-05-27T17:48:10+00:00Added an answer on May 27, 2026 at 5:48 pm

    In the expression #0={1 2 3 . #0#}, think of #0= as an anchor and #0# as a link to that anchor – that is, in the list the first three elements are 1 2 3 but the fourth element is a pointer to the start of the list, therefore forming a three-element circular list. If you keep advancing over that list (by successive mcdrs), you’ll see a three element list in a cycling pattern 1 2 3 1 2 3 ..., always showing that the fourth element jumps back to the first.

    Studying the above function makes it clear why this is happenning. The pro procedure simply calls inner on the lst parameter (a proper list, a list with null as its last element) and then returns the modified lst, the interesting part is what happens in inner:

    • (if (null? (mcdr l)): If we’re on the last non-null element of the list, replace the next element (which should be a null in a proper list), by a reference to the first element, which we know is in the lst parameter: (set-mcdr! l lst)
    • Otherwise, keep advancing over the list: (inner (mcdr l))

    To summarize: the pro procedure gets as its input a proper list and returns the same list but with the last element pointing back to its first element – a circular list.

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

Sidebar

Related Questions

i have this stored procedure, doing a select query with couple of inner joins
Is there anything wrong with this procedure? Enter in username and email in a
Is there a method or a class in igraph to do this procedure fast
I got this project, where there this error keeps occurring and its not on
There is this example code, but then it starts talking about millisecond / nanosecond
There's this program, pdftotext, that can convert a pdf file to a text file.
There's this Excel file I want users to be able to download from my
There is this option available in Visual Studio 2008. Is there a similar option
There's this ... MSDN page, IQueryable(Of T) Interface . Can you do a better
there is this check-in-out program here at my workplace, it only takes the data

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.