# Syntax for active patterns

**URL:** <https://discourse.julialang.org/t/syntax-for-active-patterns/71407>\
**Category:** General Usage\
**Tags:** mlstylejl\
**Created:** [November 12, 2021, 10:27pm UTC](https://discourse.julialang.org/t/syntax-for-active-patterns/71407 "2021-11-12T22:27:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [November 12, 2021, 10:27pm UTC](https://discourse.julialang.org/t/syntax-for-active-patterns/71407/1 "2021-11-12T22:27:43Z")

</div>

```julia
@active Split(xs) begin
    n = length(xs)
    n%2==0 ?
        (xs[begin:Int(n/2)], xs[Int(n/2+1):end]) :
        (xs[begin:Int(floor(n/2))], xs[Int(ceil(n/2))], xs[Int(floor(n/2+1)):end])
end

@match [-2,-1,0,1,2] begin
    Split(left, right) => [left, empty(left), right]
    Split(left, mid, right) => [left, [mid], right]
end

```

Is this good style?

Is it possible to use `[left..., mid, right...]` instead of `Split(left, mid, right)`?

@thautwarm

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [November 12, 2021, 10:28pm UTC](https://discourse.julialang.org/t/syntax-for-active-patterns/71407/2 "2021-11-12T22:28:49Z")

</div>

Ah, a private discussion 😉

---

<div class="post-metadata">

**Author:** ![thautwarm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thautwarm/32/37760_2.png) [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Post date:** [November 12, 2021, 10:37pm UTC](https://discourse.julialang.org/t/syntax-for-active-patterns/71407/3 "2021-11-12T22:37:42Z")

</div>

In general, a pattern like `[left..., mid, right...]` does not have a unique match, and MLStyle does not support it.

You `Split` pattern looks good to me, and I can see it is useful for certain tasks.
