Fork me on GitHub
#beginners
<
2016-01-18
>
kopasetik02:01:01

OK, why do I get object#lkadfllajdsf when I run this:

kopasetik02:01:22

Figured it out. Never mind!

mfikes02:01:12

Transducer?

mfikes02:01:23

By the way, @kopasetik, consider run! instead of map since you want side effects to occur.

kopasetik02:01:11

@mfikes: Thanks. Making a little lightning talk on destructuring.

meow02:01:38

@kopasetik: sounds like a good idea - where will you be presenting it?

kopasetik02:01:01

2 places in the next 2 days.

kopasetik02:01:58

Why is it pertinent to a JS meetup? Well, it’ll be a comparison of destructuring in Clojure to destructuring in ES6 JS

meow03:01:09

nice. will you be at clojure/west 2016?

kopasetik03:01:21

Crossing my fingers about Clojure/west. Just applied for an opportunity grant. simple_smile

meow03:01:49

what about submitting a speaking proposal

meow03:01:27

I need to get started on a proposal. Or just keep procrastinating.

meow03:01:03

or go smoke another cig...

kopasetik03:01:33

Heh, I’m feeling like that’s a bit ambitious as I’m pretty green as a Clojure dev. A lightning talk is one thing, but a talk at conference?

kopasetik03:01:08

But, might as well try, right?

meow03:01:22

go for it

meow03:01:16

you could do a 40 minute presentation on destructuring

kopasetik03:01:29

Question- how might I get the JSON from this address using Clojure: http://www.omdbapi.com/?s=highlander

kopasetik03:01:45

It doesn’t have any access origin restrictions

meow03:01:21

you never know who might be interested in the subject: https://github.com/clojurewest/clojurewest2016/wiki/Suggested-Topics

martinklepsch09:01:18

@kopasetik: you can use slurp to just get it as a string

martinklepsch09:01:41

Then there is clojure.data.json which can parse it for you

kopasetik10:01:22

@martinklepsch: Thanks! You can use slurp with URLs?

eleonore10:01:17

Has anyone used ring-cors (https://github.com/r0man/ring-cors) or knows a way to set 'Access-Control-Allow-Origin' for a (simple) Clojure app

kopasetik10:01:51

Error message: Exception in thread "main" java.io.FileNotFoundException: Could not locate data/json__init.class or data/json.clj on classpath., compiling:(clojure_noob/core.clj:1:1)

kopasetik11:01:47

Never mind. Fixed it!

martinklepsch11:01:00

@kopasetik: left computer earlier, glad you got it working simple_smile http://clojuredocs.org is great to look up things like slurp and what exactly they're doing simple_smile

kopasetik17:01:42

I’m having trouble mapping across the JSON data that I’m getting back from an API call

kopasetik17:01:48

This works...

kopasetik17:01:35

But this doesn’t...

martinklepsch17:01:41

@kopasetik: printing in general is a side effectful function

martinklepsch17:01:16

@kopasetik: map is lazy which causes nothing to be printed because the result isn't used

martinklepsch17:01:23

or are you experiencing another issue?

kopasetik17:01:32

@martinklepsch: Yes, that must be it. How do I iterate across the data set to print it if I can’t use map? Or can I make my mapping work by adding a default return value to the function?

martinklepsch17:01:33

@kopasetik: see the example in the link above it explains the problem + solution

martinklepsch17:01:13

simple answer is wrap the map call in doall

martinklepsch17:01:40

another alternative would be using doseq but for now doall should be sufficient simple_smile

kopasetik17:01:24

Just looked at the documentation examples. Thanks! 😄

martinklepsch17:01:05

clojuredocs is full of these examples, if you ever have a function not behaving as you expect chances are there's an example covering it simple_smile

kopasetik17:01:33

I don’t think that I would have been able to figure out that specific problem just by looking at Clojuredocs

martinklepsch17:01:02

Well for that case there are channels like this one simple_smile

Drew Verlee17:01:54

can someone explain why

(map vals ({:name "drew" :glitter-index 0 } {:name "alex" :glitter-index 1 }))
is
=> ()
I would expect
(("drew" 0) ("alex" 1))

donaldball18:01:12

The parentheses around the third form don’t stand for “list of maps”, they stand for “execute the fn found in the first position with the rest of the args"

donaldball18:01:30

You just got “lucky” in that clojure maps can be evaluated as fns

donaldball18:01:47

You probably want to use a vector of maps: [{:name “drew” :glitter-index 0} …]

Drew Verlee18:01:36

@donaldball, gotcha. I was just thinking it was because it was expecting a function/that wasn't a list of maps simple_smile

mfikes18:01:12

@drewverlee: You can also prevent evaluation by quoting: (map vals '({:name "drew" :glitter-index 0 } {:name "alex" :glitter-index 1 }))

Drew Verlee18:01:07

@mfikes, thanks. I recall you quote things to use them as their DS rather then have them eval.

todd.decker18:01:59

How compatible is Clojure with the R5RS standard for Scheme? Is it close enough that only minor edits and perhaps helper functions are needed?

Drew Verlee19:01:09

yea i'm signed up for http://clojureremote.com/! I'm sure this conference has gotten lots of love in this channel already, but if your on the fence there is a coupon through Clojure Gazette (lispcast). Also sense its remote their isn't the normal overhead/cost associated with conferences. I feel this makes it very 'beginner' friendly simple_smile.

kopasetik22:01:54

Question - I know that I can use slurp to access data from http websites and apis. Is there any way that I can use it to access apis that require authentication for access?

chris23:01:01

@kopasetik: Clj-http has all kinds of features, including a few different auth schemes