How to resolve the algorithm Collections step by step in the Raven programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Collections step by step in the Raven 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 Raven programming language

Source code in the raven programming language

[ 1 2 3 'abc' ] as a_list
a_list print

list (4 items)
 0 => 1
 1 => 2
 2 => 3
 3 => "abc"

{ 'a' 1 'b' 2 } as a_hash
a_hash print

hash (2 items)
 a => 1
 b => 2

17 a_list 1 set      # set second item
42 a_hash 'b' set    # set item with key 'b'
42 a_hash:b          # shorthand

a_list 1 get         # get second item
a_hash 'b' get       # get item with key 'b'
a_hash.b             # shorthand

42 a_list push       # append an item
a_list pop           # remove last item
42 a_list shove      # prepend an item
a_list shift         # remove first item
42 a_list 1 insert   # insert item second, shuffling others down
a_list 1 remove      # retrieve second item, shuffling others up

  

You may also check:How to resolve the algorithm Matrix multiplication step by step in the Java programming language
You may also check:How to resolve the algorithm Loops/While step by step in the AmigaE programming language
You may also check:How to resolve the algorithm Idiomatically determine all the characters that can be used for symbols step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Zeckendorf number representation step by step in the Arturo programming language
You may also check:How to resolve the algorithm Animation step by step in the Standard ML programming language