1. Write a Prolog program that returns the length of a list of numbers. For example: size([1, 2, 3, 4], len). then return len=4.
2. Write a Prolog program that reverses the given list. For example: reverse([a, b, c, d], X). then return X=[d, c, b, a].
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.
1. Write a Prolog program that returns the length of a list of numbers. For example:...
PROLOG: Write a prolog predicate that counts occurrences of 'x', 'y', or 'z' in a list. For example, count([x,[y,[a,2],[a,3]],[a,4]], 2) should return true. I only want to count occurrences of x,y,z not a. the base case is that any [a,int] list will have a count of 0. So any sublist with 'a' does not count. another example of what will return true is: count([x,[a,1],[a,5]], 1) The predicate must have the form count(X,Y) where X is the list structure passed and...
Write a Prolog program to find the maximum, minimum, and range of values in a list of numbers. Please also provide the program with output.
Write a program in prolog to reverse the elements of a list. Don't call the following library functions that already exist. reverse_list([], []). reverse_list([Head | Tail], Out) :- reverse_list(Tail, TailReversed), append(TailReversed, [Head], Out).
Code in prolog a predicate windows/3 that returns the list of all windows (sublists of consecutive elements) of length 3 of the given list. ?- windows([1,3,a,4,b],Ys). Ys = [[1,3,a],[3,a,4],[a,4,b]] ?- windows([1,3],Ys). Ys = []
THIS IS A PROLOG QUESTION: Write a Prolog rule to repeat each element of the list TWO times. Hint: You should use recursion. For example, repeat_elements([a,b,c], Result) should return Result as [a,a,b,b,c,c] The result of repeating an empty list [] is an empty list [] so your base case should be the following: repeat_elements([], []). % This is the base case Once you complete your rule by adding recursion rule to the base case, you should test it by a...
PYTHON --create a program that accepts a list of words and returns the longest word inside that list can only use --- append, len, str, float, range, strip, split, int --create a program that accepts a list of words and a specific length. function will returns a new list that contains the words found with the specific length, and return an empty list if none are found can only use --- append, len, str, float, range, strip, split, int
for future viewers please dont use this for spring 2020 Write a Prolog program to split a list into two lists of positive and negative numbers. For example: ?- split([20,-10,30,22,45,0,-15,0,12], L1, L2). L1 = [20,30,22,45,12] L2 = [-10,-15]
///Program needs to write in prolog/// 6. A binary tree is either empty or it is composed of a root element and two successors, which are binary trees themselves. In Prolog we represent the empty tree by the atom 'nil' and the non-empty tree by the term t(X,L,R), where X denotes the root node and L and R denote the left and right subtree, respectively. The following Prolog term represents the given binary tree below. T1 = t(a,t(b,t(d,nil,nil),t(e,nil,nil)),t(c,nil,t(f,t(g,nil, nil),nil))) d...
Question 1a - Increasing Numbers in List - First Occurence(3 points) Write a function numIncreasing1(L) that takes as input a list of numbers and returns a list of the first sequence within that is increasing order, and has a length of at least 2. If no increasing sequential numbers are found, (ie. the input list is in descending order) then naturally a list of just the first value is returned. Increasing sequence means for a number to be valid it...
Write a C program that reads a sequence of numbers and display a message 1. The numbers a re red from the standard input. 2. The first number is the length of the sequence (n) followed by n numbers. 3. If n is 0 or negative, the program displays the message "Error_1" followed 4. If the length is shorter than n, it displays "Error_2" followed by a new line 5. The program inspects the list and display one of the...