The right thing to do is to consider three cases separately:

* zero or one elements: return `sum(y)*dx`.  The `sum` function will do the right thing.
* 2 elements: `sum(y)*(dx*0.5)`
* 3+ elements: iterate yourself, but initialize the summand to `y[1]*0.5 + y[2]`

However, you have to use `start/end/done` rather than `length(y)` or `y[i]` to get the length and elements, respectively.