Baseline: tree as shared
This commit is contained in:
1679 files changed
+1024562
No files matched your search
@@ -0,0 +1,24 @@
|
||||
# probe: a list of structs, averages, and round()
|
||||
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
||||
# expect-stdout: ada 84.0 84.0
|
||||
# expect-stdout: bo 77.0 77.0
|
||||
@fieldwise_init
|
||||
struct Student(Copyable, Movable):
|
||||
var name: String
|
||||
var scores: List[Int]
|
||||
|
||||
def mean(self) -> Float64:
|
||||
var total = 0
|
||||
for s in self.scores:
|
||||
total += s
|
||||
return Float64(total) / Float64(len(self.scores))
|
||||
|
||||
|
||||
def main():
|
||||
var a: List[Int] = [90, 85, 77]
|
||||
var b: List[Int] = [60, 72, 81, 95]
|
||||
var people = List[Student]()
|
||||
people.append(Student("ada", a^))
|
||||
people.append(Student("bo", b^))
|
||||
for p in people:
|
||||
print(p.name, p.mean(), round(p.mean()))
|
||||
Reference in new issue
Block a user