# Fun One Liners

**URL:** <https://discourse.julialang.org/t/fun-one-liners/28352>\
**Category:** General Usage\
**Created:** [September 3, 2019, 11:13pm UTC](https://discourse.julialang.org/t/fun-one-liners/28352 "2019-09-03T23:13:18Z")\
**Posts on this page:** 1\
**Showing post:** 64

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [September 16, 2019, 11:17am UTC](https://discourse.julialang.org/t/fun-one-liners/28352/64 "2019-09-16T11:17:21Z")

</div>

You can also use my pkg [Reduce.jl](https://github.com/chakravala/Reduce.jl) for that if you want symbolic optimized common sub-expressions

```Julia
julia> using Reduce; load_package(:scope)

julia> Algebra.optimize(:(z = a^2*b^2+10*a^2*m^6+a^2*m^2+2*a*b*m^4+2*b^2*m^6+b^2*m^2))
quote
    g40 = b * a
    g44 = m * m
    g41 = g44 * b * b
    g42 = g44 * a * a
    g43 = g44 * g44
    z = g41 + g42 + g40 * (2g43 + g40) + g43 * (2g41 + 10g42)
end

```

or if you really want `@pure` you can just locally define a new method for that like I described here

> [@Marking more standard library methods as pure to enable LLVM optimizations?](https://discourse.julialang.org/t/marking-more-standard-library-methods-as-pure-to-enable-llvm-optimizations/28732/8):
>
> ```julia
> module Grassmann
> @pure binomial(n::Int,k::Int) = Base.binomial(n,k)
> end
> 
> ```
> 
> This replaces the `Base.binomial` method with a local method that is pure.

---

_[View the full topic](https://discourse.julialang.org/t/fun-one-liners/28352)._
