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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:42:47+00:00 2026-05-23T13:42:47+00:00

I am trying to make a function call using the data I read from

  • 0

I am trying to make a function call using the data I read from an input file. I have the following function that takes a list of vertices and an arbitrary numbers of commands. (I simplified the function a bit here).

(create-graph vertex-list cmd0 cmd1 ... cmdn)

My input file would have something like:

(2
(vertex-create "Paris")
(vertex-create "London"))

where 2 is the the number of vertices.

With that input, I would like to call create-graph as

(create-graph
  '(v1 v2)
  (set! v1 (vertex-create "Paris"))
  (set! v2 (vertex-create "London"))
)

where v1 and v2 are symbols created for each vertex.

What I have now is to construct the whole function as a string and use eval-string. But is there a way to make that function call without using eval-string? Using eval for some parts should be fine. More specifically, I think I need to be able to do these dynamically:

  • create a list of symbols, and
  • create the commands (e.g. (set! v1 (vertex-create “Paris”)))

I would appreciate your input. 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-05-23T13:42:47+00:00Added an answer on May 23, 2026 at 1:42 pm

    Yes, you can do this without eval. Yes, that’s a much better idea. It’s important to understand that every program can be seen as an interpreter for its inputs, but once you understand eval, you should never use it again….

    Your program might wind up looking something like this:

    #lang racket
    
    (define cmds (file->value input-file))
    
    (define vertex-names (for ([i (in-range (length cmds))])
                           (string->symbol (format "v~s" i))))
    
    (create-graph
     (for/list ([v (in-list vertex-names)]
                [cmd (in-list cmds)])
       (list
        v
        (match cmd
          [(list 'vertex-create str) (vertex-create str)]
          ... other choices? ...
          ))))
    

    I assumed that rather than specifying the number of vertices, that you’d just infer it from the length of the list of commands. Also, I can’t see what other “commands” there might be. Also,
    your set!s are unnecessary and yucky :).

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

Sidebar

Related Questions

Im trying to make a function return a string from a ajax call. This
I'm trying to make a call to a DLL function (via GetProcAddress etc) from
I have a PHP file using json_encode to make a single call, but it
I'm trying to make a autoscrolling/carousel like function for an unordered list of images.
I trying to make my first AJAX with JSON call using jQuery and CodeIgniter.
I'm trying to make an ajax call to grab session data to insert into
So, I'm trying to make a simple call using jQuery .getJSON to my local
Trying to make a make generic select control that I can dynamically add elements
Trying to make a MySQL-based application support MS SQL, I ran into the following
Trying to make a generic PL/SQL procedure to export data in specific XML format,

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.