This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-02
Channels
- # aleph (2)
- # announcements (3)
- # babashka (12)
- # beginners (55)
- # calva (11)
- # clj-http (12)
- # clj-together (2)
- # cljs-dev (41)
- # clojure (51)
- # clojure-denmark (2)
- # clojure-europe (32)
- # clojure-nl (17)
- # clojure-norway (2)
- # clojure-switzerland (1)
- # clojure-uk (3)
- # clojurescript (34)
- # cursive (20)
- # data-science (3)
- # datahike (23)
- # datomic (3)
- # events (1)
- # fulcro (1)
- # honeysql (4)
- # inf-clojure (2)
- # interop (38)
- # java (3)
- # kaocha (8)
- # lsp (51)
- # luminus (2)
- # malli (2)
- # nextjournal (5)
- # off-topic (21)
- # pedestal (2)
- # polylith (12)
- # re-frame (4)
- # reagent (8)
- # reitit (4)
- # releases (1)
- # ring (4)
- # shadow-cljs (179)
- # spacemacs (2)
- # specter (1)
- # xtdb (13)
Is there a way one can check if a list of a map has more than one index? (meaning has more than 0 index) for example ({:game "God of war", :genre "Action/adventure"}, {:game "Elden Ring", :genre "Action-role play"})
. In this case the list of a map has index 0 and 1.
By index you mean an entry?
If so, you can simply (> (count m) 1)
I'm not sure why you are calling them an "index" and giving them numbers like 0 and 1 but note that maps are unordered.
btw count will realise all entries of lazy seq and in some cases might block (eg. (count (range))
)
in those case it is better to use combination of next and seq
(if (seq (next xs)) true false)
there is also bounded-count
function that can help
Ah, sorry, I somehow missed the "list" part and thought it's a map, not a list of maps - sloppy reading.
Anyway, the answer still more or less applies.
@U04V4KLKC’s note about bounded-count
might be useful if your collection is big and you don't want to realize it all.
Thanks @U06BE1L6T and @U04V4KLKC
May I know what is the equivalent of the following in clojure
FileSystem fs = FileSystem.Factory.get();
Am a bit confused cause it is a class in a class https://docs.alluxio.io/os/javadoc/edge/alluxio/client/file/FileSystem.Factory.html#get--
So am wondering am I right to do
(ns alluxio-test.core
(:import [alluxio.client.file FileSystem]))
I'm not sure how to do the Factory
I just know it would be something like (.get ....
Clojure refers to nested classes in the same way the JVM does: they get a dollar sign at the nesting FileSystem$Factory
jshell> java.nio.file.DirectoryStream.Filter.class.getName()
$2 ==> "java.nio.file.DirectoryStream$Filter"
when in doubt, you can use jshell
to get the full class name using java syntaxDoes this mean I need to change to FileSystem$Factory
in my import and my first instinct is
(.get (FileSystem$Factory.))
first confirm that you have FileSystem$Factory
imported by just typing that symbol at the REPL
I think generally I'm not too clear when things are static methods and whatnot. And it gets more confusing when I try to convert things to Clojure :x
Hello everyone, has anyone used a library for translations with po? Read / write po files, scan code to find a tr called.
Maybe something like django-rosetta
its quite complicated but we have separate processes that scan the code for translatable strings. At runtime the po files are turned into maps with the string to translate as the key, and then java.text.MessageFormat
takes over from there
I need to run a few different tasks on separate schedules. Is it reasonable to use Mount to create a state out of each scheduled runner? I figure Mount would give me visibility of running schedules and the ability to start/stop them independently as needed.
I tried to embed an nREPL Server to my app by doing the following in one of my namespaces:
(:require [nrepl.server :refer [start-server]])
(defonce server (start-server :port 7888))
This broke my lein uberjar
; it was getting stuck without any error messages.
I was able to fix this by changing the above line to
(defonce server (delay (start-server :port 7888)))
and deref’ing it from my main
namespace.
Can anyone please help me understand why this was happening?Ah, I didn’t know that, it makes sense now, thank you very much! Do you happen to know if there is a way that I could get any indication for this during compilation?
Wow, turns out I hadn’t understood the implications of what you said completely. I thought that trying to start the nrepl server while lein uberjar
’ing was causing some failure, for which I was expecting some indication of; turns out the nrepl server is starting just fine and waiting for connections, that’s why packaging is not moving forward. Thank you very much, I feel so much better now!
1. What is the "correct" way to network clojure applications? 2. If I'm providing a service is that typically done over HTTP? 3. Is there proprietary clojure protocols that enable intercommunication between clojure applications? 4. What library, standard are otherwise is recommended for HTTP? Sockets? Other?
Well, I don't know what ways clojure is able to either 1. communicate with other clojure applications 2. communicate with other clojurescript applications 3. consume general purpose apis over socket/http/other
like, maybe an overview or list of bonafide libraries
I though I saw a video that mentioned something about a communications protocol "baked into clojure" that allows the passing of fully formed clojure data over the wire?
that'd have been a few years back
otherwise, there are tons of libraries both in clojure and using anything in java or javascript that do all those things, so could be anything
maybe that was a protocol for the clojure db
or maybe that was low-level internal protocol
I can't rightly recall
clojure programs are themselves represented as data which is a neat capability to have for rpc
in my experience (which by no means is complete) clojure programs typically speak http by embedding some http server in them (jetty, http-kit, undertow, aleph, netty's http stuff, etc)
second to http would be some kind of messaging "thing" kind of thing (rabbitmq, activemq-artemis, redis pubsub, etc)
there are other kinds of approaches, like you can use protocol buffers to define servers (I know some companies do this using the json encoding of protolbuffers, which is odd)
for data encoding, json remains king of heterogeneous environments, edn (a subset of clojure syntax) is ok to a point, but transit (basically edn but trying to take advantage of optimized codecs for other formats like json and msgpack) is very popular for communicating between clojure and clojurescript
the sad emoji was I was hoping to find some recommendations, which I was provided after 😛
if you just want some kind of instant cluster thing, you might want to checkout jgroups