This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # beginners (20)
- # boot (4)
- # cider (2)
- # cljs-dev (25)
- # clojure (45)
- # clojure-dev (1)
- # clojure-greece (5)
- # clojure-italy (20)
- # clojure-nl (12)
- # clojure-russia (11)
- # clojure-uk (256)
- # clojurescript (176)
- # data-science (33)
- # datomic (47)
- # docs (1)
- # duct (13)
- # fulcro (54)
- # graphql (24)
- # hoplon (3)
- # jobs (1)
- # leiningen (32)
- # luminus (3)
- # midje (1)
- # mount (2)
- # off-topic (3)
- # onyx (5)
- # overtone (1)
- # parinfer (12)
- # pedestal (4)
- # re-frame (60)
- # reagent (11)
- # reitit (3)
- # ring-swagger (21)
- # rum (1)
- # shadow-cljs (16)
- # spacemacs (23)
- # tools-deps (19)
- # vim (79)
is there an existing clojure/java function for “incrementing” a string ala
> "some_label_1".succ => "some_label_2"
@pithyless If your broader need is to generate unique symbols for use in code,
gensym is a builtin for this purpose, often used to generate unique symbols in macro code. For example
Thanks, I’m aware of
gensym, but here I’m iterating over a domain which established ordering of arbitrary strings via
I solved this via regexp, but I would not be so bold as @U054UD60U to say there are no uses for a sensible autoincrementing string operation (the ruby one does things like map
If you need to generate ids like that, I’d go with a function to parts existing ids, one to increment the parts according to your needs (leading
0s anyone?) and building a string representation for it again.
@pithyless sorry I didn't want to sound to harsh, but such function does not make any sense as a core function to a language, imho.
I figured as much; I just thought maybe one of the string extensions (`expez/superstring`,
funcool/cuerdas, others?) may have covered the use-case. Either way, thanks for the confirmation 🙂
I don't know Ruby, but from quick Googling it seems that it's much more complicated than that. E.g.,
abcd => abce
@pithyless that use case can be handled cleanly by Specter
(def str<->long (parser #(Long/parseLong %) str)) (transform [#"\d+" str<->long] inc "a99bc123") ;; => "a100bc124" (transform [#"\d+\z" str<->long] inc "a99bc123") ;; => "a99bc124"
Decomposing the problem with a composable abstraction lets you handle not just that use case, but related use cases like:
(setval #"\d+" "" "a99bc123") ;; => "abc" (transform [#"\d+" str<->long] #(* 10 %) "a99bc123") ;; => "a990bc1230" (transform (subselect #"\d+") reverse "a99bc123") ;; => "a123bc99"
This may be a silly question, but is there a supported way to typehint arguments of a function in
defprotcol? Basically, is it possible to do something like -
In one namespace:
In another namespace:
(defprotocol MyProtocol (a-function [this ^SomeJavaType argument]))
? Currently I'm having to re-bind
(defrecord MyRecord MyProtocol (a-function [this ^SomeJavaType argument] ...))
argumentin the both of
a-functionw/ the type-hint in order to avoid reflection, which is ugly. Trying to typehint the args results in a compiler exception that the protocol can't be resolved.
Or should something like this be done with
definterface instead? (I haven't had to use
Does anyone know if 1. Anyone is working on porting the CLJ/Clojure cli to windows 2. If I wanted to view the code for the CLJ where would I look ?
@bobjohnson11 Likely someone on the #tools-deps channel knows the latest status of getting those things working on Windows. Last I recall hearing it mentioned, it wasn't implemented yet.
fyi, the scripts are not directly usable out of the repo as there are some bits and pieces that get modified during the build process
Thanks for the tip. I'm interested in how the power shell script will work and how the CLJ and Clojure wrapper scripts work will work.
I have a question about Rich's Ant colony code I've found on Github.
move isn't, but "Must be called in a transaction".
Wow, I guess I've had it opened in my browser for so long that I didn't even realize it's not available anymore. Let me try to find it.
if I recall, the stm's transactions also merge,
(dosync (foo)) and then foo is
(defn foo  (dosync ...)) the transaction merge and execute as a single transaction
random thought from the old memory banks: has anyone built/used something like the CL
*features* variable in clj?
dosync having dynamic extent means that once dosync is on the call stack, everything after that executes inside the transaction (and so can do things that only work inside a transaction) until dosync is popped off the call stack
So is there any reason to use dosync in turn and not using it in move? Since both will be merged?