In: Computer Science
You must write each of the following scheme functions. You must use only basic scheme functions do not use third-party libraries to support any of your work. Do not use any function with side effects.
Write a function (indices L1 X) that takes a list of elements L1 and an element X. The function returns a list of the indices in L1 that contain X. See the following examples for clarificaton.
(indices '(a b c a e f a) 'a') ---> (0 3 6) (indices '(a (a b) b c d) 'a) ---> (0) (indices '(a b c a e f a) 'z) ---> () (indices '(() (a b) a b ()) '()) ---> (0 4)
PYTHON CODING:-
OUTPUT:-
1.
Enter the no of element in the list:7
Enter the elements of this list:
a
b
c
a
e
f
a
Enter the element that indices search in this list: a
The output indices list:
['a', 'b', 'c', 'a', 'e', 'f', 'a'], a---->[0, 3, 6]
2.
Enter the no of element in the list:5
Enter the elements of this list:
a
(a b)
b
c
d
Enter the element that indices search in this list: a
The output indices list:
['a', '(a b)', 'b', 'c', 'd'], a---->[0]
3.
Enter the no of element in the list:7
Enter the elements of this list:
a
b
c
a
e
f
a
Enter the element that indices search in this list: z
The output indices list:
['a', 'b', 'c', 'a', 'e', 'f', 'a'], z---->[]
3.
Enter the no of element in the list:5
Enter the elements of this list:
( )
(a,b)
a
b
( )
Enter the element that indices search in this list: ( )
The output indices list:
['( )', '(a,b)', 'a', 'b', '( )'], ( )---->[0, 4]