Convert Double Type Variables to Int in Haskell

Akhil Sharma
Updated on 20-Apr-2023 12:02:45

902 Views

In Haskell, we will convert double type variables into int by using user-defined function, doubleToInt along with floor, round and ceiling functions. In the first example, we are going to use (doubleToInt d = floor d) function and in the second example, we are going to use (doubleToInt d = round d). And in the third example, we are going to use (doubleToInt d = ceiling d). Algorithm Step 1 − The doubleToInt function is defined using floor function as, doubleToInt d = floor d. Step 2 − The program execution will be started from main function. The ... Read More

Convert Int Type Variables to Double in Haskell

Akhil Sharma
Updated on 20-Apr-2023 12:02:13

2K+ Views

In Haskell, we will convert int type variables into double by using user-defined function, intToDouble along with fromIntegral, realToFrac and realPart functions. In the first example, we are going to use (intToDouble n = fromIntegral n) function and in the second example, we are going to use (intToDouble n = realToFrac n). And in the third example, we are going to use (intToDouble n = realPart (fromIntegral n :+ 0)). Algorithm Step 1 − The intToDouble function is defined using fromIntegral function. Step 2 − The program execution will be started from main function. The main() function has ... Read More

Convert Int Type Variables to String in Haskell

Akhil Sharma
Updated on 20-Apr-2023 12:01:17

3K+ Views

In Haskell, we will convert int type variables into string by using user-defined function, intToString along with show, map and printf functions. In the first example, we are going to use (intToString n = show n) function and in the second example, we are going to use (intToString n = intercalate "" (map show [n])). And in the third example, we are going to use (intToString n = printf "%d" n). Algorithm Step 1 − The intToString function is defined using show function as, intToString n = show n. Step 2 − The program execution will be started ... Read More

Convert String Type Variables into Int in Haskell

Akhil Sharma
Updated on 20-Apr-2023 12:00:41

1K+ Views

In Haskell, we will convert string type variables into integer by using user-defined function, stringToInt along with read and readMaybe functions. This can also be implemented using pattern matching and recursion. In the first example, we are going to use (stringToInt str = readMaybe str) function and in the second example, we are going to use (stringToInt "" = Nothing; stringToInt ('-':xs) = negate ; stringToInt xs; stringToInt xs = case reads xs of [(n, "")] -> Just n and _ -> Nothing). Algorithm Step 1 − The stringToInt function is defined using readMaybe function Step 2 ... Read More

Convert String Type Variables into Boolean in Haskell

Akhil Sharma
Updated on 20-Apr-2023 12:00:01

579 Views

In Haskell, we will convert string type variables into boolean by using user-defined function, stringToBool along with Maybe Bool, toLower and readMaybe functions. In the first example, we are going to use (stringToBool :: String -> Maybe Bool) function and in the second example, we are going to use (stringToBool str = case map toLower str of). And in third example, we are going to use (stringToBool str = case readMaybe str of). Algorithm Step 1 − The stringToBool function is defined. Step 2 − The program execution will be started from main function. The main() function has whole ... Read More

Haskell Program to Print Reverse Pyramid Star Pattern

Akhil Sharma
Updated on 20-Apr-2023 11:58:49

217 Views

Haskell has internal functions like mapM and ForM functions to print a revered Pyramid pattern star. A reverse pyramid star pattern is a pattern of asterisks (stars) arranged in the shape of an inverted pyramid. Algorithm Step 1 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. In the main function, a number is passed up to which the reverse pyramid star pattern is to be printed. The main function defines the mapM_ function as, Step 2 − The variable named, “n” is ... Read More

Haskell Program to Print Pyramid Star Pattern

Akhil Sharma
Updated on 20-Apr-2023 11:57:56

247 Views

In Haskell, we can use mapM and ForM functions to print pyramid-patterned stars. A pyramid star pattern is a design or arrangement of stars or other symbols in the shape of a pyramid. It is created by printing stars 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 a triangular shape. The pattern is usually symmetrical, with the number of stars or symbols in each row equal to the row number, and the middle of each row lined up vertically. Algorithm Step ... Read More

Create GUI to Get Sunset and Sunrise Time Using Python

Tamoghna Das
Updated on 20-Apr-2023 11:38:11

591 Views

What is Python and what are its advantages? Python is a high-level programming language that is used for a wide range of applications, including web development, scientific computing, data analysis, and artificial intelligence. It has a simple and elegant syntax that makes it easy to read and write, and a large standard library that provides many useful tools and functions. Some of the advantages of Python include its readability, ease of use, flexibility, and portability. It is an open-source language, which means that it is freely available and can be modified and distributed by anyone. Python also has a large ... Read More

Create a GUI to Get Domain Information Using Tkinter

Tamoghna Das
Updated on 20-Apr-2023 11:29:23

401 Views

In today's world, many businesses depend heavily on their online presence. Before setting up a website or purchasing a domain name, it is essential to get as much information as possible about the domain you plan to use. It may include information like domain owner, server location, IP address, WHOIS details, and much more. Therefore, in the following instruction manual, we'll guide you about creating a GUI to get domain information using Tkinter. What is GUI? GUI (Graphical User Interface) is a way to present data to the user in the form of interactive windows, buttons, and menus instead of ... Read More

Create a GUI to Find the IP of a Domain Name Using Python

Tamoghna Das
Updated on 20-Apr-2023 11:24:23

780 Views

When it comes to networking, IP addresses and domain names are two critical concepts that ensure seamless communication between devices on the internet. In this tutorial, we will learn how to create a Graphical User Interface (GUI) using Python that can be used to find the IP address assigned to a domain name. We will cover the following sections − Understanding IP Addresses and Domain Names Installing the Required Libraries Building the GUI Testing the Application Real World Examples Understanding IP Addresses and Domain Names Before we dive into building the application, it's important to understand what IP ... Read More

Advertisements