Akhil Sharma has Published 671 Articles

Golang program to create a block using curly braces

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:59:43

519 Views

We can create a block in golang using curly braces and then create a variable inside the block to have the scope only inside the block and not outside it. In this article, we will use three examples to create a block using curly braces. In the first example few ... Read More

Golang program to convert the hash collection into string

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:58:41

647 Views

Golang has json package that is used for converting the hask collection into strin. A hashmap belongs to hash collection which stores the data as key:value pairs, whereas a string is a sequence of characters and it is immutable. In this article, we will use two examples to convert the ... Read More

Golang program to demonstrate the time arithmetic

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:56:22

443 Views

We are going to calculate the current time using the Now function from time package in Go programming language for demonstrating the time arithmetic. The time arithmetic is calculated using mathematical functions. In both examples, we will use mathematical calculations to find the past, future and the duration using Sub ... Read More

Haskell Program to create a simple recursive function

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:06:59

747 Views

In this article, we are going to understand how to create a simple function in Haskell using user-defined function. Here, the user-defined recursive functions are defined that will contain base case and recursive case. Then, these functions are being called recursively by passing the argument to it. In all the ... Read More

Haskell Program to return multiple values from the function

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:06:28

870 Views

In Haskell, we can return multiple values from the function by using user-defined function along with tuple, custom data type and Maybe data type. In the first example, we are going to use (myFunction = ("Hello, World!", 42)) and in the second example, we are going to use (data MyData ... Read More

Haskell Program to return a string from the function

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:05:22

723 Views

In this article, we are going to learn how to return a string from a function using user-defined function along with record syntax and let binding. In the first example, we are going to use (myFunction = "Hello, World!") function and in the second example, we are going to use ... Read More

Haskell Program to pass a string to the function

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:04:31

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 ... Read More

Haskell Program to return an array from the function

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:03:40

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 = ... Read More

Haskell Program to pass an array to the function

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:02:11

452 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 ... Read More

Haskell Program to create a function with arguments and a return value

Akhil Sharma

Akhil Sharma

Updated on 01-Mar-2023 11:00:58

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. ... Read More

Advertisements