- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 185 Articles for Haskell
336 Views
This article will help us learn how to pass a string to the function in Haskell with identity function and lambda expression. In the first example, we are going to use (myFunction inputString = inputString) function and in the second example, we are going to use (myFunction = id). And in third example, we are going to use lambda expression, (myFunction = \inputString -> inputString). Method 1: Passing a string to the user-defined function In this method, the user-defined functions are defined that will contain the function definition with some returning value and is being called by passing a string ... Read More
385 Views
This article will help us learn how to return an array from the function in haskell using user-defined function along with list comprehension and recursion. In the first example, we are going to use (show (getArray)) function and in the second example, we are going to use (getArray n = [x | x [Int] getArray n = [x | x Int) -> [Int] -> [Int] getArray f xs = map f xs main :: IO () main = do putStrLn (show (getArray (*2) [1, 2, 3, 4, 5])) Output [2, 4, 6, 8, ... Read More
451 Views
In Haskell, we will pass an array to the function by using user-defined functions. In all the examples, we are going to pass an array to the user-defined functions to perform the certain tasks. These functions can be sumArray, maxArray, minArray, countEvens, etc. In this method, the user-defined functions are created that will contain the function definition with some returning value and is being called by passing an array as argument to it. Algorithm Step 1 − The user defined function is defined by writing its definition with a return value. Step 2 − Program execution will ... Read More
478 Views
In this article, we are going to understand how to create a function with argument and a return value in Haskell using a user-defined function. The user-defined functions are defined that will contain the function definition with some returning value and is being called by passing desired arguments to it. These functions perform various operations as per the definition. In all the examples, we are going to define user-defined functions to perform certain tasks that will return some value and are passed with some arguments like, add, mult, maxOfTwo and other functions. Algorithm Step 1 − The user ... Read More
271 Views
We are going to learn how to create a function without argument but return a value using user-defined function. In this article, the user-defined functions are defined that will contain the function definition with some returning value and is being called without passing any arguments to it. In all the examples, we are going to define user-defined functions to perform the certain tasks that will return some value but are passed without arguments like, factorial, celsiusToFahrenheit, circleArea and other functions. Algorithm Step 1 − The user defined function is defined by writing its definition with a ... Read More
200 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
328 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
156 Views
This haskell tutorial will help us in calculating the value from the given fraction and exponent of a number. To find this, the input is taken as fraction and exponent, and its corresponding value is computed. Algorithm Step 1 − The “Data.Ratio” is imported to work over fractions. Step 2 − The calculateValue function is defined 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. Step 4 − The variables named, “fraction” and “exponent” are initialized. ... Read More
304 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
582 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