Sum a list · اجمع قائمة
Sum a list
Add up every number in a list and return the total. Start a running total at 0, then loop over the list and add each value to it.
This pattern — a running total that grows inside a loop — comes up everywhere in programming.
مجموع قائمة
اجمع كل رقم في القائمة وأرجع المجموع الكلي. ابدأ بمجموع متراكم قيمته 0، ثم مرر عبر القائمة وأضف كل قيمة إليه.
هذا النمط — وهو مجموع متراكم ينمو داخل حلقة تكرار — يظهر في جميع أنحاء البرمجة.
Write sum_list(xs) that returns the total of all numbers in the list xs. An empty list sums to 0. · اكتب sum_list(xs) تُرجع مجموع جميع الأرقام في القائمة xs. القائمة الفارغة مجموعها 0.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.