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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:40:45+00:00 2026-05-18T08:40:45+00:00

Example input: ((a1 . b) (a1 . c)): I have one list with two

  • 0

Example input:

((a1 . b) (a1 . c)): 

I have one list with two elements, those elements are lists or pairs with two elements. And i want to check if the first element of the first pair/list is equal to the first element of the second pair/list.

output: If so, i want to create a new list with two lists, the first is the list:
while (b < c) -> (a1 . b(even)) (a1 . b+2(even))…
The other list is the same, but with the odd’s

How do I implement this in scheme:

INPUT:

((1 . 1) (1 . 7))

OUTPUT:

(((1 . 2) (1 . 4) (1 . 6)) ((1 . 3) (1 . 5) (1 . 7)))

I have one list with two elements. Each element is also a list with two elements, both integers >= 0 and < 8

I have to create this:

input ((a1 . b) (a1 . c)) 

output: (if (and (= a1 a2) (odd? b))
          While < b c
             (list (a1 . b+1) (a1 . b+3) (a1 . b+n)...)) 
             (list (a2 . b) (a2 . b+2) (a2 . b+4)...)

I had done this, but i can’t find where i’m failing, could you help me?….

;;; Verify if absissa0 = absissa1

(define (game-position input)
  (if (= (car (car j)) (cdr (cdr j)))
          (col1_col2 j)
          (error "Not valid"))))
;;; verify if absissa0 is even

(define (col1_col2 gstart)
  (if (even? (cdr (car jstart))) 
      (list (pos-start jstart))
      (list (pos-start (list (cons (car (car jstart)) (- (cdr (car jstart)) 1)) (car (cdr jstart))))))


;;; Loop that creates positions of even's and odd's

(define (pos-start j2)
  (while ( < (cdr (car j2)) (- (cdr (cdr j2)) 2))
      ((cons (car (car j2)) (+ (cdr (car j2)) 2)) (pos-start (list (cons (car (car j2)) (+ (cdr (car j2)) 2)) (car (cdr j2)))))
      (odd_2 (list (cons (car (car j2)) (+ (cdr (car j2)) 1)) (car (cdr j2)))))

(define (odd_2 j3)
  (while ( < (cdr (car j3)) (- (car (cdr j3)) 2))
      ((j3) (odd_2 (list (cons (car (car j3)) (+ (cdr (car j3)) 2)) (car (cdr j3)))
         (value)))
  • 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-18T08:40:45+00:00Added an answer on May 18, 2026 at 8:40 am

    I’m a bit rusty in scheme, I’ve managed to get this solution to your problem,
    it use recursion vs while, but I’m not accustomed to that construct in scheme:

    (define data (list (cons 1 1) (cons 1 7)))
    
    (define (neven n) (if (even? n) n (+ n 1)))
    
    (define (sublist a mn mx) 
      (cond 
        ((<= mn mx ) (cons (cons a mn) (sublist a (+ mn 2) mx)))
        (else '())))
    
    (define (game-position input)
       (if (= (caar input) (caadr input))
           (list (sublist (caar input) 
                          (neven (cdar input)) 
                          (cdadr input))
                 (sublist (caar input) 
                          (+ 1 (neven (cdar input))) 
                          (cdadr input)))
           (error "no match")))
    
    (game-position data)
    

    edit: It works in guile and drscheme. Hope it will works in plt-scheme too.
    edit: sublist inner working

    First the parameters:

    • a is the car of the pairs contained into the list
    • mn is the cdr of the first pair
    • mx is the upper limit of the serie.

    the body of the function is quite simple:

    if the cdr of the current pair is smaller or equal to the upper limit then return a list
    composed by a pair (a . mn) and the list created by a call to sublist with the mn parameter changed to reflect the next possible pair.
    if the current pair will have a cdr higher than the upper limit then return null (empty list) in order to close the cons issued by the previous invocation of sublist.

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

Sidebar

Related Questions

In my example below I'm using a dijit.form.DateTextBox : <input type=text name=startDate dojoType=dijit.form.DateTextBox constraints={datePattern:'MM/dd/yyyy'}
Example: You have a shortcut s to SomeProgram in the current directory. In cmd.exe
Example I have Person , SpecialPerson , and User . Person and SpecialPerson are
example: I want to see if array[5] holds a value or is empty.
Example C API signature: void Func(unsigned char* bytes); In C, when I want to
Example: select ename from emp where hiredate = todate('01/05/81','dd/mm/yy') and select ename from emp
example: a_list = [1, 2, 3] a_list.len() # doesn't work len(a_list) # works Python
Example: an Order object (aggregate root) has a collection of OrderLine objects (child entities).
Example: The user login to the webpage => Click on a button This action
Example int *ptr; *ptr = 1000; can I catch memory access violation exception using

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.