Fork me on GitHub
#beginners
<
2021-12-25
>
Willem Hoogland08:12:15

I just started with clojurescript and created a reframeproject. Now I am getting this error message when starting a REP. The required namespace "react-dom" is not available, it was required by "reagent/dom.cljs".

v3ga09:12:10

are you using shadow-cljs?

FiVo12:12:43

This sounds like you need to installl your react deps either via npm or yarn.

☝️ 2
ho0man14:12:31

Hi everyone, Suppose I write a custom class loader ... how can I make my JVM to add this class loader to its hierarchy of classloaders ? (Also are there any special concerns I need to address while using Clojure compared to Java when setting custom class loaders ?) Thanks a lot ----- This is sort of a follow up question to this https://clojurians.slack.com/archives/C053AK3F9/p1640024375266700.

andy.fingerhut19:12:56

There is no problem asking your question here, but I will point out that as soon as you are asking questions about Java classloaders, you are probably past beginner territory 🙂

andy.fingerhut19:12:23

The channels #clojure and/or #java on this Slack community might be better target audiences for such a question.

noisesmith18:12:58

or even #clojure-dev - as one of the key parts of how clojure works is maintaining an updated classloader that keeps up with all your new definitions as they are compiled

popeye18:12:09

How can we convert below java code in clojure?

int m = (1 << n);
        for (i = 0 ; i < m ; ++i) {
            int bits[] = new int[n];
            for (j = 0; j < n ; ++j) bits[j] = 0;
            j = 0;
            int x = i;
            while (x != 0) {
                bits[j] = x & 1;
                ++j;
                x = (x >> 1);
            }
            int sum = 0;
            for (j = 0 ; j < n ; ++j) {
                if (bits[j] == 1) {
                    sum -= arr[j];
                }
                else {
                    sum += arr[j];
                }
            }
            if (sum % k == 0) {
                good = true;
                break;
            }
        }

popeye18:12:53

This has array used, how can I better this in clojure way ?

hiredman19:12:57

Looks like a straight port of some C code, it zeros a newly allocated array, which java already does

hiredman19:12:54

Usually it is better to take a step back from the code, and ask what the code does, and do that vs mechanical porting

roelof19:12:53

a little late but for everyone a merry X-mas

🎄 2