This surprised me....
user=> (#())
()
user=> ((fn []))
nil
Is it important/intentional that an anonymous function created with the literal #(…) returns an empty list?
I doubt it is intentional for any deep reason, but it is a consequence of the implementation
(macroexpand '#()) => (fn* [] ())
A function created with #()
always expands to a fn form that has a body wrapped in parens
you don't need the macroexpand in this case. just '#()
will expand it
i suspect you are sending in a function maybe in a test? if so, the idiom (constantly nil)
or whatever appropriate value is always the best way to accomplish this (in my opinion)
Can anything be done about some->
boxing math?
user=> (some-> 1.12 (int) (pos?))
Boxed math warning, /tmp/form-init1986363389393762289.clj:3:35 - call: public static boolean clojure.lang.Numbers.isPos(java.lang.Object).
true
user=> (-> 1.12 (int) (pos?))
true
I think only rewriting it with when
or if
with a proper tag can get rid of the boxing.
Hi, I just created a new clojurescript project via lein new figwheel hello_world
. Then in the new folder, lein figwheel
starts something, but I can never get the repl. If I connect to 0.0.0.0:3449
with my browser, I get the text Figwheel template. Checkout your developer console.
and in my console, the error
GET <http://0.0.0.0:3449/js/compiled/hello_world.js>
Loading failed for the <script> with source "<http://0.0.0.0:3449/js/compiled/hello_world.js>".
and indeed in the resources/public/js/compiled/
folder of my project there's no hello_world.js
. On the other hand, I can use figwheel
on the flappy-birds
demo. Does anyone have any idea on what's going on?I think I got it (I was skipping npm install
). And also, there's a clojurescript channel! Sorry 🙈
is there any way to +1 issues https://clojure.atlassian.net/browse/CLJ-2365
guess i'd need to log in for that then
You can also vote on ask.clojure
done that!
Is ‘cucumber’ still relevant in Clojure land? Most of the libraries I’ve found seem stale.
I'd expect the introduction of cucumber to be an ask from the product team, the clojure libs mean it's possible (and I think this has mainly happened where an organization migrated from mostly ruby dev to making new services in clojure)
heh it was like that in my current company, ruby and clojure
but as far as I know (i wasn’t there when this decision was made) it was about QA and consistency. So everyone use cucumber to make things the same for QA.
At least this was an idea 😉
yeah, my recent jobs didn't have qa (internal only tools...) so that stuff folded into product
I’ve had good experiences using Specflow for C# but have never tried in Clojure
never heard of it, what does it do?
That’s the important bit, thanks. If you have a specific use case you’re running into, a comment there describing it would be very useful
The BDD library, right? I would be interested to know how many Clojure users use this as well.
It’s a Behavior Driven Development tool.
Uses Gherkin syntax to define behavior and then test for impl.
I did just find this:
I use cucumber everyday in my work. It works but It is bad idea to use it in project. Just don’t use it :)
I use it because of legacy business decision, so I have to.
@kwladyka what problems have you had?
last I ran into it was trying to use .listFiles
with a FileFilter
In short words it makes code unnecessary complex and tests take longer.
You can write similar syntax using pure Clojure.
It is hard to describe that ad hoc, but keep your projects simple and don’t look fancy stuff :)
Hi, anyone know a way to read an EDN file that was mistakenly spit from a clojure seq via print
vs pr
or pr-str
? Fortunately the structure is simple. it’s just a big vector of maps that only have a few keys. Just getting it in with all the map values as strings would work fine, as I could then do the transforms I need to the correct data types afterwards
Yes that makes sense. Thank you!
@eloipoch small example?
sure here’s whats in my “edn” lol
{:KEY_VALS {:NGA_ID 1036089},
:TABLE_OWNER EGMS,
:START_SCN 9525183027094M,
:XID 3A0013005E210100,
:LOGON_USER XXX,
:ROW_ID AABcYQAASAABtcmAAK,
:COMMIT_SCN 9525183027136M,
:TABLE_NAME NGA_BASE,
:OPERATION UPDATE,
:UNDO_CHANGE# 2M}
I think it’s making a best effort based on the first char or something. it doesn’t complain until it hits the :XID
value about the value being a number‘not’ being a number
In looking at the docs, wasn’t sure about how to handle that situation, as most what’s there seems to understandably be focused on handlers for tagged literals
so you could start by placing a double quote before each comma, this seems a safe bet from your example
and then work your way back to the first space and also place a double quote there?
hmm, not exactly, but maybe something like this
I am guessing you might have thousands of those, though? If so, one might consider writing some kind of one-off text processing hack-ish program that uses regex to process each line and look for things that seem like they ought to have double quotes around them, and add them.
After that, then use clojure.edn/read on the resulting text file.
ah yeah, I can do that for sure. Just fixup the string first. I didn’t even think of that, was wondering if I could be done with some sort of otps/handlers to read-string. And yeah, only about 300,000 lool
I do not know of any variations or options on clojure.core/read, clojure.edn/read, or similar Clojure data readers that would accept that input.
@eloipoch what you can also do is use edamame, which gives fairly accurate locations in its exceptions:
user=> (require '[edamame.core :as e])
nil
user=> (def ex (slurp "/tmp/example.edn"))
#'user/ex
user=> (e/parse-string ex)
Execution error (ExceptionInfo) at clojure.tools.reader.impl.errors/throw-ex (errors.clj:34).
[line 4, col 23] Invalid number: 3A0013005E210100.
user=> (ex-data *e)
{:type :reader-exception, :ex-kind :reader-error, :file nil, :line 4, :col 23}
and then fix it accordingly, in a loopIf there are 300,000, though, the one-off regex-based text processing program will probably be a lot faster.
but to you guys point, just fixing it prior is workable. fortunately the data, strucutre-wise are homogenous, so a regex or pretty simple algo, should allow me to stick the quotes in
especially if you can use the keyword names to avoid replacing things that shouldn't be.
hmm, you can use edamame in a loop and just do search and replace on the invalid number. the rest will be parsed as symbols
heck, that will even work with clojure.edn
yeap, i’m actually messing with it now as we speak with intellij’s regex find/replace. This came up at 2AM, so my mental backtracking algo, for my solution search wasn’t exactly working well lol
yah that works too
thanks a mil guys., Other set of eyes, the most important tool in comp sci lol
I’d probably do a keyboard macro in emacs or vim and be done pretty quick
No problem. Also, you've probably already done it, but probably a good time to go back and change that print
to pr
If you can add it to the ask question, that’s where we will look for that info
Hello everyone 🙂 I am a fellow Clojure dev thinking about a potential future Clojure project in the message queues space. I’d like to know more about the interests of Clojurians in this space - with the aim of building something to eventually meet those needs. I made a short survey if you have a few minutes (it’s really short) https://account606590.typeform.com/to/sirkUS13 EDIT: looking at the first results, it takes about 1:20min to complete on average
Am curious to hear more about what you have in mind, and what pain points you’ve previously experienced. Survey feedback: The answer options for Q3 did not match the question 🙂. For Q4, I would have preferred to choose all that are acceptable to me, instead of just one.
Hi 😊 I'll definitely write more about the pain points. I don't want to influence the survey right now. How does Q3 not match ? It mean "or" as is: " (or (choose-own-tools you) (choose-team-tools you ) ). " Noted for Q4, I agree it would have been better. Feel free to comment extra choices in the free form.