Fork me on GitHub
#beginners
<
2016-01-30
>
doddenino00:01:50

I'm having some trouble with hickory, does anyone have experience with it here?

polymeris02:01:55

@gabehollombe: interesting, thanks. There are so many functions to learn 😛

polymeris02:01:39

so... it would make more sense for iterate to be called iterations

jonahbenton03:01:03

hey @doddenino: hickory uses jsoup, which many have experience with. do you have more details about the problem?

gabehollombe03:01:59

@polymeris: I don’t think so, because you’re not interested in the value of each iteration when you call iterate — you just want it to iterate, yeah?

gabehollombe03:01:20

reductions is so-named because you want all the reductions. (compare vs reduce)

polymeris03:01:54

@gabehollombe: but iterate returns a seq of the intermediate values, no?

polymeris03:01:16

it should just return the last... if you go by the name

gabehollombe04:01:28

ah, I see what you’re getting at.

polymeris04:01:52

I think I saw one of your talks... are you involved in phaser?

polymeris04:01:28

funny, I am currently working with pixi and thought about going with phaser, first

polymeris04:01:54

trying to wrangle it into a form that works with FP/cljs

gabehollombe05:01:00

@polymeris: not involved with, but I have given Phaser talks! 😃

gabehollombe05:01:09

Yeah, use Pixi if you just want rendering, Phaser if you want more of a game framework. Although Phaser.next a.k.a. Lazer, will have their own renderer (no longer using Pixi) if I understand it right

polymeris05:01:22

@gabehollombe: either way (phaser or pixi), I have found it hard to getting it to work with cljs. The interop works ok, but it's just not designed with FP in mind. Any tips?

polymeris05:01:32

E.g... where should I store all that state pixi generates?

doddenino08:01:43

@jonahbenton I have a div containing spans. These spans can contain text, or another span containing text. I'm trying to get the text. I tried all the combinations of descendant, child, and, or, but I can only get one of the two span times at a time, not both together 😞

gabehollombe08:01:23

@polymeris: Alas, I haven’t done any FP style games yet

krchia14:01:40

um, is there a way to specify the argument order of a function when using -> or ->>?

krchia14:01:21

i have a function (-> arg (fn1 arg ..) (fn2 arg0 arg1))

tragiclifestories15:01:23

having some protocol confusion here

tragiclifestories15:01:48

got this code:

(defprotocol ApiResource
  (resource-url [self] [self opts]))

(defn _resource-url
  "Construct URL for resource from `:id` and `:resource-type` keys."
  ([subject {:keys [base-url]}]
   (if-let [path (_resource-url subject)]
     (construct-full-url path base-url)))

  ([subject]
   (let [id (:id subject)
         type (:resource-type subject)]
     (if (and id type)
       (str "/" type "/" id)
       nil))))

(extend-type java.lang.Object
  ApiResource
  (resource-url [self] (_resource-url self))
  (resource-url [self opts] (_resource-url self opts)))

(resource-url {}) ;; expect nil, get ArityException

tragiclifestories15:01:40

exception I get (with variation in the random numbers)

Unhandled clojure.lang.ArityException
   Wrong number of args (1) passed to: core/eval27713/fn--27714

                      AFn.java:  429  clojure.lang.AFn/throwArity
                      AFn.java:   32  clojure.lang.AFn/invoke
                      core.clj:   46  hypertension.core/eval27478/fn/G
                          REPL:    1  hypertension.core/eval27717

tragiclifestories15:01:41

The way I see it I've got single-arity implementations of everything, so I don't see what I've messed up

solicode15:01:20

I believe that should look something like this:

(extend-type java.lang.Object
  ApiResource
  (resource-url
    ([self] (_resource-url self))
    ([self opts] (_resource-url self opts))))

krchia15:01:19

is there a function for something like this

krchia15:01:37

(when (test-if-thing-exists) test-if-thing-exists)

tragiclifestories15:01:50

presumably test-if-thing-exists on its own would be enough?

krchia15:01:10

yea, but i want to do something with it and then return the value

krchia15:01:17

but i don’t want to call test-if-thing-exists twice

tragiclifestories15:01:29

if-let and when-let maybe

krchia15:01:41

will look those up, thanks!

Drew Verlee18:01:04

In the following code from this excellent blog post (http://sw1nn.com/blog/2012/04/11/clojure-stm-what-why-how/), the author is trying to convey an idea about commute. That the commute function will update the ref based on the value of the ref it reads 'at commit'. I'm I correct in assuming however, that in this case commute is meaningless/usless because we're in a single thread? As in the first log-deposits will always happen before the second'. Or put another way, it seems like commutes have not purpose unless your using multiple threads. Are dosync or commute starting background threads? I thought you would need to use future explicitly for this to happen.

Drew Verlee18:01:59

I'm also having trouble understanding why the commute function is called 'twice' as explained here: http://conj.io/store/v1/org.clojure/clojure/1.5.0/clj/clojure.core/commute. What does it mean >and returns the in-transaction-value of ref. why not commit this value at that point. Finally, I don't understand how the correct value is resolved using commute if their all potentially using 'old values' of ref. (which is what it looks like is happening the example at the end of this blog: http://squirrel.pl/blog/2010/07/13/clojure-alter-vs-commute/).

Drew Verlee18:01:32

+ 100 cool points bounty.

chedgren19:01:19

I'm getting some Json using cljs-ajax but the map has "string" intead of :key. How do i get key-keys instead of string keys

chedgren19:01:44

If I ask i figure it out immediately after asking... Nvm

Drew Verlee20:01:21

Maybe the second 'commit'time' computation is 'usually less expensive' because its assumed large parts of the function are already evaluated?

(+ x 1 (+ 1 1)) ;; in-transaction
(+ x 1 2) ;; at commit time

fred20:01:26

Hello, I'm trying to teach myself clojure by transforming nested maps into CSS code but stuck with basic function composition...

(def css1 {"body" {:background-color :#d0e4fe}
           "p"    {:font-family      "Times New Roman"
                   :font-size        :20px}})

(defn o [[property value]] 
  (str (name property) " : " (if (keyword? value) (name value) (str "\"" value "\"")) ";"))
(defn oo [block] 
  (clojure.string/join "\n" block))
(defn ooo [[selector block]] 
  (str selector " { " block " }"))
(defn oooo [nestedmaps]
  (clojure.string/join "\n" nestedmaps))
do you think my approach is totally flawed?

Tim22:01:33

are go-loops for async going to necessarily have side-effects? All the examples I see are like this:

(go-loop []
  (let [fun (<! output-chan)]
    (println "check")
    (println (get fun 0))
    (println (get fun 1))
    (recur)))

Drew Verlee23:01:32

@tmtwd: from my very naive perspective, no, your go loops don't necessarily have to have side effects. The ones your viewing probably do so they can show you how things are being executed.