### 8.1.10 Accumulating terms: accumulate_head_tail

The first terms and last terms of a list can be accumulated by replacing them with their sum using the accumulate_head_tail command. This command takes the list, the number of initial terms to sum, and the number of end terms to add, and returns the list with the initial terms and end terms replaced by their sums. For example, the command

accumulate_head_tail([1,2,3,4,5,6,7,8,9,10],3,4)

will return

[6,4,5,6,34]