# What general-purpose commands do you usually end up adding to your projects?

**URL:** <https://discourse.julialang.org/t/what-general-purpose-commands-do-you-usually-end-up-adding-to-your-projects/4889>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 16, 2017, 9:47pm UTC](https://discourse.julialang.org/t/what-general-purpose-commands-do-you-usually-end-up-adding-to-your-projects/4889 "2017-07-16T21:47:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [July 16, 2017, 9:47pm UTC](https://discourse.julialang.org/t/what-general-purpose-commands-do-you-usually-end-up-adding-to-your-projects/4889/1 "2017-07-16T21:47:08Z")

</div>

Related to this response from Stefan,

- [https://github.com/JuliaLang/julia/issues/14672#issuecomment-171665475](https://github.com/JuliaLang/julia/issues/14672#issuecomment-171665475)

What commands do you usually end up adding to your projects to get around common nuisances?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [July 17, 2017, 5:24am UTC](https://discourse.julialang.org/t/what-general-purpose-commands-do-you-usually-end-up-adding-to-your-projects/4889/2 "2017-07-17T05:24:49Z")

</div>

I use this for unit tests:

```julia
"Lenient comparison operator for `struct`, both mutable and immutable (type with \\eqsim)."
@generated function ≂(x, y)
    if !isempty(fieldnames(x)) && x == y
        mapreduce(n -> :(x.$n == y.$n), (a,b)->:($a && $b), fieldnames(x))
    else
        :(x == y)
    end
end

```

---

<div class="post-metadata">

**Author:** ![Balinus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balinus/32/243_2.png) [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Post date:** [July 17, 2017, 12:28pm UTC](https://discourse.julialang.org/t/what-general-purpose-commands-do-you-usually-end-up-adding-to-your-projects/4889/3 "2017-07-17T12:28:10Z")

</div>

Not sure if there is a built-in command for listing files in a directory but I use this one almost everywhere!

`searchdir(path, key) = filter(x -> contains(x, key), readdir(path))`

---

<div class="post-metadata">

**Author:** ![AlexFreik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexfreik/32/35471_2.png) [@AlexFreik](https://discourse.julialang.org/u/AlexFreik)\
**Post date:** [April 16, 2022, 9:11pm UTC](https://discourse.julialang.org/t/what-general-purpose-commands-do-you-usually-end-up-adding-to-your-projects/4889/4 "2022-04-16T21:11:33Z")

</div>

if anyone wants to make this check recursive (for the case when inner fields can be `struct` as well) – just replace `:(x.$n == y.$n)` with `:(x.$n ≂ y.$n)`.
