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. · לחץ על הרץ כדי לראות את התוצא כאן.