clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
2021-05-25T04:29:00.371400Z

is there any interest in the community to port clojure to webassembly? I know clojure is deeply tied to java ecosystem but being able to write clojure could that compiles to wasm can drive a lot growth and opportunities for both clojure and wasm for now, rust is the go to wasm supported language and that will probably remain forever c# is coming up as the 2nd good language with blazor - the huge push from Microsoft golang will probably end up next; if Clojure can try, it could take that space! people can mention clojurescript but that will miss the whole point!!

2021-05-25T08:38:25.375100Z

If you are seeing 'targeting wasm' as a sacrifice and most of what wasm is about crypto and the security problems that are associated with it, I have to take that, this topic has don't have much relevance here

seancorfield 2021-05-25T16:15:31.384600Z

I thought it was mostly an interesting note about the tech -- I haven't really looked at WASM so @thegobinathโ€™s made me curious and the links above were just the first few things that I turned up, mostly relating to suitability for Clojure. I was genuinely surprised to see that statement on the wiki! ๐Ÿ˜

markaddleman 2021-05-25T04:30:38.371700Z

Does webassembly support garbage collection? I think there are proposals for it but I'm not sure if it's implemented

2021-05-25T04:37:05.371900Z

yeah.. not sure but the area seems active https://github.com/WebAssembly/gc

seancorfield 2021-05-25T05:36:52.373Z

Perhaps of interest https://clojureverse.org/t/any-news-for-webassembly-for-clojure/5274

seancorfield 2021-05-25T05:38:18.373600Z

(the former initially asks about cljs/wasm interop but some of the responses speak to the more general issue of transpilation to wasm)

seancorfield 2021-05-25T05:39:43.373800Z

The main benefits to Clojure/Script (and ClojureCLR) is that they bring with them access to vast, established ecosystems of libraries โ€” Iโ€™m not sure how much of that youโ€™d end up sacrificing to target WASM?

seancorfield 2021-05-25T05:47:17.374Z

Seems like (the lack of) multithreading and GC in WASM would be big obstacles to porting Clojure to it. Also โ€œA June 2019 study from the Technische Universitรคt Braunschweig analyzed the usage of WebAssembly in the Alexa top 1 million websites and found the prevalent use was for malicious crypto mining, and that malware accounted for more than half of the WebAssembly-using websites studied.โ€ ๐Ÿ‘€ โ€” from https://en.wikipedia.org/wiki/WebAssembly#Security_considerations

Aron 2021-05-25T06:33:21.374400Z

Any good tech is always used first by criminals, this is just expected at this point. Especially if it's low cost, low risk, high potential value. If anything, that quote from the wiki is a statement about how bad the browser is that it allows installation of such software without any real help to the average person using a browser to analyse what is installed and deal with it. Of course, such tools would first have to be developed not for the browser but for the OS, and there are lots on the market, but I am not sure I can trust them to such high degree as it would be necessary here.

fmnoise 2021-05-25T12:38:38.380600Z

Hi everyone, maybe stupid question, but is there any way to force certain namespace to reload each time when using clojure.tools.namespace.repl/refresh? My case is: I have a edn file and I'd like that any changes in this file to force reload in namespace which reads this file.

borkdude 2021-05-25T12:43:45.381500Z

@fmnoise I am not using tools.namespace refresh stuff, but you can force a reload using the :reload option in require

2021-05-25T12:48:22.381600Z

with pure clojure.tools.namespace you can use refresh-all. But this function will unload and load back everything tracked so far.

2021-05-25T12:50:16.381800Z

You can try to use some library to manage dependencies (like integrant) to achieve what you want. But this will affect for sure your project structure

fmnoise 2021-05-25T12:51:58.382100Z

thanks!

fmnoise 2021-05-25T12:52:03.382300Z

thanks!

Joel 2021-05-25T14:08:13.383500Z

If i have a string such as "alias/keyword" how can i create a keyword with the namespace of the alias?

alexmiller 2021-05-25T14:09:36.384100Z

you can use the ns-whatever functions to resolve aliases

alexmiller 2021-05-25T14:10:21.384400Z

look it up in the map returned from ns-aliases etc

๐Ÿ‘ 1
zendevil 2021-05-25T18:52:13.386300Z

Hi Iโ€™m trying to create a function that does the following: input: [[1] [1 2]], output: [[1 1] [1 2]] input: [[1 2] [2] [1 2]], output: [[1 2 1] [2 2 1] [2 2 2]] input: [[1 2] [1] [1 2]], output: [[1 1 1] [1 1 2] [2 1 1] [2 1 2]] This is what I have so far:

(defn match-meta-pattern
  [metapattern]
  (loop [result [] metapattern metapattern]
    (if (seq metapattern)
      (recur
       ;;;;;;;;;;;;
       (do (prn "meta" (first metapattern))
           (prn "->" result)
             (if-not (seq result)
               [[(nth (first metapattern) 0)]]
               (map (fn [next-pattern] (map (fn [running-pattern]
                              (conj running-pattern next-pattern)) result))
                (first metapattern))))
       ;;;;;;;;;;;;
       (rest metapattern))
      result)))

dpsutton 2021-05-25T18:53:32.386500Z

can you explain the logic?

zendevil 2021-05-25T18:54:02.387300Z

Each subvector represents the various values of the branch

2021-05-25T18:55:13.387800Z

you list a single input for each example, but your function takes 2 arguments

dpsutton 2021-05-25T18:58:30.389200Z

i did not understand the logic explanation ๐Ÿ™‚

2021-05-25T18:59:02.390600Z

yeah, that too, and I don't see a pattern between input and output at all, so hard to say

emccue 2021-05-25T18:59:28.391500Z

i see the pattern

emccue 2021-05-25T18:59:54.392100Z

[[a b c] [d e]] -> [[a d] [a e] [b d] [b e] [c d] [c e]]

emccue 2021-05-25T19:00:15.392400Z

terminology is wierd though

emccue 2021-05-25T19:00:21.392700Z

this is a combinatorics thing

dpsutton 2021-05-25T19:00:27.393100Z

it's just a cross product?

2021-05-25T19:00:43.393400Z

none of the inputs have a 3 element vector as the first element

dpsutton 2021-05-25T19:01:24.393800Z

oh yeah, it's just a cross product

zendevil 2021-05-25T19:02:45.394400Z

@dpsutton itโ€™s not a cross product because a cross b is defined only when length a = length b

2021-05-25T19:03:32.395Z

cross product with padding

dpsutton 2021-05-25T19:04:05.395500Z

that's not true

dpsutton 2021-05-25T19:04:56.395700Z

๐ดร—๐ต={(๐‘ฅ,๐‘ฆ)|๐‘ฅโˆˆ๐ด,๐‘ฆโˆˆ๐ต}

zendevil 2021-05-25T19:06:46.396900Z

@dpsutton thatโ€™s the operation, but itโ€™s not called cross product

2021-05-25T19:06:46.397Z

a cross join

dpsutton 2021-05-25T19:09:49.397500Z

cartesian product is the technical term i guess. maybe i misremembered but i thought there were largely interchangeable

2021-05-25T19:11:03.398700Z

vectors and sets

dpsutton 2021-05-25T19:11:27.399200Z

i went back to halmos naive set theory to check. been a while since my set theory days. i was wrong and apologies

dpsutton 2021-05-25T19:20:54.399300Z

(defn cartesian [set & sets]
  (if (seq sets)
    (for [x    set
          tail (apply cartesian sets)]
      (conj tail x))
    (for [x set]
      (list x))))

(cartesian [1] [1 2])
(cartesian [1 2] [2] [1 2])
(cartesian [1 2] [1] [1 2])

๐Ÿš€ 1
max minoS 2021-05-25T23:09:05.401700Z

I'm trying to set my m2 repo location using profiles.clj, what is the difference between the :local-repo and the :repositories "local" here? https://wiki.archlinux.org/title/Clojure#m2_repo_location