Programming Paradigms , using Haskell !!!!
I need help on this problem , Intersection of list of list HASKELL
I need to use my own definition for intersection . Its my homework assignment.
example like :
intersection [ [2, 8, 6, 5, 8, 8, 8], [8, 8, 1, 1, 4, 8], [3, 3, 8, 10, 8, 10, 8, 7, 8, 8, 3]]
Output: [8, 8, 8]
intersection [ [1, 2, 3, 4], [5, 6, 7], [8], [9, 10]]
Output: [ ]
I discovered that exists a function intersect :: Eq a => [a] -> [a] -> [a] ( but it's available only for 2 lists)
You need to find your current intersection result and intersect it with next list until you run out of lists or till it becomes empty.
One way is could be merge sort, it's one kind of intersection but would be more complicated.
One neat way is :
> import Data.List > foldl1 intersect [X,Y,Z] ANSWER
Reference: https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html
https://riptutorial.com/haskell/example/7552/merge-sort
Programming Paradigms , using Haskell !!!! I need help on this problem , Intersection of list...
Hi everyone, I need help in Haskell, please. Write a Haskell function that takes an Int i as its only parameter and uses a list comprehension to caclulate m(i) = 1 + 1/2 + 1/3, ... + 1/i
USING SCHEME PROGRAMMING LANGUAGE define a function addSubList that processes a list of lists of numbers and adds up all sub-lists. The output of your function is a flat list of numbers. (You can assume that your function only receives valid input). Example: (define Q '(1 2 (3 4) 1 5 (7 8))) ;;;;;;;;;;;;;;;;;;;;; ; (addSubList Q) ; => '(1 2 7 1 5 15) ;;;;;;;;;;;;;;;;;;;
Haskell Programming 2. Returns the plural of a word by adding "s' unless the word ends in "y", in which can you remove the "y" and add "ies" 3. Write a function that takes two lists and returns a list of only those elements that appear in both lists. 4. Write a function that takes a list and an element and returns the number of times the element appears in the list. 5. Remove the leading spaces from a string...
I need help modifying this python code: a) I need to take 2 attributes of the data as int - (columns (3 & 5) of my data) b) I need to take 2 more attributes as floats -(columns 4&6 of my data) c) I need to take 1 attribute as string (column 16 of my data) How would I modify this code # # Initial version - "standard programming" # # Define a list for the data. The data structure...
I really need help with this python programming assignment Program Requirements For part 1, I need a program with 2 functions specifically these • fib(): Takes a single integer argument num terms greater than or equal to 1 and for each of the num terms terms of the Fibonacci sequence prints 1) the number of the term—i.e., 1, 2, 3..., 2) the corresponding Fibonacci number, and 3) the ratio of the current and previous Fibonacci numbers as shown below. The...
Need help with this C++ homework
I need help problem 1-9 that possible if my wish?
Thank you friend
Tiet
WRITE FUNCTION PROTOTYPES for the following functions. The functions are described below on page 2. (Just write the prototypes) When necessary, use the variables declared below in maino. mm 1.) showMenu m2.) getChoice 3.) calcResult m.) showResult 5.) getInfo mm.) showName 7.) calcSquare 8.) ispositive int main { USE THESE VARIABLES, when needed, to write function prototypes (#1 - #8)...
my question is on a java program. i have added all instructions for this homeowrk assignment. from how the input is entered and what the output should read. im seeing if i can get a psuedo code setup for how the algorithm should be setup. Build an Intersection Check program. User inputs two points as x-y coordinates in twodimension space. Two points represent two end points of a line segment. Then, user can input second two points for the second...
Need some help with this java problem, thanks!
Failure to submit will result in a ZERO FOR THIS LAB. NO EXCEPTIONS. Write a program that prints out the lists alter the following methods are called. Method takes an of integers as a parameter. The method moves the minimum value in the list to the front, otherwise preserving the order of the elements. For example, if a variable called list stores the following values: [4. 7, 9, 2. 7, 7. 5....
This question is on PYTHON Object Oriented Programming using Lists only. I need the full python coding for this question. Write a FlightBooking class with 2 collections: flight(list) and landing(list). Follow names in the UML diagram given below. UML DIAGRAM: FlightBooking _flight: list _landing: list __init__(self) addFlight(self,flight) addLanding(self,landing) removeFlight(self,pilot,flightNo) removeLanding(self,landingDateTime,destination) searchFlight(self,pilot,flightNo) : Flight searchLanding(self,landingDateTime,destination) : Landing flightStr(self) : string landingStr(self) : string 1. Constructor has 0 parameters, set collections to empty lists. 2. Add methods for both collections: - 1...
I
need help with this problem this is what I put and these are the
errors I got
Given the lists list1 and list2 that are of the same length, create a new list consisting of the last element of listi followed by the last element of list2, followed by the second to last element of listi, followed by the second to last element of list2, and so on (in other words the new list should consist of alternating elements...