Anonymous user
Top rank per group: Difference between revisions
m
→{{header|Dyalect}}
(Updated to work with Nim 1.4: added missing parameter type. Renamed "top" as "printTop". Added a parameter "people" to the proc. Miscellaneous other changes.) |
|||
Line 952:
<lang dyalect>type Employee(name,id,salary,department)
func Employee.toString() {
"$\(this
}
Employee("Tyler Bennett","E10297",32000,"D101"),
Employee("John Rappl","E21437",47000,"D050"),
Line 972:
Employee("Timothy Grove","E16398",29900,"D190")
]
func topNSalaries(n) {
//We sort employees based on salary
employees.sort(
let max =
employees.len() - 1
} else {
n
}
for i in 0..max {
yield employees[i]
Line 982 ⟶ 987:
}
for e in seq {
print(e)
}</lang>
|