
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

171 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 [a..b]) function. Algorithm Step 1 − The user-defined isArmstrong function is defined. 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 variables named, “lower” and “upper” are ... Read More

2K+ Views
In Haskell, we will compare numbers and strings using library function using compare, min and max functions. Also, by using Eq and Ord typeclasses. In the first example we are going to use (compare num1 num2 and compare str1 str2) function and in the second example, we are going to use (max num1 num2 and min str1 str2) function. And in third example, we are going to use (num1 == num2) function along with (num1 /= num2) typeclasses. Algorithm Step 1 − The Data.Ord library is imported, which contains the compare function. Step 2 − Program execution ... Read More

453 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 are going to use (properFraction $ x / y) function. Algorithm Step 1 − The Data.Fixed module is imported to use divMod function. Step 2 − The variables named, “x” and “y” are being initialized. It will hold the floating point numbers whose remainder value is to be found ... Read More

295 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 going to use (signum x) function. Algorithm Step 1 − Define the magnitude function Step 2 − Program execution will be started from main function. The main() function has whole control of the program. Step 3 − The variable named, “num” is being initialized. It will hold the number ... Read More

241 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 Step 1 − The Data.Ratio module is imported to use denominator 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 calls the denominator function with the rational number and prints ... Read More

299 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 b then "yes" else "no"). And in third example, we are going to use pattern matching. Algorithm Step 1 − Define the boolToString function Step 2 − The program execution will be started from main function. The main() function has whole control of the program. It is written as ... Read More

317 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 = toEnum) function. Algorithm Step 1 − The Data.Int module is imported. Step 2 − The program execution will be started from main function. The main() function has whole control of the program. Step 3 − The variable named, “intVar” is being initialized. It will hold the Int type variable ... Read More

341 Views
In Haskell, we can use fromIntegral function along with toInteger and truncate function, div and mod functions to convert long type variable into int. In the first example, we are going to use ( let intVar = fromIntegral longVar :: Int) and in the second example, we are going to use (let highPart = fromIntegral (longVar `div` 2^32) :: Int and let lowPart = fromIntegral (longVar `mod` 2^32) :: Int). Algorithm Step 1 − The program execution will be started from main function. The main() function has whole control of the program. It is written as main ... Read More

2K+ Views
In Haskell, we will convert int type variables to char by using user-defined function using chr function, toEnum function and list indexing. In the first example, we are going to use (intToChar I | i >= 0 && i = 0 && i = 0 && i = 0 && i Maybe Char intToChar i | i >= 0 && i putStrLn $ "The character value is " ++ [c] ++ "." Nothing -> putStrLn "Invalid input. Please enter an integer between 0 and 255." Output The character ... Read More

1K+ Views
In Haskell, we can use pattern matching, digitToInt, reads and a user-defined functions to convert char-type variables to int. In the first example, we are going to use cases for matching the pattern and in the second example, we are going to use (charToInt c = if isDigit c then Just (digitToInt c) else Nothing). And in third example, we are going to use (charToInt c = case reads [c] of [(x, "")] -> Just x and _ -> Nothing) function. Algorithm Step 1 − The internal function is defined Step 2 − Program execution will be started ... Read More