clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
aratare 2021-02-28T02:56:52.325800Z

@seancorfield splendid! Thanks a lot 🙂

seancorfield 2021-02-28T03:57:00.326700Z

@rextruong Let me know if version 1.0.206 addresses your needs.

aratare 2021-02-28T04:06:19.327300Z

Will do once I'm back at my station 🙂

aratare 2021-02-28T07:42:02.327800Z

@seancorfield Can confirm that it's working great now! Thanks again 🙂

👍 1
borkdude 2021-02-28T09:48:03.328500Z

@seancorfield Thanks a lot for the tools.cli updates :)

👍 1
Hagenek 2021-02-28T10:53:10.328900Z

Any of you have experiences with Gorilla REPL, do you still use it? And in what situations.

emilaasa 2021-02-28T15:46:55.336400Z

I used it a bit for some calculations where I wanted interactive visualizations. I mostly make due without it but when doing more mathy things I'd use it again. Probably with nrepl tho.

jsmesami 2021-02-28T18:56:01.340900Z

Is there a link to download the latest Linux install script for CLI tools? For example in a update-everything script I'm able to Curl https://github.com/clojure-lsp/clojure-lsp/releases/*latest*/download/clojure-lsp-native-linux-amd64.zip but for CLI tools I have to modify the script every time new version is available.

2021-02-28T19:00:38.341Z

If you use Homebrew, you could do brew upgrade clojure/tools/clojure to get the latest released version.

2021-02-28T19:00:50.341200Z

That should work for macOS and LInux

jsmesami 2021-02-28T19:01:42.341400Z

No, not yet, still not convinced to use homebrew on LInux 🙂 Maybe it's time to give it a try.

2021-02-28T19:01:47.341700Z

If you want an unchanging URL for curl, that is up to Clojure maintainers whether they plan to provide such a thing (or perhaps already do). @alexmiller would know.

2021-02-28T19:05:44.342100Z

This URL exists right now, and appears to be an alias to the latest version of the install script, but I don't know if that is promised to continue to exist: https://download.clojure.org/install/linux-install.sh

jsmesami 2021-02-28T19:08:55.342300Z

Nice! Thank you:)

seancorfield 2021-02-28T19:38:50.342500Z

I use brew on Ubuntu - so much nicer than dealing with shell script installation every time.

👀 1
borkdude 2021-02-28T19:45:53.342700Z

@jsmesami You could also scrape the brew recipe and then use that to get the newest linux script ;)

🔥 1
dharrigan 2021-02-28T19:57:13.342900Z

It's important to know which distribution you're using, as each distro (family) has it's own package managers

joelkuiper 2021-02-28T21:18:39.346500Z

Silly question, probably one of those cases where the answer is obvious 😅 Say I have a keyword (def kw :example) and I want a function or macro that takes the keyword as an argument and returns a quoted list with the value of that argument in the second position, something like '[?a :example ?b] what would be the best way to do so?

2021-02-28T21:33:55.348700Z

Here is a way to write a function that returns what you describe:

user=> (defn template1 [kw] ['?a kw '?b])
#'user/template1
user=> (def kw :example)
#'user/kw
user=> (template1 kw)
[?a :example ?b]

2021-02-28T21:34:23.348900Z

That returns the same value you describe that would be read if you typed '[?a :example ?b] at a REPL

joelkuiper 2021-02-28T21:35:12.349100Z

yeah that seems to work, thanks! I was a little bit confused about the '[?a ?b ?c] vs ['?a b '?c]

joelkuiper 2021-02-28T21:35:44.349300Z

thanks 🙂 somehow my mind was tricked into thinking the position of the quotes mattered in this case

2021-02-28T21:35:56.349500Z

If you put quote before the [ of a vector, the entire thing is quoted, and will not be evaluated.

2021-02-28T21:36:35.349700Z

If you want some of the vector elements evaluated, and some not, then don't put a ' before the [, but do put it before any elements that you do not want to be evaluated

2021-02-28T21:36:54.349900Z

The position of the quotes DO matter

joelkuiper 2021-02-28T21:38:05.350100Z

yes of course, the problem is that the thing I want to put that in is itself quoted

2021-02-28T21:38:47.350300Z

You mean, you want the return value of the function to be included in part of a larger collection, which is currently quoted in your code?

joelkuiper 2021-02-28T21:39:09.350500Z

yes exactly

2021-02-28T21:39:59.350700Z

To do that, you must make that larger collection no longer quoted as a whole. Or use a function like vec or vector to build that collection instead of a literal [ ... ] expression, if it is a vector. Similarly hash-map or set if it is a map or set.

2021-02-28T21:40:28.350900Z

Quoting an entire collection with ' does not let you pick and choose pieces of it to be evaluated.

joelkuiper 2021-02-28T21:42:24.351100Z

I think I got it now 😄 thanks!

joelkuiper 2021-02-28T21:43:00.351300Z

(conj '[:find (count ?x) .
        :in $ ?table
        :with ?v
        :where
        [?table :example ?record]]
      ['?record attr '?v])
is an order of magnitude faster than
'[:find (count ?x) .
  :in $ ?table ?attr
  :with ?v
  :where
  [?table :example ?record]
  [?record ?attr ?v]]
so this silly workaround will do for now

borkdude 2021-02-28T22:00:43.351700Z

@joelkuiper There is also this, hidden in the dark corners of the clojure std libs:

$ bb -e "(require '[clojure.template :as t]) (t/apply-template '[?x] '[:foo ?x :bar] [:baz])"
[:foo :baz :bar]

👍 1
alexmiller 2021-02-28T22:01:19.351900Z

that download link above is NOT something we officially publish or guarantee will work

👌 1
alexmiller 2021-02-28T22:02:12.352100Z

it is possible for it to be out of sync with the numbered versions

alexmiller 2021-02-28T22:04:24.352300Z

if it would be helpful to publish a file in a known place with the current stable version (or link), I'd be happy to think about what to do there

alexmiller 2021-02-28T22:05:00.352500Z

this file is basically that https://github.com/clojure/brew-install/blob/1.10.2/stable.properties but it's branch-specific so probably not stable enough

👍 1
joelkuiper 2021-02-28T22:05:07.352800Z

wow, TIL 😄