Found 185 Articles for Haskell

Haskell Program to read coordinate points and determine its quadrant

Akhil Sharma
Updated on 23-Jan-2023 11:14:11

161 Views

This tutorial will help us in reading the x and y coordinates and determine its quadrant. If both the coordinates are positive, the point lies in first quadrant; if x coordinate is positive and y coordinate is negative, the point lies in fourth quadrant ; if x coordinate is negative and y coordinate is positive, the point lies in second quadrant and if both the coordinates are negative, then point lies in third quadrant. Algorithm Step 1 − The quadrant function is defined using certain conditions on x and y coordinates. Step 2 − Program execution will be ... Read More

Haskell Program to calculate the volume and area of Sphere

Akhil Sharma
Updated on 23-Jan-2023 11:12:16

149 Views

This tutorial will help us in calculating the volume and area of Sphere. The volume of a sphere is a measure of the amount of space inside the sphere. And area involves the surface area of the sphere. Method 1: Using the User-defined Function In this method, we will see two examples where we have used user-defined function with different techniques. Algorithm Step 1 − The Text.Printf module is imported. Step 2 − The volume and area functions are defined on the basis of simple mathematical formula as volume r = (4.0 / 3.0) * pi * (r ^ ... Read More

Haskell Program to calculate the volume and area of Cone

Akhil Sharma
Updated on 23-Jan-2023 11:10:26

153 Views

This tutorial will help us in calculating the volume and area of the Cone. The volume of a cone is a measure of the amount of space inside the cone. And area involves the surface area of the cone that is obtained from the lateral area of a cone. The formula for the volume of a cone is V = (1/3) * π * r^2 * h, where r is the radius of the base of the cone, h is the height of the cone, and π is approximately equal to 3.14. And the formula for the surface area of ... Read More

Haskell Program to calculate the volume, diagonal, and area of Cuboids

Akhil Sharma
Updated on 23-Jan-2023 11:08:10

151 Views

This tutorial will help us in calculating the volume, diagonal, and area of the Cuboids. The volume of a cuboid is a measure of the amount of space inside the cuboid. And area involves the surface area of the cuboid. The diagonal of a cuboid is a line segment connecting two opposite vertices of the cuboid. It is also known as the "space diagonal" or "body diagonal" of the cuboid. Algorithm Step 1 − The volume, diagonal and area functions are defined on the basis of simple mathematical formula as volume l w h = l * w ... Read More

Haskell Program to calculate the volume and area of the Cylinder

Akhil Sharma
Updated on 23-Jan-2023 10:28:46

194 Views

This tutorial will help us in calculating the volume and area of the Cylinder. The volume of a cylinder is a measure of the amount of space inside the cylinder. The area involves the surface area of the cylinder. The formula for the volume of a cylinder is the product of the base area of the cylinder, which is given by πr^2 and the height h. The formula for the surface area of a cylinder is the sum of the areas of the two circular faces and the area of the rectangular lateral surface. Algorithm Step 1 − The ... Read More

Haskell Program to convert the string into a floating-point number

Akhil Sharma
Updated on 20-Jan-2023 10:21:03

589 Views

This article will help us in converting the string into a floating point number. In Haskell, you can use the read function to convert a string to a floating-point number. Another way to convert a string to a floating-point number is by using the readMaybe function. This function is similar to the read function, but it returns a Maybe value instead of raising an exception when the input string is not valid. All these functions are part of the standard library and we can use them to easily convert strings to a floating point number in Haskell. Algorithm Step ... Read More

Haskell Program to find the hyperbolic arctangent of the given value

Akhil Sharma
Updated on 20-Jan-2023 10:17:56

98 Views

This tutorial will help us in finding hyperbolic arctangent of the given value. The hyperbolic arctangent, also known as the inverse hyperbolic tangent, is the inverse function of the hyperbolic tangent. It is denoted by atanh (or arctanh) and can be defined as atanh(x) = (ln(1+x) - ln(1-x)) / 2 Syntax atanh(angle) Here, atanh() is a function and value is passed as parameter to compute the hyperbolic arctangent of the value passed. It returns a value in the range of (-infinity, infinity). In Haskell, the atanh() function is a part of the Floating class, which is a subclass of ... Read More

Haskell Program to find the hyperbolic arccosine of the given value

Akhil Sharma
Updated on 20-Jan-2023 10:38:18

100 Views

This article will help us in finding hyperbolic arccosine of the given value. The hyperbolic arccosine, also known as the inverse hyperbolic cosine, is the inverse function of the hyperbolic cosine. It is defined as acosh(x) = log(x + sqrt(x^2 - 1)) for x > 1, where log is the natural logarithm. The output of this function is a real number. Syntax acosh(angle) Here, acosh() is a function and value is passed as parameter to compute the hyperbolic arccosine of the value passed and value passed must be greater than 1. Method 1: Using acosh() function In this method, ... Read More

Haskell Program to find the hyperbolic arcsine of the given value

Akhil Sharma
Updated on 20-Jan-2023 10:13:07

97 Views

This tutorial will help us in finding hyperbolic arcsine of the given value. The hyperbolic arcsine (also known as "area hyperbolic sine" or "inverse hyperbolic sine") of a value, denoted as asinh(x), is the inverse function of the hyperbolic sine function (sinh(x)), which is defined as − asinh(x) = ln(x + sqrt(x^2 + 1)) Syntax asinh(angle) Here, asinh() is a function to compute the hyperbolic arcsine of the given value and value is passed as parameter to compute the hyperbolic arcsine of the value passed. It is included in the Prelude module, which is automatically imported into ... Read More

Haskell Program to convert a number into a complex number

Akhil Sharma
Updated on 20-Jan-2023 10:09:09

140 Views

This tutorial will help us in converting a number into a complex number. In Haskell, the Data.Complex library provides a Complex type to represent complex numbers. The :+ operator is used to construct a complex number from its real and imaginary parts. Method 1: Using convertToComplex Function In this approach, the convertToComplex function takes a real number as input and returns a complex number with the real component equal to the sum of the input and the predefinedReal value and the imaginary component equal to the predefinedImaginary value. The main function gets a real number and then uses convertToComplex ... Read More

Advertisements