How to resolve the algorithm Function definition step by step in the Erlang programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Function definition step by step in the Erlang programming language

Table of Contents

Problem Statement

A function is a body of code that returns a value. The value returned may depend on arguments provided to the function.

Write a definition of a function called "multiply" that takes two arguments and returns their product. (Argument types should be chosen so as not to distract from showing how functions are created and values returned).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Function definition step by step in the Erlang programming language

Source code in the erlang programming language

% Implemented by Arjun Sunel
-module(func_definition).
-export([main/0]).

main() ->
	K=multiply(3,4),
	io :format("~p~n",[K]).
	
multiply(A,B) ->
	case {A,B} of 
		{A, B} -> A * B
	end.


-module(func_definition).
-export([main/0]).

main() ->
	K=multiply(3,4),
	io :format("~p~n",[K]).
	
multiply(A,B) -> A * B.


  

You may also check:How to resolve the algorithm System time step by step in the Batch File programming language
You may also check:How to resolve the algorithm Comma quibbling step by step in the Astro programming language
You may also check:How to resolve the algorithm Matrix digital rain step by step in the Go programming language
You may also check:How to resolve the algorithm Unix/ls step by step in the Delphi programming language
You may also check:How to resolve the algorithm Ordered words step by step in the Burlesque programming language