This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-21
Channels
- # aatree (88)
- # admin-announcements (14)
- # alda (26)
- # announcements (4)
- # avi (6)
- # aws (7)
- # beginners (80)
- # boot (268)
- # braid-chat (58)
- # cider (4)
- # clara (54)
- # cljs-dev (16)
- # cljsrn (27)
- # clojars (13)
- # clojure (123)
- # clojure-chicago (2)
- # clojure-czech (8)
- # clojure-france (5)
- # clojure-hamburg (2)
- # clojure-miami (6)
- # clojure-nl (5)
- # clojure-russia (285)
- # clojure-spain (2)
- # clojurebridge (3)
- # clojurescript (137)
- # code-reviews (14)
- # community-development (6)
- # core-async (8)
- # core-matrix (10)
- # cursive (2)
- # datascript (1)
- # datomic (24)
- # dirac (2)
- # emacs (5)
- # hoplon (4)
- # incanter (6)
- # jobs (7)
- # ldnclj (42)
- # ldnproclodo (2)
- # leiningen (1)
- # mount (60)
- # off-topic (15)
- # om (134)
- # onyx (65)
- # perun (4)
- # portland-or (2)
- # proton (15)
- # random (1)
- # re-frame (24)
- # reagent (7)
- # testing (4)
- # yada (9)
@meow: that's what happened, but by that point my functions were all interdependent, which led me to my current problem 😞
@slester: at first look, is this the most key line making it hard to prevent circular deps?
updated-state (-> state check-minister check-princess check-end-game)
@eggsyntax: not exclusively, there are lots of others (actions and gameplay) that are interdependent
Yeah, I can see how some of it could be difficult to untangle. I suspect a layer of abstraction over the actions -- so that you can essentially program to an interface in your gameplay fns -- might go a long way. And possibly the same thing on the other side, so that if actions need to trigger gameplay fns, they're calling an interface.
The code itself seems pretty well-written; the rules of the game themselves make it an inherently tangly problem. I think it can definitely be decomplected, but I don't see a single silver-bullet solution.
(& to be clear, I'd implement those interfaces using protocols [possibly deftypes as well, but there might not be much need for them here].)
@slester: Whoops, meant to post all that in #C053PTJE6, but I guess here's just as good since there hasn't actually been much discussion yet in #C053PTJE6.
Quick Question:
(> 5 2) yields true
(> "b" "a") gives an error
What is the idiomatic way to compare strings?
Do I need to hack something together with (compare) ?
Yeah, in emacs/cider at the repl I just get an error
So here's what I did, let me know if you think it's too terrible:
(defn C>
([x] true)
([x y] (> (compare x y) 0)))
yeah, it looks ugly to me, but it seems to work
I was surprised though that the > and < functions don't generalize to other data types like = does
I suspect it might be either adherence to the precedent set by Clojure and/or desire for performance optimization.
I suspect it’s half that those operators predate protocols, and half that I suspect Rich has no interest in choosing which ordering is best for sets that can defensibly have multiple order fns
@richhickey: which is it?
Hey everyone, I have a function like this ->
(defn body->multipart [xs]
(let [res (MimeMultipart.)]
(for [{:keys [body content-type]} xs]
(let [part-fn (condp string/starts-with? content-type
"text" text-part
data-part)]
(.addBodyPart res (part-fn body))))
res))
When I do (.getCount (body->multipart [{:content-type "text" :body "hi"}]))
I get 0, meaning that no body parts
were added.
Now, If I manually do this in the repl --
(def res (MimeMultipart.))
(for [{:keys [body content-type]} xs]
(let [part-fn (condp string/starts-with? content-type
"text" text-part
data-part)]
(.addBodyPart res (part-fn body))))
(.getCount res) ;; 1
I am sure I am missing something nooby. Any thoughts?hi, i am new to clojure and trying to learn the language thing is i dont know if im being too syntax oriented i cant seem to find much resources regarding how the loops work or conditionals work perhaps im looking in the wrong place any ideas?
im more use to learning by example with a bit of explanation
@iha2: Two things worth checking out are require
and load-file
. They can be invoked at the REPL and can load code.
@mfikes: load file sort of runs the whole file and returns the output, require for me can’t find the file on classpath even as load-file does and works
@iha2: does the file you are loading with load-file
define the functions in a namespace? (Perhaps you need to access the functions using a namespace qualifier.)
@iha2: If there is a function defined in that file, after doing (load-file <filename>)
, you should be able to call the function using (hiclustering/function-name …)
hey @jack_liang: have you seen https://clojurebridge.github.io/community-docs/docs/clojure/for/ and https://clojurebridge.github.io/community-docs/docs/clojure/if/ ?
hey @tmtwd: square brackets are not reader macros; reader macro behavior is triggered by other specific characters, e.g. http://clojure.org/reference/reader#macrochars
@tmtwd: []
indicate vectors (as opposed to lists).
Clojure has more data structure types than "regular" Lisp.
They have vectors, arrays, maps, etc but no literal syntax for them
@joshua.d.horwitz: i made a list of getting started things that I am using to learn http://blog.clojuregeek.com/getting-started
I think the clojure koans are a better starting place then 4clojure
bummer http://clojuredocs.org/clojure.data/diff doesn’t handle comparing a set vs an empty set well
Would seq work for you? https://clojuredocs.org/clojure.core/seq
ill check it out shaun thanks, i also may have spoke too soon and my function may have been trying to turn nil into a set… i’ll report back
@slester: are you enjoying working through 4clojure? i find i get stuck as well but am trying to leverage this channel and http://clojuredocs.org for ideas etc