In Haskell, we can use library function like pred, subtraction and fromMaybe to get the predecessor of an integer number. In the first example, we are going to use (pred number) function and in the second example, we are going to use subtraction while in third example, we are going to use (fromMaybe 0 (predMaybe x)) function. Algorithm Step 1 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. It calls the pred function with the value and prints its predecessor ... Read More
In Haskell, we have library function like, by using Mod and Rem function to check if the given number is odd or not. In the first example, we are going to use (isOdd n = n `mod` 2 /= 0) function and in the second example, we are going to use (isOdd n = (n `rem` 2) == 1) function. Algorithm Step 1 − The isOdd function is defined using mod function as, isOdd n = n `mod` 2 /= 0. Step 2 − Program execution will be started from main function. The main() function has ... Read More
In Haskell, we can use divMod and quotRem functions to get the division and remainder of a given number. In the first example, we are going to use (divMod x y) function and in the second example, we are going to use (quotRem 20 7) function. Algorithm Step 1 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. Step 2 − The variables named, “x” and “y” are being initialized. The interal function will divide them by taking them as argument. Step ... Read More
In Haskell, we can use realPart function and pattern matching to get the real part from a complex number. In the first example we are going to use (realPart c) function and in the second example, we are going to use patter matching as (x:+_) = c. Algorithm Step 1 − The Data.Complex module is imported to work over the complex numbers. 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. Step 3 − The variable named, “c” is being ... Read More
In Haskell, we can use isIEEE, isInfinite and isNaN functions to check whether a given number is finite or not. In the first example we are going to use (isIEEE n) function with if-else statement and in the second example, we are going to use (isInfinite n) function. And in third example, we are going to use (isNaN) function along with (isInfinite n) function. Algorithm Step 1 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. Step 2 − The variable named, ... Read More
In Haskell, we can use numerator, div, quot and gcd functions to find the numerator from a given rational number. In the first example we are going to use numerator (r) function and in the second example, we are going to use (n `div` gcd n d) function. And in third example, we are going to use (numerator r `quot` gcd (numerator r) (denominator r)) function. Algorithm Step 1 − The Data.Ratio module is imported to use numerator function. Step 2 − Program execution will be started from main function. The main() function has whole control of the program. ... Read More
In Haskell, we can use GCD function to find the LCM of the given number. In the first example we are going to use (a * b) `div` (gcd a b) function and in the second example, we are going to use foldl' (\x y -> (x*y) `div` (gcd x y)) function. In third example, we are going to use gcd' b (a `mod` b) function. Algorithm Step 1 − The lcm function is defined using gcd function as, lcm a b = (a * b) `div` (gcd a b). Step 2 − Program execution will be started ... Read More
In Haskell, we will find the GCD using library function like gcd, div function and recursion. In the first example, we are going to use gcd (a b) function and in the second example, we are going to use (a `div` b) function. In third example, we are going to use recursion. Method 1: Finding the GCD using gcd function In this method, the gcd function takes two integers as input and returns the greatest common divisor of these two numbers. This function is defined in the Prelude library. Algorithm Step 1 − Program execution will be started from ... Read More
In Haskell, we can use library function like mod, even and quot to check whether, the given number is an EVEN number or not. In this article we are going to have examples that are using n `mod` 2 == 0 even function as well as n `quot` 2 == 0 function. Algorithm Step 1 − The isEven function is defined using mod function as, isEven n = n `mod` 2 == 0. Step 2 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main ... Read More
The marketing division will soon be transformed by machine learning. It has in many ways already begun. By 2020, 30% of companies will utilize machine learning in their sales process, according to Gartner. These businesses are also employing machine learning to overcome some of marketing's most difficult problems, such as personalization, immediate customer assistance, and big data, in order to stay one step ahead of their rivals. So, not just computer scientists can use machine learning. Marketers must take notice. What Is Machine Learning? Let's study the definitions of machine learning and artificial intelligence before moving on to ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP