Found 185 Articles for Haskell

Haskell program to check whether the input number is a Prime number

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 12:21:57

325 Views

This tutorial discusses writing a program to check whether the input number is a Prime number in the Haskell programming language. Haskell is a Declarative, Strongly Typed, and Functional programming Language. The computations in Haskell are mathematical functions. A prime number is a number having only 1 and the number itself as a factor. Note 1 is neither a prime nor a composite number because it has only one factor. For example, 3 is a prime number because it has only two factors 1 and the number 3 itself. In this tutorial we see, Program to check whether a ... Read More

Haskell Program to Print the Multiplication Table in Triangular Form

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 12:20:00

140 Views

This tutorial discusses writing a program to print the multiplication table in the triangular form in the Haskell programming language. For example, the multiplication table for the number 10 in the triangular format is 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 6 12 18 24 30 36 7 14 21 28 35 42 49 8 16 24 32 40 48 56 64 9 18 27 36 45 54 63 72 81 10 20 30 40 50 60 70 80 90 100 Algorithm Steps Take input or initialize an integer variable ... Read More

Haskell Program to Swap Two Numbers

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 12:13:51

653 Views

This tutorial discusses writing a program to swap two numbers in the Haskell programming language. Variables are immutable in Haskell i.e once declared their values cannot be changed. So we cannot swap the values of two variables, but we can mimic this by swapping values in a list and tuple. In this tutorial we see, Program to swap two numbers in a binary tuple. Program to swap two numbers in a list. In Haskell, tuples are used to store elements of different data types as a collection. Tuples are identified by parenthesis at the ends. Tuples support only ... Read More

Haskell Program to determine the name and version of the operating system

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 12:10:33

138 Views

This tutorial discusses writing a program to find the operating system info in the Haskell programming language. Haskell provides functions to find the system info. These functions can be accessed by importing the Info module from the System package in Haskell. In this tutorial, we see Program to display the name of the Operating System. Program to display the architecture of the processor. Program to display the compiler name. Program to display the compiler version. Syntax To import a module in Haskell the syntax is to follow. import packageName.moduleName To import the Info module from the system ... Read More

Haskell Program To Perform nCr (r-combinations)

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 12:06:48

283 Views

This tutorial discusses writing a program to perform nCr combinations in the Haskell programming language. The nCr is used to find the number of ways r items can be selected from n items given that order doesn’t matter. The nCr is defined as n! / ( r! (n-r)! ). For example number of ways in which 3 items can be selected from 5 items is 5! / ( 3! (5-3)! ), i.e 10 ways. In this tutorial we see, Program to find the factorial of a number (helper function to find the nCr combinations). Program to find the ... Read More

Haskell Program to Find the Perimeter of a Circle

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 12:00:56

213 Views

This tutorial discusses writing a program to find the perimeter of a circle in the Haskell programming language. The perimeter of the circle is the length of the boundary of the circle. The perimeter of a circle is also called the circumference. The perimeter of a circle is defined as 2*pi*r where r is the radius of the circle. For example area of the circle with a radius of 4 units is 25.13274 (2*pi*4). In this tutorial, we see two ways to implement a program to find the perimeter of a circle. Program to find the perimeter of ... Read More

Haskell Program to Find the Area of a Trapezium

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:55:05

75 Views

This tutorial discusses writing a program to print the area of a trapezium in the Haskell programming language. A trapezium is a quadrilateral with one opposite side parallel. The above figure is a trapezium. The length of one of the parallel sides is denoted by a and the other side is denoted by b. The height of the trapezium is denoted by h. The area of a trapezium is defined as (a+b)/(2*h), where a and b are the lengths of the parallel sides and h is the height or distance between the parallel sides. In this tutorial, we see ... Read More

Haskell Program to Find the Area of a Square

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:53:01

301 Views

This tutorial discusses writing a program to print the area of a square in the Haskell programming language. The square is a quadrilateral with all sides of the same length. The area of a square is equal to the square of the size of the side. If the side of the square has a size of 5 units, then the area of that is 25 units(5*5). In this tutorial, We see four ways to implement. Program to compute the area of a square using the infix operator “*”. Program to compute the area of a square using the ... Read More

Haskell Program to Calculate the Power of a Number

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:41:06

708 Views

This tutorial discusses writing a program to calculate the power of a number in the Haskell programming language. The nth power of a number is the value when the number is multiplied by itself n times. The power of numbers can be expressed in exponential forms “a^n”, a is raised to the power of n. Here a is called the base and n is called an exponent. For example, 2 raised to the power of 5 is 2^5 i.e 32. In this tutorial, we see different ways to implement a program to calculate the power of a number. Program ... Read More

Haskell Program to Find the Surface area and Volume of Cuboid

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:36:41

186 Views

This tutorial discusses writing a program to find the Surface area and volume of a cuboid in the Haskell programming language. A cuboid is a solid shape that has six rectangular faces. A cuboid has three dimensions length, breadth, and height. The surface area of a cuboid is the total area of the six rectangular faces i.e 2*length*breadth + 2*length*height + 2*breadth*height. The volume of the cuboid is length*breadth*height. As volume is area*height. In this tutorial we see, Program to find the surface area of a cuboid. Program to find the volume of a cuboid. Algorithm Steps ... Read More

Advertisements