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)
(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.
Get Answers For Free
Most questions answered within 1 hours.