This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-07
Channels
- # admin-announcements (4)
- # beginners (63)
- # boot (67)
- # clara (29)
- # cljs-dev (38)
- # cljsjs (10)
- # clojars (7)
- # clojure (336)
- # clojure-belgium (3)
- # clojure-dev (22)
- # clojure-greece (30)
- # clojure-nl (1)
- # clojure-russia (9)
- # clojure-spain (3)
- # clojure-spec (169)
- # clojure-uk (12)
- # clojurescript (45)
- # clojurex (4)
- # core-matrix (3)
- # cursive (58)
- # datascript (3)
- # datomic (18)
- # events (38)
- # hoplon (228)
- # immutant (5)
- # lambdaisland (6)
- # leiningen (3)
- # luminus (8)
- # off-topic (11)
- # om (113)
- # om-next (2)
- # onyx (10)
- # parinfer (7)
- # planck (22)
- # re-frame (11)
- # reagent (25)
- # robots (7)
- # spacemacs (3)
- # specter (10)
- # yada (3)
cross-post from lein channel
---
Hello all,
I have this specific use case where i need to run $ lein run
with sudo
(i know bad idea, but its just for testing).
does anyone know what this warning is trying to tell me:
WARNING: You're currently running as root; probably by accident.
Press control-C to abort or Enter to continue as root.
Set LEIN_ROOT to disable this warning.
is LEIN_ROOT something i set on my .bashrc
or my .lein
config ?the former @dviramontes
@ghadi does it look like:
LEIN_ROOT=true
?
@dviramontes: you can also set it just one time if you add it before lein run
LEIN_ROOT=true lein run
that way you don’t have to change any configs just to try something out
How about (into [:ul [:li :first-item]] list-items)
?
yeah i'm aware that works, but wondering if there's a way to do it the other way... perhaps writing a macro? I'm just being a bit stubborn about it
(let [t (transient [])]
(dotimes [i 10]
(conj! t i))
(persistent! t))
=> [0 1 2 3 4 5 6 7 8 9]
Blithely, because t
in the former is an immutable vector
conj
takes an immutable data structure and returns a new immutable data structure that contains the given value
It does not change the immutable data structure argument
You need to accumulate the intermediate t
values if you want all the integers from 0 to 9 in it
dotimes
won’t let you do that. It’s used when you want side effects.
(mapv (fn [i] i) (range 10))
would be one way to do it immutably
(into [] (range 10))
might be more idiomatic
Or simply (range 10)
if you don’t need it to be a vector, just a seq
note that into will do transients under the hood for you too
Interesting. I just wanted to wrap both of them into a time
to do a side-by-side comparison, but apparently it's not as easy as it seems 🙂
Performance testing in the JVM is something of a dark art
For quick and dirty analyses though, try the criterium
library
@alexmiller funny you mentioned it, I am just reading the 2nd chapter of your Clojure Applied
where you are explaining it and doing various experimentations with code snippets of my own. Serendipitous...
why would the space between (inc 199)
and (/ 100 (-7 2)
cause the solutions to differ by 5000?
there's no way that can happen @dmbennett
open a new repl from scratch, try putting and removing how many spaces you want, there's no way that can happen
interesting, it only holds the 5 after it errors from the /100
form and then when eval-ing the next runs (+ (inc 199)(/ 100 (- 7 2)))
returns the 5 and 220
I don't know what repl you're using, but the default clojure REPL doesn't exhibit that behaviour
user=> (+ (inc 199) (/100 5))
RuntimeException Invalid token: /100 clojure.lang.Util.runtimeException (Util.java:221)
5
RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:221)
RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:221)
iDave-MBP:~ dmbennett$ which lein repl
/usr/local/bin/lein
iDave-MBP:~ dmbennett$ lein -version
Leiningen 2.6.1 on Java 1.8.0_25 Java HotSpot(TM) 64-Bit Server VM