Akhil Sharma has Published 550 Articles

Haskell Program to Check Armstrong Number

Akhil Sharma

Akhil Sharma

Updated on 25-Apr-2023 15:35:09

In Haskell we can check whether a given number is Armstrong or not using list comprehension and sum function. Armstrong numbers, also known as narcissistic numbers, are numbers such that the sum of the cubes of their digits is equal to the number itself. For example, the number 153 is ... Read More

Haskell Program to Check Leap Year

Akhil Sharma

Akhil Sharma

Updated on 25-Apr-2023 15:34:14

In Haskell, we can check whether a given year is a leap year is not using simple boolean expression. A leap year is a year that has an extra day (February 29th) compared to a normal year. For example, 2004 is a leap year. To determine if a year is ... Read More

Haskell Program to Convert Array to Set (HashSet)

Akhil Sharma

Akhil Sharma

Updated on 25-Apr-2023 15:26:36

In Haskell, we will convert Array to Set (HashSet) by using fromList, nub and foldr functions. In the first example, we are going to use ( let set = Set.fromList arr) and in the second example, we are going to use ( let set = nub arr). And ... Read More

Haskell Program to Convert File to Byte Array

Akhil Sharma

Akhil Sharma

Updated on 25-Apr-2023 15:25:46

In Haskell, we will convert File to byte array by using B.readFile function along with fromIntegral and foldl function. In the first example, we are going to use ( let byteArray = B.unpack bytes) and in the second example, we are going to use (let wordArray = map fromIntegral ... Read More

Haskell Program to convert primitive types to objects

Akhil Sharma

Akhil Sharma

Updated on 25-Apr-2023 15:12:55

In Haskell, we will convert primitive types to objects by using accessor functions along with getName function, constructors and record syntax. In the first example, we are going to use (getName person = name person) and in the second example, we are going to use (getName (Person name _) = ... Read More

Haskell Program to Print Right Triangle Star Pattern

Akhil Sharma

Akhil Sharma

Updated on 24-Apr-2023 11:39:31

In haskell we can use mapM, forM as well as recursive function to create a simple right triangle star pattern. What is a Right Triangle Star Pattern? A right triangle pattern is a series of asterisks or other characters arranged in a triangular shape. In the case of a right ... Read More

Haskell Program To Find The Perfect Number

Akhil Sharma

Akhil Sharma

Updated on 24-Apr-2023 11:37:54

In haskell we can use list comprehension and brute-force method to find the perfect number. What is a Perfect Number? Perfect numbers are positive integers that are equal to the sum of their proper divisors. A divisor of a positive integer n is a positive integer that divides n exactly, ... Read More

Haskell Program to Check Whether a Number is Prime or Not

Akhil Sharma

Akhil Sharma

Updated on 24-Apr-2023 11:37:11

To check whether a given number is prime or not we are going to use mod function and list comprehension method in Haskell. What is a Prime Number? A prime number is a positive integer greater than 1 that is only divisible by 1 and itself. In other words, a ... Read More

Haskell Program to Check if two strings are anagram

Akhil Sharma

Akhil Sharma

Updated on 24-Apr-2023 11:36:12

In Haskell we can check if given two strings are anagram or not using sort function and freqMap. What is Anagram? An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. For example, ... Read More

Haskell Program to Check Palindrome

Akhil Sharma

Akhil Sharma

Updated on 24-Apr-2023 11:34:26

This tutorial will help us in checking if any number is palindrome number or not using user-defined function and boolean functions in haskell. A palindrome number is a number that remains the same when its digits are reversed. The following example will give you a clear idea about Palindrome number. ... Read More

Previous 1 ... 3 4 5 6 7 ... 55 Next
Advertisements