> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/f/function_composition.md).

# Function composition

```ruby
func compose(f, g) {
    func(x) { f(g(x)) }
}

var fg = compose(func(x){ sin(x) }, func(x){ cos(x) })
say fg(0.5)      # => 0.76919635484100842185251475805107
```
