How to resolve the algorithm Arrays step by step in the Lingo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Arrays step by step in the Lingo 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 Lingo programming language
Source code in the lingo programming language
a = [1,2] -- or: a = list(1,2)
put a[2] -- or: put a.getAt(2)
-- 2
a.append(3)
put a
-- [1, 2, 3]
a.deleteAt(2)
put a
-- [1, 3]
a[1] = 5 -- or: a.setAt(1, 5)
put a
-- [5, 3]
a.sort()
put a
-- [3, 5]
ba = bytearray(2, 255) -- initialized with size 2 and filled with 0xff
put ba
--
ba[1] = 1
ba[2] = 2
ba[ba.length+1] = 3 -- dynamically increases size
put ba
--
ba[1] = 5
put ba
--
You may also check:How to resolve the algorithm Vector products step by step in the AWK programming language
You may also check:How to resolve the algorithm File input/output step by step in the Retro programming language
You may also check:How to resolve the algorithm Magic 8-ball step by step in the uBasic/4tH programming language
You may also check:How to resolve the algorithm Babbage problem step by step in the zkl programming language
You may also check:How to resolve the algorithm Paraffins step by step in the jq programming language