How to resolve the algorithm Vector step by step in the Ring programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Vector step by step in the Ring programming language

Table of Contents

Problem Statement

Implement a Vector class (or a set of functions) that models a Physical Vector. The four basic operations and a pretty print function should be implemented.

The Vector may be initialized in any reasonable way.

The four operations to be implemented are:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Vector step by step in the Ring programming language

Source code in the ring programming language

# Project : Vector

decimals(1)
vect1 = [5, 7]
vect2 = [2, 3]
vect3 = list(len(vect1))

for n = 1 to len(vect1)
    vect3[n] = vect1[n] + vect2[n]
next
showarray(vect3)

for n = 1 to len(vect1)
    vect3[n] = vect1[n] - vect2[n]
next
showarray(vect3)

for n = 1 to len(vect1)
    vect3[n] = vect1[n] * vect2[n]
next
showarray(vect3)

for n = 1 to len(vect1)
    vect3[n] = vect1[n] / 2
next
showarray(vect3)

func showarray(vect3)
     see "["
     svect = ""
     for n = 1 to len(vect3)
         svect = svect + vect3[n] + ", "
     next
     svect = left(svect, len(svect) - 2)
     see svect
     see "]" + nl

  

You may also check:How to resolve the algorithm Greatest subsequential sum step by step in the Haskell programming language
You may also check:How to resolve the algorithm XML/Input step by step in the Sidef programming language
You may also check:How to resolve the algorithm Averages/Pythagorean means step by step in the EchoLisp programming language
You may also check:How to resolve the algorithm Ramer-Douglas-Peucker line simplification step by step in the Nim programming language
You may also check:How to resolve the algorithm Loop over multiple arrays simultaneously step by step in the AutoHotkey programming language