#clojure log - Oct 05 2013

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:15 bja: ugh, ported codebase to latest cljs and core.async, promptly found out that specljs makes use of cljs.core.format

0:21 chare: I return

0:22 frozenlock: I have a website (called "A") on compojure. I have another website (called "B") on another server accessed via ssh. Is it possible to access B's website throught A? With an iframe perhaps?

0:25 xeqi: frozenlock: are you port forwarding?

0:25 frozenlock: I can, yes.

0:26 xeqi: also, are you looking for a proxy server to point to B ?

0:27 frozenlock: Yes.

0:27 Well "A" should become a proxy.

0:27 I wonder if it's possible to incoporate it in the compojure framework however...

0:28 say current "A" url---> /some-url/hello and then the "B" /welcome/item1. When passing throught A ---> /some-url/hello/welcome/item1

0:29 Am I crazy? :p

0:30 xeqi: frozenlock: possibly. 1) Is the ssh access for security? 2) Does "B" use any absolute url's in it's html/js/css ?

0:31 frozenlock: 1) it's nice if it can be secure, but it's more for NAT traversing 2) "B" is also compojure; I have absolute power over it.

0:35 xeqi: frozenlock: I don't know of anything prebuilt. You could make a wildcard route and use clj-http to talk to "B" over a forwarded ssh port, but you'd have to be careful with passing cookies all the way through

0:37 frozenlock: Oh I see... so "A" request any required stuff from "B" via clj-http and then it uses it as its 'own' and give it to the user.

0:38 xeqi: assuming I understand your problem correctly, yes

0:39 frozenlock: I think you do, and your solution makes perfect sense, thanks :D

0:41 And the "B" server is very simple... I think it doesn't even need cookies (it simply uses GET/POST for basic browsing), so that should be quite straightforward.

0:42 xeqi: frozenlock: one question is if "A" could just do what "B" is doing, but I assume the NAT traversal gives "B" access to different resources (like a db)

0:42 frozenlock: In short, pretty much.

0:53 Wow... I wasn't expecting to find something like that for clojure o_O https://github.com/hugoduncan/clj-ssh

1:59 sm0ke: is there a variant of assert which return the expression value instead of nil?

2:01 ambrosebs: sm0ke: you'll probably need to write your own

2:05 sm0ke: ambrosebs: got it i defined assert# .. dont know what else to call it (defn assert# [n] (assert n) n)

2:29 mullr: sm0ke: how about 'non-nil'? (+ a (non-nil (do-something)))

2:30 sm0ke: ,(doc non-nil)

2:30 clojurebot: Huh?

2:33 muhoo: ,non-nil?

2:33 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: non-nil? in this context, compiling:(NO_SOURCE_PATH:0:0)>

2:33 muhoo: ,nik?

2:33 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: nik? in this context, compiling:(NO_SOURCE_PATH:0:0)>

2:33 muhoo: ,nil?

2:33 clojurebot: #<core$nil_QMARK_ clojure.core$nil_QMARK_@c18ba8>

2:41 mullr: sm0ke: Sorry, I mean as a different name for the function you wrote and called 'asset#'

2:46 ('assert#', rather)

3:01 dcunit3d: got a question for using quil (processing for clojure)

3:02 so i've got a project that uses incanter

3:02 and incanter includes charts that allow you to graph functions and data easily

3:02 but it doesn't allow you to work with images very easily.

3:03 so i'm looking at either using seesaw (swing) or quil (processing)

3:03 i've explored a little with both, but i'm trying to double buffer the images i'm adding.

3:05 quil is pretty straightforward. i can instantiate a PImage and directly copy a row of data into the pixels array. but then that means i'm working with 100 PImage objects with each refresh of the image.

3:06 will that result in a slowdown? and how do i ensure that the resources required for these objects is released. is there a strategy where i can just instantiate 100 PImage references to be used. and then just update the same objects each time, so the objects don't need to be instantiated?

3:17 dusty_col: hi

3:17 Q: how do I make a list of chars (\A \B \C) into a string? calling (str) on it doesn't seem to do it, makes a str containing the parens

3:18 TEttinger: hey dusty_col. ##(apply str [\A \B \C])

3:18 lazybot: ⇒ "ABC"

3:18 TEttinger: (apply str [\A \B \C]) is what you're after

3:18 dusty_col: *looks up apply*

3:19 TEttinger: apply takes a function and a collection, and uses the collection as args to the function.

3:19 dusty_col: sweet, that's what i was looking for. thx!

3:19 TEttinger: ,(apply + [1 2 3 4 5])

3:19 clojurebot: 15

3:19 dusty_col: ,(println "Thanks")

3:19 clojurebot: Thanks\n

3:19 TEttinger: haha np

3:19 next up: map and reduce

3:25 dusty_col: lol yea i am doing exercism.io

3:25 had to loop over string and replace chars

3:25 with loop/recur

3:25 or that's how i did it anyways

3:26 TEttinger: there's also clojure.string/replace: ##(doc clojure.string/replace)

3:26 lazybot: ⇒ "([s match replacement]); Replaces all instance of match with replacement in s. match/replacement can be: string / string char / char pattern / (string or function of match). See also replace-first."

3:26 dusty_col: well that's a little too easy, i think the point of the exercise is learning how to recurse

3:27 TEttinger: ,(clojure.string/replace "Chicken" \C \T)

3:27 clojurebot: "Thicken"

3:28 TEttinger: yeah, recursion is important too

3:28 frozenlock: I think I had to recurse 2 or 3 times total :-/

3:28 Must be doing something wrong...

3:28 *I

3:28 TEttinger: nope, frozenlock

3:28 you shouldn't need to do it often, but all the standard lib is built around it

3:29 so it just helps to be able to read code using it

3:29 frozenlock: great :)

3:29 It's also a pain to write, IMO :p

3:29 TEttinger: indeed.

3:29 especially compared to more declarative stuff like map

3:29 dusty_col: so i'm trying to get a job at a clojure shop

3:29 but i can barely write hello world

3:30 TEttinger: 4clojure!

3:30 dusty_col: what is a good roadmap to get up to speed? topics & projects wise

3:30 TEttinger: I find 4clojure confusing, I often don't udnerstand the questions. Some are helpful.

3:30 TEttinger: they

3:30 they're meant to be kinda obtuse I think

3:30 to make you come at the problem from multiple angles

3:31 dusty_col: a buddy suggested something like arithmetic, strings, control structures, functions, io, little web app..

3:31 TEttinger: learning the standard FP stuff is most important in the long run. it also depends on those things.

3:32 so... map, reduce, apply, into, comp, potentially juxt, how lazyseqs work...

3:32 probably in around that order, juxt and comp are just cool stuff

3:33 but not needed

3:33 oh, filter too

3:33 filter is easy enough

3:34 ,(filter (fn [item] (> 10 item)) [1 2 3 4 5 10 11 12])

3:34 clojurebot: (1 2 3 4 5)

3:34 frozenlock: dusty_col: just don't "(map #(some-fn %) [1 2 3])" like I did for like a month :p

3:35 dusty_col: frozenlock: why not, what's wrong with map

3:35 TEttinger: nothing

3:35 it's the #(some-fn %)

3:35 which is the same as some-fn

3:35 just slower

3:36 dusty_col: oh

3:36 frozenlock: and more verbose

3:36 for absolutely nothing

3:36 dusty_col: oh he's making a closure to call the function with it's parameter?

3:36 i might understand ;)

3:36 TEttinger: yes, which is what the function name on its own does already

3:37 ,(time (map #(inc %) [1 2 3]))

3:37 clojurebot: "Elapsed time: 0.121924 msecs"\n(2 3 4)

3:37 TEttinger: ,(time (map inc [1 2 3]))

3:37 clojurebot: "Elapsed time: 0.035407 msecs"\n(2 3 4)

3:37 sveri: hi, i am trying to get the last value from a list, now when i do ((fn [x] (comp first reverse x)) '(1 2 3)) i get a function definition back instead of the last value, how do i use comp correctly? (doing ((fn lll [x] (println (first (reverse x)))) '(2 3 4)) works in the repl)

3:39 TEttinger: (fn [x] ((comp first reverse) x))

3:39 comp returns a function

3:39 you want to call the function I think

3:40 but why not use last?

3:40 ,(last '(1 2 3))

3:40 clojurebot: 3

3:41 TEttinger: sveri?

3:42 chare: guys here is my update on my progress

3:42 I'm reading http://www.arcsynthesis.org/gltut/Positioning/Tut04%20Perspective%20Projection.html

3:42 whats your guys progress on starcraft clone project?

3:44 Tettinger update on your project please?

3:44 sveri: TEttinger: ah, that works, thank you very much

3:44 TEttinger: no prob

3:44 comp is tricky, I only recently started using it. it's nice

3:45 sveri: TEttinger i am doing the 4clojure tasks and looked for some different solutions

3:45 TEttinger: ah.

3:45 frozenlock: ditto. I don't use it often however... mostly only to reduce the number of parens.

3:45 TEttinger: there's also #(nth % (dec (count %))) I believe

3:46 sveri: TEttinger yea, and a recur version which i like most

3:47 (fn [[x & xs]] (if xs) recur xs) x), however, i wonder why i need two [[ instead of one [? do you know that?

3:47 TEttinger: it's a destructuring

3:48 it really takes one arg, but converts it to the head x and the & rest as a sequence xs

3:48 sveri: TEttinger ok, i guess i understand that

3:50 TEttinger: so if you did with one [

3:52 (fn [x & xs] (if xs) recur xs) x) ;; this takes 1 or more args, and will act really weird because it won't have the same type for x on the first call (the-fn 1 2 3) starts with x as 1 and xs as [2 3], the recursion recurs with x as [2 3] and no xs

3:53 gah that wasn't very clear

3:55 sveri: TEttinger but i think i got it

3:55 :-)

3:58 frozenlock: Wasn't there someone trying to implement TCO for clojure?

4:15 chare: lets talk about something

4:15 i'm bored

4:16 jonasen: frozenlock: https://github.com/cjfrisz/clojure-tco

4:20 frozenlock: jonasen: last commit 11 months ago :-/

4:20 So it's not getting inside clojure.core I assume...

4:21 jonasen: tco will not get into core before java supports it

4:26 cark: jonasen: that's to say ..never

4:27 so annoying =(

4:27 jonasen: cark: that's probably the case

5:14 dcunit3d: does anyone have experience working with BufferedImages or graphics and clojure

5:18 chare: use opengl

5:35 TEttinger: dcunit3d, some, what's up?

5:37 (BufferedImage. 50 50 BufferedImage/TYPE_4BYTE_ABGR) ;; is a line in some font drawing code i have

5:37 dcunit3d: i'm trying to display handwritten digit data in images, using seesaw (swing) or quil (processing)

5:38 TEttinger: display and just display, or save as png or something?

5:38 dcunit3d: i want to display them on a JPanel or something

5:39 but i want to read in 100 digits and display them as they are being processed

5:39 TEttinger: ok.

5:39 why an image?

5:39 can't you use swing fields?

5:40 dcunit3d: i've read the image data into the program and so i'm trying to display it

5:41 TEttinger: ok, in swing it shouldn't be hard. let me look it up

5:41 what kind of data is it? just a vector?

5:41 vector of bufferedImages?

5:41 dcunit3d: i also want to display the hidden layer's of the neural network, so you can see them as they change.

5:42 the data i've reading in is just a persistent vector, containing 784x1 vectors each representing an image

5:43 each image is 28x28, but they are unrolled

5:44 i can use quil to easily write to the pixels array of a PImage. and pretty much just set the pixels directly with with the 784x1 vector.

5:45 but that requires instantiating a 100 PImage objects, and then I'm worried about memory consumption.

5:45 TEttinger: HAHAHAHAHAA Oracle Enterprise Search is temporarily unavailable.

5:45 WHAT

5:45 dcunit3d: lol

5:45 chare: dcunit3d: just use opengl

5:46 dcunit3d: what libraries are available for it? there's penumbra, but it hasn't been updated in a while

5:46 TEttinger: http://www.docjar.com/docs/api/java/awt/image/BufferedImage.html

5:47 so what digit data is this

5:47 is it just 0-9?

5:47 or fingers?

5:47 dcunit3d: http://yann.lecun.com/exdb/mnist/

5:47 0-9

5:48 TEttinger: ohhhhh

5:48 dcunit3d: i used gloss to parse the binary data. and i'm planning on using incanter to process the data.

5:48 TEttinger: I thought you meant number data, you mean images of numbers made by hand... that makes sense now

5:49 dcunit3d: https://github.com/dcunited001/handwritten-digits/blob/master/src/handwritten_digits/draw.clj

5:49 TEttinger: so if someone types 99999, it should show 5 different writing styles of "9"?

5:50 dcunit3d: basically it reads in each digit image and label and trains them. then there's a set of digits where it tries to guess which one it is.

5:51 so it's handwritten digit recognition.

5:51 TEttinger: ah.

5:51 dcunit3d: i don't really need graphics, but it'd be cooler if it did

5:52 TEttinger: of course!

5:52 so you want to draw...

5:53 dcunit3d: yeh, but i'm having a hard time getting swing set up. and i'd like for the graphics to be independent of the data being processed.

5:54 or i'm trying to figure out the best way to split up the data processing and the images.

5:54 TEttinger: I don't really know how I can help yet...

5:54 chare: dcunit3d: just use opengl through JOGL

5:54 TEttinger: sorry.

5:57 dcunit3d: thanks anyways

5:57 i'm not sure i'm asking the right thing

5:59 chare: opengl...

5:59 not hard...

6:01 TEttinger: dcunit3d, it sounds like a cool program though

6:10 dcunit3d: chare: are there any good examples of working with images in JOGL?

6:10 chare: you do the usual opengl stuff nothing special

6:11 dcunit3d: i've never done opengl stuff

6:12 TEttinger: dcunit3d: it looks like you're mostly doing close-to-the-metal graphics stuff

6:13 maybe you could do this with just seesaw, I dunno

6:13 can you take the code you posted and make a gist or something that has some possible things to fill in later?

6:14 dcunit3d: yeh, ill do that

6:14 chare: dcunit3d look the easy thing to do is just demand TEttinger write the code for you and start getting abusive if he doesn't help, thats what i do

6:15 dcunit3d: lol

6:15 i'm trying to get some advice. i want to write it myself.

6:17 here's a cool project with some examples. it uses quil and jogl.

6:17 https://github.com/quephird/nehe-quil

6:17 dublindan: Hey, I'm having trouble with compojure routes.. can someone help me out a bit?

6:18 dcunit3d: but it has some windows-specific dependencies in the project.clj

6:18 dublindan what kind of problems?

6:19 dublindan: dcunit3d: I'm using luminus in case it matters. If I run the template code, it works fine, but when I change it I can't load anything other than /

6:19 It doesn't fall through to the not-found handler, it just doesn't load anything

6:20 dcunit3d: is there anyway to list the routes that are configured?

6:20 dublindan: I don't know, I'm not familiar enough with ring/compojure yet..

6:23 Hmm, odd, I just started a new blank project and added a new route and that worked.. guess I need to tinker more, must have broke something somewhere :-/

6:24 dcunit3d: neither am i, haven't done webdev with clojure yet

6:25 dublindan: I used compojure about two years ago and had no problems, but haven't really used it since and been away from clojure for almost a year.. so very much not up to speed anymore

6:27 weird, I think its working now, but I did not change anything

6:27 must be a configuration thing then

7:04 Does anybody know how to use Enlive's auto-reloading? Placing (net.cgrand.reload/auto-reload *ns*) into the file with my templates in it doesn't work.

7:26 klrr_: okey, this question might seem a bit crazy, but since i found monadic streaming IO (http://richhickey.github.io/clojure-contrib/monadic-io-streams-api.html) is there any library that provides similar monadic IO as haskell or is that one too dependent on haskell's type system?

7:45 mklappstuhl: hey there

7:46 I'm just arguing with a friend over using keywords vs strings as keys in maps

7:48 or not only in maps but as property of an object type we have in our application

7:50 It's the ticker of stock symbols. in some places (maps with ticker symbols as keys) it makes things easier to have them as symbols instead of strings but on the other hand I feel like making them keywords increases complexity and could introduce wierd conversions here and there

7:51 cark: keywords are good as keys, when you need to use them in your code. On the other hand, if it's data, you might want to keep them as string

7:53 for instance it's cool to have databse fields as keywords, because you use these in your code

7:56 but i wouldn't keywordize customer names or customer ids

7:58 lutra: khm, hi?

9:05 wakeup: Hi

9:06 Somebody familiar with the cllojure.java.jdbc API? I am wondering is there is a way to open a connection, reuse it and manually close it afterwards.

9:07 joegallo: it's just a java.sql.Connection, so... yes

9:08 https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj#L753

9:08 call connection yourself, and then do your calls, too, but you'd have to deal with the binding of *db*

9:09 yedi: so for many of my views, I pull the current user from the session, however I want to test various views / fns from the repl

9:09 wakeup: joegallo: with-connection is deprecated. And how do I get a connection in the first place?

9:09 joegallo: don't pay attention to that

9:09 yedi: is there a preferred way to do this simply?

9:10 wakeup: joegallo: There is get-connection, which requires an existing open connection?

9:11 joegallo: with-connection, which i linked to, is calling get-connection

9:11 which takes a db-spec

9:11 utkarsh: How can I write a macro "q" which does this: (q (hello) (world)) == '((hello) (world)) ?

9:14 I mean such that (= '((hello) (world)) (q (hello) (world))) returns true

9:15 joegallo: (defmacro q [& body] `'~body)

9:16 utkarsh: joegallo: thanks!

9:16 joegallo: that said, what do you need it for, utkarsh?

9:17 i mean, what's the big difference between (q (hello)) and '((hello))?

9:17 utkarsh: joegallo: was just curious mainly

9:17 joegallo: k

9:18 i mean, for that matter, q is a built-in

9:18 it's called quote

9:18 ah, well, not quite

9:18 ,(quote (hello))

9:18 clojurebot: (hello)

9:18 joegallo: ,(quote (hello) (world))

9:18 clojurebot: (hello)

9:18 joegallo: yeah, small different there

9:18 utkarsh: joegallo: yep, that's why I was curious, quote was just returning the first param

9:33 TimMc: utkarsh: 'foo *is* (quote foo)

9:33 &''''''foo

9:33 lazybot: ⇒ (quote (quote (quote (quote (quote foo)))))

9:44 sm0ke: is possible to debug lisp code in the traditional way by setting breakpoints and stuff?

9:44 i dont find any ide which does that

9:51 wakeup: sm0ke: it's not very desirable, we have the REPL, STEP, and BREAK.

9:52 also TRACE

9:52 (I am talking in terms of CL, don't know what clojure's counterparts are)

9:52 sm0ke: wakeup: clojure has repl for sure

9:52 :P

9:53 wakeup: sm0ke: actually I wouldn't call that a REPL but you, something like it

9:53 s/you/yeah

9:53 sm0ke: wakeup: whats a repl?

9:54 wakeup: sm0ke: it involves not throwing java stack traces

9:54 conditions/restarts, the like

9:55 sm0ke: wakeup: so you mean to say that in common list you litter your code by writing (break) every where?

9:55 common lisp*

9:55 wakeup: Yo but you can use BREAK to set breakpoints.

10:29 pyykkis: hi. I'm planning to run a set of io limited operations parallel without need for coordination.

10:29 should i use futures or core.async go?

10:30 I'm not even interested about the results, operations write to a separate files as a side effect

10:39 jonasen: pyykkis: I'd go with futures

10:55 pyykkis: jonasen: any rationale? I'd love to learn. I made a quick spike and it seems with futures main thread is automatically waiting for thread pool to finish.

10:55 teemu_f: Hi, I'm struggling with learning map destructuring. Any good tutorials on that topic?

10:56 pyykkis: jonasen: with go blocks, i needed to set up a channel for coordinating main thread not to exit before go blocks are done.

10:57 teemu_f: If you can grab a book, here's the best tutorial i've found: http://www.clojurebook.com/

10:58 teemu_f: pyykkis: thanks, I already have it

10:58 pyykkis: teemu_f: here's a compact but through explanation http://clojure.org/special_forms#Special Forms--Binding Forms (Destructuring)

11:01 teemu_f: pyykkis: ok, I just have to practice more in repl :)

11:24 jonasen: pyykkis: I'm no expert, just seems like core.async is overkill... You could also look at pmap

11:24 `cbp: just map futures and then map deref over them

11:25 unless your collection is hundreds of items that works fine

11:25 jonasen: `cbp: It there were 100s of items, wouldn't pmap be a good choice?

11:26 arkh_: I haven't needed a clojure contrib library for a while - where is cond-let ?

11:26 `cbp: jonasen: you'd have to partition them

11:28 jonasen: i'd prolly go the core.async route on that though. It's hard for me to find a use case for pmap

11:44 faust45: hi guys

11:44 what is the best way to debug my app ?

11:44 from repl

12:27 tshauck: Hi, what would be a good way to go about applying a function to the first column in a vector of vectors (used to be a csv file)

12:32 `cbp: tshauck: apply map vector

12:32 tshauck: that transposes the matrix

12:32 er vector of vectors w/e

12:45 tshauck: `cbp: Ok, I'll give that a try... the big picture is I want to parse a date string in the first "column", then group by the month from the resulting date, and sum the second "column"

12:46 ruzu: does not knowing java hurt learning clojure? i really don't want to learn java. i fear for my soul. :'(

12:46 tshauck: `cbp: I'd like to get the rows as [date number] but maybe this isn't the best way to go about it?

12:52 jkj: hello android clojure developers

12:52 i have some trouble getting repl to run

12:52 the application starts though... should i start the repl someway from my app

12:54 `cbp: tshauck: you'll need to give an example I can't really help you when I'm just guessing

12:55 ruzu: plenty of people learn clojure without knowing java

12:56 ruzu: tchnomancy here previously that you only need to know clojures std lib to use clojure

12:56 said*

12:57 tshauck: ##(let [x [[1 2] [3 4]]] (apply map vector x))

12:57 lazybot: ⇒ ([1 3] [2 4])

12:57 coventry: ruzu: You end up picking up a lot of information about the java ecosystem by osmosis, but it doesn't seem to harmful when that happens on an as-needed basis.

12:58 tshauck: `cbp: heres and example of my data and a bit of a desc: https://gist.github.com/tshauck/6842961

13:03 `cbp: tshauck: something like this? https://www.refheap.com/19447

13:05 tshauck: `cbp: I think that get me going, thanks

13:26 teemu_f: I'd appreciate any help with this gist: https://gist.github.com/tfrisk/6841473

13:29 `cbp: teemu_f: doseq is for sideeffects like printing, and it returns nil. If you wanna return values from a collection use for instead of doseq

13:30 teemu_f: but for your use case i'd use filter

13:31 teemu_f: I was just thinking filters when I took a break..

13:31 sometimes you just have to stop staring your code

13:31 `cbp: teemu_f: just replace doseq with for and it should work

13:33 teemu_f: thanks, now I get a vector

13:34 coventry: What does mjolnir have to do with datomic?

13:34 teemu_f: maybe I'll call it a day and continue tomorrow with fresh brains..

13:38 coventry: Oh, I see. It's using datomic to track aspects of the program it's building.

13:52 dublindan: How do I get all permutations of pairs of two lists? Thought I saw a function for it earlier, but can't seem to remembr the name of it now..

13:55 ambrosebs: dublindan: list comprehension with `for`?

13:55 dublindan: ambrosebs: ok, thanks

14:19 bolted: Is it acceptable to ask for 4clojure help in here?

14:20 andyfingerhut: I'm pretty sure that is on topic

14:21 nDuff: bolted: there _used_ to be an explicit policy of "no project euler", but I don't think that's still the case. And, for that matter, I could be mixed up with #python.

14:21 Go ahead and ask, anyhow. :)

14:22 bolted: Okay, thank you :) I'm working on #28, "flatten a list." http://www.4clojure.com/problem/28

14:23 noonian: what have you tried so far?

14:25 bolted: Right now, the idea in my head is: define a function called my-flatten [xs], then 1) look at the first element, 2) If it's not a collection, conjoin (first xs) to (my-flatten (rest xs))

14:27 noonian: ok, that makes sense, what if it is a collection

14:28 bolted: if it is a collection, (conj (my-flatten (first xs)) (my-flatten (rest xs)))

14:29 But this always stack overflows, and 1) I'm not sure which branch is overflowing and 2) In my head, we should always hit the base case, where the first element isn't a collection

14:29 noonian: ah

14:30 gfredericks: how do you test if it's a collection?

14:30 bolted: (if (coll? (first xs)) ...)

14:30 gfredericks: ,(coll? nil)

14:30 clojurebot: false

14:30 gfredericks: k I don't know why it stack overflows then.

14:31 could you paste a full expression that stack overflows so we can look at it?

14:31 (refheap.com)

14:31 noonian: yeah, it sounds like your logic is pretty sound but the implementation might be flawed

14:31 bolted: Sure. Let me get it back to the state it was in before, I mangled it trying to debug it

14:34 andyfingerhut: ,(rest '(a))

14:34 clojurebot: ()

14:34 andyfingerhut: ,(coll? (rest '(a)))

14:34 clojurebot: true

14:34 andyfingerhut: ,(next '(a))

14:34 clojurebot: nil

14:35 noonian: (empty? nil)

14:35 ,(empty nil)

14:35 clojurebot: nil

14:35 noonian: ,(empty? nil)

14:35 clojurebot: true

14:36 bolted: https://www.refheap.com/19451

14:36 So this stack overflows on both my tests, but I'm not totally sure this is what I originally had

14:37 andyfingerhut: It stack overflows because of the combination of rest and coll? behavior shown above.

14:37 bolted: Oh, (rest '()) is also a collection.

14:38 noonian: your if is poorly nested I think

14:38 andyfingerhut: It is common to use (seq xs) to determine when you reach the end, before testing anything about the first element.

14:38 noonian: it is returning (conj (first x) (my-flatten (rest x))) in all cases

14:39 bolted: ,(seq '())

14:39 clojurebot: nil

14:39 andyfingerhut: i.e. try putting (if (seq xs) ...) around your current function.

14:39 er, your current function body

14:40 I'm not saying it will make the function completely correct, but it should eliminate the infinite regress

14:40 noonian: bolted: I think this is what you want, http://pastebin.com/iYSdWJgZ

14:41 bolted: you were closing your if on this line: (my-flatten (first x)) (my-flatten (rest x)))

14:41 and not concating them together

14:42 bolted: noonian: oh whaaaat. thank you, that's a silly mistake to make

14:43 andyfingerhut: You're right, it does eliminate the stack overflow

15:00 ruzu: i think the best thing about clojure ... is rich hickey's hair

15:04 rlb: So I think I am going to need to add some jni bits to a project -- is there a recommended way to handle that via lein, or would people tend to make it a separate java project?

15:05 TEttinger: I'm sorry, rlb.

15:05 there's also JNA if you want a bit less hassle and a bit less performance

15:06 https://github.com/Chouser/clojure-jna/ I think the readme is really outdated

15:07 rlb: TEttinger: right -- may end up being able to use jna, but I'd also like to know what if any recommendations people have for handling jni.

15:08 i.e. can it fit in with lein much at all, or should I just create artifact(s) via mvn/gradle/whatever.

15:08 etc.

15:08 TEttinger: http://www.paullegato.com/blog/jni-leiningen-native-path/ ?

15:10 sm0ke: llasram: there?

15:10 rlb: TEttinger: right, thanks -- I'd seen that, but if I read it correctly, that suggests a way to use existing jni jar/.so's with lein, but lein's not building them.

15:11 TEttinger: ah. JNI is confusing...

15:11 sm0ke: llasram: what do you think of using nippy in abracad for encoding and decoding binary data...its fater and more comprehensive

15:11 TEttinger: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L252 is a little more doc

15:11 what is nippy?

15:12 rlb: I'm guessing that the simplest thing would be to just build the artifacts separately, and then use that to access them from clojure, but I wasnted to check in case there was somethng I'd missed.

15:12 sm0ke: TEttinger: https://github.com/ptaoussanis/nippy

15:12 rlb: "wanted to check"

15:14 dav: user=> (def a '(+ 3 4)) ; -> #'user/a user=> (apply (first a) (rest a)) ; -> 4 ;; What's wrong?

15:15 gfredericks: dav: symbols are not functions

15:15 TEttinger: this is nice, sm0ke

15:16 gfredericks: well

15:16 actually they are

15:16 just not in the way you're expecting

15:16 riley526: Question: Is there a way to require and call a fn in a namespace inside of a let, given a string like "my.ns.whatever/func"? e.g. (let [myns (require-by-str "my.ns.whatever")] (call-fn-in-ns myns "func"))

15:16 gfredericks: ,('+ '{= 12, + 14})

15:16 clojurebot: 14

15:17 gfredericks: dav: ^

15:17 riley526: I don't know if that's a good example

15:17 dav: gfredericks: how is (3 4) = to { = 3, + 4 } though?

15:18 sm0ke: yea its pretty cool.. but i dont know about the awkward names nippy/thaw

15:18 gfredericks: riley526: (let [sym (read-string s), ns (-> sym namespace symbol)] (require ns) ((resolve sym) "some" "args"))

15:18 noonian: ,(apply '+ '(3 4))

15:18 clojurebot: 4

15:18 gfredericks: dav: it's not; I was trying to demonstrate what symbols do when you call them as functions

15:19 ,(apply '+ '(3 4 5 6 7))

15:19 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (5) passed to: Symbol>

15:19 noonian: ('+ 4)

15:19 dav: gfredericks: I understand I needed an eval now. But I don't understand why I got what I got..

15:19 noonian: ,('+ 4)

15:19 clojurebot: nil

15:19 sm0ke: its cooler than saying nippy/deserialize though

15:19 noonian: ('+ 4 5)

15:19 dav: gfredericks: it takes the second arg somehow?

15:19 noonian: ,('+ 4 5)

15:19 clojurebot: 5

15:19 noonian: what do symbols do when called as functions?

15:19 gfredericks: dav: the same reason you get ##(apply :+ ["foo" "bar"])

15:19 lazybot: ⇒ "bar"

15:19 gfredericks: symbols do the same thing keywords do

15:19 noonian: ah

15:20 dav: gfredericks: k thanks. not exactly the most intuitive feature of the language imho..

15:20 gfredericks: right you are

15:20 probably not often used either

15:21 riley526: gfredericks: ah, interesting... resolve is like ns-resolve, but it resolves all the way down to the fn...

15:21 TEttinger: ##(let [a [+ 3 4] b '(+ 3 4)] (str "vector: " (apply (first a) (rest a)) " list: " (apply (first b) (rest b))))

15:21 lazybot: ⇒ "vector: 7 list: 4"

15:21 riley526: gfredericks: great help, thanks!

15:21 TEttinger: that would have bit me too/

15:22 gfredericks: riley526: unless you're working on some kind of tooling, I'd avoid that kind of stuff though

15:22 if possible

15:23 TEttinger: good example

15:23 riley526: gfredericks: well I'm just toying around with the idea of stuffing a str representation of a function into a db and calling it later with some args, like a task queue or something

15:23 TEttinger: thanks. I've got a similar question to riley526

15:24 pandeiro: riley526: what are the drawbacks/gotchas to that approach? i was wondering about something similar myself for serializing fns

15:24 srruby: I want to use a jar file from within clojure. Is there a simple way to do this without learning maven?

15:24 riley526: pandeiro: I honestly don't know, haha. Just exploring right now.

15:24 TEttinger: https://github.com/Prismatic/hiphip is wonderful but doesn't work with AOT. I have my own AOT fork that is a complete hack but works. I want to clean mine up a bit so it can get merged into Prismatic's version.

15:24 riley526: pandeiro: I would love to know of other ways of accomplishing something similar.

15:25 TEttinger: https://github.com/Prismatic/hiphip/issues/1#issuecomment-23361820

15:25 pandeiro: riley526: yeah on the surface it seems like a simple, effective way to do it

15:25 TEttinger: I don't get macros quite yet.

15:25 riley526 there's also metadata holding a string representation of the source.

15:26 pandeiro: i was looking at the code for Prismatic's dommy cljs lib and the use of macros really baffled me...

15:26 TEttinger: (there can also be metadata I mean)

15:26 riley526: TEttinger: in the defn of the fn itself?

15:27 I feel weird about storing actual source code to be run later

15:27 TEttinger: riley526, I bet that would be a good usage for a macro. defn+

15:29 riley526, I was thinking you could have defn+ that acts like defn but stores the macro body as a string in metadata

15:29 *but also

15:29 riley526: gfredericks: given my use case, is there a better approach you would recommend?

15:30 nDuff: TEttinger: Someone's done that, actually.

15:30 TEttinger: nDuff, the defn with source in the fn as meta?

15:30 or hiphip with AOT?

15:30 nDuff: TEttinger: https://github.com/technomancy/serializable-fn/

15:31 riley526: nDuff: oh cool

15:32 TEttinger: damn under 25 lines...

15:33 dublindan: If I have a collection like [[:a 1] [:b 2] [:a 3] [:a 4] [:b 5]], does anyone have any suggestions for an easy way to turn that into a map like: {:a [1 3 4] :b [2 5]} ?

15:34 noonian: ,(into {} [[:a 1]])

15:34 clojurebot: {:a 1}

15:34 noonian: hmm

15:34 i'd use reduce

15:37 dublindan: yeah, playing with reduce now. Lemme see what I can do..

15:37 TEttinger: frequencies?

15:38 yeah, reduce.

15:38 dublindan: ,(reduce (fn [m x] (assoc m (first x) (conj ((first x) m) (second x)))) {} [[:a 1] [:b 2] [:a 3] [:a 4] [:b 5]])

15:38 clojurebot: {:b (5 2), :a (4 3 1)}

15:39 dublindan: ok, that works

15:40 TEttinger: seems useful, what's it for?

15:42 dublindan: Grouping results from a database query

15:43 TEttinger: ah.

15:46 dav: is there any rationale for why bindings and arglist use vector syntax (brackets) rather than parens or something else?

15:47 TEttinger: yes.

15:47 it stands out more, and it allows slightly faster random access

15:48 dav: TEttinger: what do you mean random access? these are actually treated as vectors under the hood?

15:48 TEttinger: yes

15:48 as opposed to lists

15:48 dav: hmm ok

15:48 thanks

15:52 gfredericks: I don't think random access has anything to do with it

15:53 they only exist at compile time

15:54 holo: i just thought about something "random", and can't find anything on the web: bindings for cobol..

15:55 does it make sense?

15:55 gfredericks: I'm thinking it's impossible to create a lazy seq that has some given metadata in each tail without creating my own version of the LazySeq class

16:00 TEttinger: so, I'm trying to get w01fe's example to work...

16:01 (defmacro import-vars [ns] `(do ~@(for [[sym qual] (ns-map ns)] (read-string (clojure.repl/source-fn qual))))) ;; this is what I have now.

16:01 I have no idea what ~@ does

16:01 nDuff: TEttinger: inside `(), `@ is an unsplice

16:02 TEttinger: ...see http://clojure.org/reader

16:02 err, ~@

16:08 ,`(one two ~@(for [k [1 2 3]] (str "key-" k)))

16:08 clojurebot: (sandbox/one sandbox/two "key-1" "key-2" "key-3")

16:08 nDuff: TEttinger: ^^ does that make it clearer?

16:08 TEttinger: ...compare to...

16:08 ,`(one two ~(for [k [1 2 3]] (str "key-" k)))

16:08 clojurebot: (sandbox/one sandbox/two ("key-1" "key-2" "key-3"))

16:09 TEttinger: uhhh yes I think

16:09 it puts the contents in the `() as opposed to nesting it

16:09 like apply

16:25 so, ns-interns returns a map of stuff like {lefts #'clojure.zip/lefts} . How do I get the var bit off of lefts, and only have the quoted qualified symbol?

16:26 noonian: ,`map

16:26 clojurebot: clojure.core/map

16:26 noonian: ,#'map

16:26 clojurebot: #'clojure.core/map

16:27 noonian: ,(symbol #'map)

16:27 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.String>

16:27 noonian: ,@#'map

16:27 clojurebot: #<core$map clojure.core$map@1645bda>

16:27 noonian: what do you want the symbol for?

16:27 ,(name #'map)

16:27 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to clojure.lang.Named>

16:28 TEttinger: it's really hard to explain. let me try to figure out where to start...

16:28 noonian: ,(quote #'map)

16:28 clojurebot: (var map)

16:29 TEttinger: So hiphip is a lib by prismatic that works fine at runtime when JITed. but when you AOT it, it tries to load the same namespace more than once, for every type they have implemented array stuff for.

16:30 https://github.com/Prismatic/hiphip/tree/master/src/hiphip everything but array loads type-impl, and only one should be imported.

16:30 but compile gets all of them

16:30 so I need to find a way to import type-impl into the current ns, basically

16:32 https://github.com/Prismatic/hiphip/blob/master/src/hiphip/double.clj see how it uses load? I don't think you can load it more than once.

16:32 in different namespaces

16:33 bobwilliams: hello

16:33 noonian: hmm idk much about aot compile issues

16:33 bobwilliams: what is the correct way to handle the case where you are reducing and encounter a nil?

16:33 user=> (reduce * [1 2 nil 4])

16:34 for example

16:34 right now i'm using a try / catch but not sure that's the best way

16:34 klrr_: is reduce like haskell's foldr?

16:34 noonian: threading macro and filter would be a nice way

16:34 (->> [1 2 nil 4] (filter identity) (reduce *))

16:34 ,(->> [1 2 nil 4] (filter identity) (reduce *))

16:34 clojurebot: 8

16:35 bobwilliams: awww

16:35 good idea

16:35 noonian: or

16:35 ,(reduce * (keep identity [1 2 nil 4])

16:35 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

16:35 noonian: ,(reduce * (keep identity [1 2 nil 4]))

16:35 clojurebot: 8

16:35 bobwilliams: perfect!

16:35 thanks so much noonian!

16:35 noonian: you're welcome!

16:44 that will also filter out falses btw

16:45 dav: Is it possible to, at runtime, examine a function's "code" and substitute certain expressions in it for another expression? I just read up a bit on macros and it didn't seem that obvious..

16:45 bobwilliams: gilbertw1, TEttinger, noonian: thanks again! https://github.com/bobwilliams/project-euler/blob/master/clojure/problem-11.clj

16:47 TEttinger: yay

16:48 noonian: dav: macro expansion happens at compile time, so you could examine constants in the code (or symbols that are macros) and substitute them with other code

16:49 ,(macroexpand or)

16:49 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/or, compiling:(NO_SOURCE_PATH:0:0)>

16:49 noonian: ,(macroexpand 'or)

16:49 clojurebot: or

16:49 noonian: ,(macroexpand '(or true false))

16:49 clojurebot: (let* [or__3943__auto__ true] (if or__3943__auto__ or__3943__auto__ (clojure.core/or false)))

16:50 noonian: so at compile time (or true false) gets substituted by those let and if expressions

16:50 ,(macroexpand '(or false))

16:50 clojurebot: false

16:51 noonian: ,(macroexpand '(or (= false true) true))

16:51 clojurebot: (let* [or__3943__auto__ (= false true)] (if or__3943__auto__ or__3943__auto__ (clojure.core/or true)))

16:52 pepijndevos: Any mathy people around? I'm trying to compute the speed of the wheels of a car making a turn.

16:52 dav: alright let me give of an example of what i'm trying to do, let's say I'm writing a function that gets some values from a key/value database storage. And I want to programmatically "scan" the function for what it needs and fetch the values from the db PRIOR to running the code of the function.

16:53 for instance (defn f [a b] (+ a b (dbValueGet "abc") (dbValueGet "def"))

16:53 I'd like to "scan" for dbValueGets and get the values prior to evaluating f

16:53 then I'd like to be able to "substitute" the values in once I decide to execute the code

16:54 is that something that would be possible?

16:54 TEttinger: yes, I think

16:54 noonian: hmm, I don't really understand the use case

16:54 TEttinger: ,(doc clojure.repl/source-fn)

16:54 clojurebot: "([x]); Returns a string of the source code for the given symbol, if it can find it. This requires that the symbol resolve to a Var defined in a namespace for which the .clj is in the classpath. Returns nil if it can't find the source. For most REPL usage, 'source' is more convenient. Example: (source-fn 'filter)"

16:55 noonian: but you could return say, a vector of the values, and another function which when called executes it with the values or something

16:56 (defn f [a b] (let [abc-val (dbValueGet "abc"), def-val (dbValueGet "def")] [[abc-val def-val] (fn [] (+ a b abc-val def-val))]))

16:57 dav: noonian: I want to avoid having to write every single function in my code base as a closure or something of that sort if possible.

16:58 TEttinger: you mean I would actually have to parse the code myself rather than manipulate it as a list?

16:59 noonian: you could write a macro that does that pattern for you

16:59 dav: my understanding is that lisp code is just lists.. why can't I just manipulate it as such?

16:59 TEttinger: dav: I am not the person to ask.

16:59 I'm pretty sure you can use macros for this...

16:59 dav: noonian: can a macro take a function, transform it, and return another one?

16:59 TEttinger: yes

17:00 ,(doc complement)

17:00 clojurebot: "([f]); Takes a fn f and returns a fn that takes the same arguments as f, has the same effects, if any, and returns the opposite truth value."

17:00 noonian: you would write a macro that expands into code that does that

17:00 dav: ok let me google a bit more on that you guys have given me a few buzz words to look for. thanks!

17:00 noonian: but you can write functions that do that also, and don't even need macros

17:01 pepijndevos: you could also write dbValueGet as a macro, that when provided with a literal value, expands into the value from the database.

17:01 dav: TEttinger: complement is just a trivial closure..

17:01 noonian: (defn complement [f] (fn [& args] (not (apply f args))))

17:01 TEttinger: yes.

17:01 but it does what you asked

17:02 ...kinda

17:02 dav: TEttinger: it doesn't modify the inside of f, it only changes the result of f.

17:02 pepijndevos: injecting the values can probably be done as you describe. what about scanning for the required database keys prior to running?

17:03 pepijndevos: what is the use case? Do you just want to get a list of all the keys?

17:05 dav: pepijndevos: that is one of the requirements

17:05 pepijndevos: I think if you get me on the way of doing that, I can probably figure out how to do the rest..

17:06 I was hoping for "ultimate flexibility" i.e. some function f is effectively a "list" and I would have loved to traverse it and manipulate it as such. I can't seem to find how to do that..

17:06 noonian: so, a macro is just a normal function whos return value is code

17:06 using defmacro instead of defn makes it run at compile time instead of runtime

17:07 but you can write functions that return code to, perhaps to be used from a macro

17:07 pepijndevos: (defmacro dbValueGet [key] (swap! all-keys conj key) `(dbValueGet* key))

17:07 that way it should fill the atom by just loading all the code… maybe

17:08 noonian: idk if that would work using an atom like that at compile time

17:09 dav: ok you're using some concepts I'm not yet familiar with pepijndevos (swap! and `)

17:09 assuming you define dbValueGet in this way

17:09 pepijndevos: alternatively you could just grep the code :D

17:09 dav: and f(a,b) in the way I did above

17:09 how do you write a function that looks at f and spits out the keys ("abc", "def") ?

17:10 maybe f needs to be a macro..

17:10 pepijndevos: you don't, dbValueGet will store them at macro-expansion time

17:10 dav: aaaaah.

17:10 noonian: yeah, I think you want f to be a macro

17:10 dav: cute.

17:10 pepijndevos: if it works...

17:11 dav: does it know "where it was called from" ?

17:11 i.e. which function needs what keys

17:11 noonian: so, earlier when you said you don't want to have to write all your code with clojures

17:12 you can make a macro that in the background creates those clojures and returns the appropriate thing so its clean to use

17:12 sorry, closures* :p

17:13 pepijndevos: https://www.refheap.com/19455

17:14 dav: I guess if you guys have the patience and interest, I should tell you more about the usecase. The idea is to implement a spreadsheet (Excel) like computation graph.

17:14 In a spreadsheet, cells depend on other cells output, and combine them with some function

17:15 pepijndevos: works! https://www.refheap.com/19456

17:15 dav: For instance, cell A1 could be "=A2*A3+A4"

17:15 And not only you want to be able to evaluate the cells and compute their results, you want to be able to manipulate the computation graph as such, see who depends on what, etc.

17:15 (without evaluating)(

17:17 pepijndevos: very nice. now is there a way to know that "b" is used in foo?

17:17 pepijndevos: maybe… macros have some magic properties

17:20 Does this math make any sense? https://www.refheap.com/19457

17:22 I think the radius/trail functions are okay, but the ratio is not okay.

17:22 AimHere: What angle is the 'angle' here, for the radius/trail functions?

17:24 Seems odd for symmetry reasons that the rear-wheel formula is X/tan when the front wheel formula is X/sin

17:28 dav: pepijndevos: ratio looks fine to me

17:29 pepijndevos: AimHere, it's the degrees that the fromt wheels are turned

17:31 AimHere, If you draw a triangle between the wheelbase and the point where the front wheel "intersects" the rear wheel. The idea is that sin will give you the length of the long side of the triangle, wile tan gives you the straight side. Which should be the distance from the rear wheels to the intersection point. Maybe...

17:32 I used this and some experimenataion: http://www.personal.psu.edu/njk909/turning_radius.JPG

17:32 well, not really that. I just took the center of the two wheels.

17:33 dav, at least I'm applying ratio twice now, which I don;t think is right...

17:33 dav: pepijndevos: are you at psu?

17:34 pepijndevos: psu?

17:34 dav: pepijndevos: http://www.personal.*psu*.edu/njk909/turning_radius.JPG

17:34 pepijndevos: thought maybe this was your page..

17:34 pepijndevos: no, just googled that

17:34 dav: ok

17:35 pepijndevos: the trail function is supposed to give the length of the bottom line in that picture.

17:35 I thought I might need to use that instead of radius, as the wheels are further inwards than the front wheels.

17:37 But the speed difference for the wheels seems to be to large

18:00 tshauck: Hi, is there a good way to apply two different functions to a map... I have (def j '({:a "1", :b "2013-01-01"} {:a "2", :b "2013-01-01"})) I'd like apply a function f to all the :a's and a function g to all the :b's

18:05 llasram: tshauck: Like? ##(map (juxt (comp dec :a) (comp inc :b)) [{:a 1, :b 2} {:a 3, :b 4}])

18:05 lazybot: ⇒ ([0 3] [2 5])

18:09 tshauck: llasram: ya, that seems to ahve the desired effect... I now just have to figure out what it does :)

18:09 or i guess how it works

18:09 llasram: ~juxt

18:09 clojurebot: if you think 'complement is great, wait till you see 'juxt

18:09 llasram: ~juxt

18:09 clojurebot: juxt is usually the right answer

18:09 llasram: That's the one I was looking for :-)

18:13 tshauck: so, if I understand this, comp combines the getting of they key with function that's applied then juxt will "chain" those function across the map... does that sound right?

18:20 llasram: Kind of. comp is function composition and juxt is function juxtaposition

18:21 comp creates a function which chains together multiple function, connecting return values to arguments

18:22 juxt creates a function which "simultaneously" applies multiple functions to the same argument, returning a vector of the results

18:31 akurilin: Is it bad tone to inject namespaces like timbre, clj-time, c.t.t in all of my namespaces? I use them almost everywhere

18:32 In project.clj, that is.

18:33 bordatoue: is there a way to iterate through more than one seq at a time, for example if I have [1 2 3] [4 5 6] [ 7 8 9] can I iterate through all the three seq and print [1,4,7] [2,5,8] [3,6,9]

18:35 llasram: bordatoue: `map` takes any number of seqs as arguments: ##(map vector [1 2 3] [4 5 6] [7 8 9])

18:35 lazybot: ⇒ ([1 4 7] [2 5 8] [3 6 9])

18:36 llasram: akurilin: Yeah, that's not really common / never seen it. If you want some automation, https://github.com/technomancy/slamhound/ can help you

18:36 bordatoue: llasram: what if I want to replace the seq with reading a line for three different files can I accomplish it using map

18:37 llasram: bordatoue: `line-seq` turns a reader into a seq of lines. pass three of those to `map` and you read a line from each file for each `map`d function call

18:37 bordatoue: llasram: thanks, I guess it will work with any lazy-seq then

18:38 llasram: For the most part, all seqs are created equal

18:41 dobry-den: akurilin: I had a case where I wanted all files in a namespace to have the same set of :require'd namespaces and for now just wrote a macro that (require '...) various files

18:41 akurilin: dobry-den, llasram , cool, thanks for the advice

18:49 dav: TEttinger / noonian / pepijndevos - Seems like the backquote operator does exactly what I want? Turns code into a list and I can manipulate it and then evaluate it.. If you didn't mention it I assume it was because there's something wrong with it?

18:49 TEttinger: I don't know what backquote does, but you're probably right.

18:50 ,(`(+ 1 2))

18:50 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn>

18:50 nightfly: ,`(+ 1 2)

18:50 clojurebot: (clojure.core/+ 1 2)

18:50 dav: super powerful no ?

18:50 nightfly: ,(let [hello :moo] `(+ 1 ~hello))

18:50 clojurebot: (clojure.core/+ 1 :moo)

18:51 nightfly: yup, even better when writing macros

18:53 dav: does anyone have a sense of performance hit if most if my code is "backquoted", modified programmatically, and only then executed?

18:53 I assume there's a one time code at macro-expansion time and then that's it?

18:53 s/code/cost/

18:53 yedi: so I have a few clojure fns, that create my elasticsearch index. I'm working on an ansible playbook to set it up. how should I go about doing that? is there an easy way to make a standalone script/jar that i can jsut run along with my webapps uberjar?

18:53 i mean i'm sure it's possible, but i'm not sure what the best methodology would be

19:01 ToxicFrog: I have an xml-seq. I want to get all of its content, concatenated, without tags - basically, recursively take the content of the root node, replace all nodes in the content vector with their content, and then concatenate. This sounds like something zipper should be able to do. Yes/no?

19:02 dnolen: dav: sounds like a horrible idea, eval compiles, there is no interpretation :)

19:07 arrdem: dnolen: true, but you can do code generation and eval at runtime..

19:07 dav: not that it's a good idea, but it can be done.

19:07 dnolen: arrdem: that is a good idea depending on the situtation

19:08 arrdem: dnolen: okay fair enough. I've yet to have to generate code that way, but I can imagine wanting to.

19:10 dnolen: arrdem: http://blog.getprismatic.com/blog/2013/5/1/graph-faster-abstractions-for-structured-computation

19:11 arrdem: dnolen: I mean... http://github.com/arrdem/sad

19:12 dnolen: instaparse too... :D

19:15 dav: dnolen: OMG. Graph is pretty much what I was trying to implement!!

19:17 dnolen: well maybe not exactly, but I'm trying to build a spreadsheet-style computation graph. I don't think I fully understand what Graph does.. but it seems like there are some similar ideas..

19:21 "But eval isn't evil in Clojure--there's no heavyweight construction of a compiler, no risk of mis-interpreting strings, just the same machinery we use to write macros." => seems like I was right to turn to Clojure for what I'm trying to do.

19:24 carif: is there a way to get tab completion in the clojure repl? I'm using 1.5.1

19:27 AimHere: carif > well I'm using emacs + nrepl and hitting tab does some completioning for me, but I don't know which bit of the puzzle is doing the completion

19:27 technomancy: carif: should work with `lein repl` too

19:28 carif: technomancy, lein repl! just tried it, works, cool

19:28 technomancy, ty

19:29 technomancy: sure

19:56 indigo: Weird, my REPL just crashed

20:20 dav: anyone uses vim fireplace? seems like it recompiles/reloads everything each time I Eval an expression. Isn't there a way to avoid that? it's slow..

20:22 llasram: dav: Have you launched a nREPL server (via `lein repl`) in another terminal first?

20:23 dav: IIRC, fireplace doesn't do that for you, and if it lacks an existing server to connect to, lanuches a new JVM to evaluate each form

20:23 dav: llasram: yes I have.

20:24 llasram: Oh well. I'm afraid there my ability to make suggestions ends

20:24 dav: llasram: but you're right, seems like this is what's going on

20:24 llasram: maybe it's not talking to it somehow.

20:32 looks like lein repl isn't creating a port file.. :(

20:33 llasram: Which version of Leiningen are you running? And which version of fireplace?

20:33 There was a change to the location of the port file somewhat recently

20:33 And just to double-check -- you are running Leiningen w/in a project, yes?

20:34 dav: llasram: lein 1.7.1-1ubuntu1

20:34 llasram: and latest git of fireplac

20:34 I don't see any port files in my whole project tree

20:35 llasram: Oh, yeah, that's an old old version of Leiningen

20:35 For doing development with Leiningen, I recommend following the instructions on https://github.com/technomancy/leiningen to install the most recent stable release

20:36 You'll find that much is broken if you aren't using a leiningen 2.x version

20:37 dav: argl

20:37 llasram: It's not bad

20:37 dav: I wish there was an ubuntu ppa

20:38 llasram: Nah. It's the same thing as how Leiningen itself downloads specific artifact versions from external Maven artifact repositories

20:38 You want to lock that stuff in packages for distribution

20:38 But for development, you want to use a specific release you manage, isolated from the operating system

20:40 dav: Downloading Leiningen to /home/david/.lein/self-installs/leiningen-2.3.3-standalone.jar now...

20:42 alright I'm up and running

20:44 llasram: works! Thanks for the help!!!

20:44 llasram: np! Glad it was so easy :-)

21:26 mullr: In some clojurescript code I'm working on, I'd like to see if I can use with-meta on a value. In regular clojure, this is simply (instance? clojure.lang.IObj value), since IObj is the home of with-meta. Clojurescript models this as the IWithMeta protocol, but since protocols aren't reified at runtime the instance test always returns false. Any ideas?

21:27 (and I just found the answer, after typing the question)

21:27 for posterity, that answer is to use satisfies?

22:15 dobry-den: Clojure101 question: Let's say you're processing a bunch of maps you get back from an API. like {:m 4, ...}. do you generally write one transformation that turns those maps into {:media-type :image, ...}.

22:16 Or do you write a (media-type _) function -- (media-type {:m 4 ...}) -> :image

22:18 llasram: ddima_: It depends?

22:18 er,

22:18 ^^ dobry-den

22:19 dobry-den: What would it tend to depend on?

22:20 llasram: Any number of things. Your question is kind of vague :-). If an existing API worked in terms of the original {:m 4} maps, I'd do the latter. If writing an entirely new layer, might do the former

22:23 dobry-den: Yeah, this is my own layer. I'm wondering how to organize the code in my own domain. The two options that stand out are transformating the maps add soon as they come in or writing functions that operate on the original maps. and never transform the maps.

22:23 mullr: llasram: I agree, that's a good way to think of it. I've found it valuable to have a standard data representation within a component, and to expose said data to other parts of the system via functions like (media-type _)

22:24 dobry-den: In an OO language, I would write my own wrapper class. Message.new({:m 4, :usr "chuck"}).media_type ;=> :image

22:27 mullr: dorby-den: I don't think that way of thinking is entirely wrong. Encapsulating data access via functions lets you make decisions later on about how to do it

22:28 A layer of indirection solves all problems! But the same set of decisions apply as to whether you need it or not.

22:30 In clojure, people tend to lean towards sharing generic data (maps, etc), and thinking hard about what exactly that data should look like. This works because there's just a few core data structures that are really good. But there are times you want to encapsulate the access as well.

22:31 /diatribe

22:48 bitemyapp: akurilin: around?

22:49 akurilin: bitemyapp, sup

22:49 bitemyapp: akurilin: what improvements/changes to bulwark did we discuss?

22:50 akurilin: I've got the email you sent, so there's at least a couple of things, but I wanted to make certain I'm aware of everything.

22:50 akurilin: Merging of map, overriding of 503 message, "work" variable name

22:51 bitemyapp: 503 message I'm down with. Pretty sure I explained "work" to you. I could just document it better.

22:51 akurilin: merging of map though?

22:52 akurilin: merge rather than or the config map

22:52 * bitemyapp nods

22:52 bitemyapp: Makes sense to me.

22:58 namccarty: Clojure is doing something to me that I don't understand, and that is making me scared. I can't figure out why it is throwing up an arity exception here: http://i.imgur.com/BSwJSgD.png

22:58 akurilin: bitemyapp, I was going to offer to PR but I'm completely swamped this weekend/week

22:58 bitemyapp: akurilin: it's already in my README and I'm charging ahead with it.

22:58 akurilin: okie dokie

22:58 bitemyapp: I'm generalizing the handlers into being part of the config.

22:58 I just needed to know what was what.

22:59 namccarty: Anyone with more experience with me understand what is happening there?

22:59 Or less experience, I don't discriminate

23:02 coventry: namccarty: Looks like the anon fn passed to reducing-and-map is being passed 1 arg when it expects 2.

23:02 llasram: namccarty: I don't know what `reducing-and-map` is, but it seems to expect a function of only 1 argument for it' first argument

23:03 coventry: namccarty: The error message is a little confusing, because it looks like it's talking about check-regions, when actually it's talking about check-regions$fn, the anon fn defined in it.

23:03 llasram: namccarty: The arity exception is for check-regions$fn, which means a fn defined w/in check-regions

23:04 coventry: jinx!

23:04 namccarty: coventry: Thanks, I just realized my mistake there, thought i was seeing an extra pair of square brackets and the error confused me

23:04 llasram: Geez

23:04 bitemyapp: has anybody here heard of a library called fusillade?

23:05 I just found something by that name chilling out in my test cases and I'm not really sure where it came from.

23:05 llasram: namccarty: And BTW, using a text-based paste service like refheap.com is usually preferred to a screenshot

23:05 bitemyapp: ...I think I wrote fusillade. n/m

23:05 akurilin: lol

23:05 llasram: bitemyapp: One of those days, huh?

23:05 coventry: namccarty: (require 'clojure.repl) (pst) would provide a more detailed stacktrace, which might have helped you see the problem faster.

23:06 namccarty: llasram: Thanks for clearing that up, I'm not used to clojures exceptions, I would have used pastebin or something, but my kde kept crashing when i tried to use my pastebin widget

23:06 bitemyapp: llasram: to my credit, I figured out it was my library because it had a good name.

23:06 llasram: I just started coding for the evening (1933 here) and I'm a bit...fuzzy.

23:06 namccarty: coventry: thanks for the tip, ill have to remember that when my next confusing error pops up

23:06 bitemyapp: I'm also on a break from caffeine.

23:07 ddellacosta: howdy

23:07 llasram: bitemyapp: Good luck with that. It's tough!

23:07 namccarty: also my kde kept crashing when i then decided to take a screen shot, i am mad at kde, but now my code works

23:07 so no i am less mad

23:07 chare: i'm back

23:07 ddellacosta: bitemyapp: yo

23:09 bitemyapp: llasram: Thanks. I'm doing okay so far with tylenol, exercise, and sleep.

23:09 paracetamol if you like.

23:18 akurilin: bulwark 0.0.4 is on Clojars. * 0.0.4 Merging of config maps for partial overrides, overriding of condition handlers, documenting "work" variable name, updated clj-time to new API

23:18 akurilin: is there anything you wanted for blackwater?

23:18 akurilin: bitemyapp, yay, thanks :)

23:18 bitemyapp: perhaps the "with-no-blackwater-logging" thingy?

23:18 akurilin: bitemyapp, you said that was better handled with robert hooke by the user,no?

23:19 although I guess people would have to implement their own helper method

23:19 over and over again

23:19 bitemyapp: akurilin: hum. I was making an immediate solution available and I would prefer users to understand that blackwater is ultimately just AOP via hooke, but a helper function is sensible.

23:22 akurilin: there's also a sticky pattern that robert-hooke does *not* handle that users might find annoying that I could take care of in blackwater.

23:22 namely, the with-hooks-disabled macro can only handle a single var at a time. The Korma stuff is a single var, but the JDBC stuff is not.

23:22 akurilin: ah

23:23 bitemyapp: this is kinda something I want anyway :)

23:23 So you lucked out - I wanna fix this anyway before I go back to working on Simonides.

23:34 chare: lets talk about stupid stuff

23:34 because we are all stupid

23:35 that means you are stupid

23:37 coventry: chare: Since you like graphics programming, you should watch http://www.infoq.com/presentations/Clojure-LLVM Presenter gets 100-fold speed-up on computation of mandelbrot set by changing out his LLVM backend to target his GPU.

23:37 chare: coventry are you going to work on starcraft clone if i watch it

23:38 bitemyapp: technomancy: ^^

23:51 chare: I need to buy a new computer

23:51 what parts do you recommend

23:53 bitemyapp: chare: this is #clojure - you should look into reddit for your needs.

23:54 chare: where in reddit

23:54 namccarty: r/buildapc is nice

23:55 right1: isn't intel's new cpu line coming out soon

Logging service provided by n01se.net