How to resolve the algorithm Collections step by step in the E programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Collections step by step in the E programming language
Table of Contents
Problem Statement
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Create a collection, and add a few values to it.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Collections step by step in the E programming language
Source code in the e programming language
? def constList := [1,2,3,4,5]
# value: [1, 2, 3, 4, 5]
? constList.with(6)
# value: [1, 2, 3, 4, 5, 6]
? def flexList := constList.diverge()
# value: [1, 2, 3, 4, 5].diverge()
? flexList.push(6)
? flexList
# value: [1, 2, 3, 4, 5, 6].diverge()
? constList
# value: [1, 2, 3, 4, 5]
? def constMap := [1 => 2, 3 => 4]
# value: [1 => 2, 3 => 4]
? constMap[1]
# value: 2
? def constSet := [1, 2, 3, 2].asSet()
# value: [1, 2, 3].asSet()
? constSet.contains(3)
# value: true
You may also check:How to resolve the algorithm Variadic function step by step in the E programming language
You may also check:How to resolve the algorithm Sorting algorithms/Bubble sort step by step in the E programming language
You may also check:How to resolve the algorithm Loops/Downward for step by step in the E programming language
You may also check:How to resolve the algorithm Multiplication tables step by step in the E programming language
You may also check:How to resolve the algorithm Time a function step by step in the E programming language