Question

1.      Define a recursive function ALL-SAME-AS-ELEMENT that has two arguments, an atom and a list. ALL-SAME-AS-ELEMENT...

1.      Define a recursive function ALL-SAME-AS-ELEMENT that has two arguments, an atom and a list. ALL-SAME-AS-ELEMENT should test whether all the elements in the list are the same as the atom. Should this be the case, the value returned should be T, otherwise NIL. Examples:
(ALL-SAME-AS-ELEMENT 'X '(X X X)) (Links to an external site.)
T
(ALL-SAME-AS-ELEMENT 'Y '(X Y X)) (Links to an external site.)
NIL

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
1.      Define a recursive function ALL-SAME-AS-ELEMENT that has two arguments, an atom and a list. ALL-SAME-AS-ELEMENT...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters...

    Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 5×6=6+6+6+6+6 2. Recursive findings Write a recursive boolean method named reFinding. The method should search an array for a specified value, and return true if the value is found in the array, or false if the value is not found in...

  • Define a recursive function SINGLETONS such that if e is any list of numbers and/or symbols...

    Define a recursive function SINGLETONS such that if e is any list of numbers and/or symbols then (SINGLETONS e) is a set that consists of all the atoms that occur just once in e. Examples: (SINGLETONS ( ))-> NIL (SINGLETONS '(G A B C B))-> (G A C) SINGLETONS '(H G ABCB))(HGAC) (SINGLETONS (AGABC B)) (G C) SINGLETONS '(B GA BCB))(GAC) [Hint: When e is nonempty, consider the case in which (car e) is a member of (cdr e), and...

  • Recursive Multiplication in Python Design a recursive function that accepts two arguments into the parameters x...

    Recursive Multiplication in Python Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 6 × 4 = 4 + 4 + 4 + 4 + 4 + 4

  • Define a function called collapse() which takes a list as input. Each element of the list...

    Define a function called collapse() which takes a list as input. Each element of the list will either be an integer, or a list of integers. The function should modify the input list by replacing all of the elements which themselves are lists with the sum of their elements. For example: Test Result vals = [1, 2, 3, 4, 5] collapse(vals) print(vals) [1, 2, 3, 4, 5] vals = [1, [2, 3], 4, 5] collapse(vals) print(vals) [1, 5, 4, 5]...

  • Function 4: my-map In CLISP define your own function that duplicates the functionality of mapcar from...

    Function 4: my-map In CLISP define your own function that duplicates the functionality of mapcar from the standard library. You may not use the built-in mapcar function as a helper function. Your implementation must be recursive. ·         Input: The input to my-map is a function that takes a single argument and a homogeneous list of elements of the same data type compatible with the procedure. Note: the function argument can be named or anonymous (lambda). ·         Output: A new list...

  • RecursiveExponent.java Write a recursive function that accepts two arguments into parameters x and y, and which...

    RecursiveExponent.java Write a recursive function that accepts two arguments into parameters x and y, and which returns the value of x raised to the power y. Hint: exponentiation is equivalent to performing repetitions of a multiplication. For example, the base 4 raised to the 6th power = 4*4*4 * 4 * 4 * 4 = 4,096. The only file that you need to create is RecursiveExponent.java. Your main method should prompt the user to supply the base and exponent values...

  • Please help with all four questions regarding LISP Programming. Thank you. Please answer all questions with...

    Please help with all four questions regarding LISP Programming. Thank you. Please answer all questions with output plesase. LISP Programming Assignment It is a good idea to start this assignment early; Lisp programming, while not inherently difficult, often seem somewhat foreign at first, particularly when it comes to recursion and list manipulation. This assignment is loosely based on material by Dr. Henri Casanova.   Problem #1 Define a function that takes two arguments and returns the greater of the two. Problem...

  • Define a function named insert that takes an integer atom and a sorted list as parameters....

    Define a function named insert that takes an integer atom and a sorted list as parameters. The function should return a list with the integer in the correct position in the sorted list. For example: insert [3, (2 4 6 8)] = (2 3 4 6 8) insert 9, ()] = (9) insert[3, (2 3 4 5)] = (23 3 4 5) Note that in the case of that last example, it does not matter which 3 comes first in...

  • Please place all of the following functions (defun …) into a SINGLE .lsp file As such,...

    Please place all of the following functions (defun …) into a SINGLE .lsp file As such, be sure to use the EXACT SAME function names and parameter numbers and orders I provide ​ Write a function ONEFIB that takes a single parameter n and returns the nth Fibonacci number. Write a function ALLFIB that takes a single parameter n and returns a list of the first n Fibonacci numbers. Do not worry about efficiency here. HINT: You can use ONEFIB...

  • ANSWER USING PYTHON Write a recursive function that takes 2 sorted lists as arguments and returns...

    ANSWER USING PYTHON Write a recursive function that takes 2 sorted lists as arguments and returns a single, merged sorted list as a result. For example, if the two input lists are [0, 2, 4, 6, 8] and [1, 3, 5, 7, 9], the returned result should be [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]. Remember that you can add lists in Python using the + operator ([0] + [1,2,3] = [0,1,2,3]) and can take slices of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT