# A library for rearranging filter map join, etc. Clojure style

**URL:** <https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841>\
**Category:** Questions & Answers\
**Created:** [March 27, 2024, 6:52pm UTC](https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841 "2024-03-27T18:52:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyrn](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/tyrn/32/1731_2.png) [@Tyrn](https://racket.discourse.group/u/Tyrn)\
**Post date:** [March 27, 2024, 6:52pm UTC](https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841/1 "2024-03-27T18:52:53Z")

</div>

Hi,

I've seen a Racket library which allows for structuring filtering and mapping Clojure style, like this:

```scheme
  (->> (-> (cs/replace authors #"\"(?:\\.|[^\"\\])*\"" " ") ;; Remove quoted substrings.
           (cs/replace #"\"" " ") ;; Remove odd quotes.
           (cs/split #","))
       (filter (fn [author]
                 (-> (cs/replace author #"[-.]+" "")
                     (cs/blank?)
                     (not))))
       (map (fn [author] (as-> (cs/split author #"-") b
...

```

So far as I can remember, even `->>` was there. I can't find anything, though.

---

<div class="post-metadata">

**Author:** ![Zeb](https://avatars.discourse-cdn.com/v4/letter/z/57b2e6/32.png) [@Zeb](https://racket.discourse.group/u/Zeb)\
**Post date:** [March 27, 2024, 9:12pm UTC](https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841/2 "2024-03-27T21:12:59Z")

</div>

You're probably thinking of threading.

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [March 27, 2024, 11:11pm UTC](https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841/3 "2024-03-27T23:11:31Z")

</div>

In addition to threading, there’s also Qi and at least one “Racket like it’s Clojure” package. I recommend searching the docs for -\> and ~\> and seeing possibilities come up.

---

<div class="post-metadata">

**Author:** ![Tyrn](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/tyrn/32/1731_2.png) [@Tyrn](https://racket.discourse.group/u/Tyrn)\
**Post date:** [March 28, 2024, 2:59am UTC](https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841/4 "2024-03-28T02:59:10Z")

</div>

Yes, it's about threading (?), and the keyword that stuck in my memory is ~\>\>, not -\>\>, from Qi 😊 .

Why are there so many almost identical libraries?

---

<div class="post-metadata">

**Author:** ![Zeb](https://avatars.discourse-cdn.com/v4/letter/z/57b2e6/32.png) [@Zeb](https://racket.discourse.group/u/Zeb)\
**Post date:** [March 28, 2024, 5:00am UTC](https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841/5 "2024-03-28T05:00:47Z")

</div>

Just in case I wasn't clear, I mean there's a racket library named threading. I can't tell if you're saying it's about threading (the concept) or the library by that name.

---

<div class="post-metadata">

**Author:** ![Tyrn](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/tyrn/32/1731_2.png) [@Tyrn](https://racket.discourse.group/u/Tyrn)\
**Post date:** [March 28, 2024, 9:18am UTC](https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841/6 "2024-03-28T09:18:07Z")

</div>

I'm not sure about the terminology. It looks like `threading` and `qi` do much the same thing.

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [March 28, 2024, 1:37pm UTC](https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841/7 "2024-03-28T13:37:58Z")

</div>

Qi builds on threading (at least conceptually) but offers quite a bit more. For example: `(define-flow avg (~> (-< + count) /))` defines a variadic avg that computes the average of it’s numerical inputs.

---

<div class="post-metadata">

**Author:** ![JohnSnow](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@JohnSnow](https://racket.discourse.group/u/JohnSnow)\
**Post date:** [March 29, 2024, 6:19am UTC](https://racket.discourse.group/t/a-library-for-rearranging-filter-map-join-etc-clojure-style/2841/8 "2024-03-29T06:19:34Z")

</div>

The threading library mentioned above has a simplified version called "create threading in 2 easy steps",

[https://lexi-lambda.github.io/racket-macro-exercises/index.html](https://lexi-lambda.github.io/racket-macro-exercises/index.html)
