How to resolve the algorithm Return multiple values step by step in the OCaml programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Return multiple values step by step in the OCaml programming language

Table of Contents

Problem Statement

Show how to return more than one value from a function.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Return multiple values step by step in the OCaml programming language

Source code in the ocaml programming language

let addsub x y =
  x + y, x - y


let sum, difference = addsub 33 12 in
  Printf.printf "33 + 12 = %d\n" sum;
  Printf.printf "33 - 12 = %d\n" difference


  

You may also check:How to resolve the algorithm Inheritance/Single step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Primorial numbers step by step in the Java programming language
You may also check:How to resolve the algorithm Arithmetic/Integer step by step in the SSEM programming language
You may also check:How to resolve the algorithm Stack step by step in the Tcl programming language
You may also check:How to resolve the algorithm Check that file exists step by step in the F# programming language