Found 185 Articles for Haskell

Haskell Program to convert Hexadecimal to Decimal

Akhil Sharma
Updated on 06-Apr-2023 10:46:08

357 Views

This tutorial will help us to creat a haskell program that can covert a given hexadecimal number to a decimal number using revers, map and fold1 functions Hexadecimal to decimal conversion is the process of converting a number from the hexadecimal number system to the decimal number system. The hexadecimal number system uses a base of 16, which means that there are 16 unique symbols used to represent numbers in this system (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). The decimal number system, on the other hand, uses a base of ... Read More

Haskell Program to convert Decimal to Octal

Akhil Sharma
Updated on 06-Apr-2023 10:44:56

105 Views

We can convert the Decimal number to an Octal using the recursion and unfoldr function of Haskell. Decimal to octal conversion is a process of converting a decimal (base-10) number to its equivalent representation in octal (base-8) numbering system. In decimal numbering system, we use 10 digits (0 to 9) to represent a number. In octal numbering system, we use 8 digits (0 to 7) to represent a number. To convert a decimal number to its equivalent octal representation, we divide the decimal number by 8 repeatedly until the quotient becomes 0, and keep track of the remainders. The remainders, ... Read More

Haskell Program to Print Half Diamond Star Pattern

Akhil Sharma
Updated on 06-Apr-2023 10:43:33

70 Views

We can create a half-diamond star pattern in Haskell using recursive and replicate functions. The half-diamond star pattern is a pattern made up of asterisks (*) arranged in the shape of a half-diamond. It is typically created by printing a series of asterisks in a pyramid shape, starting with a single asterisk in the first row, two asterisks in the second row, and so on, until the middle row which contains the maximum number of asterisks. From that row onwards, the number of asterisks decreases until there is only a single asterisk in the last row. Algorithm Step 1 ... Read More

Haskell Program to Print Hollow Right Triangle Star Pattern

Akhil Sharma
Updated on 06-Apr-2023 10:41:38

137 Views

In Haskell we can use the replicate function and recursive function to create a hollow right triangle star pattern. A hollow right triangle star pattern is a pattern made up of asterisks (*) that forms a right triangle shape with empty spaces in the middle as shown below. ** * * * * * * * * * * * * ******** The shape is created by printing asterisks in a specific order, with the number of asterisks in each row increasing as the ... Read More

Haskell Program to Print 8-Star Pattern

Akhil Sharma
Updated on 06-Apr-2023 10:39:42

84 Views

In this tutorial, we are going to learn how to develop a Haskell program to print 8 start patterns using the internal replicate and concat function. An '8' star pattern is an ASCII art representation of the number 8 using asterisks. as shown below − ******** * * * * ******** * * * * ******** The asterisks are arranged in such a way that they form the shape of the number 8. Algorithm Step 1 − ... Read More

Haskell Program to Create Pyramid ‘and’ Pattern

Akhil Sharma
Updated on 06-Apr-2023 10:38:51

91 Views

In this tutorial, we are going to understand how to develop a Haskell program that will create a pyramid pattern of ‘&’ using mapM, forM, and recursive function. A pyramid ‘&’ pattern is a design or arrangement of ‘&’ or other symbols in the shape of a pyramid as shown below. & &&& &&&&& &&&&&&& &&&&&&&&& It is created by printing ‘&’ or symbols in multiple rows, starting from the top and moving downwards. Each row contains one more symbol than the previous row, creating the illusion of ... Read More

Haskell Program to Print Square Star Pattern

Akhil Sharma
Updated on 06-Apr-2023 10:36:54

204 Views

In Haskell we can use internal functions like mapM, forM or recursive functions to print square star pattern. A square star pattern is a two-dimensional pattern made up of stars (or asterisks, represented by the '*' symbol) arranged in the shape of a square as shown below. **** **** **** **** The square pattern is formed by printing a specified number of lines, each containing a specified number of stars. The pattern can be of any size, with the number of lines and the number of stars in each line determining the overall size of the square pattern. Algorithm ... Read More

Haskell Program to Print Star Pascal’s Triangle

Akhil Sharma
Updated on 06-Apr-2023 10:35:15

267 Views

In Haskell we can use mapM function and forM function to print a star Pascal’s Triangle. A star Pascal's triangle is a variation of the traditional Pascal's triangle that uses asterisks (or stars) instead of numbers to form a triangular pattern as shown below. * * * * * * * * * Pascal's triangle is a triangular array of numbers, where each number in the triangle is the sum of the two numbers above it. In ... Read More

Haskell Program to Print Mirror Upper Star Triangle Pattern

Akhil Sharma
Updated on 06-Apr-2023 10:32:04

79 Views

In this article, we are going to learn how we can develop a haskell program to print mirror upper start triangle patterns using mapM function, and unliness functions. A mirror upper star triangle pattern is a pattern made up of stars (asterisks) that form a triangle shape, with the top of the triangle pointing upwards. The following star pattern will give you a better understanding of mirror upper start triangle pattern. * *** ***** ******* ********* The pattern is called "mirror" because the left and right sides of the ... Read More

Haskell Program to Print Upper Star Triangle Pattern

Akhil Sharma
Updated on 06-Apr-2023 10:29:57

77 Views

This tutorial will help us in printing the upper star triangle pattern using mapM function, forM function, and unliness functions in Haskell. An upper star triangle pattern is a graphical representation of a triangle made up of asterisks or stars as shown below. * ** *** **** ***** It's called an "upper" star triangle because the triangle starts at the top and the number of stars in each row decreases as we move down the triangle. Algorithm Step 1 − We will start with defining a user-defined function as printStars function. Step 2 − Program execution will be ... Read More

Advertisements