Question

In: Computer Science

You must write each of the following scheme functions. You must use only basic scheme functions...

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)

Solutions

Expert Solution

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]


Related Solutions

You must write each of the following scheme functions. You must use only basic scheme functions...
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 (merge-sorter L1) that takes list-of-integers L1 and returns all elements of L1 in sorted order. You must use a merge-sort technique that, in the recursive case, a) splits L1 into two approximately-equal-length lists, b) sorts those lists, and then c) merges the...
You must write each of the following scheme functions. You must use only basic scheme functions...
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. This problem need to use DrRacket software. Racket Language. Write a function named (forget-n L1 N) that returns the elements of L1 except for the first N. If N is negative, return all elements. If N exceeds the length of L1 return the empty list....
You must write each of the following scheme functions. You must use only basic scheme functions...
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. This problem needs to use DrRacket software. Racket Language. 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 clarification....
You must write each of the following scheme functions. You must use only basic scheme functions,...
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. This problem need to use DrRacket software. Racket Language. Write a function named (first-n L1 N) that returns the first N elements of L1. If N is negative, return the empty list. If N exceeds the length of L1 return all elements of L1. (first-n...
You must write each of the following scheme functions. You must use only basic scheme functions...
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. This problem need to use DrRacket software. Racket Language. Write a function (join-together L1 L2) that takes a sorted list (ascending) of integers L1 and a sorted list of elements L2 and returns a sorted list containing all elements of both L1 and L2. See...
You must write each of the following scheme functions. You must use only basic scheme functions...
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 named (list-replace ALIST SYM VAL) that accepts a list of elements and returns that list where all SYM's (a single symbol) have been replaced by the VAL (some scheme value). The replacement must occur even within nested lists. For example: (list-replace '(a...
Scheme Programming - Racket R5RS Longest Non-Decreasing Subsequence You will write two Scheme functions that compute...
Scheme Programming - Racket R5RS Longest Non-Decreasing Subsequence You will write two Scheme functions that compute a longest non-decreasing subsequence from a list of numbers. For example, if you type > (lis '(1 2 3 2 4 1 2)) you might get (1 2 3 4) Note that there may be more than one longest non-decreasing subsequence. In the above example, your program might also find (1 2 2 4) or (1 2 2 2). You should concentrate first on...
Assignment Write each of the following functions. The function header must be implemented exactly as specified....
Assignment Write each of the following functions. The function header must be implemented exactly as specified. Write a main function that tests each of your functions. Specifics In the main function ask for a filename and fill a list with the values from the file. Each file should have one numeric value per line. This has been done numerous times in class. You can create the data file using a text editor or the example given in class – do...
C++ Code each of the following functions RECURSIVELY  (each function should use only the parameter value, and...
C++ Code each of the following functions RECURSIVELY  (each function should use only the parameter value, and any local function variables you might need ..no variables are to be declared outside the functions). void upTo(int number) This function prints all values from 1 up to the number. upTo(5); should output: 1 2 3 4 5 HINT: the following functions involve separating a digit from a number. Use of the arithmetic operators % and / are helpful here. Remember a % 10...
Please answer this multi-part question. Thank you! For this assignment you must write the following functions...
Please answer this multi-part question. Thank you! For this assignment you must write the following functions in Scheme: 4 Write a recursive function called mergesort that sorts a list by doing the following: (a) Use split to split the list into two roughly equal-sized partitions. (b) Recursively sort both partitions. (c) Use merge to merge the sorted partitions together. Once again you will need two base cases, one for the empty list and the other for a single-element list. >...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT