All examplesLanguage Install Aner
List, Dictionary, and Set basics
Store mixed values, look up ordered Dictionary entries, remove Set duplicates, and stably sort numbers or Strings without imports.
Download .aner source// Core collections need no imports or mandatory type arguments.
let values = List(10, "hello", 1.5, true, null)
values.append("last")
print(values)
print(cast<Int64>(values.get(0)) + 5)
print(values.get_or(index: 99, default: "missing"))
let record = Dictionary()
record.set(key: "name", value: "Aner")
record.set(key: "count", value: values.len())
record.set(key: "optional", value: null)
print(record.get("name"))
print(record.contains("optional"))
print(record.get("optional"))
print(record.get_or(key: "unknown", default: "missing"))
print(record.keys())
// Integer 1, float 1.0, text "1", and true stay distinct.
let unique = Set(1, "1", 1.0, true, null, 1)
print(unique.len())
print(unique.to_list())
print(unique.union(Set("new", 1)).to_list())
// Sorting permits mixed numbers and preserves each stored type.
let numbers = List(3, 1.5, 1, -2.0)
numbers.sort()
print(numbers)
let words = List("pear", "apple", "banana")
words.sort()
print(words)
let flags = List(true, false, true)
flags.sort()
print(flags)
// List(1, "two").sort() would report R2901 before changing the List.
Make it your experiment.
With Aner installed, save this program as examples/collections_basic.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/collections_basic.aner
aner run examples/collections_basic.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Iris and Wine are teaching datasets with their own attribution. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution