Create Function with Arguments but Without Return Value in Haskell

Akhil Sharma
Updated on 01-Mar-2023 10:58:36

298 Views

In Haskell, we will create a function with arguments but without a return value by using user-defined functions. In this article, the user-defined functions are defined that will contain the function definition without returning any value and is being called by passing some desired arguments to it. In all the examples, we are going to define user-defined functions to perform the certain tasks that don’t return any value but are passed with arguments like, printSum, printString , printList and other functions. Algorithm Step 1 − The user defined function is defined by writing its definition without ... Read More

Create Function Without Argument and Return Value in Haskell

Akhil Sharma
Updated on 01-Mar-2023 10:57:16

497 Views

In Haskell, we can create a function without argument and without a return value by using user-defined functions. In all the examples, we are going to define user-defined functions to perform the certain tasks that don’t return any value and are passed without argument like, printGreeting, printMultipleLines, printSquares functions. Algorithm Step 1 − The user defined function is defined by writing its definition without returning any value. 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. In the ... Read More

Create Dynamic Breadcrumbs Using JavaScript

Rushi Javiya
Updated on 01-Mar-2023 10:51:47

4K+ Views

The breadcrumbs help website users to understand the navigation path, and windows file explorer is the best example that provides the breadcrumbs. When you open a file explorer, you can see the current location in the file explorer at the top bar. Also, if you click on any location, it jumps to that location. There are two main benefits of using dynamic breadcrumbs on the website. The first is that users can know about the navigation path, and another is users can jump on any location directly in the navigation path. Here, we will see different approaches to ... Read More

Write a Simple Code of Memoization Function in JavaScript

Shubham Vora
Updated on 01-Mar-2023 10:46:23

407 Views

Memoization is the optimization technique to improve the performance of the function. Before we start with the memoization technique, let’s understand why we require it using the example below. Example (Naïve approach to finding Fibonacci number) In the example below, we have implemented the naïve approach to find the nth Fibonacci number. We used the recursive approach to find the nth Fibonacci series. Finding the nth Fibonacci using recursive approach number in JavaScript Enter the number to find the nth Fibonacci number. ... Read More

Use Polyfill in JavaScript

Shubham Vora
Updated on 01-Mar-2023 10:38:38

2K+ Views

The developers of JavaScript always keep adding new features to the JavaScript language to improve performance and add better functionalities. Sometimes, it happens that new features don’t support by the old browser versions. For example, the exponential operator is introduced in ES7, and the trailing comma in the object is also valid in ES7. Now, while developing the application, we have added used the exponential operator in the application. It will work with the newer versions of the browser, but if someone is using a very old version of the browser, they can get errors like the exponential operator is ... Read More

Calculate Base 10 Logarithm in Haskell

Akhil Sharma
Updated on 01-Mar-2023 10:35:10

521 Views

This tutorial will help us in calculating the base 10 logarithm of the given value. A logarithm is a mathematical function that calculates the power to which a number (called the base) must be raised to produce a given value. The base 10 logarithm, is a logarithm in which the base is 10. Method 1: Using Internal Functions In this method, we are going to use build-in log and log base function to calculate bas 10 log of a given number. Algorithm Step 1 − The Prelude library is imported to use log functions. Step 2 − ... Read More

Calculate Base 2 Logarithm in Haskell

Akhil Sharma
Updated on 01-Mar-2023 10:07:53

1K+ Views

In Haskell, the logarithm is a mathematical function that calculates the power to which a number (called the base) must be raised to produce a given value. The base 2 logarithm, also known as binary logarithm, is a logarithm in which the base is 2. For example, the base 2 logarithm of 8 is 3, because 2 to the power of 3 equals 8 (2^3 = 8). Method 1: Using logBase function In this method, the log function takes a value of type Double and returns the base 2 logarithm of that value, which is also of type Double. The ... Read More

Calculate Cube Root of a Given Number in Haskell

Akhil Sharma
Updated on 01-Mar-2023 10:06:30

595 Views

This Haskell article will help us in calculating the cube root of the given number. The cube root of a number is a value that, when multiplied by itself three times, equals the original number. For example, the cube root of 8 is 2 because 2 x 2 x 2 = 8. In mathematics, cube root of a number x is represented as ∛x. Algorithm Step 1 − Define a user-defined function and name it as cubeRoot Step 2 − Program execution will be started from main function. The main() function has whole control of the ... Read More

Calculate Square Root of a Given Number in Haskell

Akhil Sharma
Updated on 01-Mar-2023 10:05:43

3K+ Views

There are different techniques in Haskell to calculate a square root of a number. The square root of a number is a value that, when multiplied by itself, equals the original number. For example, the square root of 9 is 3 because 3 x 3 = 9. Algorithm Step 1 − Defined the square root 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 takes an integer whose square root is to be calculated. Step 3 − ... Read More

Calculate Area of the Rhombus in Haskell

Akhil Sharma
Updated on 01-Mar-2023 10:03:56

167 Views

In Haskell there are different methods to calculating the area of the rhombus. We can use sides, diagonals and height on the basis of which, its area can be computed by various methods. Algorithm Step 1 − The Text.Printf module is imported. Step 2 − Defined the Rhombus fuction Step 3 − Program execution will be started from main function. The main() function has whole control of the program. It is written as main = do. It takes two integers as diagonals and prints the area using the rhombusArea function. Step 4 − The ... Read More

Advertisements