How to resolve the algorithm Arrays step by step in the Transd programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Arrays step by step in the Transd programming language

Table of Contents

Problem Statement

This task is about arrays. For hashes or associative arrays, please see Creating an Associative Array. For a definition and in-depth discussion of what an array is, see Array.

Show basic array syntax in your language. Basically, create an array, assign a value to it, and retrieve an element   (if available, show both fixed-length arrays and dynamic arrays, pushing a value into it). Please discuss at Village Pump:   Arrays.
Please merge code in from these obsolete tasks:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Arrays step by step in the Transd programming language

Source code in the transd programming language

module1 : {
  v1: Vector(),
  v2: Vector(),
  v3: Vector([1,2,3,4]),
  v4: Vector(["one","two","three"]),
  // the type of vector values can automaticaly deduced
  v5: [1.0, 2.5, 8.6], // Vector
  v6: ["one","two","three"] // Vector
}

(with v [1,2,3]
  (textout (get v 1)) // <= 2
  (erase v 1)
  (textout v) // <= [1, 3]
  (append v 7)
  (textout v) // <= [1, 3, 7]
)

(with v [3,1,5,2,4]
  (textout (reverse v)) // <= [4, 2, 5, 1, 3]
  (textout (sort v)) // <= [1, 2, 3, 4, 5]
  (textout (shuffle v)) // <= [5, 3, 4, 1, 2]
)

  

You may also check:How to resolve the algorithm Sorting algorithms/Selection sort step by step in the PHP programming language
You may also check:How to resolve the algorithm Ranking methods step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Cholesky decomposition step by step in the Haskell programming language
You may also check:How to resolve the algorithm Distributed programming step by step in the OCaml programming language
You may also check:How to resolve the algorithm Poker hand analyser step by step in the Go programming language