Fork me on GitHub
#clojure
<
2019-10-29
>
ag00:10:03

ah, right…

jumpnbrownweasel00:10:09

Couldn't resist trying to create a more functional version of ->> with no syntactic tricks.

(defn fn->> [init & fs]
    (reduce (fn [x f] (f x)) init fs))

  (fn->> 121
         inc inc
         (comp clojure.string/join reverse str))

=> "321"

hiredman00:10:07

#((apply comp (rest %&)) (first %&))

noisesmith00:10:32

I think you need a reverse in there as well

jumpnbrownweasel01:10:12

Yes, this works (anon fn syntax removed because it confuses me)

(defn fn->> [init & fs]
    ((apply comp (reverse fs)) init))

🙂 4
maxp04:10:37

This command clj -Spom adds extra blank lines to pom.xml file. Also it adds "<sourceDirectory>src</sourceDirectory>" every time at the end when <build> tag is missing. How can I submit this bug?

kwladyka19:11:02

I have the same issue

seancorfield04:10:20

@maxp That sounds familiar. What version of Java are you using?

seancorfield04:10:30

According to that ticket: Fixed in clj 1.10.1.478 -- are you using that latest version of the CLI @maxp?

seancorfield04:10:49

I don't think I've heard about that other issue but you can ask a question about it in this category https://ask.clojure.org/index.php/activity/contrib-libs/tools-deps-alpha and the Clojure team will see it and either raise a new JIRA issue in response or answer with any known issues around it.

Alex Miller (Clojure team)05:10:36

the extra blank lines should be fixed in the latest version

Alex Miller (Clojure team)05:10:36

the sourceDirectory thing is intentional (but needs some attention still probably)

Alex Miller (Clojure team)05:10:20

it has been brought up before but I don't know that it made it into a ticket

maxp06:10:51

@seancorfield I use openjdk version "11.0.4" 2019-07-16, Clojure 1.10.1 release

maxp06:10:23

sourceDirectory added at the end when there is no <build> tag. When <build> exists "sourceDirectory" appended once to it.

Meepu07:10:06

Could someone help me understand jdk? I had an Ubuntu Trusty running oraclejdk8. Then someone upgraded to Ubuntu Xenial, which no longer supports oraclejdk8. We switched back to Trusty for now, but it seems like we need to upgrade oraclejdk (or switch to openjdk) at some point. I'm looking for materials to understand how JDK versioning / Java versioning is related to Clojure and Lein versioning. That would tell me if I need to upgrade Clojure or Lein as well, which would give me a better estimate of how much of a hassle the upgrade would be.

maxp07:10:23

@meepu probably you can use openjdk-8 instead of oracle-jdk-8. I used that for a long time after oracle-6.

David Pham07:10:26

I think you can use openjdk as a drop in replacement to Oracle

Meepu07:10:47

Yes, openjdk8 is one of our options. I'd like to understand if switching to it would be a long-term or short-term solutions - is 8 going to be outdated soon?

didibus07:10:28

Clojure just recently stopped supporting JDK 1.6 and 1.7. So currently it requires JDK 8 or above

didibus07:10:29

I'd say it'll probably support JDK 8 for a few more years

didibus07:10:08

I can't predict the future, but I don't see why not. It supported JDK 1.6 for a really long time.

didibus07:10:06

Other then using JDK 8+, you shouldn't have to touch Clojure or Lein

didibus07:10:35

So a move from Oracle JDK 8+ to OpenJDK 8+ shouldn't break anything

Meepu13:10:38

Thanks didibus, this was great info!

vlaaad08:10:52

also you absolutely should not use oracle jdk for legal reasons

vlaaad08:10:21

although don't quote me, I'm not a lawyer 😄

weavejester12:10:26

Is there a problem with the latest Lein and the default #inst tag?

ghadi12:10:52

lein does bizarre things with bootclasspath on java 8 which causes issues with #inst @weavejester

abdullahibra13:10:39

Hello everyone

abdullahibra13:10:26

is parsing clojure functions via regexp possible ?

Alex Miller (Clojure team)13:10:56

I don't know, but if so, it would probably be harder than it's worth

Alex Miller (Clojure team)13:10:11

why not use a clojure parser/reader?

abdullahibra14:10:47

yeah maybe, but i was curious about regexp

Alex Young13:10:07

Is the answer not "No, because you can't count balanced parens in a regexp"?

👆 4
Lennart Buit16:10:03

a regex as in its formal definition, or the perl-derived regex eDSL that we have been using for ages now 😛

Alex Young16:10:26

That's cheating 😛

Lennart Buit16:10:36

I can’t actually find a conclusive source on what the expressive power of perl regex’es is… so sad

lvh19:10:33

oh man I can help you with that

lvh19:10:43

well, it depends where you draw the line

lvh19:10:53

but the answer is "definitely turing complete" if it's "everything perl5 will do"

lvh19:10:32

if you exclude ?{} and ??{} then the answer is "probably not": some context-free, some context-sensitive patterns definitely yes

Lennart Buit19:10:30

yeah inlining perl code is usually not something that transfers to ‘non-perl languages’

Lennart Buit19:10:13

while other constructs invented in perls regex can be used to match (some) non-regular languages are definitely being c/p’ed to other languages that embed the same ‘DSL’

dpsutton13:10:35

i think bruce uses a regex parser for rebel readline. so the answer is yes-ish?

Alex Young14:10:26

If what you're thinking of is https://github.com/bhauman/rebel-readline/blob/1fc954215bc287ad590dac8e52c782d6077fee55/rebel-readline/src/rebel_readline/clojure/tokenizer.clj then it looks to me like a parser which internally uses regexes to match tokens, but isn't a regex itself

Alex Young14:10:47

depends exactly what the question needs 🙂

Alex Miller (Clojure team)14:10:03

which is exactly what the clojure reader does

dpsutton14:10:32

regex for tokens is the standard way to parse things i suppose. I just remember seeing a bug that someone was hitting on a larger form throwing a regex error. I think @hiredman man diagnosed it was probably the repl and turned out to be a limitation in the size of forms that rebel could read

denik16:10:17

does anyone know how one can get relative times in juxt/tick? I'm looking for something as simple as next monday which should return the timestamp at midnight of the nearest monday closest to and excluding today (if today was monday)

denik16:10:33

well, here's a solution (some #(when (= (t/day-of-week %) t/MONDAY) %) (iterate t/inc (t/tomorrow)))

👍 4
Lennart Buit16:10:41

Hey, I was looking for libraries that derive customer facing error messages from clojure specs explain-data format. I found https://github.com/alexanderkiel/phrase but I was wondering whether there were other alternatives

Lennart Buit16:10:32

I am specifically looking at error messages for users, so expound is too technical already

bfabry20:10:30

user=> (frequencies [##NaN ##NaN])
{##NaN 1, ##NaN 1}

thumbnail20:10:19

This is to be expected. NaN is by design not equal to itself. As it describes something not being a number, not anything specific.

bfabry20:10:03

maybe not fixable without breaking more serious mathsy things though

hiredman20:10:51

using NaN as a key in a map is asking for trouble, because by definition NaN is not equal to itself

hiredman20:10:35

using floats in general is fraught too

hiredman20:10:43

user=> (assoc {} ##NaN :a ##NaN :b)
{##NaN :a, ##NaN :b}
user=> (get (assoc {} ##NaN :a ##NaN :b) ##NaN)
nil
user=>

bfabry20:10:37

it’s kinda interesting. in a maths context I totally accept NaN is not equal to itself. but from a programming point of view it also makes sense that it should be. unfortunately we only have one type of equality

bfabry20:10:19

another reason to be wary of primitives I guess

andy.fingerhut20:10:11

This is an IEEE 754 standard-specified thing. https://github.com/jafingerhut/batman

andy.fingerhut20:10:01

There is also a section specifically on NaN in this article: https://clojure.org/guides/equality

andy.fingerhut20:10:36

We only have one clojure.core/=, but we also have clojure.core/==. Java has == and .equals. I don't have a reference or certainty on this, but have heard that Rust lets you have more fine control of double types with NaN vs. double types without NaN.

lilactown22:10:50

in ClojureScript / JS we have Number.isNaN

lilactown22:10:15

(not to be confused with isNaN, unqualified, which will have surprising behavior)