This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-01
Channels
- # admin-announcements (3)
- # beginners (25)
- # boot (21)
- # cider (39)
- # cljs-dev (86)
- # cljsrn (20)
- # clojars (4)
- # clojure (70)
- # clojure-canada (1)
- # clojure-greece (101)
- # clojure-poland (16)
- # clojure-russia (35)
- # clojure-spec (202)
- # clojure-uk (24)
- # clojurescript (69)
- # cursive (23)
- # datomic (34)
- # devcards (7)
- # dirac (5)
- # editors (3)
- # emacs (6)
- # events (1)
- # hoplon (52)
- # instaparse (1)
- # jobs (4)
- # jvm (2)
- # lein-figwheel (2)
- # leiningen (10)
- # luminus (2)
- # mount (1)
- # off-topic (12)
- # om (55)
- # om-next (8)
- # onyx (19)
- # pedestal (4)
- # planck (1)
- # re-frame (27)
- # reagent (5)
- # remote-jobs (1)
- # spirituality-ethics (14)
- # tmp-json-parsing (6)
- # untangled (121)
- # yada (32)
When it comes to iterating through sequences, why is there a first
or rest
but not an all
?
What use would there be for an all
that wouldn't be served just by the sequence itself, or a map, or something?
I think I’m having difficulty understanding how to apply certain data types, or extract certain data from a JSON rest response.
Can you show a concrete example? My guess is that it's probably something that can be handled with a simple map
@dmbennett: serves me right for naming something tmp.
@dmbennett: the equivalent or ruby's Array#each
would be doseq
, i.e. loop through a sequence for side effects
but depending on what you're trying to do there might be better ways. You should get familiar with doseq
, map
, for
, doall
, dotimes
, loop
When you don’t need a reference to “moving element”, you can also use run!
(run! println [1 2 3])
Clojure Boot/HttpKit newbie question: Given this basic sample app running via Boot:
(ns geo.main
(:require [org.httpkit.server :refer [run-server]]
[geo.handler :refer [app]])
(:gen-class))
(defn -main [& args]
(run-server app {:port 8080}))
I find that the -main
, while working, isn’t blocking the thread and immediately exits silently and with code 0
. This appears to work with Leiningen (to the best of my knowledge. What am I doing stupidly?Moreover, the code works fine and the webserver correctly returns when run-server
is called via the repl.
@dp take a look at https://github.com/pandeiro/boot-http
can someone enlighten me this particular cljs code?
(defn jsonp
([uri] (jsonp (chan) uri))
([c uri]
(let [gjsonp (Jsonp. (Uri. uri))]
(.send gjsonp nil #(put! c %))
c)))
looking at the jsonp api in google closure I see that send's first arg is the payload but in this case its nil, I somehow understand channels, does that mean that this function just opens the chan without any payload?It is sending nil
to the uri
and when it gets a response, it put!
s that response onto the channel.
`(defrecord Planet [name moons volume mass]) => user.Planet (def earth (Planet. "Earth" 1 1.08e12 5.9e24)) => #'user/earth (def earth-> (->Planet "Earth" 1 1.08e12 5.9e24)) => #'user/earth-> (= earth earth->) => true`
I prefer the second one. To use the first one in a different ns you will need to “import” the class, while the second one you can just “require” the ns