Question

How can you use recursion in lisp (clisp) to process infix. Example (Thisisinfix '(1 + 2...

How can you use recursion in lisp (clisp)
to process infix. Example (Thisisinfix '(1 + 2 * ( 1 + 2)) = 7
(Thisisinfix '((1 + 2) * ( 1 + 2))) = 9
I need the general idea of how this works, not the full functional code.
This also needs to be done not using any kind of variables such as let, or any sets, only recursion,
however you can define other functions using defun if that helps.

I am looking to get better with lisp, so once again if you could explain the steps and/or
rational behind the thought process / calls that would be great.

Homework Answers

Answer #1
//this code is to find factorial of a number 
(defun factorial (n)   //genral function definition defun (keyword ) factorial (name of function)
                       //(n) is the parameter of the function 
    (if (= n 1)        //this is the base case for recursion that means if n is equal to 1 then it will execute 
        1 
        (* n (factorial (1- n)))))  //lets break this call 
                   

 In lisp two numbers or equation after symbol denotes operation 
  n*(factorial(1-n))
for n=3 this will run as 
  3*(factorial(1-3))
  2*(factorial(2-1))
  //base case is triggered and value goes like from down to up 
  1
  2*(1)
  3*(2)
 =6
this is how a function of recurrsion looks like and then the breakup of the equation with function calls 
hope you got it 

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
---------------- Overview: ---------------- This lab will consist of several independent exercises that must all use recursion...
---------------- Overview: ---------------- This lab will consist of several independent exercises that must all use recursion to solve various problems. Some problems will have fairly short solutions, but declaring and using classes/objects is still required. Some could benefit from having some kind of data structure being passed between calls. Feel free to use your LinkedList if you think it could help. Some solutions will be a mix of iteration and recursion, but all solution need to be recursive in some...
Please if you can explain in paragrahs with details and example that would be great! I...
Please if you can explain in paragrahs with details and example that would be great! I am trying to undertand the Guassian Curve. 1) How does the number of trials affect the accuracy of the Guassian Curve? 2) How does the number of trials affect the Precision of the Guassian Curve? Sorry, I meant to say Gaussian Function or Normal distribution Function.
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
1) What kind of significant advantage can you get by using adaptive immunity? A) Fast defense...
1) What kind of significant advantage can you get by using adaptive immunity? A) Fast defense against antigen that you have previously encountered. B) Act against any pathogen as soon as they are encountered the first time. C) Creates effector cells with specificity for any antigens that is ever encountered again. D) All antibody destruction always, anytime.
CAN ANYONE SOLVE THIS BY USING R ? CAN YOU PLEASE NOT USE the (CORRECT=F FUNCTION)...
CAN ANYONE SOLVE THIS BY USING R ? CAN YOU PLEASE NOT USE the (CORRECT=F FUNCTION) WHEN SOLVING PART B, I AM NOT VERY CLEAR WITH THAT. 2) From a random sample of 673 items made by a particular manufacturing process, it is found that 27 are defective. (a) (1 mark) Find a 99.5% confidence interval for the proportion of defective items made by the process. (Also include the commands and output.) (b) (1 mark) Give the command and output...
1.     Prompt 1: How does social referencing work? Can you give an example? When is social referencing...
1.     Prompt 1: How does social referencing work? Can you give an example? When is social referencing useful and when is it not? Why would you not want to use social referencing when responding to a toddler who has just taken a spill? 2.     Prompt 2: Can you give an example of a cultural script? Do you have any cultural scripts? What are they? 3.     Prompt 3: Make up a scene involving the RERUN process of problem solving.
1. Mass media play a role in creating gender roles and stereotypes. Unconsciously we can adopt...
1. Mass media play a role in creating gender roles and stereotypes. Unconsciously we can adopt the gender identities presented in the media. Which of the following media theories do you think could play a role in creating our gender roles and stereotypes? Select as many as you think apply. Select one or more: a. Agenda Setting b. Gatekeeping c. Terminal Credibility d. Uses and gratification e. Product Placement and Immersive Advertising 2. Which of the following BEST describes why...
After reviewing data from a sample, an inference can be made about the population. For example,...
After reviewing data from a sample, an inference can be made about the population. For example, Find a data set on the internet. Some suggested search terms: Free Data Sets, Medical Data Sets, Education Data Sets. Based on the trends and the history of your data set, make a claim. What kind of test (left, right, two tailed) would you have to complete? Show work Find a data set on the internet. Some suggested search terms: Free Data Sets, Medical...
1, How does the Taguchi loss function relate to QFD? 2, Can you share any real-world...
1, How does the Taguchi loss function relate to QFD? 2, Can you share any real-world examples of some of the process management techniques
Chem 112 Fall 2017Name_____________________________________Writing Assignment # 1 -- 17.5 ptsInstructions: Choose 2 pharmaceutical drugs (you can...
Chem 112 Fall 2017Name_____________________________________Writing Assignment # 1 -- 17.5 ptsInstructions: Choose 2 pharmaceutical drugs (you can choose from the list provided or find ones that interest you) and answer the following questions for EACH drug. This first part is worth 7.5 pts. Then write a 2-3 page essay on one of these two drugs, you can pick which one interests you more. The essay should include the mechanism of action of the drug (how exactly it works to affect the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT