Fork me on GitHub
#beginners
<
2019-04-04
>
andrew51301:04:25

Is there a shorthand syntax to define a map having a keyword with the same name as its value? For example in JS I'm used to {foo} being shorthand for {foo: foo}

seancorfield01:04:17

No. But that seems to be a common question from folks used to JS.

orestis05:04:09

There was a discussion in ClojureVerse about this @andrew513 which I think resulted in some macro - but most people shied away from it.

chvanikoff09:04:37

Hi, can somebody explain, what’s the meaning of keywords :user or :repl in .lein/profiles.clj? I’m feeling confused since some tutorials says something like “put this to the file: {:user {:plugins [[cider/cider/nrepl "0.21.1"]]}}" while others show exactly the same but with :repl instead of user as a top-level keyword. Also, I believe I’ve seen other options, not only :user and :repl, so where do I read more about it?

joelsanchez09:04:23

this document talks about those two profiles and everything else https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md

chvanikoff09:04:57

seems what I was looking for, thanks!

twaima10:04:15

how mto make map eager? 🤔

michael.e.loughlin10:04:48

for what purpose? it's possible to define map using reduce, which is eager

michael.e.loughlin10:04:30

(defn transform-each [f coll]
  (reduce #(conj %1 (f %2)) [] coll))

alexmiller11:04:24

You can use map as a transducer with something like into, which will be eager

alexmiller11:04:09

(into [] (map inc) (range 10))

robert.law13:04:31

By eager I assume you mean non-lazy? if so then use mapv rather than map i.e. (mapv inc (range 10))

dpsutton14:04:04

alex's example is eager here. It is using (map inc) as a transducer. There are some added performance benefits to this method as well

kamuela14:04:14

This is such a beginner question, I'm having a problem figuring out what I ought to even ask... but I'm working on something from exercism, which included a project folder with a project.clj and src and test folders. I'm able to run lein test to run the built-in tests to see if my functions work correctly. However, when I run lein repl, I try to use (ns beer-song) to enter that namespace, which happily goes along, but I can't seem to access any of the functions in that file. I'm guessing I'm somehow misunderstanding the module system maybe, anything common I'm neglecting?

joelsanchez14:04:14

that'd be (require 'beer-song)

joelsanchez14:04:09

and then (in-ns 'beer-song) if you want to set it as the current ns

kamuela14:04:33

Perfect! Thank you, that moved things along. If I go and change something now and save the file, do I need to re-require or do something else to have the new code be used in the given repl?

joelsanchez14:04:58

your editor should help you with that. in cursive I alt-shift-L to load a file into a repl or alt-shift-p to load a form

joelsanchez14:04:13

you can use clojure.tools.namespace.repl/refresh too

kamuela14:04:13

I'm using cursive on a mac, where would I see that configuration for shortcuts

joelsanchez14:04:59

in the contextual menu you can find a "REPL" item that lists some common actions

joelsanchez14:04:20

see #cursive too

manutter5115:04:20

@kamuela If you want to re-configure the load-in-repl command, check in Preferences under Keymap -> Plugins -> Cursive -> Load file in REPL

mathpunk17:04:49

@twaima I found this instructive on async programming -- the tl;dw is, Don't completely discount promises as a way of handling async programming https://www.youtube.com/watch?v=rV1gTJ2wsZg

mathpunk17:04:29

that bicycle there is representing that, maybe core.async is a finely tuned and expensive racing bike, and promises are a easy-to-maintain fixed gear

mathpunk17:04:38

i thought it was interesting