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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:15:28+00:00 2026-06-03T05:15:28+00:00

I think I read somewhere that you could bind multiple definitions to a single

  • 0

I think I read somewhere that you could bind multiple definitions to a single name in scheme. I know I might be using the terminology incorrectly. By this I mean it is possible to do the following (which would be really handy to defining an operator)?

I believe I read something like this (I know this is not real syntax)

(let ()
define operator "+"
define operator "-"
define operator "*"
define operator "/"))

I want to test another variable against every operator.

  • 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-03T05:15:30+00:00Added an answer on June 3, 2026 at 5:15 am

    I’m not really sure what you’re asking. Do you want a single procedure that can handle different types of arguments?

    (define (super-add arg1 arg2)
      (cond ((and (string? arg1) (string? arg2))
             (string-append arg1 arg2))
            ((and (number? arg1) (number? arg2))
             (+ arg1 arg2))
            (else
              (error "UNKNOWN TYPE -- SUPER-ADD"))))
    
    (super-add "a" "b") => "ab"
    (super-add 2 2) => 4
    

    Are you interested in message passing?

    (define (math-ops msg)  ;<---- returns a procedure depending on the msg
      (cond ((eq? msg 'add) +)
            ((eq? msg 'sub) -)
            ((eq? msg 'div) /)
            ((eq? msg 'multi) *)
            (else
              (error "UNKNOWN MSG -- math-ops"))))
    
    ((math-ops 'add) 2 2) => 4
    ((math-ops 'sub) 2 2) => 0
    

    Also the proper syntax for a let binding:

    (let (([symbol] [value])
          ([symbol] [value]))
       ([body]))
    
    (let ((a 2)
          (b (* 3 3)))
       (+ a b))
    
     => 11
    

    It will be very hard to help more than this without you clarifying what it is you are trying to do.

    EDIT: After your comment, I have a little bit better of an idea for what you’re looking for. There is not way to bind multiple values to the same name in the way that you mean. You are looking for a predicate that will tell you whether the thing you are looking at is one of your operators. From your comment it looked like you will be taking in a string, so that’s what this is based on:

    (define (operator? x)
        (or (string=? "+" x) (string=? "-" x) (string=? "*" x) (string=? "/" x)))
    

    If you are taking in a single string then you will need to split it into smaller parts. Racket has a built in procedure regexp-split that will do this for you.

    (define str-lst (regexp-split #rx" +" [input str]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I read somewhere that some modules only have object oriented interfaces (
I think I've read somewhere that Django's ORM lazily loads objects. Let's say I
I think I read every single web page relating to this problem but I
From what I've read from Herb Sutter and others you would think that volatile
I've read somewhere (I dont recall exactly where) that Git (and probably any other
I have read somewhere that to handle large number arithmetic (really really large) we
When I started iPhone development, I read somewhere that it's possible to attach a
I read somewhere that older VB .net (pre VB .NET 2005?) couldn't use overloaded
Is there some global state somewhere that I can access the currently-running test name?
I've read Visual VM remotely over ssh but I think I've not fully understood

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.