| 1 | func any(list) {
|
| 2 | ## Returns true if any value in the list is truthy.
|
| 3 | ##
|
| 4 | ## If the list is empty, return false.
|
| 5 |
|
| 6 | for item in (list) {
|
| 7 | if (item) {
|
| 8 | return (true)
|
| 9 | }
|
| 10 | }
|
| 11 | return (false)
|
| 12 | }
|
| 13 |
|
| 14 | func all(list) {
|
| 15 | ## Returns true if all values in the list are truthy.
|
| 16 | ##
|
| 17 | ## If the list is empty, return true.
|
| 18 |
|
| 19 | for item in (list) {
|
| 20 | if (not item) {
|
| 21 | return (false)
|
| 22 | }
|
| 23 | }
|
| 24 | return (true)
|
| 25 | }
|
| 26 |
|
| 27 | func sum(list; start=0) {
|
| 28 | ## Computes the sum of all elements in the list.
|
| 29 | ##
|
| 30 | ## Returns 0 for an empty list.
|
| 31 |
|
| 32 | var sum = start
|
| 33 | for item in (list) {
|
| 34 | setvar sum += item
|
| 35 | }
|
| 36 | return (sum)
|
| 37 | }
|