Akhil Sharma has Published 421 Articles

Haskell Program to Convert String value to byte Value

Akhil Sharma

Akhil Sharma

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

In Haskell, we will convert String Value to Byte value by using ord , B.pack and fromNum functions. In the first example, we are going to use (stringToBytes = map ord ) function and in the second example, we are going to call (stringToBytes = B.pack) function. And in the ... Read More

Haskell Program to Convert Set of String to Array of String

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 15:00:44

In Haskell, We can use listArray and toList functions as well as list comprehension to convert set of string to array of string. In the first example, we are going to use (setToArray set = listArray (1, Set.size set) (Set.toList set)) function and in the second example, we are going ... Read More

Haskell Program to Convert List to Set

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 14:59:18

Haskell programming has internal functions like fromList, Set.fromList and foldr functions that can be used to convert list to set. In the first example, we are going to use (listToSet = Set.fromList) function and in the second example, we are going to call (set = Set.fromList xs) function directly from ... Read More

Haskell Program to Convert List to a Map

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 14:57:54

In Haskell, we will convert List to a Map by using fromList and foldl functions. This can also be done using recursion and pattern matching. In the first example, we are going to use (listToMap xs = Map.fromList xs) function and in the second example, we are going to use ... Read More

Haskell Program to Convert String to an Array

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 14:56:48

In Haskell, we will convert String to an Array by using listArray and intersperse functions. In the first example, we are going to use (stringToArray s = listArray (0, length s - 1) s) function and in the second example, we are going to use (stringToArray s = s) function. ... Read More

Haskell Program to Convert Character to String

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 14:55:14

In Haskell, we can convert Character to String by using user-defined function, show function, list comprehension and (:[]) notation. In the first example, we are going to use (charToString c = [c]) function and in the second example, we are going to use (charToString c = show c) function. Where ... Read More

Haskell Program to Convert Data to Hexadecimal

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 14:51:47

In Haskell, we will convert Data to Hexadecimal by using intToDigit, toHex and showHex functions. In the first example, we are going to use toHex function and (stringToHex = concatMap (\c -> toHex (fromEnum c))) function and in the second example, we are going to use convertToHex x = showHex ... Read More

Haskell Program to Print Inverted Star Pattern

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 14:36:40

In Haskell, to print Inverted star pattern we will be using mapM_, reverse, unlines and replicate functions. In the first example, we are going to use ( invertedStarPattern n = mapM_ putStrLn (reverse [replicate i '*' | i

Haskell Program to Print Diamond Star Pattern

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 14:34:57

In Haskell, to print Diamond star pattern we will be using mapM_, reverse, unlines and replicate functions. In the first example, we are going to use ( diamondStarPattern n = unlines $ topHalf ++ bottomHalf where topHalf = [replicate (n - i) ' ' ++ replicate ((2 * i) - 1) '*' | i

Haskell Program to Print Mirror Lower Star Triangle Pattern

Akhil Sharma

Akhil Sharma

Updated on 28-Mar-2023 12:48:38

In haskell, we can use unlines and replicate functions to print mirror lower star in triangle pattern. In the first example, we are going to use ( mirrorLowerTriangle n = unlines [replicate i '*' | i

1 2 3 4 5 ... 43 Next
Advertisements