A parallelogram refers to the quadrilateral which has two pairs of parallel sides where opposite sides are equal in length, and the opposite angles are equal in measure. In this article we are going to find all possible coordinates of a Parallelogram. Basically, we will find all the possible coordinates from the given three coordinates to make a parallelogram of a non-zero area. Here the three given coordinates are not fixed points and can change. Therefore, if three coordinates are given, we may claim that there are only three coordinates from which we can build a parallelogram. As per ... Read More
In this article we are going to change all lower-case text to upper-case text in a file in java. Suppose the text file contains the following data − “Merry and Jack are studying.” Then after updating the text file with specific value the result will be − “MERRY AND JACK ARE STUDYING.” This modification is done with the help of toUpperCase() Method. It belongs to the String class in java. Let’s deep dive into this article, to know how it can be done by using Java programming language. To show you some instances Instance-1 Suppose the original content of the ... Read More
In this article, we are going to understand how to create a simple function in Haskell using user-defined function. Here, the user-defined recursive functions are defined that will contain base case and recursive case. Then, these functions are being called recursively by passing the argument to it. In all the examples, we are going to define certain functions to perform certain tasks. All these functions include, base and recursive cases. The function defined includes factorial, fibonacci, sumList, etc. Algorithm Step 1 − The user defined recursive function is defined with base and recursive case. Step 2 − ... Read More
In Haskell, we can return multiple values from the function by using user-defined function along with tuple, custom data type and Maybe data type. In the first example, we are going to use (myFunction = ("Hello, World!", 42)) and in the second example, we are going to use (data MyData = MyData { stringValue :: String, intValue :: Int }). And in third example, we are going to use, (myFunction :: Maybe (String, Int)). Method 1: Using Tuple In this method, a function can return multiple values by using a tuple. A tuple is a data structure that holds multiple ... Read More
In this article, we are going to learn how to return a string from a function using user-defined function along with record syntax and let binding. In the first example, we are going to use (myFunction = "Hello, World!") function and in the second example, we are going to use (myFunction = stringValue myData). And in third example, we are going to use let binding, (myFunction = let str = "Using let binding!" in str). Method 1: Returning a string from the user-defined function In this method, the user-defined functions are defined that will contain the function definition and return ... Read More
This article will help us learn how to pass a string to the function in Haskell with identity function and lambda expression. In the first example, we are going to use (myFunction inputString = inputString) function and in the second example, we are going to use (myFunction = id). And in third example, we are going to use lambda expression, (myFunction = \inputString -> inputString). Method 1: Passing a string to the user-defined function In this method, the user-defined functions are defined that will contain the function definition with some returning value and is being called by passing a string ... Read More
This article will help us learn how to return an array from the function in haskell using user-defined function along with list comprehension and recursion. In the first example, we are going to use (show (getArray)) function and in the second example, we are going to use (getArray n = [x | x [Int] getArray n = [x | x Int) -> [Int] -> [Int] getArray f xs = map f xs main :: IO () main = do putStrLn (show (getArray (*2) [1, 2, 3, 4, 5])) Output [2, 4, 6, 8, ... Read More
In Haskell, we will pass an array to the function by using user-defined functions. In all the examples, we are going to pass an array to the user-defined functions to perform the certain tasks. These functions can be sumArray, maxArray, minArray, countEvens, etc. In this method, the user-defined functions are created that will contain the function definition with some returning value and is being called by passing an array as argument to it. Algorithm Step 1 − The user defined function is defined by writing its definition with a return value. Step 2 − Program execution will ... Read More
In this article, we are going to understand how to create a function with argument and a return value in Haskell using a user-defined function. The user-defined functions are defined that will contain the function definition with some returning value and is being called by passing desired arguments to it. These functions perform various operations as per the definition. In all the examples, we are going to define user-defined functions to perform certain tasks that will return some value and are passed with some arguments like, add, mult, maxOfTwo and other functions. Algorithm Step 1 − The user ... Read More
We are going to learn how to create a function without argument but return a value using user-defined function. In this article, the user-defined functions are defined that will contain the function definition with some returning value and is being called without passing any arguments to it. In all the examples, we are going to define user-defined functions to perform the certain tasks that will return some value but are passed without arguments like, factorial, celsiusToFahrenheit, circleArea and other functions. Algorithm Step 1 − The user defined function is defined by writing its definition with a ... Read More