Akhil Sharma has Published 671 Articles

Haskell Program to check the given number is an Odd number using library function

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 14:57:52

2K+ Views

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 ... Read More

Haskell Program to get the Division and Remainder using library function

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 14:56:52

870 Views

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 ... Read More

Haskell Program to get the real part from a Complex number

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 14:55:40

76 Views

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 ... Read More

Haskell Program to check a given number is finite or not

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 14:54:26

102 Views

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 ... Read More

Haskell Program to get the numerator from a rational number

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 14:53:00

99 Views

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 ... Read More

Haskell Program to find the LCM using library function

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 14:51:59

75 Views

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 ... Read More

Haskell Program to find the GCD using library function

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 14:50:14

143 Views

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 ... Read More

Haskell Program to check the given number is an EVEN number using library function

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 14:48:37

605 Views

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 == ... Read More

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

Akhil Sharma

Akhil Sharma

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

156 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. ... Read More

Golang program to include a module inside the class

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 12:00:19

99 Views

In Go programming language, a new module is initiated using init command after which we can import other modules in our code. There is no concept of class in Go, only structs are used. In this article, we will use one example to include a module inside the class. In ... Read More

Advertisements