Run a function whose name is in a listHow do I check if a list is empty?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How to randomly select an item from a list?How do you split a list into evenly sized chunks?Getting the last element of a listHow to make a flat list out of list of listsHow do I get the number of elements in a list?How do I concatenate two lists in Python?How to clone or copy a list?

How to improve the size of cells in this table?

Why is the order of my features changed when using readFeatures in OpenLayers v4.6.5?

Milky way is orbiting around?

My players like to search everything. What do they find?

What is the difference between a historical drama and a period drama?

Why did the "Orks" never develop better firearms than Firelances and Handcannons?

Explain how 'Sharing the burden' puzzle from Professor Layton and the Miracle Mask should be solved

Why would a propellor have blades of different lengths?

Did Stalin kill all Soviet officers involved in the Winter War?

Park the computer

What is the maximum amount of diamond in one Minecraft game?

Is there a typical layout to blocking installed for backing in new construction framing?

CPA filed late returns, stating I would get money; IRS says they were filed too late

PhD: When to quit and move on?

Show that there are infinitely more problems than we will ever be able to compute

Is it possible that Curiosity measured its own methane or failed doing the spectrometry?

Does taking on an assistant professor position prevent me from doing post-docs later?

How can I effectively map a multi-level dungeon?

When do I make my first save against the Web spell?

What does the ash content of broken wheat really mean?

Why did moving the mouse cursor cause Windows 95 to run more quickly?

Using Sed to add counter to keyword

How can one synthesise a conjugated alkyne chain?

Does the Defensive Duelist feat stack with the Warforged integrated protection?



Run a function whose name is in a list


How do I check if a list is empty?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How to randomly select an item from a list?How do you split a list into evenly sized chunks?Getting the last element of a listHow to make a flat list out of list of listsHow do I get the number of elements in a list?How do I concatenate two lists in Python?How to clone or copy a list?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm still learning Racket.



I have to call an unknown function. The function and its parameters are in the following list:



(define l1 '((function-name parameter1)
(function-name parameter3)))


To run that function, I'm doing:



(first (car l1)) (second (car l1)) another-parameter


But I get the error:



 application: not a procedure;
expected a procedure that can be applied to arguments
given: 'function-name
arguments...:


How can I run that function-name?



UPDATE:



I have tried Óscar's answer:



(eval (first (car l1)) (second (car l1)) another-parameter)


And I get the error:



 eval: arity mismatch;
the expected number of arguments does not match the given number
given: 3
arguments...:


I have also tried:



(define-namespace-anchor a)
(define ns (namespace-anchor->namespace a))
(eval (first (car l1)) (second (car l1)) another-parameter ns)


And I get the same error:



 eval: arity mismatch;
the expected number of arguments does not match the given number
given: 4
arguments...:


Then, I tried this:



(eval (list (first (car l1)) (second (car l1)) another-parameter))


And I get the error:



function-name: unbound identifier;
also, no #%app syntax transformer is bound in: function-name


Finally, I have tried:



(eval (list (first (car l1)) (second (car l1)) another-parameter) ns)


And I get an internal error from function-name. But this function, works perfectly.



function-name could be at least three functions (or more), this is why I haven't put it here before. All of them will have two lists as parameters, and they will return #t or #f.



One of then, then one is testing now is:



(define match (lambda (list1 list2) ...))


Obviously, list1 and list2 are lists.



UPDATE 2:

I have tried Óscar's Minimal, Complete and verifiable example, and it works. But, I have modified to used on my on work, and it doesn't work. Look:



(define function-name
(lambda (list1 list2)
(append list1 list2)))

(define parameter1 '(1 2))
(define parameter3 '(3 4))
(define another-parameter '(5 6))

(define l1 '((function-name parameter1)
(function-name parameter3)))

(define-namespace-anchor a)
(define ns (namespace-anchor->namespace a))

(define another-function
(lambda (l1 the-parameter)
(cond
[(eval (list (first (car l1)) (second (car l1)) 'the-parameter) ns) l1])
)
)

(another-function l1 another-parameter)


I have created another-function, and it fails with the parameter 'the-parameter. It complains saying:



the-parameter: undefined;
cannot reference an identifier before its definition


So the problem is when I use a function's parameter as a parameter for the eval function.










share|improve this question






























    0















    I'm still learning Racket.



    I have to call an unknown function. The function and its parameters are in the following list:



    (define l1 '((function-name parameter1)
    (function-name parameter3)))


    To run that function, I'm doing:



    (first (car l1)) (second (car l1)) another-parameter


    But I get the error:



     application: not a procedure;
    expected a procedure that can be applied to arguments
    given: 'function-name
    arguments...:


    How can I run that function-name?



    UPDATE:



    I have tried Óscar's answer:



    (eval (first (car l1)) (second (car l1)) another-parameter)


    And I get the error:



     eval: arity mismatch;
    the expected number of arguments does not match the given number
    given: 3
    arguments...:


    I have also tried:



    (define-namespace-anchor a)
    (define ns (namespace-anchor->namespace a))
    (eval (first (car l1)) (second (car l1)) another-parameter ns)


    And I get the same error:



     eval: arity mismatch;
    the expected number of arguments does not match the given number
    given: 4
    arguments...:


    Then, I tried this:



    (eval (list (first (car l1)) (second (car l1)) another-parameter))


    And I get the error:



    function-name: unbound identifier;
    also, no #%app syntax transformer is bound in: function-name


    Finally, I have tried:



    (eval (list (first (car l1)) (second (car l1)) another-parameter) ns)


    And I get an internal error from function-name. But this function, works perfectly.



    function-name could be at least three functions (or more), this is why I haven't put it here before. All of them will have two lists as parameters, and they will return #t or #f.



    One of then, then one is testing now is:



    (define match (lambda (list1 list2) ...))


    Obviously, list1 and list2 are lists.



    UPDATE 2:

    I have tried Óscar's Minimal, Complete and verifiable example, and it works. But, I have modified to used on my on work, and it doesn't work. Look:



    (define function-name
    (lambda (list1 list2)
    (append list1 list2)))

    (define parameter1 '(1 2))
    (define parameter3 '(3 4))
    (define another-parameter '(5 6))

    (define l1 '((function-name parameter1)
    (function-name parameter3)))

    (define-namespace-anchor a)
    (define ns (namespace-anchor->namespace a))

    (define another-function
    (lambda (l1 the-parameter)
    (cond
    [(eval (list (first (car l1)) (second (car l1)) 'the-parameter) ns) l1])
    )
    )

    (another-function l1 another-parameter)


    I have created another-function, and it fails with the parameter 'the-parameter. It complains saying:



    the-parameter: undefined;
    cannot reference an identifier before its definition


    So the problem is when I use a function's parameter as a parameter for the eval function.










    share|improve this question


























      0












      0








      0








      I'm still learning Racket.



      I have to call an unknown function. The function and its parameters are in the following list:



      (define l1 '((function-name parameter1)
      (function-name parameter3)))


      To run that function, I'm doing:



      (first (car l1)) (second (car l1)) another-parameter


      But I get the error:



       application: not a procedure;
      expected a procedure that can be applied to arguments
      given: 'function-name
      arguments...:


      How can I run that function-name?



      UPDATE:



      I have tried Óscar's answer:



      (eval (first (car l1)) (second (car l1)) another-parameter)


      And I get the error:



       eval: arity mismatch;
      the expected number of arguments does not match the given number
      given: 3
      arguments...:


      I have also tried:



      (define-namespace-anchor a)
      (define ns (namespace-anchor->namespace a))
      (eval (first (car l1)) (second (car l1)) another-parameter ns)


      And I get the same error:



       eval: arity mismatch;
      the expected number of arguments does not match the given number
      given: 4
      arguments...:


      Then, I tried this:



      (eval (list (first (car l1)) (second (car l1)) another-parameter))


      And I get the error:



      function-name: unbound identifier;
      also, no #%app syntax transformer is bound in: function-name


      Finally, I have tried:



      (eval (list (first (car l1)) (second (car l1)) another-parameter) ns)


      And I get an internal error from function-name. But this function, works perfectly.



      function-name could be at least three functions (or more), this is why I haven't put it here before. All of them will have two lists as parameters, and they will return #t or #f.



      One of then, then one is testing now is:



      (define match (lambda (list1 list2) ...))


      Obviously, list1 and list2 are lists.



      UPDATE 2:

      I have tried Óscar's Minimal, Complete and verifiable example, and it works. But, I have modified to used on my on work, and it doesn't work. Look:



      (define function-name
      (lambda (list1 list2)
      (append list1 list2)))

      (define parameter1 '(1 2))
      (define parameter3 '(3 4))
      (define another-parameter '(5 6))

      (define l1 '((function-name parameter1)
      (function-name parameter3)))

      (define-namespace-anchor a)
      (define ns (namespace-anchor->namespace a))

      (define another-function
      (lambda (l1 the-parameter)
      (cond
      [(eval (list (first (car l1)) (second (car l1)) 'the-parameter) ns) l1])
      )
      )

      (another-function l1 another-parameter)


      I have created another-function, and it fails with the parameter 'the-parameter. It complains saying:



      the-parameter: undefined;
      cannot reference an identifier before its definition


      So the problem is when I use a function's parameter as a parameter for the eval function.










      share|improve this question
















      I'm still learning Racket.



      I have to call an unknown function. The function and its parameters are in the following list:



      (define l1 '((function-name parameter1)
      (function-name parameter3)))


      To run that function, I'm doing:



      (first (car l1)) (second (car l1)) another-parameter


      But I get the error:



       application: not a procedure;
      expected a procedure that can be applied to arguments
      given: 'function-name
      arguments...:


      How can I run that function-name?



      UPDATE:



      I have tried Óscar's answer:



      (eval (first (car l1)) (second (car l1)) another-parameter)


      And I get the error:



       eval: arity mismatch;
      the expected number of arguments does not match the given number
      given: 3
      arguments...:


      I have also tried:



      (define-namespace-anchor a)
      (define ns (namespace-anchor->namespace a))
      (eval (first (car l1)) (second (car l1)) another-parameter ns)


      And I get the same error:



       eval: arity mismatch;
      the expected number of arguments does not match the given number
      given: 4
      arguments...:


      Then, I tried this:



      (eval (list (first (car l1)) (second (car l1)) another-parameter))


      And I get the error:



      function-name: unbound identifier;
      also, no #%app syntax transformer is bound in: function-name


      Finally, I have tried:



      (eval (list (first (car l1)) (second (car l1)) another-parameter) ns)


      And I get an internal error from function-name. But this function, works perfectly.



      function-name could be at least three functions (or more), this is why I haven't put it here before. All of them will have two lists as parameters, and they will return #t or #f.



      One of then, then one is testing now is:



      (define match (lambda (list1 list2) ...))


      Obviously, list1 and list2 are lists.



      UPDATE 2:

      I have tried Óscar's Minimal, Complete and verifiable example, and it works. But, I have modified to used on my on work, and it doesn't work. Look:



      (define function-name
      (lambda (list1 list2)
      (append list1 list2)))

      (define parameter1 '(1 2))
      (define parameter3 '(3 4))
      (define another-parameter '(5 6))

      (define l1 '((function-name parameter1)
      (function-name parameter3)))

      (define-namespace-anchor a)
      (define ns (namespace-anchor->namespace a))

      (define another-function
      (lambda (l1 the-parameter)
      (cond
      [(eval (list (first (car l1)) (second (car l1)) 'the-parameter) ns) l1])
      )
      )

      (another-function l1 another-parameter)


      I have created another-function, and it fails with the parameter 'the-parameter. It complains saying:



      the-parameter: undefined;
      cannot reference an identifier before its definition


      So the problem is when I use a function's parameter as a parameter for the eval function.







      list functional-programming scheme racket






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 10:22







      VansFannel

















      asked Mar 25 at 18:40









      VansFannelVansFannel

      21k85 gold badges292 silver badges510 bronze badges




      21k85 gold badges292 silver badges510 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          2














          You can use eval and quasiquoting for this, it works for your input. Do notice that this is how you should post your questions, it's a Minimal, Complete, and Verifiable example that anyone can copy and run, without having to guess what you were thinking:



          (define function-name
          (lambda (list1 list2)
          (append list1 list2)))

          (define parameter1 '(1 2))
          (define parameter3 '(3 4))
          (define another-parameter '(5 6))

          (define l1 '((function-name parameter1)
          (function-name parameter3)))

          (define-namespace-anchor a)
          (define ns (namespace-anchor->namespace a))

          (define another-function
          (lambda (l1 the-parameter)
          (cond
          [(eval `(,(first (car l1)) ,(second (car l1)) ',the-parameter) ns)
          l1])))

          (another-function l1 another-parameter)
          => '((function-name parameter1) (function-name parameter3))





          share|improve this answer

























          • Thanks for your answer. I have tried it and I get errors. I have updated my question. I'm testing the last error to know if it is my fault. Thanks.

            – VansFannel
            Mar 26 at 7:48











          • As always: please post the real functions you’re using to test. At least an skeleton, so we know what parameters they’re expecting, etc.

            – Óscar López
            Mar 26 at 7:50











          • Sorry. Question updated.

            – VansFannel
            Mar 26 at 7:59











          • This should work, and notice the quote before another-parameter: (eval (list (first (car l1)) (second (car l1)) 'another-parameter) ns). If you still get an internal error from function-name, then there's something wrong with function-name, not with the way eval is doing its job.

            – Óscar López
            Mar 26 at 9:15












          • I think I have found my problem. I have updated the question, but the problem is that I'm using as the parameter another-parameter a parameter from the function that eval is inside. Thanks a lot.

            – VansFannel
            Mar 26 at 10:27


















          4














          Please consider evaluating the procedure like this:





          (define l1 `((,sin ,(+ 1 2))
          (,+ 1 2 3)))

          (sin (+ 1 2)) ; ==> 0.14..
          ((caar l1) (cadar l1)) ; ==> 0.14..
          (apply (caar l1) (cdar l1)) ; ==> 0.14..

          (+ 1 2 3) ; ==> 6
          (apply (caadr l1) (cdadr l1)) ; ==> 6


          Why does this work? Well. Your attempted to call the name of a procedure. By evaluating the procedure name you get the actual procedure object. You can indeed evaluate a procedure in the REPL and see what you get back:



          + ; ==> #<procedure:+>
          l1 ; ==> ((#<procedure:sin> 3) (#<procedure:+> 1 2 3))


          If l1 were defined as '((sin (+ 1 2)) (+ 1 2 3)) evaluating it would return ((sin (+ 1 2)) (+ 1 2 3)) so there is a big difference.



          And of course. Using the quasiquote/unquote is just a fancy way of writing this:



          (define l1 (list (list sin (+ 1 2))
          (list + '1 '2 '3)))





          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55344480%2frun-a-function-whose-name-is-in-a-list%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            You can use eval and quasiquoting for this, it works for your input. Do notice that this is how you should post your questions, it's a Minimal, Complete, and Verifiable example that anyone can copy and run, without having to guess what you were thinking:



            (define function-name
            (lambda (list1 list2)
            (append list1 list2)))

            (define parameter1 '(1 2))
            (define parameter3 '(3 4))
            (define another-parameter '(5 6))

            (define l1 '((function-name parameter1)
            (function-name parameter3)))

            (define-namespace-anchor a)
            (define ns (namespace-anchor->namespace a))

            (define another-function
            (lambda (l1 the-parameter)
            (cond
            [(eval `(,(first (car l1)) ,(second (car l1)) ',the-parameter) ns)
            l1])))

            (another-function l1 another-parameter)
            => '((function-name parameter1) (function-name parameter3))





            share|improve this answer

























            • Thanks for your answer. I have tried it and I get errors. I have updated my question. I'm testing the last error to know if it is my fault. Thanks.

              – VansFannel
              Mar 26 at 7:48











            • As always: please post the real functions you’re using to test. At least an skeleton, so we know what parameters they’re expecting, etc.

              – Óscar López
              Mar 26 at 7:50











            • Sorry. Question updated.

              – VansFannel
              Mar 26 at 7:59











            • This should work, and notice the quote before another-parameter: (eval (list (first (car l1)) (second (car l1)) 'another-parameter) ns). If you still get an internal error from function-name, then there's something wrong with function-name, not with the way eval is doing its job.

              – Óscar López
              Mar 26 at 9:15












            • I think I have found my problem. I have updated the question, but the problem is that I'm using as the parameter another-parameter a parameter from the function that eval is inside. Thanks a lot.

              – VansFannel
              Mar 26 at 10:27















            2














            You can use eval and quasiquoting for this, it works for your input. Do notice that this is how you should post your questions, it's a Minimal, Complete, and Verifiable example that anyone can copy and run, without having to guess what you were thinking:



            (define function-name
            (lambda (list1 list2)
            (append list1 list2)))

            (define parameter1 '(1 2))
            (define parameter3 '(3 4))
            (define another-parameter '(5 6))

            (define l1 '((function-name parameter1)
            (function-name parameter3)))

            (define-namespace-anchor a)
            (define ns (namespace-anchor->namespace a))

            (define another-function
            (lambda (l1 the-parameter)
            (cond
            [(eval `(,(first (car l1)) ,(second (car l1)) ',the-parameter) ns)
            l1])))

            (another-function l1 another-parameter)
            => '((function-name parameter1) (function-name parameter3))





            share|improve this answer

























            • Thanks for your answer. I have tried it and I get errors. I have updated my question. I'm testing the last error to know if it is my fault. Thanks.

              – VansFannel
              Mar 26 at 7:48











            • As always: please post the real functions you’re using to test. At least an skeleton, so we know what parameters they’re expecting, etc.

              – Óscar López
              Mar 26 at 7:50











            • Sorry. Question updated.

              – VansFannel
              Mar 26 at 7:59











            • This should work, and notice the quote before another-parameter: (eval (list (first (car l1)) (second (car l1)) 'another-parameter) ns). If you still get an internal error from function-name, then there's something wrong with function-name, not with the way eval is doing its job.

              – Óscar López
              Mar 26 at 9:15












            • I think I have found my problem. I have updated the question, but the problem is that I'm using as the parameter another-parameter a parameter from the function that eval is inside. Thanks a lot.

              – VansFannel
              Mar 26 at 10:27













            2












            2








            2







            You can use eval and quasiquoting for this, it works for your input. Do notice that this is how you should post your questions, it's a Minimal, Complete, and Verifiable example that anyone can copy and run, without having to guess what you were thinking:



            (define function-name
            (lambda (list1 list2)
            (append list1 list2)))

            (define parameter1 '(1 2))
            (define parameter3 '(3 4))
            (define another-parameter '(5 6))

            (define l1 '((function-name parameter1)
            (function-name parameter3)))

            (define-namespace-anchor a)
            (define ns (namespace-anchor->namespace a))

            (define another-function
            (lambda (l1 the-parameter)
            (cond
            [(eval `(,(first (car l1)) ,(second (car l1)) ',the-parameter) ns)
            l1])))

            (another-function l1 another-parameter)
            => '((function-name parameter1) (function-name parameter3))





            share|improve this answer















            You can use eval and quasiquoting for this, it works for your input. Do notice that this is how you should post your questions, it's a Minimal, Complete, and Verifiable example that anyone can copy and run, without having to guess what you were thinking:



            (define function-name
            (lambda (list1 list2)
            (append list1 list2)))

            (define parameter1 '(1 2))
            (define parameter3 '(3 4))
            (define another-parameter '(5 6))

            (define l1 '((function-name parameter1)
            (function-name parameter3)))

            (define-namespace-anchor a)
            (define ns (namespace-anchor->namespace a))

            (define another-function
            (lambda (l1 the-parameter)
            (cond
            [(eval `(,(first (car l1)) ,(second (car l1)) ',the-parameter) ns)
            l1])))

            (another-function l1 another-parameter)
            => '((function-name parameter1) (function-name parameter3))






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 26 at 11:28

























            answered Mar 25 at 19:15









            Óscar LópezÓscar López

            186k27 gold badges247 silver badges332 bronze badges




            186k27 gold badges247 silver badges332 bronze badges












            • Thanks for your answer. I have tried it and I get errors. I have updated my question. I'm testing the last error to know if it is my fault. Thanks.

              – VansFannel
              Mar 26 at 7:48











            • As always: please post the real functions you’re using to test. At least an skeleton, so we know what parameters they’re expecting, etc.

              – Óscar López
              Mar 26 at 7:50











            • Sorry. Question updated.

              – VansFannel
              Mar 26 at 7:59











            • This should work, and notice the quote before another-parameter: (eval (list (first (car l1)) (second (car l1)) 'another-parameter) ns). If you still get an internal error from function-name, then there's something wrong with function-name, not with the way eval is doing its job.

              – Óscar López
              Mar 26 at 9:15












            • I think I have found my problem. I have updated the question, but the problem is that I'm using as the parameter another-parameter a parameter from the function that eval is inside. Thanks a lot.

              – VansFannel
              Mar 26 at 10:27

















            • Thanks for your answer. I have tried it and I get errors. I have updated my question. I'm testing the last error to know if it is my fault. Thanks.

              – VansFannel
              Mar 26 at 7:48











            • As always: please post the real functions you’re using to test. At least an skeleton, so we know what parameters they’re expecting, etc.

              – Óscar López
              Mar 26 at 7:50











            • Sorry. Question updated.

              – VansFannel
              Mar 26 at 7:59











            • This should work, and notice the quote before another-parameter: (eval (list (first (car l1)) (second (car l1)) 'another-parameter) ns). If you still get an internal error from function-name, then there's something wrong with function-name, not with the way eval is doing its job.

              – Óscar López
              Mar 26 at 9:15












            • I think I have found my problem. I have updated the question, but the problem is that I'm using as the parameter another-parameter a parameter from the function that eval is inside. Thanks a lot.

              – VansFannel
              Mar 26 at 10:27
















            Thanks for your answer. I have tried it and I get errors. I have updated my question. I'm testing the last error to know if it is my fault. Thanks.

            – VansFannel
            Mar 26 at 7:48





            Thanks for your answer. I have tried it and I get errors. I have updated my question. I'm testing the last error to know if it is my fault. Thanks.

            – VansFannel
            Mar 26 at 7:48













            As always: please post the real functions you’re using to test. At least an skeleton, so we know what parameters they’re expecting, etc.

            – Óscar López
            Mar 26 at 7:50





            As always: please post the real functions you’re using to test. At least an skeleton, so we know what parameters they’re expecting, etc.

            – Óscar López
            Mar 26 at 7:50













            Sorry. Question updated.

            – VansFannel
            Mar 26 at 7:59





            Sorry. Question updated.

            – VansFannel
            Mar 26 at 7:59













            This should work, and notice the quote before another-parameter: (eval (list (first (car l1)) (second (car l1)) 'another-parameter) ns). If you still get an internal error from function-name, then there's something wrong with function-name, not with the way eval is doing its job.

            – Óscar López
            Mar 26 at 9:15






            This should work, and notice the quote before another-parameter: (eval (list (first (car l1)) (second (car l1)) 'another-parameter) ns). If you still get an internal error from function-name, then there's something wrong with function-name, not with the way eval is doing its job.

            – Óscar López
            Mar 26 at 9:15














            I think I have found my problem. I have updated the question, but the problem is that I'm using as the parameter another-parameter a parameter from the function that eval is inside. Thanks a lot.

            – VansFannel
            Mar 26 at 10:27





            I think I have found my problem. I have updated the question, but the problem is that I'm using as the parameter another-parameter a parameter from the function that eval is inside. Thanks a lot.

            – VansFannel
            Mar 26 at 10:27













            4














            Please consider evaluating the procedure like this:





            (define l1 `((,sin ,(+ 1 2))
            (,+ 1 2 3)))

            (sin (+ 1 2)) ; ==> 0.14..
            ((caar l1) (cadar l1)) ; ==> 0.14..
            (apply (caar l1) (cdar l1)) ; ==> 0.14..

            (+ 1 2 3) ; ==> 6
            (apply (caadr l1) (cdadr l1)) ; ==> 6


            Why does this work? Well. Your attempted to call the name of a procedure. By evaluating the procedure name you get the actual procedure object. You can indeed evaluate a procedure in the REPL and see what you get back:



            + ; ==> #<procedure:+>
            l1 ; ==> ((#<procedure:sin> 3) (#<procedure:+> 1 2 3))


            If l1 were defined as '((sin (+ 1 2)) (+ 1 2 3)) evaluating it would return ((sin (+ 1 2)) (+ 1 2 3)) so there is a big difference.



            And of course. Using the quasiquote/unquote is just a fancy way of writing this:



            (define l1 (list (list sin (+ 1 2))
            (list + '1 '2 '3)))





            share|improve this answer



























              4














              Please consider evaluating the procedure like this:





              (define l1 `((,sin ,(+ 1 2))
              (,+ 1 2 3)))

              (sin (+ 1 2)) ; ==> 0.14..
              ((caar l1) (cadar l1)) ; ==> 0.14..
              (apply (caar l1) (cdar l1)) ; ==> 0.14..

              (+ 1 2 3) ; ==> 6
              (apply (caadr l1) (cdadr l1)) ; ==> 6


              Why does this work? Well. Your attempted to call the name of a procedure. By evaluating the procedure name you get the actual procedure object. You can indeed evaluate a procedure in the REPL and see what you get back:



              + ; ==> #<procedure:+>
              l1 ; ==> ((#<procedure:sin> 3) (#<procedure:+> 1 2 3))


              If l1 were defined as '((sin (+ 1 2)) (+ 1 2 3)) evaluating it would return ((sin (+ 1 2)) (+ 1 2 3)) so there is a big difference.



              And of course. Using the quasiquote/unquote is just a fancy way of writing this:



              (define l1 (list (list sin (+ 1 2))
              (list + '1 '2 '3)))





              share|improve this answer

























                4












                4








                4







                Please consider evaluating the procedure like this:





                (define l1 `((,sin ,(+ 1 2))
                (,+ 1 2 3)))

                (sin (+ 1 2)) ; ==> 0.14..
                ((caar l1) (cadar l1)) ; ==> 0.14..
                (apply (caar l1) (cdar l1)) ; ==> 0.14..

                (+ 1 2 3) ; ==> 6
                (apply (caadr l1) (cdadr l1)) ; ==> 6


                Why does this work? Well. Your attempted to call the name of a procedure. By evaluating the procedure name you get the actual procedure object. You can indeed evaluate a procedure in the REPL and see what you get back:



                + ; ==> #<procedure:+>
                l1 ; ==> ((#<procedure:sin> 3) (#<procedure:+> 1 2 3))


                If l1 were defined as '((sin (+ 1 2)) (+ 1 2 3)) evaluating it would return ((sin (+ 1 2)) (+ 1 2 3)) so there is a big difference.



                And of course. Using the quasiquote/unquote is just a fancy way of writing this:



                (define l1 (list (list sin (+ 1 2))
                (list + '1 '2 '3)))





                share|improve this answer













                Please consider evaluating the procedure like this:





                (define l1 `((,sin ,(+ 1 2))
                (,+ 1 2 3)))

                (sin (+ 1 2)) ; ==> 0.14..
                ((caar l1) (cadar l1)) ; ==> 0.14..
                (apply (caar l1) (cdar l1)) ; ==> 0.14..

                (+ 1 2 3) ; ==> 6
                (apply (caadr l1) (cdadr l1)) ; ==> 6


                Why does this work? Well. Your attempted to call the name of a procedure. By evaluating the procedure name you get the actual procedure object. You can indeed evaluate a procedure in the REPL and see what you get back:



                + ; ==> #<procedure:+>
                l1 ; ==> ((#<procedure:sin> 3) (#<procedure:+> 1 2 3))


                If l1 were defined as '((sin (+ 1 2)) (+ 1 2 3)) evaluating it would return ((sin (+ 1 2)) (+ 1 2 3)) so there is a big difference.



                And of course. Using the quasiquote/unquote is just a fancy way of writing this:



                (define l1 (list (list sin (+ 1 2))
                (list + '1 '2 '3)))






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 21:32









                SylwesterSylwester

                37k2 gold badges31 silver badges58 bronze badges




                37k2 gold badges31 silver badges58 bronze badges



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55344480%2frun-a-function-whose-name-is-in-a-list%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현