Question

You can only use built in Lisp functions and you cannot use setq function. Write a...

You can only use built in Lisp functions and you cannot use setq function.

Write a function in Lisp called f7 that returns the element at a given location of a list. The locations start at 0. Example: (f7 ‘(c (a b) (d c) (x y)) 2) returns (d c)

Homework Answers

Answer #1

(elt '(c (a b) (d c) (x y)) 2)

returns (d c)

Here f7 is elt, a function in lisp. It allows returning list elements through given index. Here the given index is 2. Therefore, (d c) comes in second index starting from zeroth index.

For example:

(elt '(m n o p q r) 2)

Returns - > o because it comes in the second index.

elt function always starts with index zero.

m has index zero.

n has index one.

o has index two.

p has index three.

q has index four.

r has index five.

As in the function query index 2 is called. Therefore o with index 2 is returned.

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
You can only use built in Lisp functions and you cannot use setq function. Write a...
You can only use built in Lisp functions and you cannot use setq function. Write a function f2 that decides whether a list has an atom inside. Example: (f2 ‘((a b)(c d))) returns nil, (f2 ‘(a (b c))) returns t
Write a LISP function that accepts two lists as it's only arguments. The function should return...
Write a LISP function that accepts two lists as it's only arguments. The function should return a new list with the arguments as it's elements. So, if you pass the function (a b c) and (1 2 3), the function should return ((a b c) (1 2 3)).
Write a function called odd_rms that returns orms, which is the square root of the mean...
Write a function called odd_rms that returns orms, which is the square root of the mean of the squares of the first nn positive odd integers, where nn is a positive integer and is the only input argument. For example, if nn is 3, your function needs to compute and return the square root of the average of the numbers 1, 9, and 25. You may use built-in functions including, for example, sum and sqrt, except for the built-in function...
Write a function called odd_rms that returns orms, which is the square root of the mean...
Write a function called odd_rms that returns orms, which is the square root of the mean of the squares of the first nn positive odd integers, where nn is a positive integer and is the only input argument. For example, if nn is 3, your function needs to compute and return the square root of the average of the numbers 1, 9, and 25. You may use built-in functions including, for example, sum and sqrt, except for the built-in function...
In this example you are allowed to use from the C standard library only functions for...
In this example you are allowed to use from the C standard library only functions for input and output (e.g. printf(), scanf()) Complete the following functions using C programming language: a) Complete the int Q7a(intQ7_input) function takes a seven-digit positive integer as input and returns it reversed. For example, if the integer is 9806593, the program should print 3956089. You are not permitted to use any function of C standard library other than scanf()and printf().You are not permitted to use...
In this example you are allowed to use from the C standard library only functions for...
In this example you are allowed to use from the C standard library only functions for input and output (e.g. printf(), scanf()) For this exercise you should be able to write a logical expression (i.e., with logical operators) which checks if some integer x consists of exactly 5 digits. Ex: 30498 and -14004 are 5-digit numbers, while 1018, -2 and 46 are not. Complete the intQ2(intQ2_input) function that takes an input integer parameter and returns 1 if the number is...
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...
using dr.racket programing language If we write a function that tests whether a list contains only...
using dr.racket programing language If we write a function that tests whether a list contains only strings, odd numbers, or even numbers, you will notice that the code that iterates through the list stays the same, with the only change being the predicate function that checks for the desired list element. If we were to write a new function for each of the tests listed above, it would be more error-prone and an example of bad abstraction. We could write...
Write a PYTHON function called myMax which accepts a LIST of numbers and returns the maximum...
Write a PYTHON function called myMax which accepts a LIST of numbers and returns the maximum number in the list. Do NOT use Python’s built-in function max. Example: result = myMax([-999000, -1000000, -2000000]); print(result) #output is -999000 Example: result = myMax([1000000, 1000001, 1000002]); print(result) #output is 1000002
Task 2: Compare strings. Write a function compare_strings() that takes pointers to two strings as inputs...
Task 2: Compare strings. Write a function compare_strings() that takes pointers to two strings as inputs and compares the character by character. If the two strings are exactly same it returns 0, otherwise it returns the difference between the first two dissimilar characters. You are not allowed to use built-in functions (other than strlen()) for this task. The function prototype is given below: int compare_strings(char * str1, char * str2); Task 3: Test if a string is subset of another...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT