Fork me on GitHub
#beginners
<
2016-07-27
>
seancorfield00:07:25

What does that do in JS?

seancorfield00:07:18

(specifically, the unary + there)

seancorfield00:07:30

And is d a JS object that you’d be mutating there?

seancorfield00:07:56

In which case (set! (.-close d) (something (.-close d)) I guess… where something is a function that does whatever the unary + in JS does…?

krchia02:07:19

yeah, i did a bit of reading and i’m not too sure what it means

krchia02:07:50

i think the closest thing that made sense was typecasting it to a number.. i think?

seancorfield03:07:03

@krchia: Could be… I’ve seen some very bizarre JS code that does coercions between types. I guess you’d have to know what values d.close could possibly have and then work out a conforming cljs version from that.

seancorfield03:07:17

I suspect that d.close could be null and +null produces 0 so (or (.-close d) 0) would work for that...

seancorfield03:07:51

…but +"1" produces 1 so if d.close could be a string, I don’t know what the best cljs code would be...

val_waeselynck06:07:37

@krchia @seancorfield yeah unary + is coercion to number, this looks like data sanitizing code

val_waeselynck06:07:27

@krchia: I would use goog.string#toNumber()

krchia15:07:07

@val_waeselynck: thanks!

krchia15:07:46

i’m not sure what is going on here

scriptor15:07:29

@krchia: what happens if you assign the result of the (.range ... expression to a var and call that?

krchia15:07:22

@scriptor: what do you mean?

krchia15:07:07

i can’t do that in isolation, since range is a function of d3.time.scale

krchia15:07:20

are you thinking it’s being confused with the cljs fn range?

scriptor15:07:39

@krchia: as in, if you just have

(def foo (.range (.scale js/d3.time) (clj->js [0 890])))
(foo 5)

scriptor15:07:50

just want to make sure that works

krchia15:07:26

yeah, it doesn’t work

krchia15:07:28

it’s in my snippet

krchia15:07:42

oh whoops let me try that

krchia15:07:57

oh, foo works

andrewzhurov15:07:49

Hello, can I get a hint what dudes do when need to get "some" for all values in the list ? Is it a job for "reduce" only ? or is there an elegant way (sry for interupt)

krchia15:07:49

oh my gosh

krchia15:07:57

i just realized i had [vector ..]

krchia15:07:23

my god, i’m not sure if this mistake taught me anything other than not to be careless .. :’(

scriptor15:07:27

ah, yeah, that'd do it

krchia15:07:49

@brownmoose3q: not sure what you’re asking, could you give an example case?

scriptor15:07:57

@brownmoose3q: what do you mean by getting "some" for all values?

scriptor15:07:24

can you give an example?

andrewzhurov15:07:58

I'd like get every value in the seq in the way some does it. So, not a source value from the seq, mod modified one through predicate

scriptor15:07:02

can you give an example of what you want? Sorry, it's a bit hard to understand what you're saying

scriptor15:07:18

are you thinking of every? ?

andrewzhurov15:07:07

I'll check it no

krchia15:07:34

i guess you could do map then filter the nils?

krchia15:07:02

oh, keep is exactly that

andrewzhurov15:07:03

or filter and then apply

andrewzhurov15:07:10

oh, i'll check

scriptor15:07:16

yeah, keep will work since when will return nil

andrewzhurov15:07:55

yes, cool, thanks for help!

mocker19:07:20

Bleh, failing at getting clojure code to add a new row to google sheets spreadsheet.

roberto20:07:34

how can you serve a file with compojure? I don’t want to serve static files, just a file that gets generated dynamically (like an audio file)

donaldball21:07:37

iirc ring lets you put an inputstream in the :body of your response

roberto22:07:17

yeah, thanks, figured it out