> For the complete documentation index, see [llms.txt](https://april.gitbook.io/learning-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://april.gitbook.io/learning-js/chapter-13./13.6/untitled-3.md).

# 13.6.1 배열 안의 함수

예

* 자주 하는 일을 한 셋으로 묶는 파이프라인
* 장점 : 배열을 사용하면 작업 단계를 언제든 쉽게 바꿀 수 있음 (제거, 추가 자유로움)

<예제>

```javascript
const sin = Math.sin;
const cos = Math.cos;
const theta = Math.PI/4;
const zoom = 2;
const offset = [1, -3];

const pipeline = [
    function rotate(p) {
        return {
            x: p.x * cos(theta) - p.y * sin(theta),
            y: p.x * sin(theta) + p.y * cos(theta),
        };
    },
    function scale(p) {
        return { x: p.x * zoom, y: p.y * zoom };
    },
    function translate(p) {
        return { x: p.x + offset[0], y: p.y + offset[1] };
    },
]

const p = { x: 1, y: 1 };
let p2 = p;
for (let i=0; i<pipeline.length; i++) {
    p2 = pipeline[i](p2);
}
```
