This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-18
Channels
- # architecture (25)
- # beginners (57)
- # boot (3)
- # cider (38)
- # clara (6)
- # cljsrn (6)
- # clojure (54)
- # clojure-china (4)
- # clojure-greece (1)
- # clojure-italy (3)
- # clojure-romania (1)
- # clojure-russia (7)
- # clojure-spec (68)
- # clojure-uk (46)
- # clojurescript (73)
- # community-development (2)
- # core-async (7)
- # cursive (17)
- # datomic (143)
- # duct (2)
- # emacs (12)
- # events (5)
- # figwheel (3)
- # fulcro (15)
- # hoplon (19)
- # jobs (12)
- # jobs-discuss (85)
- # nginx (3)
- # off-topic (111)
- # onyx (7)
- # other-languages (1)
- # re-frame (30)
- # reagent (19)
- # remote-jobs (1)
- # ring (7)
- # rum (1)
- # shadow-cljs (18)
- # spacemacs (4)
- # specter (4)
- # sql (24)
- # test-check (1)
- # unrepl (10)
- # vim (6)
- # yada (1)
Hey guys Im new to clojure and I have a question? I am trying to convert all of my shell and sql scripts to clojure so that I can test and whats going on with my scripts. I can select data just fine. I can insert data into the database just fine manually but I would like to be able to select from my database then manipulate the data from my select statement then insert the data into another table. Here is my select query that I am using (jdbc/query db ["select SUM(amount) from product where dt >= '2017-12-1' and dt <= '2017-12-31'"])
(jdbc/query db ["select id, SUM(amount) from product where dt >= '2017-12-1' and dt <= '2017-12-31'"])
(answered in #sql )
i’m trying to get into using the repl to help me with my clojurescript development. I can’t seem to get proto repl for atom to do anything useful, so now I’m just trying to use figwheel. I just tried doing the following set of commands:
app:cljs.user=> (doc doc)
-------------------------
cljs.repl/doc
([name])
Macro
Prints documentation for a var or special form given its name
nil
app:cljs.user=> (doc nothere)
nil
app:cljs.user=> (doc inc)
But figwheel hangs forever on (doc inc)
. Am I doing something dumb?i don't know the answer, but the doc
function is provided by cljs.repl
as you can see in your output, so maybe try doing (require '[cljs.repl :as repl])
and seeing if you can then run (repl/doc inc)
without it crashing? if you can, then it's probably an issue with how that library is being pulled in when you start your REPL.
@lee.justin.m You might try asking in #clojurescript -- not sure how many folks here are familiar with that side of the house in terms of tooling...
@seancorfield thanks yea. i think i’m running out of steam… 🙂
I published a short video about Clojure threading macros - might be useful to someone: https://curiousprogrammer.net/2018/01/18/clojure-tip-of-the-day-episode-4-threading-macros-part-1-thread-first-thread-last-thread-as/
I'm looking for a function, similar to zipmap
or map vector
but that operates on lists of maps, merging the maps together like so..
(????? [{:foo "1"} {:foo "3"}]
[{:bar "2"} {:bar "4"}])
; => [{:foo "1", :bar "2"} {:foo "3", :bar "4"}]
user=> (map merge [{:foo "1"} {:foo "3"}] [{:bar "2"} {:bar "4"}])
({:foo "1", :bar "2"} {:foo "3", :bar "4"})
@avfonarev I'm not sure if you want something like:
(let [list-vec [[1 2 3] [4 5] [6 7]]]
(apply min (mapcat identity list-vec)))
@avfonarev Like this: (map #(reduce min %) [[1 2 3] [4 5] [6 7]])
@rauh my question was a bit ambiguous, sorry. i'm looking for a minimal element in a collection
flatten is really bad, you can replace mapcat identity
with apply concat
but more often you want to suggest one of those as a replacement for flatten
I guess “bad” is an extreme thing to say - it’s a clumsy tool (since it is designed to disregard structure) and often a sign of poor design
Vectors have a standard order: lexicographical (Java is a bit weird, I know, but my vectors are equilong)
basically I hoped that the standard library has an equivalent of (first (sort comparator-function xs))
, which is linear in time, but it seems it does not
I am playing around with spec and I like it very much. It would appear helpful to turn on all instrumentation during development, including the :fn
and :ret
parts of fdef
s. However, the spec guide explicitly says that "Note that the :ret and :fn specs are not checked with instrumentation as validating the implementation should occur at testing time." I know that I can just use https://github.com/jeaye/orchestra to turn them all on, but I was just wondering what the justification was for how spec is doing it. Spec seems to be pretty well thought out and I would like to understand why something is happening before I turn it off...
instrument
is about ensuring your calls are correct; check
is about ensuring the behavior of a given function is correct.
clojure.spec
is designed around a particular "model" of testing that separates out the things that folks normally mix together in testing.
And it emphasizes that behavioral testing (of functions) is often better served by property-based (generative) testing than by example-based "unit" testing. It also emphasizes that fixed properties of behavior are important -- something we really don't pay much attention to in example-based testing -- and that in turn helps shift the focus to mostly pure, mostly simple functions, which are combined to build a highly testable system with a strong level of confidence.
@lilactown you can put files somewhere outside the source-paths
there’s no such setting
@seancorfield Thank you! What do you mean by "fixed properties" of behavior?
my ideal project arrangement seems to be anathema to the way clojure projects are typically set up:
project.clj
src/some/namespace/
- feature/
- core.cljs
- server.cljs
- tests/
- client-app/
- project.clj
...
@sabbatical2017 as a simple example: (= (reverse (reverse s)) s)
-- a property of the reverse
function is that if you call it twice on any sequence, you should get back (an equivalent to) the original sequence.
Here's another couple of examples:
(defexpect round-trip-ip->long
(more-of {:keys [result num-tests]}
true result
100 num-tests)
(tc/quick-check
100
(prop/for-all [a (gen/choose 0 255)
b (gen/choose 0 255)
c (gen/choose 0 255)
d (gen/choose 0 255)]
(= (ip->long (str a "." b "." c "." d))
(+ d (* 256 (+ c (* 256 (+ b (* 256 a))))))))))
;; tests to ensure ip->long is pretty bullet proof
(defexpect random-ip->long-test
(more-of {:keys [result num-tests]}
true result
100 num-tests)
(tc/quick-check
100
(prop/for-all [s gen/string]
(zero? (ip->long (str/replace s #"[0-9]" "."))))))
Does that help @sabbatical2017?Yes @seancorfield, this is super helpful. Thank you very much!
Hello, could smbd tell is there any archive of #announcements channel? For the last two weeks?
@janis.urbis Most channels are logged but, whilst the logging portion is still working, the display portion on http://clojureverse.org has been broken since November. Sorry.