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 8665543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:30:20+00:00 2026-06-12T17:30:20+00:00

I have a function that takes a number such as 36, and reverses it

  • 0

I have a function that takes a number such as 36, and reverses it to say

 '(6 3)

Is there anyway to combine that 6 3 to make it one number?

Here is the code that I have written.


    (define (number->rdigits num)
      (if (rdigits (/ (- num (mod num 10)) 10)))))


    (define reversible?
      (lambda (n)
        (cond
          [(null? n) #f]
          [else (odd? (+ n (list (number->rdigits n))))])))

Thanks!

  • 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-12T17:30:21+00:00Added an answer on June 12, 2026 at 5:30 pm

    You can do this using an iterative function that takes each element of the list in turn, accumulating a result. For example:

    (define (make-number lst)
      (define (make a lst)
         (if (null? lst)
             a
             (make (+ (* 10 a) (car lst)) (cdr lst))))
      (make 0 lst))
    
    (display (make-number '(6 3)))
    

    The make function uses an accumulator a and the rest of the digits in lst to build up the final result one step at a time:

    a = 0
    a = 0*10 + 6 = 6
    a = 6*10 + 3 = 63
    

    If you had more digits in your list, this would continue:

    a = 63*10 + 5 = 635
    a = 635*10 + 9 = 6359
    

    A less efficient implementation that uses a single function could be as follows:

    (define (make-number lst)
      (if (null? lst)
          0
          (+ (* (expt 10 (length (cdr lst))) (car lst)) (make-number (cdr lst)))))
    

    This function needs to calculate the length of the remainder of the list for each iteration, as well as calling the expt function repeatedly. Also, this implementation is not properly tail recursive so it builds up multiple stack frames during execution before unwinding them all after it reaches its maximum recursion depth.

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

Sidebar

Related Questions

Say I have a function that takes an arbitrary number of arguments (the last
I have the following function that takes a number like 5 and creates a
Hi i have a function that takes an integer number n and returns a
I have a PHP function that takes a variable number of arguments (using func_num_args()
I have a function called Colorbox (jQuery plugin) that takes a number of parameters
I have a function that takes a variable number of parameters, and I have
I have a function that takes an input string and then runs the string
I have a function that takes a By element, By by = By.xpath(xpathString). Inside
I have a function that takes a string-like argument. I want to decide if
I have a function that takes a const D3DVECTOR3 *pos , but I have

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.