Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Akhil Sharma
Page 42 of 51
Haskell Program to find the arccosine of the given value
This tutorial will help us in finding arccosine of the given value. The arccosine is the inverse function of the cosine. If given a value between -1 and 1, it returns the angle (in radians) whose cosine is equal to that value. For example, the cosine of pi/3 radians is equal to 0.5. Therefore, if you pass 0.5 as an input to the arccosine function, it should return pi/3 radians. Syntax acos(angle) Here, acos() is a built-in function and value is passed as parameter to compute the arccosine of the value passed. Method 1: Finding arccosine using in-built ...
Read MoreHaskell Program to find the hyperbolic arccosine of the given value
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 MoreHaskell Program to convert the string into a floating-point number
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 MoreHaskell Program to convert the string into an integer
This tutorial will help us in converting the string into an integer. In Haskell, the process of converting a string to an integer typically involves using the read function or readMaybe function from the Text.Read module. Another approach is to use the digitToInt function from the Data.Char module to convert each character in the string to its corresponding numerical value. All these functions are part of the standard library and we can use them to easily convert strings to integers in Haskell. Algorithm Step 1 − in-build() function is defined using read function. Step 2 − Program execution will ...
Read MoreHaskell Program to find the hyperbolic tangent of given radian value
This tutorial will help us in finding hyperbolic tangent of the given radian value. The hyperbolic functions are used to calculate the angles and the distances. The hyperbolic tangent function gives us the hyperbolic tangent value of the radian angle. The angle value must be a radian value. If the angle is any degree value then, it must be converted into radian value first. Syntax tanh(angle) ...
Read MoreHaskell program to multiply two floating point numbers
This tutorial will help us in multiplying two floating point numbers. The multiplication is simply an arithmetic mathematical operation. In Haskell, floating point numbers are represented as values of the Float or Double type. You can use the (*) operator or the multiply() function to multiply two floating point numbers in Haskell. Alternatively, we can also use (/) operator to multiply two floating point numbers by dividing 1 by the reciprocal of the second number. Method 1: Using Multiply Function This method uses multiply() function to multiply two floating point numbers. The function is defined before the main function, as ...
Read MoreHaskell Program to calculate the area of Cube
This tutorial will help us in calculating the area of a cube. There are various approaches to calculating the area but the mathematical formula to calculate the area will remain the same I.e., 6*(side^2). Method 1: Using cubeArea Function This example defines a function cubeArea that takes a single argument, the length of the cube's sides, and returns the area of the cube. The main function calls the cubeArea function to calculate the area. The result is then printed to the console. Algorithm Step 1 − The function cubeArea is being defined on the basis of simple mathematical formula ...
Read MoreHaskell Program to check whether a variable is defined or not
This tutorial will help us in checking whether a variable is defined or not. In Haskell, a variable is considered defined if it has a value assigned to it. The value can be of any type, including a special type called Maybe that is used to represent values that may or may not be present. Algorithm Step 1 − The Data.Maybe module is imported. Step 2 − The checkDefined function is defined as, checkDefined x = isJust x. It takes a Maybe value and returns a Bool indicating whether the value is Just (i.e. defined) or Nothing (i.e. not ...
Read MoreHaskell Program to Check the birthday and print Happy Birthday message
In Haskell, this program will help us in checking the current date against a specified birthday and prints a "Happy Birthday" message if it is a match otherwise, it will print “Not your birthday yet”. Haskell provides function to fetch the current date and also to specify a date. This program can be implemented by using various approaches including the use of toGregorian function, fromGregorian function or by using utctDay getCurrentTime. This program will only check the birthday once, when the program runs. If we want the program to check the birthday periodically or at a specific time, we ...
Read MoreHaskell Program to Iterate over enum
In Haskell, an enumeration (or "enum") is a type that has a finite set of values. The values are called constructors, and are usually defined using the data keyword. Here's an example of an enumeration type that represents the four seasons − data Season = Spring | Summer | Fall | Winter Enumerations are used to represent things like states, modes, or options that have a fixed set of possible values. Method 1: Iterate over enumeration type This method is used to directly iterate over the enumeration type in Haskell. Here, we define the list of all the enumeration ...
Read More