Fork me on GitHub
#beginners
<
2023-06-24
>
Harry10:06:29

Is there a function like map that doesn't expect a return value. Something that lets me call a function for every item in a list or do I just need to use loop?

daveliepmann10:06:02

There are several. Maybe you want run!? https://clojuredocs.org/clojure.core/run!

Harry10:06:45

Thanks run! did what I needed.

👍 4
mloughlin11:06:30

(source run!) is vaguely interesting from a learning perspective:

(defn run!
  "Runs the supplied procedure (via reduce), for purposes of side
  effects, on successive items in the collection. Returns nil"
  {:added "1.7"}
  [proc coll]
  (reduce #(proc %2) nil coll)
  nil)

💡 4
👀 2
mloughlin11:06:55

it's "just" reduce 🙂

😮 2
leifericf14:06:48

Another way is to use map with doall.

Bob B14:06:51

keep in mind that "map with doall" returns (and thus retains) a seq, while run! does not

didibus16:06:48

There's dorun if you want to force realize only for side effects

Chicão18:06:11

hello there, i'm trying to import this kotlin lib https://github.com/supabase-community/supabase-kt on deps.edn io.github.jan-tennert.supabase/gotrue-kt {:mvn/version "1.0.3"} the lib is downloaded to m2/repository I can see it on clj -Spath but i can import, does anyone knows how i can import this lib?

seancorfield18:06:31

How are you trying to import it in your code?

Chicão18:06:11

i've try

(ns mat.api.auth
  (:import (io.github.jan.supabase createSupabaseClient)))

seancorfield18:06:16

Is createSupabaseClient a class? I wouldn't expect so with a name like that...

Chicão18:06:26

it returns a SupabaseClient

seancorfield18:06:17

So that is the class you want to import then I expect

Chicão18:06:59

i was trying to do this but in clojure

import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.createSupabaseClient
import io.github.jan.supabase.gotrue.GoTrue
import io.github.jan.supabase.gotrue.gotrue


    fun provideSupabaseClient(): SupabaseClient {
        return createSupabaseClient(
            supabaseUrl = BuildConfig.SUPABASE_URL,
            supabaseKey = BuildConfig.API_KEY
        ) {
            install(GoTrue)
        }
    }

seancorfield18:06:39

Ah, so maybe it's a companion object?

🤯 2
seancorfield18:06:03

No idea how that translates to Java naming under the hood, so I've no idea how to import it into Java (or Clojure) code...

seancorfield18:06:15

Kotlin can be really tricky to call from other languages because you have to know how the various Kotlin-specific constructs compile down to JVM bytecode, at least in terms of naming.

Chicão18:06:34

i don't konw if this is the problem but someone send me this https://github.com/adambard/lein-kotlinc to compile

seancorfield18:06:30

That's not going to help you here.

🆗 2
Chicão19:06:58

@UMMMKKADU send me this https://central.sonatype.com/artifact/io.github.jan-tennert.supabase/gotrue-kt-jvm/1.0.4/overview and i could import io.github.jan-tennert.supabase/gotrue-kt-jvm {:mvn/version "1.0.3"}

Chicão19:06:11

(ns back.api.auth
  (:import (io.github.jan.supabase SupabaseClient)))

seancorfield19:06:36

That doesn't work tho', right?

seancorfield19:06:54

Ah, with -jvm...

seancorfield19:06:36

OK, yes, there you go... Does that help you with creating a client from Clojure now?

Chicão19:06:32

it help import all classes i'm exploring the namespaces i think it will help there is this import import io.github.jan.supabase.plugins.standaloneSupabaseModule that i can just use like this standaloneSupabaseModule(GoTrue, url = supabaseUrl, apiKey = supabaseKey)

dharrigan19:06:09

Perhaps not that much of a help, but I have a small (very small) example of Clojure/Kotlin interop here: https://github.com/dharrigan/cotlin

❤️ 4
Chicão19:06:15

it works

(:import (io.github.jan.supabase SupabaseClientBuilder )))

(def c (SupabaseClientBuilder. "https://<your-project>." "public-anon-key"))

🚀 2
Chicão19:06:32

the problem was it change some namespaces a bit

Chicão19:06:10

@U11EL3P9U thanks it will help i was think in create some wrapper or re implement in clojure this client for supabase since i will have to use it a lot

keychera19:06:38

@UL618PRQ9 I think what you are trying to import is a top level function, and I believe it become a static method in a class with the filename + Kt at the end, maybe this import will work

(ns mat.api.auth
  (:import (io.github.jan.supabase SupabaseClientBuilderKt)))

(SupabaseClientBuilderKt/createSupabaseClient #_...)

👍 2