asomiya 0.2.0

Control flow

Lists

A list (তালিকা) holds several values in order, inside square brackets.

Create and read

ধৰা ফল = ["আম", "কল", "লিচু"]
কোৱা(ফল)
কোৱা(ফল[০], দৈৰ্ঘ্য(ফল))
Output
["আম", "কল", "লিচু"]
আম ৩
dhora fol = ["aam", "kol", "lisu"]
kowa(fol)
kowa(fol[0], doirghyo(fol))
Output
["aam", "kol", "lisu"]
aam 3

Positions start at ০. Reading past the end is an error (R010).

Change and add

ধৰা সংখ্যাবোৰ = [১, ২, ৩]
সংখ্যাবোৰ[০] = ১০
সংযোজন(সংখ্যাবোৰ, ৪)
কোৱা(সংখ্যাবোৰ)
Output
[১০, ২, ৩, ৪]
dhora xonkhyabur = [1, 2, 3]
xonkhyabur[0] = 10
xonjojon(xonkhyabur, 4)
kowa(xonkhyabur)
Output
[10, 2, 3, 4]

Go through a list

ধৰা নম্বৰ = [৭২, ৮৫, ৯০, ৬৪]
ধৰা মুঠ = ০
ধৰা ক = ০
যেতিয়ালৈকে (ক < দৈৰ্ঘ্য(নম্বৰ)) {
    মুঠ = মুঠ + নম্বৰ[ক]
    ক = ক + ১
}
কোৱা("গড়:", মুঠ / দৈৰ্ঘ্য(নম্বৰ))
Output
গড়: ৭৭.৭৫
dhora nombor = [72, 85, 90, 64]
dhora mut = 0
dhora k = 0
jetialoike (k < doirghyo(nombor)) {
    mut = mut + nombor[k]
    k = k + 1
}
kowa("gor:", mut / doirghyo(nombor))
Output
gor: 77.75

Lists are shared

Assigning a list to another variable doesn’t copy it. Both names refer to the same list:

ধৰা ক = [১, ২]
ধৰা খ = ক
সংযোজন(খ, ৩)
কোৱা(ক)
Output
[১, ২, ৩]
dhora k = [1, 2]
dhora kh = k
xonjojon(kh, 3)
kowa(k)
Output
[1, 2, 3]

Lists can hold any values, including other lists. == compares lists item by item.