Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Collections/Oz/collections.oz
Normal file
25
Task/Collections/Oz/collections.oz
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
declare
|
||||
%% Lists (immutable, recursive)
|
||||
Xs = [1 2 3 4]
|
||||
%% Add element at the front (cons)
|
||||
Xs0 = 0|Xs
|
||||
{Show {Length Xs}} %% output: 4
|
||||
|
||||
%% Records (immutable maps with a label)
|
||||
Rec = label(1:2 symbol:3)
|
||||
{Show Rec} %% output: label(2 symbol:3)
|
||||
{Show Rec.1} %% output: 2
|
||||
%% create a new record with an added field
|
||||
Rec2 = {AdjoinAt Rec 2 value}
|
||||
{Show Rec2} %% output: label(2 value symbol:3)
|
||||
|
||||
%% Dictionaries (mutable maps)
|
||||
Dict = {Dictionary.new}
|
||||
Dict.1 := 1
|
||||
Dict.symbol := 3
|
||||
{Show Dict.1} %% output: 1
|
||||
|
||||
%% Arrays (mutable with integer keys)
|
||||
Arr = {Array.new 1 10 initValue}
|
||||
Arr.1 := 3
|
||||
{Show Arr.1} %% output: 3
|
||||
Loading…
Add table
Add a link
Reference in a new issue