#clojure logs

2013-10-05

00:15bjaugh, ported codebase to latest cljs and core.async, promptly found out that specljs makes use of cljs.core.format
00:21chareI return
00:22frozenlockI 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?
00:25xeqifrozenlock: are you port forwarding?
00:25frozenlockI can, yes.
00:26xeqialso, are you looking for a proxy server to point to B ?
00:27frozenlockYes.
00:27frozenlockWell "A" should become a proxy.
00:27frozenlockI wonder if it's possible to incoporate it in the compojure framework however...
00:28frozenlocksay current "A" url---> /some-url/hello and then the "B" /welcome/item1. When passing throught A ---> /some-url/hello/welcome/item1
00:29frozenlockAm I crazy? :p
00:30xeqifrozenlock: possibly. 1) Is the ssh access for security? 2) Does "B" use any absolute url's in it's html/js/css ?
00:31frozenlock1) 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.
00:35xeqifrozenlock: 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
00:37frozenlockOh 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.
00:38xeqiassuming I understand your problem correctly, yes
00:39frozenlockI think you do, and your solution makes perfect sense, thanks :D
00:41frozenlockAnd 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.
00:42xeqifrozenlock: 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)
00:42frozenlockIn short, pretty much.
00:53frozenlockWow... I wasn't expecting to find something like that for clojure o_O https://github.com/hugoduncan/clj-ssh
01:59sm0keis there a variant of assert which return the expression value instead of nil?
02:01ambrosebssm0ke: you'll probably need to write your own
02:05sm0keambrosebs: got it i defined assert# .. dont know what else to call it (defn assert# [n] (assert n) n)
02:29mullrsm0ke: how about 'non-nil'? (+ a (non-nil (do-something)))
02:30sm0ke,(doc non-nil)
02:30clojurebotHuh?
02:33muhoo,non-nil?
02:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: non-nil? in this context, compiling:(NO_SOURCE_PATH:0:0)>
02:33muhoo,nik?
02:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: nik? in this context, compiling:(NO_SOURCE_PATH:0:0)>
02:33muhoo,nil?
02:33clojurebot#<core$nil_QMARK_ clojure.core$nil_QMARK_@c18ba8>
02:41mullrsm0ke: Sorry, I mean as a different name for the function you wrote and called 'asset#'
02:46mullr('assert#', rather)
03:01dcunit3dgot a question for using quil (processing for clojure)
03:02dcunit3dso i've got a project that uses incanter
03:02dcunit3dand incanter includes charts that allow you to graph functions and data easily
03:02dcunit3dbut it doesn't allow you to work with images very easily.
03:03dcunit3dso i'm looking at either using seesaw (swing) or quil (processing)
03:03dcunit3di've explored a little with both, but i'm trying to double buffer the images i'm adding.
03:05dcunit3dquil 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.
03:06dcunit3dwill 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?
03:17dusty_colhi
03:17dusty_colQ: 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
03:18TEttingerhey dusty_col. ##(apply str [\A \B \C])
03:18lazybot⇒ "ABC"
03:18TEttinger(apply str [\A \B \C]) is what you're after
03:18dusty_col*looks up apply*
03:19TEttingerapply takes a function and a collection, and uses the collection as args to the function.
03:19dusty_colsweet, that's what i was looking for. thx!
03:19TEttinger,(apply + [1 2 3 4 5])
03:19clojurebot15
03:19dusty_col,(println "Thanks")
03:19clojurebotThanks\n
03:19TEttingerhaha np
03:19TEttingernext up: map and reduce
03:25dusty_collol yea i am doing exercism.io
03:25dusty_colhad to loop over string and replace chars
03:25dusty_colwith loop/recur
03:25dusty_color that's how i did it anyways
03:26TEttingerthere's also clojure.string/replace: ##(doc clojure.string/replace)
03:26lazybot⇒ "([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."
03:26dusty_colwell that's a little too easy, i think the point of the exercise is learning how to recurse
03:27TEttinger,(clojure.string/replace "Chicken" \C \T)
03:27clojurebot"Thicken"
03:28TEttingeryeah, recursion is important too
03:28frozenlockI think I had to recurse 2 or 3 times total :-/
03:28frozenlockMust be doing something wrong...
03:28frozenlock*I
03:28TEttingernope, frozenlock
03:28TEttingeryou shouldn't need to do it often, but all the standard lib is built around it
03:29TEttingerso it just helps to be able to read code using it
03:29frozenlockgreat :)
03:29frozenlockIt's also a pain to write, IMO :p
03:29TEttingerindeed.
03:29TEttingerespecially compared to more declarative stuff like map
03:29dusty_colso i'm trying to get a job at a clojure shop
03:29dusty_colbut i can barely write hello world
03:30TEttinger4clojure!
03:30dusty_colwhat is a good roadmap to get up to speed? topics & projects wise
03:30dusty_colTEttinger: I find 4clojure confusing, I often don't udnerstand the questions. Some are helpful.
03:30TEttingerthey
03:30TEttingerthey're meant to be kinda obtuse I think
03:30TEttingerto make you come at the problem from multiple angles
03:31dusty_cola buddy suggested something like arithmetic, strings, control structures, functions, io, little web app..
03:31TEttingerlearning the standard FP stuff is most important in the long run. it also depends on those things.
03:32TEttingerso... map, reduce, apply, into, comp, potentially juxt, how lazyseqs work...
03:32TEttingerprobably in around that order, juxt and comp are just cool stuff
03:33TEttingerbut not needed
03:33TEttingeroh, filter too
03:33TEttingerfilter is easy enough
03:34TEttinger,(filter (fn [item] (> 10 item)) [1 2 3 4 5 10 11 12])
03:34clojurebot(1 2 3 4 5)
03:34frozenlockdusty_col: just don't "(map #(some-fn %) [1 2 3])" like I did for like a month :p
03:35dusty_colfrozenlock: why not, what's wrong with map
03:35TEttingernothing
03:35TEttingerit's the #(some-fn %)
03:35TEttingerwhich is the same as some-fn
03:35TEttingerjust slower
03:36dusty_coloh
03:36frozenlockand more verbose
03:36frozenlockfor absolutely nothing
03:36dusty_coloh he's making a closure to call the function with it's parameter?
03:36dusty_coli might understand ;)
03:36TEttingeryes, which is what the function name on its own does already
03:37TEttinger,(time (map #(inc %) [1 2 3]))
03:37clojurebot"Elapsed time: 0.121924 msecs"\n(2 3 4)
03:37TEttinger,(time (map inc [1 2 3]))
03:37clojurebot"Elapsed time: 0.035407 msecs"\n(2 3 4)
03:37sverihi, 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)
03:39TEttinger(fn [x] ((comp first reverse) x))
03:39TEttingercomp returns a function
03:39TEttingeryou want to call the function I think
03:40TEttingerbut why not use last?
03:40TEttinger,(last '(1 2 3))
03:40clojurebot3
03:41TEttingersveri?
03:42chareguys here is my update on my progress
03:42chareI'm reading http://www.arcsynthesis.org/gltut/Positioning/Tut04%20Perspective%20Projection.html
03:42charewhats your guys progress on starcraft clone project?
03:44chareTettinger update on your project please?
03:44sveriTEttinger: ah, that works, thank you very much
03:44TEttingerno prob
03:44TEttingercomp is tricky, I only recently started using it. it's nice
03:45sveriTEttinger i am doing the 4clojure tasks and looked for some different solutions
03:45TEttingerah.
03:45frozenlockditto. I don't use it often however... mostly only to reduce the number of parens.
03:45TEttingerthere's also #(nth % (dec (count %))) I believe
03:46sveriTEttinger yea, and a recur version which i like most
03:47sveri(fn [[x & xs]] (if xs) recur xs) x), however, i wonder why i need two [[ instead of one [? do you know that?
03:47TEttingerit's a destructuring
03:48TEttingerit really takes one arg, but converts it to the head x and the & rest as a sequence xs
03:48sveriTEttinger ok, i guess i understand that
03:50TEttingerso if you did with one [
03:52TEttinger(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
03:53TEttingergah that wasn't very clear
03:55sveriTEttinger but i think i got it
03:55sveri:-)
03:58frozenlockWasn't there someone trying to implement TCO for clojure?
04:15charelets talk about something
04:15charei'm bored
04:16jonasenfrozenlock: https://github.com/cjfrisz/clojure-tco
04:20frozenlockjonasen: last commit 11 months ago :-/
04:20frozenlockSo it's not getting inside clojure.core I assume...
04:21jonasentco will not get into core before java supports it
04:26carkjonasen: that's to say ..never
04:27carkso annoying =(
04:27jonasencark: that's probably the case
05:14dcunit3ddoes anyone have experience working with BufferedImages or graphics and clojure
05:18chareuse opengl
05:35TEttingerdcunit3d, some, what's up?
05:37TEttinger(BufferedImage. 50 50 BufferedImage/TYPE_4BYTE_ABGR) ;; is a line in some font drawing code i have
05:37dcunit3di'm trying to display handwritten digit data in images, using seesaw (swing) or quil (processing)
05:38TEttingerdisplay and just display, or save as png or something?
05:38dcunit3di want to display them on a JPanel or something
05:39dcunit3dbut i want to read in 100 digits and display them as they are being processed
05:39TEttingerok.
05:39TEttingerwhy an image?
05:39TEttingercan't you use swing fields?
05:40dcunit3di've read the image data into the program and so i'm trying to display it
05:41TEttingerok, in swing it shouldn't be hard. let me look it up
05:41TEttingerwhat kind of data is it? just a vector?
05:41TEttingervector of bufferedImages?
05:41dcunit3di also want to display the hidden layer's of the neural network, so you can see them as they change.
05:42dcunit3dthe data i've reading in is just a persistent vector, containing 784x1 vectors each representing an image
05:43dcunit3deach image is 28x28, but they are unrolled
05:44dcunit3di 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.
05:45dcunit3dbut that requires instantiating a 100 PImage objects, and then I'm worried about memory consumption.
05:45TEttingerHAHAHAHAHAA Oracle Enterprise Search is temporarily unavailable.
05:45TEttingerWHAT
05:45dcunit3dlol
05:45charedcunit3d: just use opengl
05:46dcunit3dwhat libraries are available for it? there's penumbra, but it hasn't been updated in a while
05:46TEttingerhttp://www.docjar.com/docs/api/java/awt/image/BufferedImage.html
05:47TEttingerso what digit data is this
05:47TEttingeris it just 0-9?
05:47TEttingeror fingers?
05:47dcunit3dhttp://yann.lecun.com/exdb/mnist/
05:47dcunit3d0-9
05:48TEttingerohhhhh
05:48dcunit3di used gloss to parse the binary data. and i'm planning on using incanter to process the data.
05:48TEttingerI thought you meant number data, you mean images of numbers made by hand... that makes sense now
05:49dcunit3dhttps://github.com/dcunited001/handwritten-digits/blob/master/src/handwritten_digits/draw.clj
05:49TEttingerso if someone types 99999, it should show 5 different writing styles of "9"?
05:50dcunit3dbasically 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.
05:51dcunit3dso it's handwritten digit recognition.
05:51TEttingerah.
05:51dcunit3di don't really need graphics, but it'd be cooler if it did
05:52TEttingerof course!
05:52TEttingerso you want to draw...
05:53dcunit3dyeh, 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.
05:54dcunit3dor i'm trying to figure out the best way to split up the data processing and the images.
05:54TEttingerI don't really know how I can help yet...
05:54charedcunit3d: just use opengl through JOGL
05:54TEttingersorry.
05:57dcunit3dthanks anyways
05:57dcunit3di'm not sure i'm asking the right thing
05:59chareopengl...
05:59charenot hard...
06:01TEttingerdcunit3d, it sounds like a cool program though
06:10dcunit3dchare: are there any good examples of working with images in JOGL?
06:10chareyou do the usual opengl stuff nothing special
06:11dcunit3di've never done opengl stuff
06:12TEttingerdcunit3d: it looks like you're mostly doing close-to-the-metal graphics stuff
06:13TEttingermaybe you could do this with just seesaw, I dunno
06:13TEttingercan you take the code you posted and make a gist or something that has some possible things to fill in later?
06:14dcunit3dyeh, ill do that
06:14charedcunit3d 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
06:15dcunit3dlol
06:15dcunit3di'm trying to get some advice. i want to write it myself.
06:17dcunit3dhere's a cool project with some examples. it uses quil and jogl.
06:17dcunit3dhttps://github.com/quephird/nehe-quil
06:17dublindanHey, I'm having trouble with compojure routes.. can someone help me out a bit?
06:18dcunit3dbut it has some windows-specific dependencies in the project.clj
06:18dcunit3ddublindan what kind of problems?
06:19dublindandcunit3d: 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 /
06:19dublindanIt doesn't fall through to the not-found handler, it just doesn't load anything
06:20dcunit3dis there anyway to list the routes that are configured?
06:20dublindanI don't know, I'm not familiar enough with ring/compojure yet..
06:23dublindanHmm, 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 :-/
06:24dcunit3dneither am i, haven't done webdev with clojure yet
06:25dublindanI 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
06:27dublindanweird, I think its working now, but I did not change anything
06:27dublindanmust be a configuration thing then
07:04dublindanDoes 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.
07:26klrr_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?
07:45mklappstuhlhey there
07:46mklappstuhlI'm just arguing with a friend over using keywords vs strings as keys in maps
07:48mklappstuhlor not only in maps but as property of an object type we have in our application
07:50mklappstuhlIt'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
07:51carkkeywords 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
07:53carkfor instance it's cool to have databse fields as keywords, because you use these in your code
07:56carkbut i wouldn't keywordize customer names or customer ids
07:58lutrakhm, hi?
09:05wakeupHi
09:06wakeupSomebody 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.
09:07joegalloit's just a java.sql.Connection, so... yes
09:08joegallohttps://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj#L753
09:08joegallocall connection yourself, and then do your calls, too, but you'd have to deal with the binding of *db*
09:09yediso for many of my views, I pull the current user from the session, however I want to test various views / fns from the repl
09:09wakeupjoegallo: with-connection is deprecated. And how do I get a connection in the first place?
09:09joegallodon't pay attention to that
09:09yediis there a preferred way to do this simply?
09:10wakeupjoegallo: There is get-connection, which requires an existing open connection?
09:11joegallowith-connection, which i linked to, is calling get-connection
09:11joegallowhich takes a db-spec
09:11utkarshHow can I write a macro "q" which does this: (q (hello) (world)) == '((hello) (world)) ?
09:14utkarshI mean such that (= '((hello) (world)) (q (hello) (world))) returns true
09:15joegallo(defmacro q [& body] `'~body)
09:16utkarshjoegallo: thanks!
09:16joegallothat said, what do you need it for, utkarsh?
09:17joegalloi mean, what's the big difference between (q (hello)) and '((hello))?
09:17utkarshjoegallo: was just curious mainly
09:17joegallok
09:18joegalloi mean, for that matter, q is a built-in
09:18joegalloit's called quote
09:18joegalloah, well, not quite
09:18joegallo,(quote (hello))
09:18clojurebot(hello)
09:18joegallo,(quote (hello) (world))
09:18clojurebot(hello)
09:18joegalloyeah, small different there
09:18utkarshjoegallo: yep, that's why I was curious, quote was just returning the first param
09:33TimMcutkarsh: 'foo *is* (quote foo)
09:33TimMc&''''''foo
09:33lazybot⇒ (quote (quote (quote (quote (quote foo)))))
09:44sm0keis possible to debug lisp code in the traditional way by setting breakpoints and stuff?
09:44sm0kei dont find any ide which does that
09:51wakeupsm0ke: it's not very desirable, we have the REPL, STEP, and BREAK.
09:52wakeupalso TRACE
09:52wakeup(I am talking in terms of CL, don't know what clojure's counterparts are)
09:52sm0kewakeup: clojure has repl for sure
09:52sm0ke:P
09:53wakeupsm0ke: actually I wouldn't call that a REPL but you, something like it
09:53wakeups/you/yeah
09:53sm0kewakeup: whats a repl?
09:54wakeupsm0ke: it involves not throwing java stack traces
09:54wakeupconditions/restarts, the like
09:55sm0kewakeup: so you mean to say that in common list you litter your code by writing (break) every where?
09:55sm0kecommon lisp*
09:55wakeupYo but you can use BREAK to set breakpoints.
10:29pyykkishi. I'm planning to run a set of io limited operations parallel without need for coordination.
10:29pyykkisshould i use futures or core.async go?
10:30pyykkisI'm not even interested about the results, operations write to a separate files as a side effect
10:39jonasenpyykkis: I'd go with futures
10:55pyykkisjonasen: 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:55teemu_fHi, I'm struggling with learning map destructuring. Any good tutorials on that topic?
10:56pyykkisjonasen: with go blocks, i needed to set up a channel for coordinating main thread not to exit before go blocks are done.
10:57pyykkisteemu_f: If you can grab a book, here's the best tutorial i've found: http://www.clojurebook.com/
10:58teemu_fpyykkis: thanks, I already have it
10:58pyykkisteemu_f: here's a compact but through explanation http://clojure.org/special_forms#Special Forms--Binding Forms (Destructuring)
11:01teemu_fpyykkis: ok, I just have to practice more in repl :)
11:24jonasenpyykkis: I'm no expert, just seems like core.async is overkill... You could also look at pmap
11:24`cbpjust map futures and then map deref over them
11:25`cbpunless your collection is hundreds of items that works fine
11:25jonasen`cbp: It there were 100s of items, wouldn't pmap be a good choice?
11:26arkh_I haven't needed a clojure contrib library for a while - where is cond-let ?
11:26`cbpjonasen: you'd have to partition them
11:28`cbpjonasen: i'd prolly go the core.async route on that though. It's hard for me to find a use case for pmap
11:44faust45hi guys
11:44faust45what is the best way to debug my app ?
11:44faust45from repl
12:27tshauckHi, 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`cbptshauck: apply map vector
12:32`cbptshauck: that transposes the matrix
12:32`cbper vector of vectors w/e
12:45tshauck`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:46ruzudoes not knowing java hurt learning clojure? i really don't want to learn java. i fear for my soul. :'(
12:46tshauck`cbp: I'd like to get the rows as [date number] but maybe this isn't the best way to go about it?
12:52jkjhello android clojure developers
12:52jkji have some trouble getting repl to run
12:52jkjthe application starts though... should i start the repl someway from my app
12:54`cbptshauck: you'll need to give an example I can't really help you when I'm just guessing
12:55`cbpruzu: plenty of people learn clojure without knowing java
12:56`cbpruzu: tchnomancy here previously that you only need to know clojures std lib to use clojure
12:56`cbpsaid*
12:57`cbptshauck: ##(let [x [[1 2] [3 4]]] (apply map vector x))
12:57lazybot⇒ ([1 3] [2 4])
12:57coventryruzu: 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:58tshauck`cbp: heres and example of my data and a bit of a desc: https://gist.github.com/tshauck/6842961
13:03`cbptshauck: something like this? https://www.refheap.com/19447
13:05tshauck`cbp: I think that get me going, thanks
13:26teemu_fI'd appreciate any help with this gist: https://gist.github.com/tfrisk/6841473
13:29`cbpteemu_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`cbpteemu_f: but for your use case i'd use filter
13:31teemu_fI was just thinking filters when I took a break..
13:31teemu_fsometimes you just have to stop staring your code
13:31`cbpteemu_f: just replace doseq with for and it should work
13:33teemu_fthanks, now I get a vector
13:34coventryWhat does mjolnir have to do with datomic?
13:34teemu_fmaybe I'll call it a day and continue tomorrow with fresh brains..
13:38coventryOh, I see. It's using datomic to track aspects of the program it's building.
13:52dublindanHow 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:55ambrosebsdublindan: list comprehension with `for`?
13:55dublindanambrosebs: ok, thanks
14:19boltedIs it acceptable to ask for 4clojure help in here?
14:20andyfingerhutI'm pretty sure that is on topic
14:21nDuffbolted: 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:21nDuffGo ahead and ask, anyhow. :)
14:22boltedOkay, thank you :) I'm working on #28, "flatten a list." http://www.4clojure.com/problem/28
14:23noonianwhat have you tried so far?
14:25boltedRight 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:27noonianok, that makes sense, what if it is a collection
14:28boltedif it is a collection, (conj (my-flatten (first xs)) (my-flatten (rest xs)))
14:29boltedBut 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:29noonianah
14:30gfrederickshow do you test if it's a collection?
14:30bolted(if (coll? (first xs)) ...)
14:30gfredericks,(coll? nil)
14:30clojurebotfalse
14:30gfredericksk I don't know why it stack overflows then.
14:31gfrederickscould you paste a full expression that stack overflows so we can look at it?
14:31gfredericks(refheap.com)
14:31noonianyeah, it sounds like your logic is pretty sound but the implementation might be flawed
14:31boltedSure. Let me get it back to the state it was in before, I mangled it trying to debug it
14:34andyfingerhut,(rest '(a))
14:34clojurebot()
14:34andyfingerhut,(coll? (rest '(a)))
14:34clojurebottrue
14:34andyfingerhut,(next '(a))
14:34clojurebotnil
14:35noonian(empty? nil)
14:35noonian,(empty nil)
14:35clojurebotnil
14:35noonian,(empty? nil)
14:35clojurebottrue
14:36boltedhttps://www.refheap.com/19451
14:36boltedSo this stack overflows on both my tests, but I'm not totally sure this is what I originally had
14:37andyfingerhutIt stack overflows because of the combination of rest and coll? behavior shown above.
14:37boltedOh, (rest '()) is also a collection.
14:38noonianyour if is poorly nested I think
14:38andyfingerhutIt is common to use (seq xs) to determine when you reach the end, before testing anything about the first element.
14:38noonianit is returning (conj (first x) (my-flatten (rest x))) in all cases
14:39bolted,(seq '())
14:39clojurebotnil
14:39andyfingerhuti.e. try putting (if (seq xs) ...) around your current function.
14:39andyfingerhuter, your current function body
14:40andyfingerhutI'm not saying it will make the function completely correct, but it should eliminate the infinite regress
14:40noonianbolted: I think this is what you want, http://pastebin.com/iYSdWJgZ
14:41noonianbolted: you were closing your if on this line: (my-flatten (first x)) (my-flatten (rest x)))
14:41noonianand not concating them together
14:42boltednoonian: oh whaaaat. thank you, that's a silly mistake to make
14:43boltedandyfingerhut: You're right, it does eliminate the stack overflow
15:00ruzui think the best thing about clojure ... is rich hickey's hair
15:04rlbSo 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:05TEttingerI'm sorry, rlb.
15:05TEttingerthere's also JNA if you want a bit less hassle and a bit less performance
15:06TEttingerhttps://github.com/Chouser/clojure-jna/ I think the readme is really outdated
15:07rlbTEttinger: 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:08rlbi.e. can it fit in with lein much at all, or should I just create artifact(s) via mvn/gradle/whatever.
15:08rlbetc.
15:08TEttingerhttp://www.paullegato.com/blog/jni-leiningen-native-path/ ?
15:10sm0kellasram: there?
15:10rlbTEttinger: 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:11TEttingerah. JNI is confusing...
15:11sm0kellasram: what do you think of using nippy in abracad for encoding and decoding binary data...its fater and more comprehensive
15:11TEttingerhttps://github.com/technomancy/leiningen/blob/master/sample.project.clj#L252 is a little more doc
15:11TEttingerwhat is nippy?
15:12rlbI'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:12sm0keTEttinger: https://github.com/ptaoussanis/nippy
15:12rlb"wanted to check"
15:14davuser=> (def a '(+ 3 4)) ; -> #'user/a user=> (apply (first a) (rest a)) ; -> 4 ;; What's wrong?
15:15gfredericksdav: symbols are not functions
15:15TEttingerthis is nice, sm0ke
15:16gfrederickswell
15:16gfredericksactually they are
15:16gfredericksjust not in the way you're expecting
15:16riley526Question: 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:16gfredericks,('+ '{= 12, + 14})
15:16clojurebot14
15:17gfredericksdav: ^
15:17riley526I don't know if that's a good example
15:17davgfredericks: how is (3 4) = to { = 3, + 4 } though?
15:18sm0keyea its pretty cool.. but i dont know about the awkward names nippy/thaw
15:18gfredericksriley526: (let [sym (read-string s), ns (-> sym namespace symbol)] (require ns) ((resolve sym) "some" "args"))
15:18noonian,(apply '+ '(3 4))
15:18clojurebot4
15:18gfredericksdav: it's not; I was trying to demonstrate what symbols do when you call them as functions
15:19gfredericks,(apply '+ '(3 4 5 6 7))
15:19clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (5) passed to: Symbol>
15:19noonian('+ 4)
15:19davgfredericks: I understand I needed an eval now. But I don't understand why I got what I got..
15:19noonian,('+ 4)
15:19clojurebotnil
15:19sm0keits cooler than saying nippy/deserialize though
15:19noonian('+ 4 5)
15:19davgfredericks: it takes the second arg somehow?
15:19noonian,('+ 4 5)
15:19clojurebot5
15:19noonianwhat do symbols do when called as functions?
15:19gfredericksdav: the same reason you get ##(apply :+ ["foo" "bar"])
15:19lazybot⇒ "bar"
15:19gfrederickssymbols do the same thing keywords do
15:19noonianah
15:20davgfredericks: k thanks. not exactly the most intuitive feature of the language imho..
15:20gfredericksright you are
15:20gfredericksprobably not often used either
15:21riley526gfredericks: ah, interesting... resolve is like ns-resolve, but it resolves all the way down to the fn...
15:21TEttinger##(let [a [+ 3 4] b '(+ 3 4)] (str "vector: " (apply (first a) (rest a)) " list: " (apply (first b) (rest b))))
15:21lazybot⇒ "vector: 7 list: 4"
15:21riley526gfredericks: great help, thanks!
15:21TEttingerthat would have bit me too/
15:22gfredericksriley526: unless you're working on some kind of tooling, I'd avoid that kind of stuff though
15:22gfredericksif possible
15:23gfredericksTEttinger: good example
15:23riley526gfredericks: 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:23TEttingerthanks. I've got a similar question to riley526
15:24pandeiroriley526: what are the drawbacks/gotchas to that approach? i was wondering about something similar myself for serializing fns
15:24srrubyI want to use a jar file from within clojure. Is there a simple way to do this without learning maven?
15:24riley526pandeiro: I honestly don't know, haha. Just exploring right now.
15:24TEttingerhttps://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:24riley526pandeiro: I would love to know of other ways of accomplishing something similar.
15:25TEttingerhttps://github.com/Prismatic/hiphip/issues/1#issuecomment-23361820
15:25pandeiroriley526: yeah on the surface it seems like a simple, effective way to do it
15:25TEttingerI don't get macros quite yet.
15:25TEttingerriley526 there's also metadata holding a string representation of the source.
15:26pandeiroi was looking at the code for Prismatic's dommy cljs lib and the use of macros really baffled me...
15:26TEttinger(there can also be metadata I mean)
15:26riley526TEttinger: in the defn of the fn itself?
15:27riley526I feel weird about storing actual source code to be run later
15:27TEttingerriley526, I bet that would be a good usage for a macro. defn+
15:29TEttingerriley526, I was thinking you could have defn+ that acts like defn but stores the macro body as a string in metadata
15:29TEttinger*but also
15:29riley526gfredericks: given my use case, is there a better approach you would recommend?
15:30nDuffTEttinger: Someone's done that, actually.
15:30TEttingernDuff, the defn with source in the fn as meta?
15:30TEttingeror hiphip with AOT?
15:30nDuffTEttinger: https://github.com/technomancy/serializable-fn/
15:31riley526nDuff: oh cool
15:32TEttingerdamn under 25 lines...
15:33dublindanIf 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:34noonian,(into {} [[:a 1]])
15:34clojurebot{:a 1}
15:34noonianhmm
15:34nooniani'd use reduce
15:37dublindanyeah, playing with reduce now. Lemme see what I can do..
15:37TEttingerfrequencies?
15:38TEttingeryeah, reduce.
15:38dublindan,(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:38clojurebot{:b (5 2), :a (4 3 1)}
15:39dublindanok, that works
15:40TEttingerseems useful, what's it for?
15:42dublindanGrouping results from a database query
15:43TEttingerah.
15:46davis there any rationale for why bindings and arglist use vector syntax (brackets) rather than parens or something else?
15:47TEttingeryes.
15:47TEttingerit stands out more, and it allows slightly faster random access
15:48davTEttinger: what do you mean random access? these are actually treated as vectors under the hood?
15:48TEttingeryes
15:48TEttingeras opposed to lists
15:48davhmm ok
15:48davthanks
15:52gfredericksI don't think random access has anything to do with it
15:53gfredericksthey only exist at compile time
15:54holoi just thought about something "random", and can't find anything on the web: bindings for cobol..
15:55holodoes it make sense?
15:55gfredericksI'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:00TEttingerso, I'm trying to get w01fe's example to work...
16:01TEttinger(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:01TEttingerI have no idea what ~@ does
16:01nDuffTEttinger: inside `(), `@ is an unsplice
16:02nDuffTEttinger: ...see http://clojure.org/reader
16:02nDufferr, ~@
16:08nDuff,`(one two ~@(for [k [1 2 3]] (str "key-" k)))
16:08clojurebot(sandbox/one sandbox/two "key-1" "key-2" "key-3")
16:08nDuffTEttinger: ^^ does that make it clearer?
16:08nDuffTEttinger: ...compare to...
16:08nDuff,`(one two ~(for [k [1 2 3]] (str "key-" k)))
16:08clojurebot(sandbox/one sandbox/two ("key-1" "key-2" "key-3"))
16:09TEttingeruhhh yes I think
16:09TEttingerit puts the contents in the `() as opposed to nesting it
16:09TEttingerlike apply
16:25TEttingerso, 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:26noonian,`map
16:26clojurebotclojure.core/map
16:26noonian,#'map
16:26clojurebot#'clojure.core/map
16:27noonian,(symbol #'map)
16:27clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.String>
16:27noonian,@#'map
16:27clojurebot#<core$map clojure.core$map@1645bda>
16:27noonianwhat do you want the symbol for?
16:27noonian,(name #'map)
16:27clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to clojure.lang.Named>
16:28TEttingerit's really hard to explain. let me try to figure out where to start...
16:28noonian,(quote #'map)
16:28clojurebot(var map)
16:29TEttingerSo 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:30TEttingerhttps://github.com/Prismatic/hiphip/tree/master/src/hiphip everything but array loads type-impl, and only one should be imported.
16:30TEttingerbut compile gets all of them
16:30TEttingerso I need to find a way to import type-impl into the current ns, basically
16:32TEttingerhttps://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:32TEttingerin different namespaces
16:33bobwilliamshello
16:33noonianhmm idk much about aot compile issues
16:33bobwilliamswhat is the correct way to handle the case where you are reducing and encounter a nil?
16:33bobwilliamsuser=> (reduce * [1 2 nil 4])
16:34bobwilliamsfor example
16:34bobwilliamsright now i'm using a try / catch but not sure that's the best way
16:34klrr_is reduce like haskell's foldr?
16:34noonianthreading macro and filter would be a nice way
16:34noonian(->> [1 2 nil 4] (filter identity) (reduce *))
16:34noonian,(->> [1 2 nil 4] (filter identity) (reduce *))
16:34clojurebot8
16:35bobwilliamsawww
16:35bobwilliamsgood idea
16:35noonianor
16:35noonian,(reduce * (keep identity [1 2 nil 4])
16:35clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
16:35noonian,(reduce * (keep identity [1 2 nil 4]))
16:35clojurebot8
16:35bobwilliamsperfect!
16:35bobwilliamsthanks so much noonian!
16:35noonianyou're welcome!
16:44noonianthat will also filter out falses btw
16:45davIs 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:45bobwilliamsgilbertw1, TEttinger, noonian: thanks again! https://github.com/bobwilliams/project-euler/blob/master/clojure/problem-11.clj
16:47TEttingeryay
16:48nooniandav: 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:49noonian,(macroexpand or)
16:49clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/or, compiling:(NO_SOURCE_PATH:0:0)>
16:49noonian,(macroexpand 'or)
16:49clojurebotor
16:49noonian,(macroexpand '(or true false))
16:49clojurebot(let* [or__3943__auto__ true] (if or__3943__auto__ or__3943__auto__ (clojure.core/or false)))
16:50noonianso at compile time (or true false) gets substituted by those let and if expressions
16:50noonian,(macroexpand '(or false))
16:50clojurebotfalse
16:51noonian,(macroexpand '(or (= false true) true))
16:51clojurebot(let* [or__3943__auto__ (= false true)] (if or__3943__auto__ or__3943__auto__ (clojure.core/or true)))
16:52pepijndevosAny mathy people around? I'm trying to compute the speed of the wheels of a car making a turn.
16:52davalright 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:53davfor instance (defn f [a b] (+ a b (dbValueGet "abc") (dbValueGet "def"))
16:53davI'd like to "scan" for dbValueGets and get the values prior to evaluating f
16:53davthen I'd like to be able to "substitute" the values in once I decide to execute the code
16:54davis that something that would be possible?
16:54TEttingeryes, I think
16:54noonianhmm, I don't really understand the use case
16:54TEttinger,(doc clojure.repl/source-fn)
16:54clojurebot"([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:55noonianbut you could return say, a vector of the values, and another function which when called executes it with the values or something
16:56noonian(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:57davnoonian: 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:58davTEttinger: you mean I would actually have to parse the code myself rather than manipulate it as a list?
16:59noonianyou could write a macro that does that pattern for you
16:59davmy understanding is that lisp code is just lists.. why can't I just manipulate it as such?
16:59TEttingerdav: I am not the person to ask.
16:59TEttingerI'm pretty sure you can use macros for this...
16:59davnoonian: can a macro take a function, transform it, and return another one?
16:59TEttingeryes
17:00TEttinger,(doc complement)
17:00clojurebot"([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:00noonianyou would write a macro that expands into code that does that
17:00davok let me google a bit more on that you guys have given me a few buzz words to look for. thanks!
17:00noonianbut you can write functions that do that also, and don't even need macros
17:01pepijndevosyou could also write dbValueGet as a macro, that when provided with a literal value, expands into the value from the database.
17:01davTEttinger: complement is just a trivial closure..
17:01noonian(defn complement [f] (fn [& args] (not (apply f args))))
17:01TEttingeryes.
17:01TEttingerbut it does what you asked
17:02TEttinger...kinda
17:02davTEttinger: it doesn't modify the inside of f, it only changes the result of f.
17:02davpepijndevos: injecting the values can probably be done as you describe. what about scanning for the required database keys prior to running?
17:03pepijndevoswhat is the use case? Do you just want to get a list of all the keys?
17:05davpepijndevos: that is one of the requirements
17:05davpepijndevos: I think if you get me on the way of doing that, I can probably figure out how to do the rest..
17:06davI 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:06noonianso, a macro is just a normal function whos return value is code
17:06noonianusing defmacro instead of defn makes it run at compile time instead of runtime
17:07noonianbut you can write functions that return code to, perhaps to be used from a macro
17:07pepijndevos(defmacro dbValueGet [key] (swap! all-keys conj key) `(dbValueGet* key))
17:07pepijndevosthat way it should fill the atom by just loading all the code… maybe
17:08noonianidk if that would work using an atom like that at compile time
17:09davok you're using some concepts I'm not yet familiar with pepijndevos (swap! and `)
17:09davassuming you define dbValueGet in this way
17:09pepijndevosalternatively you could just grep the code :D
17:09davand f(a,b) in the way I did above
17:09davhow do you write a function that looks at f and spits out the keys ("abc", "def") ?
17:10davmaybe f needs to be a macro..
17:10pepijndevosyou don't, dbValueGet will store them at macro-expansion time
17:10davaaaaah.
17:10noonianyeah, I think you want f to be a macro
17:10davcute.
17:10pepijndevosif it works...
17:11davdoes it know "where it was called from" ?
17:11davi.e. which function needs what keys
17:11noonianso, earlier when you said you don't want to have to write all your code with clojures
17:12noonianyou can make a macro that in the background creates those clojures and returns the appropriate thing so its clean to use
17:12nooniansorry, closures* :p
17:13pepijndevoshttps://www.refheap.com/19455
17:14davI 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:14davIn a spreadsheet, cells depend on other cells output, and combine them with some function
17:15pepijndevosworks! https://www.refheap.com/19456
17:15davFor instance, cell A1 could be "=A2*A3+A4"
17:15davAnd 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:15dav(without evaluating)(
17:17davpepijndevos: very nice. now is there a way to know that "b" is used in foo?
17:17pepijndevosmaybe… macros have some magic properties
17:20pepijndevosDoes this math make any sense? https://www.refheap.com/19457
17:22pepijndevosI think the radius/trail functions are okay, but the ratio is not okay.
17:22AimHereWhat angle is the 'angle' here, for the radius/trail functions?
17:24AimHereSeems odd for symmetry reasons that the rear-wheel formula is X/tan when the front wheel formula is X/sin
17:28davpepijndevos: ratio looks fine to me
17:29pepijndevosAimHere, it's the degrees that the fromt wheels are turned
17:31pepijndevosAimHere, 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:32pepijndevosI used this and some experimenataion: http://www.personal.psu.edu/njk909/turning_radius.JPG
17:32pepijndevoswell, not really that. I just took the center of the two wheels.
17:33pepijndevosdav, at least I'm applying ratio twice now, which I don;t think is right...
17:33davpepijndevos: are you at psu?
17:34pepijndevospsu?
17:34davpepijndevos: http://www.personal.*psu*.edu/njk909/turning_radius.JPG
17:34davpepijndevos: thought maybe this was your page..
17:34pepijndevosno, just googled that
17:34davok
17:35pepijndevosthe trail function is supposed to give the length of the bottom line in that picture.
17:35pepijndevosI thought I might need to use that instead of radius, as the wheels are further inwards than the front wheels.
17:37pepijndevosBut the speed difference for the wheels seems to be to large
18:00tshauckHi, 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:05llasramtshauck: Like? ##(map (juxt (comp dec :a) (comp inc :b)) [{:a 1, :b 2} {:a 3, :b 4}])
18:05lazybot⇒ ([0 3] [2 5])
18:09tshauckllasram: ya, that seems to ahve the desired effect... I now just have to figure out what it does :)
18:09tshauckor i guess how it works
18:09llasram~juxt
18:09clojurebotif you think 'complement is great, wait till you see 'juxt
18:09llasram~juxt
18:09clojurebotjuxt is usually the right answer
18:09llasramThat's the one I was looking for :-)
18:13tshauckso, 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:20llasramKind of. comp is function composition and juxt is function juxtaposition
18:21llasramcomp creates a function which chains together multiple function, connecting return values to arguments
18:22llasramjuxt creates a function which "simultaneously" applies multiple functions to the same argument, returning a vector of the results
18:31akurilinIs it bad tone to inject namespaces like timbre, clj-time, c.t.t in all of my namespaces? I use them almost everywhere
18:32akurilinIn project.clj, that is.
18:33bordatoueis 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:35llasrambordatoue: `map` takes any number of seqs as arguments: ##(map vector [1 2 3] [4 5 6] [7 8 9])
18:35lazybot⇒ ([1 4 7] [2 5 8] [3 6 9])
18:36llasramakurilin: Yeah, that's not really common / never seen it. If you want some automation, https://github.com/technomancy/slamhound/ can help you
18:36bordatouellasram: what if I want to replace the seq with reading a line for three different files can I accomplish it using map
18:37llasrambordatoue: `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:37bordatouellasram: thanks, I guess it will work with any lazy-seq then
18:38llasramFor the most part, all seqs are created equal
18:41dobry-denakurilin: 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:41akurilindobry-den, llasram , cool, thanks for the advice
18:49davTEttinger / 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:49TEttingerI don't know what backquote does, but you're probably right.
18:50TEttinger,(`(+ 1 2))
18:50clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn>
18:50nightfly,`(+ 1 2)
18:50clojurebot(clojure.core/+ 1 2)
18:50davsuper powerful no ?
18:50nightfly,(let [hello :moo] `(+ 1 ~hello))
18:50clojurebot(clojure.core/+ 1 :moo)
18:51nightflyyup, even better when writing macros
18:53davdoes anyone have a sense of performance hit if most if my code is "backquoted", modified programmatically, and only then executed?
18:53davI assume there's a one time code at macro-expansion time and then that's it?
18:53davs/code/cost/
18:53yediso 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:53yedii mean i'm sure it's possible, but i'm not sure what the best methodology would be
19:01ToxicFrogI 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:02dnolendav: sounds like a horrible idea, eval compiles, there is no interpretation :)
19:07arrdemdnolen: true, but you can do code generation and eval at runtime..
19:07arrdemdav: not that it's a good idea, but it can be done.
19:07dnolenarrdem: that is a good idea depending on the situtation
19:08arrdemdnolen: okay fair enough. I've yet to have to generate code that way, but I can imagine wanting to.
19:10dnolenarrdem: http://blog.getprismatic.com/blog/2013/5/1/graph-faster-abstractions-for-structured-computation
19:11arrdemdnolen: I mean... http://github.com/arrdem/sad
19:12arrdemdnolen: instaparse too... :D
19:15davdnolen: OMG. Graph is pretty much what I was trying to implement!!
19:17davdnolen: 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:21dav"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:24carifis there a way to get tab completion in the clojure repl? I'm using 1.5.1
19:27AimHerecarif > 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:27technomancycarif: should work with `lein repl` too
19:28cariftechnomancy, lein repl! just tried it, works, cool
19:28cariftechnomancy, ty
19:29technomancysure
19:56indigoWeird, my REPL just crashed
20:20davanyone 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:22llasramdav: Have you launched a nREPL server (via `lein repl`) in another terminal first?
20:23llasramdav: 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:23davllasram: yes I have.
20:24llasramOh well. I'm afraid there my ability to make suggestions ends
20:24davllasram: but you're right, seems like this is what's going on
20:24davllasram: maybe it's not talking to it somehow.
20:32davlooks like lein repl isn't creating a port file.. :(
20:33llasramWhich version of Leiningen are you running? And which version of fireplace?
20:33llasramThere was a change to the location of the port file somewhat recently
20:33llasramAnd just to double-check -- you are running Leiningen w/in a project, yes?
20:34davllasram: lein 1.7.1-1ubuntu1
20:34davllasram: and latest git of fireplac
20:34davI don't see any port files in my whole project tree
20:35llasramOh, yeah, that's an old old version of Leiningen
20:35llasramFor doing development with Leiningen, I recommend following the instructions on https://github.com/technomancy/leiningen to install the most recent stable release
20:36llasramYou'll find that much is broken if you aren't using a leiningen 2.x version
20:37davargl
20:37llasramIt's not bad
20:37davI wish there was an ubuntu ppa
20:38llasramNah. It's the same thing as how Leiningen itself downloads specific artifact versions from external Maven artifact repositories
20:38llasramYou want to lock that stuff in packages for distribution
20:38llasramBut for development, you want to use a specific release you manage, isolated from the operating system
20:40davDownloading Leiningen to /home/david/.lein/self-installs/leiningen-2.3.3-standalone.jar now...
20:42davalright I'm up and running
20:44davllasram: works! Thanks for the help!!!
20:44llasramnp! Glad it was so easy :-)
21:26mullrIn 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:27mullr(and I just found the answer, after typing the question)
21:27mullrfor posterity, that answer is to use satisfies?
22:15dobry-denClojure101 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:16dobry-denOr do you write a (media-type _) function -- (media-type {:m 4 ...}) -> :image
22:18llasramddima_: It depends?
22:18llasramer,
22:18llasram^^ dobry-den
22:19dobry-denWhat would it tend to depend on?
22:20llasramAny 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:23dobry-denYeah, 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:23mullrllasram: 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:24dobry-denIn an OO language, I would write my own wrapper class. Message.new({:m 4, :usr "chuck"}).media_type ;=> :image
22:27mullrdorby-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:28mullrA layer of indirection solves all problems! But the same set of decisions apply as to whether you need it or not.
22:30mullrIn 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:31mullr/diatribe
22:48bitemyappakurilin: around?
22:49akurilinbitemyapp, sup
22:49bitemyappakurilin: what improvements/changes to bulwark did we discuss?
22:50bitemyappakurilin: 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:50akurilinMerging of map, overriding of 503 message, "work" variable name
22:51bitemyapp503 message I'm down with. Pretty sure I explained "work" to you. I could just document it better.
22:51bitemyappakurilin: merging of map though?
22:52akurilinmerge rather than or the config map
22:52bitemyappMakes sense to me.
22:58namccartyClojure 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:58akurilinbitemyapp, I was going to offer to PR but I'm completely swamped this weekend/week
22:58bitemyappakurilin: it's already in my README and I'm charging ahead with it.
22:58akurilinokie dokie
22:58bitemyappI'm generalizing the handlers into being part of the config.
22:58bitemyappI just needed to know what was what.
22:59namccartyAnyone with more experience with me understand what is happening there?
22:59namccartyOr less experience, I don't discriminate
23:02coventrynamccarty: Looks like the anon fn passed to reducing-and-map is being passed 1 arg when it expects 2.
23:02llasramnamccarty: 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:03coventrynamccarty: 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:03llasramnamccarty: The arity exception is for check-regions$fn, which means a fn defined w/in check-regions
23:04llasramcoventry: jinx!
23:04namccartycoventry: Thanks, I just realized my mistake there, thought i was seeing an extra pair of square brackets and the error confused me
23:04llasramGeez
23:04bitemyapphas anybody here heard of a library called fusillade?
23:05bitemyappI just found something by that name chilling out in my test cases and I'm not really sure where it came from.
23:05llasramnamccarty: And BTW, using a text-based paste service like refheap.com is usually preferred to a screenshot
23:05bitemyapp...I think I wrote fusillade. n/m
23:05akurilinlol
23:05llasrambitemyapp: One of those days, huh?
23:05coventrynamccarty: (require 'clojure.repl) (pst) would provide a more detailed stacktrace, which might have helped you see the problem faster.
23:06namccartyllasram: 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:06bitemyappllasram: to my credit, I figured out it was my library because it had a good name.
23:06bitemyappllasram: I just started coding for the evening (1933 here) and I'm a bit...fuzzy.
23:06namccartycoventry: thanks for the tip, ill have to remember that when my next confusing error pops up
23:06bitemyappI'm also on a break from caffeine.
23:07bitemyappddellacosta: howdy
23:07llasrambitemyapp: Good luck with that. It's tough!
23:07namccartyalso my kde kept crashing when i then decided to take a screen shot, i am mad at kde, but now my code works
23:07namccartyso no i am less mad
23:07charei'm back
23:07ddellacostabitemyapp: yo
23:09bitemyappllasram: Thanks. I'm doing okay so far with tylenol, exercise, and sleep.
23:09bitemyappparacetamol if you like.
23:18bitemyappakurilin: 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:18bitemyappakurilin: is there anything you wanted for blackwater?
23:18akurilinbitemyapp, yay, thanks :)
23:18bitemyappperhaps the "with-no-blackwater-logging" thingy?
23:18akurilinbitemyapp, you said that was better handled with robert hooke by the user,no?
23:19akurilinalthough I guess people would have to implement their own helper method
23:19akurilinover and over again
23:19bitemyappakurilin: 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:22bitemyappakurilin: 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:22bitemyappnamely, 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:22akurilinah
23:23bitemyappthis is kinda something I want anyway :)
23:23bitemyappSo you lucked out - I wanna fix this anyway before I go back to working on Simonides.
23:34charelets talk about stupid stuff
23:34charebecause we are all stupid
23:35charethat means you are stupid
23:37coventrychare: 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:37charecoventry are you going to work on starcraft clone if i watch it
23:38bitemyapptechnomancy: ^^
23:51chareI need to buy a new computer
23:51charewhat parts do you recommend
23:53bitemyappchare: this is #clojure - you should look into reddit for your needs.
23:54charewhere in reddit
23:54namccarty r/buildapc is nice
23:55right1isn't intel's new cpu line coming out soon