Akhil Sharma has Published 671 Articles

Haskell Program to Display Armstrong Number Between Two Intervals

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:27:13

97 Views

In Haskell, we can useuser-defined functions and using recursion. In the first example we are going to use (user-defined, isArmstrong and armstrongInRange) function and in the second example, we are going to use recursion with base and recursive case. Algorithm Step 1 − The user-defined isArmstrong function is defined ... Read More

Haskell Program to Display Prime Numbers Between Intervals Using Function

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:26:15

117 Views

In Haskell, we can Display Prime Numbers Between Intervals using user-defined function along with filter function and recursion. In the first example we are going to use user-defined, (isPrime) function with (primeInRange a b = filter isPrime [a..b] ) function and in the second example, we are going to use ... Read More

Haskell Program to Make a Simple Calculator Using switch...case

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:25:32

609 Views

In this article we are going to learn how to make a simple calculator in Haskell using switch…case. In the first example, we are going to use case statements with different operators and in the second example, we are going to use map of functions as (fromList [('+', (+)), ('-', ... Read More

Haskell Program to Display Factors of a Number

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:23:45

395 Views

In Haskell, we can list comprehension, filter function and recursion to display factors of a number. In the first example we are going to use (factors n = [x | x n `mod` x == 0) [1..n]) function. And in third example, we are going to use recursion with ... Read More

Haskell Program to Display Armstrong Numbers Between Intervals Using Function

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:22:33

104 Views

Haskell has functions like higher order and filter, that can be used for getting the Armstrong number between two given internvals. In the first example we are going to use (isArmstrong and armstrongInRange function with higher order) and in the second example, we are going to use (filter isArmstrong ... Read More

Haskell Program to get the remainder of float numbers using library function

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:21:30

227 Views

Haskell has internal functions like divMod, mod and properFraction to get the remainder of the float number. In the first example we are going to use (divMod' (x) (y)) function and in the second example, we are going to use (mod' x y) function. And in third example, we ... Read More

Haskell Program to get the Magnitude of the given number

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:20:47

155 Views

Haskell has internal functions like negate, abs and signum functions that can be used to get magnitude of the given number. In the first example we are going to use (negate n) function and in the second example, we are going to use (abs) function. In third example, we are ... Read More

Haskell Program to get the denominator from a rational number

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:18:50

169 Views

In Haskell, we can use denominator, div, quot and gcd functions to obtain the denominator from a rational number. In the first example we are going to use (denominator r) function and in the second example, we are going to use (d `div` gcd n d) function. Algorithm ... Read More

Haskell Program to convert boolean variables into string

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:17:55

184 Views

In Haskell, we will convert boolean variables into string by using user-defined function, boolToString along with if-else statement and pattern matching. In the first example, we are going to use (boolToString b = show b) function and in the second example, we are going to use (boolToString b = if ... Read More

Haskell Program to convert int type variables to long

Akhil Sharma

Akhil Sharma

Updated on 13-Mar-2023 15:16:11

199 Views

In Haskell, we can use internal functions like fromIntegral intToLong and toInteger function and toEnum to convert int type variable to long. In the first example, we are going to use (let longVar = fromIntegral intVar :: Int64) and in the second example, we are going to use (intToLong = ... Read More

Advertisements