Question
LIST PROGRAMMING PROBLEM Problem #1 Define a function that takes two arguments and returns the greater of the two. Problem #2 Write a function called
LIST PROGRAMMING PROBLEM Problem #1 Define a function that takes two arguments and returns the greater of the two. Problem #2 Write a function called inches that accepts feet and inches and returns the equivalent length in centimeters. If x is the first argument and y is the second, the formula is 2.54(12x + y). For example, USER(1): (inches 0 1) 2.54 USER(1): (inches 6 2.5) 189.22999999999999 Problem #3 - Remove an element from a list using Iteration Write a Common Lisp function called my-remove that takes an atom and a list in input, and returns a list that is identical to the input list, but with elements equal to the input atom removed, if any. Examples of the function in operation are shown below (user input is in red): CL-USER(1): (my-remove 'b '(a b c b d)) (a c d) CL-USER(2): (my-remove 'b '(a c d e f)) (a c d e f) CL-USER(3): (my-remove 'a '(b (a d) a d)) (b (a d) d) CL-USER(4): (my-remove 'a '()) nil Problem #4 - Remove an element from a list using Recursion Write a Common Lisp function called my-recursive-remove that takes an atom and a list in input, and returns a list that is identical to the input list, but with all occurrences of the input atom removed, if any. Examples of the function in operation are shown below (user input is in red): CL-USER(1): (my-recursive-remove 'a '(a b c d)) (b c d) CL-USER(2): (my-recursive-remove 'a '((a b) a (c d e a) (a a) b)) ((b) (c d e) nil b)) CL-USER(3): (my-recursive-remove 'a '((((a))))) (((nil))) Problem #5 - Flatten a list Write a Common Lisp function called flatten that takes a list that may have embedded lists, and returns a flattened version of it (i.e., a list whose elements are only atoms and empty lists have been removed). Examples of the function in operation (user input is in red): CL-USER(1): (flatten '(a b c d)) (a b c d) CL-USER(2): (flatten '(a () b (c d))) (a b c d) CL-USER(3): (flatten '(a (()))) (a) CL-USER(4): (flatten '(a (b c) (d e (f) ((((((g)))) h)) i) j (k) l)) (a b c d e f g h i j k l)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started