Hi everyone, I need help In Haskell Coding. Please code in Haskell, Regards
1) Write a function that takes a list of tuples of three integers each and returns a list consisting of just the tuples that are Pythagorean triples. instead of using a list comprehension, use lambda expression and a function that tests one tuple and returns a Bool. As long as the lambda expression is correct, it is OK to make this simpler by having the lambda calls another function.
Code:
isTriple :: (Int,Int,Int) -> Bool
isTriple (x, y, z) | (x^2 == y^2 + z^2) = True
| (y^2 == x^2 + z^2) = True
| (z^2 == x^2 + y^2) = True
| otherwise = False
test_all :: [(Int,Int,Int)] -> [Bool]
test_all list_of_tuple = map isTriple list_of_tuple
list_of_bool :: [Bool]
list_of_bool = test_all [(5,12,13),(3,4,5),(1,1,1),(2,5,8)]
main = do
putStrLn "list of tuples is :\n[(5,12,13),(3,4,5),(1,1,1),(2,5,8)]"
putStrLn "\nAfter testing list of Bool is as follow: "
print list_of_bool
Hi everyone, I need help In Haskell Coding. Please code in Haskell, Regards 1) Write a...
Hi everyone, I need help in Haskell coding to please only Haskell code, Regards Consider this function: applyThrice f x = f (f (f x)) this function takes a unary function: for example: >applyThrice (+2) 2 8 use ., the function composition operator, and/or $, the function application operator, to make this function more readable
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
Hello can anyone help solve this please in Python the way it's asked? Question 22 40 pts List Comprehensions Write the solution to a file named p2.py and upload it here. Comprehensions will show up at the midterm exam, so it's important to practice. a) Write a list comprehension that returns a list [0, 1,4, 9, 16, .. 625] starting from range(0, 26). (lots of list elements were omitted in ...) b) Write a list comprehension that returns the list...
Hi, I need some help finishing the last part of this Python 1 code. The last few functions are incomplete. Thank you. The instructions were: The program has three functions in it. I’ve written all of break_into_list_of_words()--DO NOT CHANGE THIS ONE. All it does is break the very long poem into a list of individual words. Some of what it's doing will not make much sense to you until we get to the strings chapter, and that's fine--that's part of...
*Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods that has the following generic methods: (1) Write the following method that returns a new ArrayList. The new list contains the nonduplicate (i.e., distinct) elements from the original list. public static ArrayList removeDuplicates(ArrayList list) (2) Write the following method that shuffles an ArrayList. It should do this specifically by swapping two indexes determined by the use of the random class (use Random rand =...
I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
HI, I am having trouble finsihing this program i was wondering if someone could help me. Thanks in adavnce. Here is the code that I have so far..... //Stack.h // implementation file for the stack class #include <iostream> using namespace std; const int stack_size = 100; class stack { private: char data [stack_size]; // elements in the stack int top; // index of the top element of the stack public: stack (); // constructor creates an empty stack void push...
I need help with this assignment in C++, please! *** The instructions and programming style details are crucial for this assignment! Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...