Found 185 Articles for Haskell

Haskell program to compute quotient and remainder

Potti Chandra Sekhar sai
Updated on 24-Nov-2022 06:26:36

506 Views

In this tutorial, we discuss writing a program to compute the quotient and remainder in Haskell programming language. Quotient and remainder are the quantities obtained as a result of dividing two quantities. Example − quotient and remainder for the division of 31/5 are 6, 1 respectively. The number can be represented as 31 (dividend) = 5(divisor) * 6(quotient) + 1(remainder). In this tutorial, we see four different ways to write a program to compute quotient and remainder. Haskell program to compute the quotient and the remainder using built-in functions div and mod Haskell program to compute the quotient and ... Read More

Haskell Program to Check if two of the three Boolean variables are true

Potti Chandra Sekhar sai
Updated on 24-Nov-2022 06:24:13

223 Views

In this tutorial, we discuss writing a program to check if two of three Boolean variables are true in the Haskell programming language Boolean variables are the type of variable which hold the boolean value true and false. In this tutorial, we see two different ways to implement a program to check if two of the three boolean values are true Program to check if two of the three boolean values are true in an iterative method. Program to check if two of the three boolean values are true in a recursive method. Algorithm steps Declare or ... Read More

Haskell program to calculate the sum of natural numbers

Potti Chandra Sekhar sai
Updated on 24-Nov-2022 06:22:43

724 Views

In this tutorial, we discuss writing a program to calculate the sum of the natural numbers in the Haskell programming language. Natural numbers are positive integers starting from 1, 2, 3...N In this tutorial, we see different ways to implement a program to compute the sum of natural numbers. Program to compute the sum of the natural numbers using a mathematical formula. Program to compute the sum of the natural numbers using a recursive function. Program to compute the sum of the natural numbers using the list method/function sum. Algorithm steps Declare or take input the range ... Read More

Haskell Program to Calculate simple interest and compound interest

Potti Chandra Sekhar sai
Updated on 24-Nov-2022 06:21:17

276 Views

In this tutorial, we discuss writing a program to calculate simple and compound interest in the Haskell programming language In this tutorial, we see Program to compute Simple interest. Program to compute Compound interest. Simple interest is an Interest method for an investment, where interest is defined as I = p*t*r/100, where p is the invested amount, t is the quantity of time in years, and r is the interest rate. (per 100). Example − For an invested amount of 1000(p), t= 2 and r =3 the interest is 60. Compound interest is an Interest method for an ... Read More

Haskell program to read numbers from standard input

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 06:06:02

1K+ Views

In this tutorial, we discuss writing a program to get input from the user in the Haskell programming language. Haskell is a Declarative, Strongly Typed, and Functional programming language. This tutorial discusses reading numbers from standard input in the Haskell Programming language. Haskell is a purely functional Language. Pure functions are the ones that return the same output for the same arguments. Taking user input changes the program’s nature to impure. Haskell introduced a type IO that differentiates impure functions from pure functions. A function declaration with type IO infers that it is an impure function that interacts with the outer ... Read More

Haskell program to get input from the user

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 06:02:32

3K+ Views

In this tutorial, we discuss writing a program to get input from the user in the Haskell programming language. Haskell is a Declarative, Strongly Typed, and Functional programming language. Computations in Haskell are mathematical functions. In this tutorial, we discuss two ways to get input from the user in Haskell. User input using the getLine method. User input using the getChar method. As Haskell is a purely functional Language. Pure functions are the functions that return the same output for the same arguments. Taking user input changes the program’s nature to impure. Haskell introduced a type IO that ... Read More

Haskell program to add two complex numbers

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:59:49

552 Views

This tutorial will discuss writing a program to add two complex numbers in the Haskell Programming Language. Haskell is a declarative, strongly typed, and functional programming language. The computations in Haskell are mathematical functions. Complex numbers are a combination of real and imaginary values. Example: 1 + 2i, where i is √-1 In this tutorial, we see four ways to Add two complex numbers. Computing the addition using the infix operator for addition “+”. Implementing addition computation in a separate function. Computing the addition using the infix operator “+” as a function. Computing the addition of complex numbers by ... Read More

Haskell program to display alphabets (A-Z) using a loop

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:54:09

451 Views

This tutorial will discuss writing a program to display characters from A-Z in Haskell programming Language. Haskell is a Functional, Declarative, and Strongly Typed Language. The computations in Haskell are mathematical functions. In this tutorial, We see two ways to display Alphabets in Haskell. An iterative Program to display Alphabets. A recursive Program to display Alphabets. Note − Haskell doesn’t support Loops, So we mimic the function of a loop with other iterative and recursive implementations. Algorithmic Steps Implement the logic for printing Alphabets. Print/display Alphabets. Displaying Alphabets In An Iterative Way Using List Comprehensions. Example Program ... Read More

Haskell program to find the gcd of two numbers

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:52:39

1K+ Views

This tutorial will discuss writing a program to find the LCM of two numbers in the Haskell Programming Language. Haskell is a functional programming language. The GCD of two numbers is the Greatest Common Divisor/ Number that divides both numbers Can also be called as Highest Common Factor. In this tutorial, we discuss five ways to implement a program to find the GCD of two numbers. Using the inbuilt function gcd. Using the inbuilt function lcm. Computing GCD using list comprehension. Computing GCD using a recursive function with three arguments. Computing GCD using a recursive function with two arguments. ... Read More

Haskell program to find lcm of two numbers

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:40:05

345 Views

This tutorial will discuss writing a program to find the LCM of two numbers in the Haskell Programming Language. Haskell is a functional programming language. LCM of two numbers is the least common multiple for that two numbers i.e smallest number that is divided by both numbers. In this tutorial, we discuss five different ways to implement a program to find the LCM of two numbers. Using inbuilt function lcm. Computing LCM using list comprehension. Computing LCM using a recursive function. Computing LCM using the HCF (Highest Common Factor) function. Algorithm steps Take the two integers as ... Read More

Advertisements