I'm not proud of this, but it works:
---
- name: List subtraction
gather_facts: no
hosts: localhost
vars:
selection: [ 1, 4, 5, 7]
tasks:
- name: Subtract one from each selection
debug:
msg: "{% set result = [] -%}
{% for v in selection -%}
{% set _ = result.append(v - 1) -%}
{% endfor %}{{ result }}"
--
This also works:
---
- name: List subtraction
gather_facts: no
hosts: localhost
vars:
selection: [ 1, 4, 5, 7]
tasks:
- name: Subtract one from each selection
debug:
msg: "{{ selection| zip_longest([-1], fillvalue=-1) | map('sum') }}"