Found 26504 Articles for Server Side Programming

Haskell Program to create a function without argument but return a value

Akhil Sharma
Updated on 01-Mar-2023 10:59:35

397 Views

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

Haskell Program to create a function with arguments but without a return value

Akhil Sharma
Updated on 01-Mar-2023 10:58:36

302 Views

In Haskell, we will create a function with arguments but without a return value by using user-defined functions. In this article, the user-defined functions are defined that will contain the function definition without returning any value and is being called by passing some desired arguments to it. In all the examples, we are going to define user-defined functions to perform the certain tasks that don’t return any value but are passed with arguments like, printSum, printString , printList and other functions. Algorithm Step 1 − The user defined function is defined by writing its definition without ... Read More

Haskell Program to create a function without argument and without a return value

Akhil Sharma
Updated on 01-Mar-2023 10:57:16

500 Views

In Haskell, we can create a function without argument and without a return value by using user-defined functions. In all the examples, we are going to define user-defined functions to perform the certain tasks that don’t return any value and are passed without argument like, printGreeting, printMultipleLines, printSquares functions. Algorithm Step 1 − The user defined function is defined by writing its definition without returning any value. Step 2 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. In the ... Read More

Haskell Program to calculate the value from the given fraction and exponent

Akhil Sharma
Updated on 01-Mar-2023 18:01:20

267 Views

This haskell tutorial will help us in calculating the value from the given fraction and exponent of a number. To find this, the input is taken as fraction and exponent, and its corresponding value is computed. Algorithm Step 1 − The “Data.Ratio” is imported to work over fractions. Step 2 − The calculateValue function is defined Step 3 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. Step 4 − The variables named, “fraction” and “exponent” are initialized. ... Read More

Haskell Program to calculate the base 10 logarithm of the given value

Akhil Sharma
Updated on 01-Mar-2023 10:35:10

527 Views

This tutorial will help us in calculating the base 10 logarithm of the given value. A logarithm is a mathematical function that calculates the power to which a number (called the base) must be raised to produce a given value. The base 10 logarithm, is a logarithm in which the base is 10. Method 1: Using Internal Functions In this method, we are going to use build-in log and log base function to calculate bas 10 log of a given number. Algorithm Step 1 − The Prelude library is imported to use log functions. Step 2 − ... Read More

Haskell Program to calculate the base 2 logarithm of the given value

Akhil Sharma
Updated on 01-Mar-2023 10:07:53

1K+ Views

In Haskell, the logarithm is a mathematical function that calculates the power to which a number (called the base) must be raised to produce a given value. The base 2 logarithm, also known as binary logarithm, is a logarithm in which the base is 2. For example, the base 2 logarithm of 8 is 3, because 2 to the power of 3 equals 8 (2^3 = 8). Method 1: Using logBase function In this method, the log function takes a value of type Double and returns the base 2 logarithm of that value, which is also of type Double. The ... Read More

Haskell Program to calculate the cube root of the given number

Akhil Sharma
Updated on 01-Mar-2023 10:06:30

604 Views

This Haskell article will help us in calculating the cube root of the given number. The cube root of a number is a value that, when multiplied by itself three times, equals the original number. For example, the cube root of 8 is 2 because 2 x 2 x 2 = 8. In mathematics, cube root of a number x is represented as ∛x. Algorithm Step 1 − Define a user-defined function and name it as cubeRoot Step 2 − Program execution will be started from main function. The main() function has whole control of the ... Read More

Haskell Program to calculate the square root of the given number

Akhil Sharma
Updated on 01-Mar-2023 10:05:43

3K+ Views

There are different techniques in Haskell to calculate a square root of a number. The square root of a number is a value that, when multiplied by itself, equals the original number. For example, the square root of 9 is 3 because 3 x 3 = 9. Algorithm Step 1 − Defined the square root function Step 2 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. It takes an integer whose square root is to be calculated. Step 3 − ... Read More

Haskell Program to calculate the area of the rhombus

Akhil Sharma
Updated on 01-Mar-2023 10:03:56

170 Views

In Haskell there are different methods to calculating the area of the rhombus. We can use sides, diagonals and height on the basis of which, its area can be computed by various methods. Algorithm Step 1 − The Text.Printf module is imported. Step 2 − Defined the Rhombus fuction Step 3 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. It takes two integers as diagonals and prints the area using the rhombusArea function. Step 4 − The ... Read More

Haskell Program to calculate the Lowest Common Multiple

Akhil Sharma
Updated on 01-Mar-2023 10:01:52

671 Views

This tutorial will help us in calculating the Lowest Common Multiple in Haskell Programming. The least common multiple (LCM) is the smallest positive integer that is a multiple of two or more integers. It can be found by listing out the multiples of each number and finding the smallest multiple that is common to all of them. For example, the LCM of 4 and 6 is 12 because 12 is the smallest number that is a multiple of both 4 and 6. Method 1: Using user-defined lcm’ function In this method, the gcd function is used from the Data.List library ... Read More

Advertisements