This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-29
Channels
- # beginners (31)
- # boot (5)
- # cider (1)
- # clara (1)
- # cljs-dev (9)
- # clojure (118)
- # clojure-nl (2)
- # clojure-russia (90)
- # clojurescript (344)
- # cursive (4)
- # datascript (1)
- # datomic (41)
- # emacs (5)
- # hoplon (48)
- # ldnclj (13)
- # lein-figwheel (13)
- # leiningen (1)
- # off-topic (1)
- # om (146)
- # omnext (1)
- # onyx (65)
- # re-frame (22)
@kopasetik: Sorry, got distracted by work. Yes, if you need to make API calls to other servers, you’ll want to depend on clj-http
: https://clojurians.slack.com/archives/beginners/p1451336138005235
@seancorfield: Thanks!
@christopherbui: also (range 1), which will be faster in some circumstances
oh boy
How did I forget about that
@kopasetik: the REPL probably uses readline. You can find the navigation commands here, under "Editing Commands", http://linux.die.net/man/3/readline
@mamapitufo: Cool, thanks.
no prob (they are really handy to know, pretty much everything uses it to provide command line editing)
this might be a stupid question but I have some code and i can run lein test
and everything runs fine. But when I run lein repl
load "tutorial/mongo
in-ns 'tutorial/mongo
init
I get Unable to resolve symbol: init in this context
. What am I missing? I feel like this is really simple and I am missing something minor.
jcomplex: tutorial/mongo isn't the name of the ns I bet
namespaces usually don't have / in them
(in-ns 'anything/at-all) will just create a garbage useless ns
it's OK, this is the beginners channel after all
OK, why doesn’t this work: (map #((if (> %1 %2) %1 %2)) [13, 64, 15, 17, 88] [23, 14, 53, 17, 80])
@kopasetik: You have an extra set of parens. This should do it: (map #(if (> %1 %2) %1 %2) [13, 64, 15, 17, 88] [23, 14, 53, 17, 80])
Also, if you're writing it that way for learning purposes, that's totally fine, but you can use the built-in max
function as well:
(map max [13, 64, 15, 17, 88] [23, 14, 53, 17, 80])
(map js/console.log ["one" "two" "three”])
Can anyone help me understand why the above doesn’t print anything to the console in a ClojureScript application?My first assumption was that the js functions can’t be passed as args to other functions like map
so I tried the following with an inline function to no avail:
(map #(.log js/console %) ["mango" "apple" "banana”])
@plaxdan: Because it’s a lazy sequence. You’re not actually running anything. If you use doall
you should see a difference:
(doall (map println ["one" "two" "three"]))
(defn print-city [city]
(let [line (str "City: " city)]
(.log js/console line)))
(defn print-cities [cities]
(doseq [city cities]
(print-city city)))
(print-cities ["Boston" "Denver" "Tokyp”])
This is working nicely now, thanks. I see from some stackoverflow questions that doseq
seems to be the idiomatic way to perform side-effects over a collection.