Fork me on GitHub
#beginners
<
2017-11-26
>
itaied12:11:00

What are the benefits of using keyword over string? In particular, in a map?

drewverlee13:11:42

@itaied One difference i know is that a keyword can be used as a function call to a map: ((:foo {:foo :bar}) {:bar :car}) => :car

timo16:11:35

hi there, anyone knows, if it is possible to run a function in the repl and get some kind of verbose output of all the steps? something like bash -x for bash-scripts?

noisesmith16:11:13

there's also profilers - a profiler can show you a lot of information about what ran (available for java or javascript)

timo16:11:09

alright, thanks, I once saw something that felt easier like this but I hardly recall any name or something (maybe 'analyze'??)

dustin16:11:03

Hey everyone, needing some advice. I plan on learning Clojure, but is it ideal as a first programming language? If so, where would be a good place to start. Some background info: I'm a frontend dev, know HTML, CSS, very little JS. Thanks!

dustin16:11:15

I thought about maybe starting with Racket.

noisesmith16:11:41

there's a trade-off, racket is designed for learning, and very well suited to be a first language, but clojurescript directly integrates with your existing skills

noisesmith16:11:23

but clojurescript is designed to be pragmatic for people that know it well, with less consideration to difficulty of learning

noisesmith16:11:47

and in no way is optimized to be a first language (whereas racket is explicitly designed to be a first language)

dustin16:11:55

Perfect, thanks!

hoopes18:11:28

Hi, I have a beginner question about spec:

ios:cljs.user=> (require '[clojure.spec.alpha :as s])

ios:cljs.user=> (s/def ::my-int int?)

ios:cljs.user=> (s/def ::my-map (s/keys :req-un [::my-int]))
:cljs.user/my-map

;; But if i try to def the keys, it fails. Why doesn't that substitution work? 

ios:cljs.user=> (def the-keys [::my-int])
#'cljs.user/the-keys
ios:cljs.user=> (s/def ::my-map (s/keys :req-un the-keys))
----  Could not Analyze  <cljs form>   line:1  column:17  ----

  Don't know how to create ISeq from: clojure.lang.Symbol

  1  (s/def ::my-map (s/keys :req-un the-keys))
                     ^---

----  Analysis Error  ----

hoopes18:11:57

Why does that second one fail? Shouldn't the-keys be my list of [::my-int]?

jumar19:11:00

@hoopes it's because s/def is a macro and gets the-keys unevaluated (that is just symbol the-keys, not the vector). Your problem is pretty similar to this one: http://increasinglyfunctional.com/2016/07/13/dynamically-generating-clojure-spec-keywords/

hoopes19:11:16

gah - i see. thanks very much for the pointer!

noisesmith23:11:37

yeah, looks like plum.csv/->record