السلام عليكم,دمتم بخير,
قرأت في شروحات لغة الاسس عن شيء يدعي “الدالة الضمنيه”… لكن لم افهم الصورة العامة منها او الهدف منها او لماذا تستخدم؟ هل هناك اي مساعدة في توضيحها, مع الشكر : )
وهذا الكود الخاص بها:
func sort (
records: ref[Array[Record]],
compare: ptr[func (ref[Record], ref[Record])]
) {
def i: Int;
def j: Int;
for i = 0, i < records.getLength() - 1, ++i {
for j = i + 1, j < records.getLength(), ++j {
if compare(records(i), records(j)) {
// Replace i with j;
}
}
}
}
// Sort ascending.
sort(records, func (r1: ref[Record], r2: ref[Record])
{
return r1.x > r2.x;
});
// Sort descending.
sort(records, func (r1: ref[Record], r2: ref[Record]) {
return r1.x < r2.x;
});