Files
pplus-library/pseudo/programs/25-nested-collections.pseudo
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

21 lines
645 B
Plaintext

// A HASHMAP of LISTs built up, then printed in sorted key order with KEYS.
// Finding: the list cannot be called Keys, because built-in names are reserved whatever their case.
// EXPECT: a: [1, 3]
// EXPECT: b: [2]
DECLARE Groups : HASHMAP OF STRING : LIST OF INTEGER
DECLARE Ks : LIST OF STRING
DECLARE Names : LIST OF STRING
DECLARE Values : LIST OF INTEGER
Names <- ["a", "b", "a"]
Values <- [1, 2, 3]
FOR I <- 0 TO LENGTH(Names)
IF NOT (Names[I] IN Groups) THEN
Groups[Names[I]] <- []
ENDIF
APPEND(Groups[Names[I]], Values[I])
NEXT I
Ks <- KEYS(Groups)
FOR EACH K IN Ks
OUTPUT K & ": " & TO_STRING(Groups[K])
NEXT K