2012-11-13
| 00:00 | amalloy | dangit, brainproxy, it's hard to even tell you what filterM's arg/return types are without haskell type notation, and iirc you don't know any haskell |
| 00:01 | Raynes | Give him a less in Haskell type signatures. |
| 00:01 | Raynes | It isn't that hard. |
| 00:02 | Raynes | lesson |
| 00:03 | amalloy | well, filterM has type: filterM :: (a -> m Bool) -> [a] -> m [a]. so it takes a list of Things, and a way to turn a Thing into a boolean wrapped in a monadic value, and produces a list of Things wrapped in a monadic value |
| 00:04 | Raynes | Don't quit your day job. |
| 00:04 | amalloy | choke on a bucket of slugs |
| 00:06 | mattmoss | amalloy: He doesn't know Haskell. He's also on the phone at the moment, so give him a few to get back to you. |
| 00:07 | amalloy | are you two in the same room? |
| 00:08 | mattmoss | He's in the next room, but his voice isn't... soft. ;) |
| 00:08 | ToxicFrog | I'm saving "choke on a bucket of slugs" for later, thanks. |
| 00:11 | amalloy | ToxicFrog: well, i toned it down a bit for #clojure. google for sebastian droge if you're interested in the original |
| 00:11 | ToxicFrog | I'm familiar with the original, but I like this version |
| 00:12 | amalloy | enjoy, then! |
| 00:12 | Raynes | That's strange. |
| 00:12 | Raynes | mattmoss: Where are you people? |
| 00:13 | mattmoss | Raynes: brainproxy and I share an apartment. In fact, I work for him. St Louis |
| 00:13 | Raynes | That's pretty hot. |
| 00:13 | Raynes | I mean, cool. |
| 00:13 | mattmoss | o_O |
| 00:16 | Raynes | mattmoss: Are you wanting to stop reading after you get to a certain line? |
| 00:16 | Raynes | Also, sorry for the innuendo. I'm that kind of person. |
| 00:17 | mattmoss | Raynes: I want to start up a server, see that a certain line of output has passed (to know the server is fully initialized), run some other code against the server, then send input to the server/process to cleanly shutdown the process. |
| 00:17 | mattmoss | Raynes: No worries. ;) |
| 00:18 | mattmoss | Raynes: I'm trying let-programs, but I get the same results... it's basically hanging in there somewhere. If I add :background, then the program returns a future immediately, but that future never realizes. |
| 00:18 | Raynes | Reason I was asking is because conch.sh will always consume all output and will hold it in memory, so you have to be careful if it's going to be dumping a lot of stuff you don't care about. You don't have to read it all, but it stays in memory until you do. |
| 00:19 | Raynes | It's hanging with {:seq true}? |
| 00:19 | Raynes | If so, are you doing this at the repl and trying to print the seq? |
| 00:20 | mattmoss | Yes to hanging with :seq true. Yes, at repl. |
| 00:21 | mattmoss | As to consuming output... there shouldn't be too much, and I can deal with that. |
| 00:22 | mattmoss | I'll try to not dump the seq to the repl immediately, see if it doesn't hang. |
| 00:23 | mattmoss | Okay, ya, that seems like the issue. |
| 00:23 | Raynes | Yeah, if you try to print the seq you wont see any output at all until the whole program is done. |
| 00:23 | Raynes | You can do something like (take 2 ..). |
| 00:23 | mattmoss | Right.... |
| 00:24 | mattmoss | Cool, looks good. I'll rewrite my stuff using that and try the whole again. Thanks! |
| 00:25 | brainproxy | mattmoss: are you listening to my phone conversations again?? |
| 00:25 | lazybot | brainproxy: What are you, crazy? Of course not! |
| 00:25 | brainproxy | for shame |
| 00:25 | mattmoss | I have a love/hate relationship with laziness. :) |
| 00:25 | Raynes | Hope it works. If not, open an issue with some code that breaks and I'll try to sort it out. |
| 00:25 | mattmoss | brainproxy: Yes. Yes I am. I can't help not. |
| 00:26 | mattmoss | Raynes: Thanks. |
| 00:26 | brainproxy | amalloy: no worries, tbh filterM is a bit of distraction at this moment, but I'll get to it |
| 00:26 | brainproxy | Raynes: i agree, i need to learn me some Haskell |
| 00:26 | Raynes | brainproxy: Haskell was my first language, but I hadn't used it until a week ago for like 4 years. So much fun now that I'm not stupid. |
| 00:26 | Raynes | s/stupid/as stupid/ |
| 00:26 | brainproxy | in fact, I've started in on the "learn you a haskell..." book, but still in the early parts of the book |
| 00:27 | Raynes | I skipped to the typeclass chapter and read up through monads. |
| 00:27 | Raynes | I'm like king of the Haskells now. |
| 00:27 | brainproxy | :p |
| 00:28 | Raynes | Look, I wrote some JSON parsing code that makes use of applicative functors and liftM: https://www.refheap.com/paste/6612 |
| 00:28 | Raynes | Obviously I win all future contests. |
| 00:31 | mattmoss | get-drunk, lol |
| 00:40 | brainproxy | so satisfies? is only for protocols? is there a similar test for interfaces? |
| 00:43 | dnolen | brainproxy: instance? |
| 00:43 | brainproxy | instance? is the way to go? |
| 00:43 | brainproxy | dnolen: cool, thanks |
| 00:43 | dnolen | brainproxy: satisfies? is also a performance killer on Clojure JVM - use wisely. |
| 00:44 | brainproxy | dnolen: there use will only come into effect when a certain runtime flag is set |
| 00:44 | brainproxy | i.e. one which is for dev purposes, not prod code |
| 00:44 | brainproxy | so should be okay |
| 00:44 | brainproxy | but thanks for the tip |
| 00:56 | Raynes | mattmoss: Bahaha, I suck at names. |
| 00:56 | mattmoss | lol |
| 00:58 | mattmoss | So... one last Q. It seems that the lazy-seq of the process output can't be released until the process is finished, correct? Because of the queue-stream stuff.... |
| 00:59 | Raynes | Released? |
| 00:59 | mattmoss | So,... I can (take 5 ...) to get the first five lines, but a subsequent (take 5 ...) will get me those same 5 lines. |
| 00:59 | Raynes | Yes, of course. It isn't a queue. |
| 00:59 | Raynes | There is a queue underneath the hood. I should probably expose it somehow, if I don't already. |
| 01:00 | mattmoss | Right. Just making sure my head is on straight. |
| 01:00 | mattmoss | I'm using the :verbose option so I can feed the input and shut the process down cleanly. |
| 01:01 | mattmoss | Whiel still watching the output |
| 01:01 | Raynes | FWIW, if things don't work it's because I haven't actually used this library for anything yet and thus you're currently a Guinea pig. |
| 01:02 | mattmoss | Well, I didn't see many other options aside from clojure.java.shell and conch, and the former wouldn't accomplish any of this. |
| 01:02 | Raynes | I want conch.sh to be the go-to library for this, so thanks for working with it. |
| 01:04 | Raynes | Anyways, in case you're wondering why I'm doing all the queue crap behind the scenes, it's because Java is the devil and the process API does not allow you to read unread data from a process if that process has been destroyed, so for timeouts to work properly and allow you to get any data you haven't yet consumed after the process is destroyed you have to make sure you process that output in real-time. So I queue it up and you get a lazy-seq of |
| 01:04 | Raynes | that queue. |
| 01:04 | Raynes | If the process gets killed and there is unread output, you can get at it with conch.sh. |
| 01:05 | Raynes | mattmoss: Also, http://amoffat.github.com/sh is where the whole concept comes from. |
| 01:05 | Raynes | In case you were curious. |
| 01:05 | mattmoss | cool |
| 01:08 | Raynes | mattmoss: Also sorry for shoving it down your throat, I just haven't had anyone who cared enough to let me do so until now. :D |
| 01:09 | mattmoss | Raynes: Not at all... Hey, I need more control than simply (sh "ls"), so I'm happy to help get conch more stable/usable/whatever. |
| 01:09 | mattmoss | Raynes: Beats me trying to figure out all sorts of Java nonsense. |
| 01:09 | mattmoss | lol |
| 01:10 | Raynes | <3 |
| 01:20 | mattmoss | Woot! |
| 01:20 | mattmoss | Raynes: I think I've got what I need... awesomeness. |
| 01:21 | mattmoss | Raynes: In any case, my brain is fried, and I need to chill for the night. Tomorrow, I can gist up some sample code for you to see. |
| 01:22 | Raynes | Cooool |
| 01:22 | Raynes | mattmoss: Night. |
| 01:24 | mattmoss | Seeya. |
| 01:34 | tomoj | hmm (defn wrap-dispatch [app dispatch] (fn [req] ((dispatch app req) req))) |
| 01:50 | amalloy | does anyone know if a decent parser-combinator library exists for clojure? i know about fnparse, but i think that's stuck in monolithic-contrib, and i've heard of parsley but don't know if it's any good |
| 01:51 | noidi | znDuff, re: my question regarding the += operator yesterday, I needed it for JS interop |
| 01:52 | noidi | I ended up writing a macro that expands (+= foo.bar baz) to (set! foo.bar (+ foo.bar baz)), which results in foo.bar = foo.bar + baz in the generated JS |
| 02:04 | Raynes | amalloy: I think parsley is kinda the only option. I have a sneaking suspicion that the library is probably one big version range though. |
| 02:05 | Raynes | Sigh |
| 02:07 | amalloy | noidi: when i was building some transients in jvm-clojure, i wrote a macro change!, such that you could write (change! (.bar foo) + baz) |
| 02:07 | amalloy | you might do the same rather than use a special-purpose += |
| 02:09 | ivenkys | folks - is there a preferred _style_ of declaring datastructures - i.e. shorthand #{} or (set {}) |
| 02:10 | ro_st | the shorthand is reader sugar for the longhand. presumably it's there for a reason :-) |
| 02:10 | ro_st | having said that, i do find myself using (list …) quite a lot |
| 02:10 | emezeske | Well (list ...) is much prettier than '(~x ~y ~z) |
| 02:11 | emezeske | But I think #{x y z} is generally prettier than (set x y z) |
| 02:11 | amalloy | emezeske: (set x y z) is also broken, isn't it? |
| 02:11 | amalloy | you mean hash-set |
| 02:11 | emezeske | amalloy: Yeah that |
| 02:11 | ivenkys | ro_st: emezeske : hmm just getting into clojure and converting a project from Java to Clojure at work - so its one of those best practices thing - |
| 02:11 | ro_st | ivenkys: you'll quickly find that it doesn't matter much. |
| 02:12 | Raynes | ivenkys: You usually have a reason for using one or the other. |
| 02:12 | emezeske | ivenkys: I am not an authority on the subject, but I say use the literals unless you have a reason not to (e.g. you're building up a set of unknown size, etc) |
| 02:12 | ro_st | clojure is so concise that most decisions are small and easy to change |
| 02:13 | Raynes | For example, why would you do (some (hash-set \x \y) ..) instead of (some #{\x \y} ..) |
| 02:13 | Raynes | If you had a vector instead of a literal, it'd make sense to do (some (set myvec) ..) |
| 02:14 | ro_st | yeah. or (fn [& args] (apply hash-map args)) to get all the named args. if i'm correct, you can only gather them like this, and you can't use a literal {} |
| 02:15 | ivenkys | Raynes: in some cases you cant use a literal - but in other places you get both versions - the reader sugar and the literal - i am sort of not sure whats considered better , i prefer the literal simply because its more readable - |
| 02:16 | ro_st | then that's the right thing to do |
| 02:16 | ro_st | generally, literal for declaring new data, fns for converting one collection type to another |
| 02:17 | ivenkys | ro_st: which is what i have gone with at the moment - i am sure someone in the team might have a different idea - but lets see how it rolls |
| 02:17 | ro_st | that's how things have settled for me |
| 02:17 | ivenkys | ro_st: Raynes :emezeske : amalloy : gents thanks for the help |
| 02:18 | ro_st | again - it's very easy to change this decision later. the thing to realise with clojure is that it's actually just getting out of your way and you can focus on solving the problems you're working on |
| 02:20 | ivenkys | ro_st: thats hopefully the plan - very early stages yet - taken a small "DSLish" component of a large high volume, low latency transaction engine (think trading engine) |
| 02:26 | brainproxy | hmmm, I want to call `and` on a collection which is being generated programatically... but `and` is a mcro |
| 02:26 | brainproxy | *macro |
| 02:26 | brainproxy | tyring to cook up a way to work around that, but maybe I'm missing something |
| 02:27 | amalloy | &(doc every?) |
| 02:27 | lazybot | ⇒ ------------------------- clojure.core/every? ([pred coll]) Returns true if (pred x) is logical true for every x in coll, else false. nil |
| 02:27 | ro_st | ahh it's a macro so that eval is lazy |
| 02:28 | brainproxy | amalloy: yeah, but every? isn't quite what I wanted, but maybe it will have to do |
| 02:28 | amalloy | brainproxy: every? is exactly what you wanted, given your initial question |
| 02:28 | amalloy | (every? identity coll) ~= (apply and coll) |
| 02:29 | brainproxy | yeah, just realized I could use identity with it to nice effect |
| 02:29 | brainproxy | thanks |
| 03:16 | maleghast | Morning All... |
| 03:16 | maleghast | Anyone in here had any experience with SpyGlass? |
| 03:17 | maleghast | I may be "letting my n00b show", but I can't work out from the docs how to handle the memcached server(s) configured in the connection I define being down. |
| 03:17 | maleghast | Any ideas? |
| 03:57 | ollivera | anyone knows a clojure bluetooth api? |
| 03:58 | maleghast | Sorry, no... |
| 03:58 | maleghast | This might be of some help to you though -> https://github.com/samaaron/serial-port |
| 04:00 | augustl | ollivera: I tend to look for Java libraries for that sort of thing |
| 04:01 | augustl | a lot of clojure libraries like that are just wrappers on top of java anyway ;) |
| 04:04 | ollivera | augustl, so I just need to create a wrapper to the java api ... isn't it? |
| 04:04 | _ulises | ollivera: if there's nothing else around, I'd say yes |
| 04:04 | _ulises | ollivera: make sure you release it too! \o/ |
| 04:05 | augustl | yeah |
| 04:05 | ollivera | _ulises, yes, I will do it |
| 04:06 | augustl | I generally don't find small clojure wrappers to be very useful |
| 04:07 | augustl | since calling Java from Clojure is generally very terse |
| 04:08 | _ulises | "terse" |
| 04:08 | augustl | can I use that word there? :) |
| 04:08 | _ulises | you can, but not in the same sentence as the word Java |
| 04:08 | _ulises | ;) |
| 04:09 | augustl | good enough for me! https://www.refheap.com/paste/6618 |
| 04:09 | _ulises | augustl: how about this http://clojure.org/jvm_hosted |
| 04:13 | augustl | or this, omnomnom https://www.refheap.com/paste/6534 |
| 04:13 | _ulises | that one's not too bad |
| 04:14 | augustl | obviously, if the Java API is verbose then your java interop will be too ;) |
| 04:14 | _ulises | indeed |
| 04:14 | augustl | and given the swing example you linked to, I too would probably prefer a clojure wrapper of some sort |
| 04:14 | _ulises | that's why I prefer if somebody else writes a wrapper around it, even if it's a super-thin one |
| 04:15 | augustl | so we seem to have a unique case here on whether or not to wrap: "it depends" |
| 04:15 | augustl | no silver bullet :( |
| 04:15 | _ulises | indeed not |
| 04:15 | amalloy | that's not necessarily true, though. you can actually remove a lot of the rubbish verbosity just by writing in a better language, especially with doto and -> when creating new objects |
| 04:15 | _ulises | I personally prefer to always wrap |
| 04:15 | _ulises | I used to use memfn a lot |
| 04:17 | augustl | amalloy: Clojure is the best Java I've seen :) |
| 04:17 | amalloy | (doto (Person.) (.setName "frank") (.setFriends (doto (FriendList.) (.add x) (.add y)))) is a good example |
| 04:17 | amalloy | you don't have to repeat anything, or invent names for the intermediate objects just so you can repeat those names |
| 04:19 | augustl | been using Lucene's Java APIs with no probs at all |
| 04:19 | augustl | and in another project I'm mixing amd matching the Java APIs Jetty and CometD, also works great |
| 04:20 | amalloy | it's even a better example of clojure's power to trim out mess if you give the object a really awful API for working with friends: (doto (Person.) (.setName "frank") (-> (.getFriends) (doto (.add x) (.add y)))) |
| 04:22 | augustl | another pretty nice example imo: https://www.refheap.com/paste/6619 |
| 04:22 | Sgeo_ | What's that do on line 38 for? |
| 04:23 | augustl | Sgeo_: I like to be explicit about doing imperative calls with side effects |
| 04:23 | augustl | so it's not for technical reasons |
| 04:23 | amalloy | is Document a Collection? it'd be nice to use .addAll once instead of .add zillions of times, if you can |
| 04:24 | _ulises | amalloy: I don't think Lucene Documents are Collections |
| 04:24 | _ulises | could be wrong though |
| 04:24 | amalloy | nope, apparently not |
| 04:24 | augustl | http://lucene.apache.org/core/4_0_0/core/org/apache/lucene/document/Document.html |
| 04:25 | augustl | it's Iterable |
| 04:25 | augustl | does that mean it's a Collection? |
| 04:25 | amalloy | no |
| 04:25 | augustl | I see |
| 04:27 | amalloy | fwiw, i think it's a little nicer to do it something like (doseq [field (cons (StringField. ...) (for [[attr value] data] (field-for-data ...))) (.add document field)) |
| 04:27 | amalloy | you get to spend more cognitive time in pure functions that way |
| 04:28 | augustl | TIL something new about doseq at least :) |
| 04:29 | amalloy | eh? |
| 04:29 | augustl | TIL = internet speak for today I learned |
| 04:29 | amalloy | i know. i don't think i said anything interesting about doseq |
| 04:30 | amalloy | it's just...it takes a collection, and you can use cons to build that collection |
| 04:30 | augustl | ah I misread it |
| 04:30 | clgv | amalloy: let's build you a shrine anyway ;) :D |
| 04:31 | augustl | so does `for` return a collection? I would probably have used map there |
| 04:31 | clgv | augustl: yes for does return a lazy seq |
| 04:31 | augustl | s/collection/seq |
| 04:31 | augustl | clgv: I see |
| 04:31 | Sgeo_ | ,(class (for [])) |
| 04:31 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (1) passed to: core$for> |
| 04:31 | Sgeo_ | ,(class (for [] (do))) |
| 04:31 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form: > |
| 04:32 | Sgeo_ | ,(class (for [_ []] (do))) |
| 04:32 | clojurebot | clojure.lang.LazySeq |
| 04:32 | clgv | ,(source for) |
| 04:32 | clojurebot | Source not found |
| 04:32 | clgv | ah right. the bots have none... |
| 04:33 | Sgeo_ | The bots have no class? |
| 04:33 | Sgeo_ | >.> |
| 04:34 | amalloy | $source for |
| 04:34 | lazybot | for is http://is.gd/hqDKdS |
| 04:34 | amalloy | i warn you now, shield your eyes |
| 05:05 | clgv | amalloy: yeah, evil code generation with loops afair ;) |
| 05:09 | augustl | amalloy: haha, wow |
| 05:26 | fckw | Buongiorno. Does anyone know whether there exist any databases that are homoiconic? |
| 05:27 | foodoo | fckw: interesting question. What would be the consequence of a homoiconic database? All database schema can be contents of other tables? |
| 05:28 | fckw | @foodoo: I have something in mind how this might look like. But before trying to write my own database, I wanted to hear whether such a thing exists already. |
| 05:29 | fckw | And yes, basically there would be no separation between the "database schmea" and the data. |
| 05:29 | maleghast | There is some weird shit going on in my IRC client today... |
| 05:29 | foodoo | on Freenode at least |
| 05:30 | Raynes | maleghast: It's just netsplits. It happens to everybody. |
| 05:30 | Raynes | $google netsplit |
| 05:30 | lazybot | [Netsplit - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Netsplit |
| 05:31 | maleghast | Raynes: Thanks - that would indeed explain it :-) |
| 05:31 | Raynes | I aim to please. |
| 05:34 | babilen | maleghast: freenode staff is sorting out routing issues (check your global notices) |
| 05:35 | maleghast | babilen: global notices (my n00b is showing again) |
| 05:36 | babilen | maleghast: notices sent to everyone on the network (10:00 [GLOBAL NOTICE] - In a few minutes there will be some network disruption whilst we sort out some internal routing issues. It shouldn't take too long, but could be a bit noisy. Thank you for your patience.) -- But this is rather off-topic in here, so lets drop it :) |
| 05:37 | fckw | @foodoo: Sorry, some idiot seems to be flooding the chat. |
| 05:37 | Raynes | Eh |
| 05:38 | Raynes | It is the middle of the night for most of the US and nobody cares about mild offtopic chatter in here if it isn't disrupting Clojure discussion. |
| 05:38 | fckw | So, again: Does anyone know of the existence of a "homoiconic database"? |
| 05:38 | Raynes | So you're okay. |
| 05:38 | Raynes | Also, nobody is flooding the room if you're talking about here. |
| 05:38 | Raynes | It was a netsplit. |
| 05:39 | fckw | Ah, ok. I was thrown out anyway multiple times. |
| 05:41 | fckw | Oh, and another question: Does anyone know whether there exists a Java/Clojure implementation of HashMap or HashTable using longs as keys? |
| 05:42 | fckw | (Well, maybe it does not make so much sense in Clojure.) |
| 05:43 | maleghast | fckw: Were you asking about homiconic database(s) before the Netsplit sent everything a bit funny? |
| 05:43 | fckw | Yes. |
| 05:44 | maleghast | Have you looked at Datomic -> https://github.com/Datomic |
| 05:45 | fckw | Nope, thanks. I'll have a look. |
| 05:45 | maleghast | I'm not certain that it's what you are looking for, but it stands a good chance of being some of what you are looking for. |
| 05:45 | maleghast | ;-) |
| 05:48 | fckw | I am neither certain what I am looking for. :D |
| 05:48 | fckw | Do you happen to also know some answer to my other question: A HashMap with the possibility of using longs as values? |
| 05:49 | maleghast | fckw: I have to be honest I have no idea - bit of a beginner at the ole Clojure myself, and I've not had to do what you describe, so I've not investigated it... |
| 05:49 | fckw | maleghast: Ok, no problem. It's honestly not so much a Clojure question but more a Java one. |
| 05:58 | terom | fckw: couldn't you just use HashMap<Long, Object> or something similar? |
| 05:59 | _ulises | terom: not sure you can check equality on Longs, and hence you can't really retrieve (k,v) from such hashmap |
| 05:59 | fckw | Using a Long as a key is internally changed to an int value, as far as I know. |
| 06:00 | terom | ah, ok... |
| 06:01 | rcg-work | hi |
| 06:02 | rcg-work | i got a question with respect to "objects" in clojure... |
| 06:02 | rcg-work | i want to do this: http://pastebin.com/m0Pc3m3s |
| 06:02 | rcg-work | but all the conds etc. look a little strange.. also dispatching an action based on a keyword looks awkward |
| 06:02 | rcg-work | i am sure there is a better (more idiomatic) solution |
| 06:03 | rcg-work | could please point me into the right direction? |
| 06:03 | augustl | why not different methods altogether? |
| 06:03 | augustl | scheduler-stop, scheduler-stop-now, etc |
| 06:04 | _ulises | rcg-work: you have cond with single cases, better use if, also what augustl and for the [k] version, you have two branches which do exactly the same, I'd combine them with (or ...) |
| 06:04 | augustl | s/methods/functions |
| 06:05 | augustl | another thing, won't (scheduler :stop) just stop the newly created scheduler? |
| 06:05 | augustl | i.e. do nothing? I'm not familiar with the Executors stuff though |
| 06:05 | rcg-work | augustl, yep (scheduler :stop) would do nothing, but this i would assume the programmer to handle |
| 06:06 | augustl | I tend to use methods with different dispatches based on arguments be methods that does the same thing |
| 06:06 | rcg-work | the point is that i want to encapsulate the executor object while still providing convenient access to it with functions and at the same time want to keep my code concise |
| 06:06 | augustl | like (def my-func ([thing] (my-func thing {})) ([thing opts] ... actual impl...)) |
| 06:07 | Chiron | Hi, I have a seq that contains maps . every map has the key :x . how to find the min :x ? |
| 06:07 | augustl | in that case, having an optional "opts" argument |
| 06:07 | augustl | rcg-work: your method seems to do completely different things though, I personally find that a bit weird |
| 06:07 | augustl | bah, I need to stop calling functions methods |
| 06:07 | _ulises | Chiron: (reduce min (map :x your-seq)) |
| 06:07 | _ulises | augustl: good idea ;) |
| 06:08 | Chiron | _ulises: wicked :) |
| 06:09 | _ulises | ,(reduce min (map :x '({:x 1} {:x 2} {:x -1 :y -10}))) |
| 06:09 | clojurebot | -1 |
| 06:09 | _ulises | phew |
| 06:09 | _ulises | it does work :) |
| 06:09 | Anderkent | o ye of little faith |
| 06:09 | rcg-work | augustl, well, my function creates a function.. that then, depending on how it is called does different things, yes |
| 06:09 | Chiron | _ulises: what if i want to the map that holds the min :x ? |
| 06:10 | rcg-work | my idea was to encapsulate the executor via a clojure and then access it via the inner fn |
| 06:10 | Chiron | _ulises: i mean i want to get the map that holds the min :x |
| 06:10 | rcg-work | and dispatch in the inner fb based on number of args and keywords |
| 06:10 | rcg-work | *fn |
| 06:10 | augustl | rcg-work: you can still encapsulate it with multiple functions :) |
| 06:10 | rcg-work | can i? |
| 06:10 | foodoo | rcg-work: If you have only one condition, it may make sense to use (when) instead of (if) because the lack of an else-clause is then more obvious |
| 06:11 | _ulises | Chiron: what if you have two maps with the same min? |
| 06:12 | Chiron | _ulises: then one of them is ok |
| 06:12 | rcg-work | i found this http://pastebin.com/dM2pfvH5 by stuart halloway |
| 06:12 | _ulises | Chiron: if you don't care, you can reduce with your own fn along the lines of (fn [m1 m2] (if (< (m1 :x) (m2 :x)) m1 m2)) |
| 06:12 | rcg-work | there he uses a map to select the appropriate function |
| 06:12 | rcg-work | would this be more idiomtic |
| 06:12 | rcg-work | ? |
| 06:13 | _ulises | Chiron: keep in mind that that fn assumes :x is in the map, so you probably need to actually (get m1 :x Integer.MAX_VALUE) but that assumes you're dealing with integers, etc. |
| 06:13 | _ulises | Chiron: but you see where I'm coming from |
| 06:13 | rcg-work | foodoo, i just used a cond with a single statement there in case i want to extend it later |
| 06:13 | augustl | rcg-work: http://pastebin.com/xmZtu0jr and so on |
| 06:14 | augustl | it does the same thing (except I changed the stop methods to take an executor), but it does it with multiple functions instead of manual dispatch based on arguments |
| 06:14 | rcg-work | augustl, but this way i expose the object to my user |
| 06:14 | augustl | rcg-work: your original function probably doesn't do what you think it does, then ;) |
| 06:14 | rcg-work | aint that considered bad? as now the user can do arbitrary, possibly dangerous things, with the object? |
| 06:14 | augustl | it will create a new executor object every time you call it |
| 06:14 | Chiron | _ulises: will try, thanks |
| 06:14 | _ulises | ,(reduce (fn [m1 m2] (if (< (m1 :x) (m2 :x)) m1 m2)) '({:x 1} {:x 2} {:x -1 :y -10})) |
| 06:14 | clojurebot | {:x -1, :y -10} |
| 06:15 | _ulises | Chiron: ^^^ |
| 06:15 | Anderkent | Chiron: alternatively, (first (sort-by :x [{:x 1} {:x 13} {:x -1}])) |
| 06:15 | rcg-work | augustl, only when i call (scheduler) this gives me function which i would use then |
| 06:15 | _ulises | ,(reduce (fn [m1 m2] (if (< (m1 :x) (m2 :x)) m1 m2)) '({:x 1} {:x 2} {:x -1 :y -10} {:y 5})) |
| 06:15 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 06:15 | _ulises | Chiron: ^^^^ |
| 06:15 | augustl | rcg-work: doh I misread it |
| 06:15 | Anderkent | ,(first (sort-by :x [{:x 1} {:x 13} {:x -1}])) |
| 06:15 | clojurebot | {:x -1} |
| 06:15 | augustl | rcg-work: nvm :) |
| 06:15 | _ulises | Anderkent: thanks :) |
| 06:15 | rcg-work | sorry bbl |
| 06:16 | Anderkent | it's a little less efficient so if your map array is huge you might want the reduce approach |
| 06:16 | Chiron | cool ! thanks fellas |
| 06:18 | augustl | rcg-work: interesting problem, my clojure-fu is low but I'm trying to think of something |
| 06:24 | augustl | rcg-work: the only alternatives i can find return a map that contains the functions you can call, so it becomes ((:stop-all my-executor)) |
| 06:25 | augustl | rcg-work: in general I wouldn't have worried that much about encapsulation. For portability and future proof-ness you could always make your own defrecord that you put the executor object in. It'll be accessible, but it allows you to change what it is composed of without affecting the users of your API |
| 06:26 | augustl | rcg-work: also, from http://clojure.org/datatypes, "Encapsulation of information is folly" ;) |
| 07:08 | tgoossens | Did factorial on 4clojure. how can i usefully compare the quality of both snippets? http://pastebin.com/vQZ3ZfBP |
| 07:12 | rcg-work | augustl, right, i see.. thanks |
| 07:13 | augustl | rcg-work: keep in mind that I'm no expert though ;) |
| 07:13 | Anderkent | tgoossens: what do you want to compare? First one's obviously better just because it uses the proper recursion constructs |
| 07:14 | tgoossens | i was mindblown about the result that someone else produced. That i asked myself the question: "has this other more difficult code an advantage over my solution?" |
| 07:14 | Anderkent | No, they just didn't know about recur I asume |
| 07:15 | Anderkent | they're doing recursion themselves if I'm reading it correctly |
| 07:16 | Raynes | tgoossens: The first one is better simply because it isn't completely hideous like the second one. |
| 07:16 | ludston | Anyone in this room do Clojurescript? |
| 07:17 | thorwil | does it matter if functions of 1 argument are wrapped in () or not, inside a (->) form? so far i thought i t doesn't, but wonder about examples i see |
| 07:17 | ludston | (#clojurescript is a bit ghetto) |
| 07:17 | Anderkent | thorwil: no, -> makes its args a list if they're not |
| 07:17 | Anderkent | ,(source ->) |
| 07:17 | clojurebot | Source not found |
| 07:17 | Anderkent | ,(doc ->) |
| 07:17 | clojurebot | "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc." |
| 07:20 | thorwil | ty |
| 07:22 | hyPiRion | You can check it out by using macroexpand-1 |
| 07:23 | hyPiRion | ,(macroexpand-1 '(-> foo (bar baz) bbq)) |
| 07:23 | clojurebot | (clojure.core/-> (clojure.core/-> foo (bar baz)) bbq) |
| 07:24 | alexnixon | tgoossens: looks like the second one is using the y combinator, so not very readable but cool from a first-principles point of view |
| 07:25 | tgoossens | what do you mean "first-principles " ? |
| 07:25 | Anderkent | tgoossens: lambda calculus |
| 07:25 | thorwil | kinda using lego blocks, not lego assemblies |
| 07:26 | Anderkent | more like making the lego blocks yourself instead of buying them |
| 07:27 | tgoossens | ok |
| 07:27 | Anderkent | Honestly it looks like they just took the lisp example from http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator |
| 07:28 | Anderkent | and changed define->def lambda -> fn and some brackets ;P |
| 07:28 | Anderkent | (i ment scheme not lisp actually) |
| 07:29 | tgoossens | do you believe it necessary to study lambda calculus in order to really understand functional programming |
| 07:29 | tgoossens | ? |
| 07:30 | Anderkent | not at all, but it's pretty interesting how much you can do with such a limited syntax |
| 08:02 | ivenkys | Any suggestions on documentation to _really_ understand HOF in Clojure ? |
| 08:04 | stevenfx | ivenkys: http://goo.gl/YXsgO |
| 08:04 | stevenfx | I have not read it tough |
| 08:05 | stevenfx | just searching about... |
| 08:05 | babilen | ivenkys: I like the way in which they are introduced in Clojure Programming (http://www.clojurebook.com/) -- In particular the logging example is wonderful (as is the rest though) |
| 08:06 | ivenkys | stevenfx: i saw that one - i "sort of" understand HOF's but when it comes to actual development i tend to not use them even when they finally turn out to be the best way - i guess i want to try and understand them in a bit more depth |
| 08:07 | ivenkys | babilen: heard good things about that book - its time to order it i guess |
| 08:07 | Anderkent | ivenkys: sounds more like pattern matching issue than understanding - there's not that much to understand in HOF, but you need to match your problem to a suitable HOF |
| 08:07 | ivenkys | babilen: stevenfx : thanks gents |
| 08:08 | Anderkent | i.e. you need to know and easily recall the functions available in clojure, which I guess mostly comes from practice |
| 08:08 | babilen | ivenkys: I like it a lot. It certainly is my favourite together with Joy of Clojure among the current lot .. (well have read the old "Programming Clojure" and "Clojure in Action" as well, so can't really compare it to many) |
| 08:09 | babilen | ivenkys: I am also looking forward to https://leanpub.com/fp-oo |
| 08:10 | stevenfx | babilen: That looks interesting |
| 08:14 | ivenkys | ~ping |
| 08:14 | clojurebot | PONG! |
| 08:15 | ivenkys | babilen: that book looks interesting - thanks |
| 08:16 | stevenfx | Has anyone here read the book? |
| 08:16 | maleghast | stevenfx: Which book? |
| 08:16 | stevenfx | https://leanpub.com/fp-oo |
| 08:19 | maleghast | stevenfx: Thanks - looks interesting, I may well pick it up - I loved his book about everyday scripting with Ruby |
| 08:19 | stevenfx | maleghast: babilen suggested it |
| 08:20 | stevenfx | maleghast: Yeah I am also looking into maby getting it |
| 08:20 | Mr_Bond | stevenfx: awesome! |
| 08:20 | maleghast | Thanks babilen |
| 08:20 | babilen | maleghast: No problem -- I am currently debating if I want to buy it right now .... |
| 08:52 | thorwil | how's (defn logout [r] /friend/logout (ring.util.response/redirect "/") wrong |
| 08:52 | thorwil | that it triggers cemerick.friend$logout$fn__1347 cannot be cast to clojure.lang.IPersistentMap ? |
| 08:52 | ToBeReplaced | it returns the function, wrap another set of parens |
| 08:52 | clgv | thorwil: that's no valid clojure: /friend/logout you probably forgot "" |
| 08:53 | Anderkent | thorwil: you're also missing a closing paren |
| 08:53 | thorwil | (defn logout [r] (friend/logout (ring.util.response/redirect "/")) |
| 08:53 | thorwil | so much for retyping it to not paste linebreaks :) |
| 08:54 | clgv | ;) |
| 08:54 | clgv | seems there is some anonymous function created in logout that accidently is casted to IPersistentMap |
| 08:55 | clgv | so probably some wrong parameter type. |
| 08:55 | Anderkent | it should be |
| 08:55 | Anderkent | (-> r |
| 08:55 | Anderkent | oh nvm |
| 08:56 | thorwil | my first thought was that i should def logout, relying on friend/logout delivering a handler. but with that, i get a 404 |
| 08:56 | Anderkent | friend/logout takes a handler and gives you back a handler, you need to apply the result to the request |
| 08:57 | Anderkent | i.e. (defn logout [r] ((friend/logout (ring.util.response/redirect "/")) r)), i think. |
| 09:00 | thorwil | Anderkent: that's 404 |
| 09:00 | Anderkent | are your routes defined correctly? |
| 09:01 | Anderkent | (is it 404 on trying to logout or on the redirect/) |
| 09:01 | thorwil | it's 404 still on /logout |
| 09:02 | Anderkent | and what's your route definition for /logout? |
| 09:03 | thorwil | Anderkent: https://www.refheap.com/paste/6620 |
| 09:04 | thorwil | as if i just say '["logout"] h/logout' that is rather lacking in context |
| 09:06 | Anderkent | right, I don't know moustache at all, so can't help you there, sorry. |
| 09:06 | thorwil | thanks for looking! :) |
| 09:11 | cgrand | thorwil: need help w/ moustache? |
| 09:13 | thorwil | cgrand: well, the intersection of moustache and friend, i guess |
| 09:14 | cgrand | without friend, your routing works? |
| 09:14 | thorwil | cgrand: that h/login called in https://www.refheap.com/paste/6620 |
| 09:15 | thorwil | the handlers https://www.refheap.com/paste/6621 |
| 09:15 | thorwil | cgrand: yes, everything prior to introducing friend was a non-issue |
| 09:16 | thorwil | now logout fails with cemerick.friend$logout$fn__1347 cannot be cast to clojure.lang.IPersistentMap |
| 09:17 | Anderkent | that's because you're returning a handler as if it was a response |
| 09:18 | cgrand | what is v/login? |
| 09:19 | thorwil | cgrand: delivers a hiccup generated login form. that part works |
| 09:20 | cgrand | v/login is a response map or a function returning a response map? |
| 09:21 | thorwil | cgrand: function returning a response map |
| 09:21 | Anderkent | https://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj#L81 as you can see friend/logout wants you to give it a handler, it then returns a function that you call with the request |
| 09:22 | Anderkent | try something like |
| 09:22 | Anderkent | (defn- logout- [r] (redirect "/")) |
| 09:22 | Anderkent | (defn logout [r] ((friend/logout logout-) r)) |
| 09:22 | cgrand | throwil: so some parenthesis are missing around v/login: you are returning the function |
| 09:26 | thorwil | cgrand: my answer was not appropriate then. view.clj: https://www.refheap.com/paste/6622 |
| 09:26 | cgrand | ok |
| 09:29 | thorwil | cgrand, Anderkent: thank you, Anderkent's 2 definitions do the trick |
| 09:33 | cgrand | thorwil: or (def logout (app friend/logout (fn [r] (redirect "/"))))… or bubble the friend/logout application up to the routes def |
| 09:33 | thorwil | logout handling seems cleaner in https://github.com/marianoguerra/immutant-recipes/blob/master/friend-acl/immutant.clj |
| 09:34 | Anderkent | thorwil: yeah, that's what cgrand suggested. You can have logout just call (redirect "/"), and then do the (friend/logout h/logout) in your routes |
| 09:34 | Anderkent | I would have suggested that but was too lazy to modify both files ;P |
| 09:35 | cgrand | https://gist.github.com/4066032 |
| 09:35 | Anderkent | (is that really [friend/logout logout] instead of (friend/logout logout)? Bizzare.) |
| 09:36 | cgrand | it is, but it's a moustache trick |
| 09:36 | thorwil | Anderkent: moustache's app macro is ... wicked :) |
| 09:36 | cgrand | à la -> but in reverse: you can apply several middle wares that way [mw1 (mw2 arg1 arg2) … handler] |
| 09:37 | Anderkent | makes sense |
| 09:37 | cgrand | and in lieu of handler you can also have a route or method dispatch |
| 09:38 | thorwil | i hope i can put all friend stuff in routing, then. so far my plan had been to have it solely in handlers |
| 09:39 | Anderkent | you should be able to, it's middleware |
| 09:59 | ro_st | anyone done remember-me for a ring web app yet? |
| 10:04 | ro_st | Raynes: any idea how to get noir to write Secure cookies? |
| 10:07 | ro_st | i want to set both of these for my ring-session cookies: http://en.wikipedia.org/wiki/HTTP_cookie#Secure_and_HttpOnly. how? |
| 10:10 | Anderkent | call put! with a map that has :secure and/or :http-only set |
| 10:11 | ro_st | thanks. where did you see that? |
| 10:11 | Anderkent | doc for put! says 'to set custom attributes provide a map', doc for ring.middleware.cookies says which attributes are accepted |
| 10:11 | Anderkent | (noir.cookies just wraps ring.middleware.cookies) |
| 10:12 | ro_st | ahh, the middleware |
| 10:12 | ro_st | thank you -bow- |
| 10:13 | ro_st | ok,so, i don't write the session cookie, ring or noir does |
| 10:13 | ro_st | ok i see ring's wrap-session has :cookie-attrs |
| 10:15 | ro_st | ah of course. noir's server start has a key for it |
| 10:47 | gauravag | what are the built in macros in clojure? |
| 10:49 | vijaykiran | gauravag: http://clojure.org/macros |
| 10:51 | algernon | git grep defmacro in clojure/src is also a reasonable estimate |
| 10:53 | gauravag | algernon: thanks |
| 11:07 | S11001001 | ,(-> #'defn meta :macro) |
| 11:07 | clojurebot | true |
| 11:07 | S11001001 | gauravag: loop over ns-publics of clojure.core accordingly :) |
| 11:08 | gauravag | ,(-> #'defn meta :macro) |
| 11:08 | clojurebot | true |
| 11:21 | gauravag | (println "is anyone able to see the fun in this?") |
| 11:29 | clgv | &(println ",(println \"I do see the fun in this!\")") |
| 11:29 | lazybot | ⇒ ,(println "I do see the fun in this!") nil |
| 11:29 | clgv | ,(println "&(println \"I do see the fun in this!\")") |
| 11:30 | clojurebot | &(println "I do see the fun in this!") |
| 11:30 | lazybot | ⇒ I do see the fun in this! nil |
| 11:30 | tgoossens | lol |
| 11:30 | tgoossens | this is funny :p |
| 11:30 | wingy | lol |
| 11:31 | clgv | ,(println "lazybot, do you like that???") |
| 11:31 | clojurebot | lazybot, do you like that??? |
| 11:31 | lazybot | clojurebot: Yes, 100% for sure. |
| 11:31 | tgoossens | wtf |
| 11:32 | clojurebot | What is seq |
| 11:32 | tgoossens | wtf did just happen :p |
| 11:33 | sw1nn | hi, any emacs+clojure-mode+auto-complete experts around? |
| 11:33 | sw1nn | I have autocomplete working in emacs+clojure-mode. but the documentation popup isn't working |
| 11:33 | sw1nn | in elisp mode it does work. any idea what the key setting is? |
| 11:37 | sw1nn | i'm using nrepl if that makes a difference |
| 11:46 | mudge | I need to replace a java switch statement with something in clojure, what in clojure should I use in place of a java swtich statement? a conp? |
| 11:46 | mudge | condp? |
| 11:46 | technomancy | pattern matching |
| 11:47 | mudge | technomancy: I should use pattern matching? |
| 11:47 | technomancy | maybe |
| 11:47 | pjstadig | case |
| 11:47 | mudge | technomancy: like write a function that uses destructuring? |
| 11:47 | pjstadig | mudge: an example might help |
| 11:47 | clgv | mudge: probably `case` |
| 11:49 | mudge | pjstadig, clgv, technomancy: here's the java code I'm replacing with clojure: https://gist.github.com/b5a54b7ea9e14edba5fa |
| 11:49 | clgv | mudge: you want `case` then |
| 11:50 | technomancy | whatever you do, follow your heart |
| 11:50 | mudge | the problem with case and condp is that they work on the first matching thing --- well I have two possible things that could match and I want the same result |
| 11:50 | clgv | technomancy: feeling romantic today? ;) |
| 11:51 | mudge | two cases expressions -> runs one result |
| 11:51 | technomancy | clgv: no just smart-alecky |
| 11:51 | clgv | mudge: case can have more than one value: (case x (2 4) :this 4 :that :default) |
| 11:51 | mudge | don't know how to do that using clojure case or condp |
| 11:51 | clgv | ,(case 4 (2 4) :this 5 :that :default) |
| 11:51 | clojurebot | :this |
| 11:52 | clgv | ,(case 2 (2 4) :this 5 :that :default) |
| 11:52 | clojurebot | :this |
| 11:53 | mudge | clgv: interesting, I see |
| 11:53 | mudge | clgv: I thought everything within parentheses would cause a function call unless preceded by ' |
| 11:54 | mudge | unless a macro was used |
| 11:54 | raek | mudge: that's almost always the case |
| 11:54 | raek | by convention |
| 11:54 | raek | but there are exceptions |
| 11:54 | clgv | mudge: no, `case` is a macro which handles lists as more than one value |
| 11:54 | mudge | clgv: gotcha, thanks! |
| 11:54 | mudge | raek: thanks |
| 11:55 | clgv | mudge: in case you ever want to match something sequential, you can use a vector in case. |
| 11:55 | raek | ah, well macros and special forms are where those exceptions happen, so you seem to understand this already |
| 11:55 | mudge | raek: is it the case that anything in parentheses is a function call unless it is a macro? |
| 11:56 | mudge | raek: oh i see, yes in special forms too |
| 11:56 | mudge | raek: so in macros and special forms then |
| 11:56 | raek | yeaj |
| 11:56 | raek | *yeah |
| 11:57 | mudge | raek: I guess that's one way to immediately tell if you are working with a macro and not a function |
| 11:57 | raek | and everything inside a macro or a special form can potentially behave specially |
| 11:57 | mudge | raek: yes, I wonder how much clojure programmers write their own macros for things |
| 11:57 | raek | well, it can be hard to tell. |
| 11:58 | raek | generally you avoid macros if you can express the same thing with "the usual" syntax |
| 11:59 | mudge | reak: what if you can express the same thing with "the usual" syntax, but it is just shorter and nicer to use a macro? |
| 11:59 | babilen | that is: use a function if possible |
| 12:00 | raek | mudge: then write a function as a base, and then provide the macro as well |
| 12:00 | raek | so that if you need the "underlying" function, you can use it |
| 12:00 | mudge | raek: okay, cool |
| 12:00 | raek | one example is bound-fn and bound-fn* in clojure.core |
| 12:01 | raek | the one with the asterisk is the function variant |
| 12:01 | raek | (bound-fn [x] some-expression) is equivalent to (bound-fn* (fn [x] some-expression)) |
| 12:02 | raek | in the latter you can provide the function dynamically at runtime, but in the first you are restricted to a "literal" |
| 12:03 | mudge | raek: cool |
| 12:31 | devn | ,(:macro (meta #'defn)) |
| 12:31 | clojurebot | true |
| 12:55 | actsasgeek | For some reason, lein cljsbuild auto started crashing with a "Too many arguments to def (core.clj:46)" exception. Has anyone seen this behavior before? It's not "inside" cljsbuild (it's not the colored stack trace). It was working just fine until I accidentally killed the JVM. http://pastebin.com/KvY0up7J |
| 13:12 | dnolen | acagle: did you try a lein cljsbuild clean? |
| 13:12 | dnolen | oops |
| 13:12 | dnolen | actsasgeek: ^ |
| 13:15 | Licenser | hmm can anyone give me a hint what 'Exception in thread "main" java.lang.NullPointerException, compiling:(login.clj:1)' means? |
| 13:15 | Licenser | something is ugly in login.clj but nullpoointer exception isn't really helping much :( |
| 13:15 | actsasgeek | dnolen: yes. |
| 13:15 | Anderkent | Licenser: can you post your login.clj somewhere? |
| 13:16 | dnolen | actsasgeek: and you're sure it's not some code change in your own code? |
| 13:16 | dnolen | actsasgeek: like a macro file? |
| 13:17 | Licenser | Anderkent https://gist.github.com/4067414 :) thanks |
| 13:18 | actsasgeek | dnolen: I have just one simple main.cljs file that I've been compiling…I tried emptying it of everything except the namespace and leon cljsbuild still crashes. |
| 13:18 | actsasgeek | (spell checker is determined that lein is leon) |
| 13:19 | dnolen | actsasgeek: did you try starting a new project to see if the issue is actually local to that project? |
| 13:19 | actsasgeek | dnolen: yeah, that's my next test. I went into a different project with clojurescript and lein cljsbuild works there. |
| 13:21 | Anderkent | Licenser: sorry, no clue :P |
| 13:21 | Licenser | Anderkent that was my reaction too ^^ |
| 13:21 | Anderkent | are you using lein? |
| 13:21 | Anderkent | or mvn/ |
| 13:21 | Licenser | lein of cause :) |
| 13:22 | Anderkent | you can run DEBUG= lein compile i think |
| 13:22 | Anderkent | for the full stack trace |
| 13:23 | Licenser | https://gist.github.com/4067453 is the stack |
| 13:23 | Anderkent | AFAIK null pointer exceptions in compiling happen when a namespace you import shadows some core functions and gen-class gets confused |
| 13:23 | Licenser | I don't really get smart form it so |
| 13:23 | Anderkent | yeah |
| 13:23 | Anderkent | that list shadowing |
| 13:23 | Licenser | ohhhhh |
| 13:23 | Anderkent | in .user |
| 13:23 | Anderkent | do :refer-clojure :except list |
| 13:23 | Licenser | but it's a waring not a i go and die a horrible unintelligable death |
| 13:23 | Anderkent | (dont remember the syntax but that will fix it) |
| 13:24 | Anderkent | it's a warning unless you're compiling and gen-class uses it |
| 13:24 | Licenser | Anderkent it's not clojurescript |
| 13:24 | Anderkent | probably a bug |
| 13:24 | Anderkent | yes, and? |
| 13:24 | Anderkent | refer-clojure is not clojure script either :) |
| 13:24 | Licenser | okay because you said refer-clojure thought that's for scriptish stuff |
| 13:24 | Anderkent | ,(doc refer-clojure) |
| 13:24 | clojurebot | "([& filters]); Same as (refer 'clojure.core <filters>)" |
| 13:25 | Anderkent | what you want is (ns <w/e> (:refer-clojure :exclude [list])) |
| 13:25 | Anderkent | in your .user ns |
| 13:25 | Licenser | I just renamed list into list-users ;) |
| 13:26 | Licenser | sneakyer solution |
| 13:26 | Licenser | what confuses the hell out of me is that the same thing was working yesterday, perhaps the null pointer exception was still to groggy from the weekend to show up for work |
| 13:28 | Licenser | Anderkent thanks mate that did the trick :) all the sadowy functions killed |
| 13:53 | aaelony | tinkering with clj-ssh.ssh and clj-ssh.cli attempting to tunnel to a server that has a mysql database I'd like to query via clojure.java.jdbc. |
| 13:53 | aaelony | Does anyone have an example from clojure that can set up the tunnel then issue one or more queries ? |
| 13:55 | solussd | is there a predicate that tests if something is a map entry? |
| 13:56 | znDuff | solussd: whether the map has something as a key, you mean? |
| 13:56 | solussd | I'm walking a map of maps and need to know if the current form is a map entry |
| 13:56 | solussd | actually, nevermind, I might as well do this at the map level. ;) |
| 13:56 | solussd | thanks |
| 13:57 | actsasgeek | dnolen: it would seem that I somehow managed to get a configuration of clojure, jayq, crate, fetch, noir and cljsbuild all working and lost it. If I use cljsbuild 0.2.1 it was working but now I get that weird error. If I use cljsbuild 0.2.9, I get an error that it can't find macros for crate on the classpath. |
| 13:57 | gfredericks | ,(ancestors (first {3 4})) |
| 13:57 | clojurebot | nil |
| 13:57 | gfredericks | ,(ancestors (class (first {3 4}))) |
| 13:57 | clojurebot | #{clojure.lang.IMapEntry java.lang.Runnable clojure.lang.Counted java.lang.Iterable clojure.lang.AFn ...} |
| 13:58 | gfredericks | map entries are runnable? |
| 13:58 | dnolen | actsasgeek: yes my other suspicion was that you have some kind of problem in your dependencies. |
| 13:58 | gfredericks | ,(filter #(re-find #"java" (str %)) (ancestors (class (first {3 4})))) |
| 13:58 | clojurebot | (java.lang.Runnable java.lang.Iterable java.util.List java.util.Map$Entry java.util.Collection ...) |
| 13:59 | gfredericks | solussd: for your no-longer-a-problem, java.util.Map$Entry might be an answer |
| 13:59 | solussd | gfredericks: yeah, there's also clojure.lang.MapEntry, but I wanted something implementation agnostic |
| 14:05 | andrewmcveigh | anyone know where cljs' "satisfies?" is declared? |
| 14:07 | andrewmcveigh | nevermind, found it. |
| 14:26 | robinkraft | Hey all, I'm looking for a way to string format a double to have a max of 7 decimal places, but without adding padding if it's actually shorter. So 3.4 -> 3.4, but 3.44444444444444 -> 3.4444444. Any suggestions? |
| 14:27 | robinkraft | Or rather, 3.4 -> "3.4", and 3.4444444444444 -> "3.4444444" |
| 14:28 | gfredericks | ,(format "%.7f" 3.4) |
| 14:28 | clojurebot | "3.4000000" |
| 14:28 | gfredericks | ,(->> (format "%.7f" 3.4) reverse (drop-while #{\0}) reverse (apply str)) |
| 14:28 | clojurebot | "3.4" |
| 14:29 | gfredericks | robinkraft: ^ that at worst :) |
| 14:29 | robinkraft | haha nice! |
| 14:32 | robinkraft | is there a round function I'm not aware of that handles rounding to a specific number of digits? round in numeric-tower only rounds to nearest integer |
| 14:33 | amalloy | $javadoc Math |
| 14:33 | lazybot | http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html |
| 14:35 | metellus | I'm surprised there isn't a format string that can do what robinkraft wanted |
| 14:35 | gfredericks | ,(Math/nextUp 3.4) |
| 14:35 | clojurebot | 3.4000000000000004 |
| 14:35 | aaelony | is this still valid? http://stackoverflow.com/questions/10751638/clojure-rounding-to-decimal-places |
| 14:35 | gfredericks | there's some weird stuff there |
| 14:36 | gfredericks | metellus: robinkraft: I don't know that there isn't. Wouldn't surprise me. |
| 14:36 | metellus | I've been looking at the Java Formatter docs and I can't find one |
| 14:37 | amalloy | i don't think there is, in java or c |
| 14:38 | gfredericks | oh crap mine borks on integers |
| 14:38 | gfredericks | robinkraft: what should it do when given "3.00000"? |
| 14:38 | robinkraft | python has a handy 'round' function: http://stackoverflow.com/a/10505705/699026 |
| 14:39 | robinkraft | I care most about not adding digits where there weren't any before, and truncating anything after 7 digits |
| 14:39 | robinkraft | so 3.000000 could stay as it is |
| 14:39 | robinkraft | but in an ideal world it'd go to 3.0 :) |
| 14:41 | amalloy | "not adding digits where there weren't any before"? |
| 14:41 | robinkraft | i.e. 3.4 -> "3.4" rather than "3.4000000" |
| 14:43 | amalloy | floating point numbers (indeed, any numbers inside a computer) don't have [decimal] digits in any meaningful sense. 3.0 is the same as 3.000000, so if you're happy with the latter staying as is, it doesn't make sense to require that 3.400000 print as 3.4 |
| 14:43 | AKFLOW | hey |
| 14:44 | AKFLOW | need some advice |
| 14:44 | AKFLOW | new to the clojure thing |
| 14:44 | robinkraft | fair enough … hmmm, well the 3.4 case is the driving force here, so then I guess it's not ok for 3.000000 to stay as is either |
| 14:44 | AKFLOW | is their like a noob section |
| 14:45 | AKFLOW | or this is it??? |
| 14:45 | lazybot | AKFLOW: How could that be wrong? |
| 14:45 | amalloy | (inc lazybot) |
| 14:45 | lazybot | ⇒ 8 |
| 14:45 | znDuff | AKFLOW: We don't bite. :) |
| 14:45 | znDuff | AKFLOW: ...well, not in #clojure. Over in, say, #bash, the rule is tough love... but this isn't there. :) |
| 14:46 | AKFLOW | I am tryng to convert matlab files to clojure files |
| 14:48 | AKFLOW | is there a way you could do it with a script |
| 14:48 | technomancy | no |
| 14:48 | AKFLOW | or are there any good pharsing example out there using clojure??? |
| 14:48 | lazybot | AKFLOW: Oh, absolutely. |
| 14:50 | znDuff | AKFLOW: Lots of tools and frameworks for parsing, yes. |
| 14:50 | AKFLOW | sweet |
| 14:50 | technomancy | though... maintained parsers, not so much |
| 14:50 | AKFLOW | ok |
| 14:50 | znDuff | Hmm. Indeed, http://www.clojuresphere.com/?query=parser has lots of things which haven't been updated in a while. |
| 14:51 | AKFLOW | SWEET !!!! let me go there and be right back thank you znDuff |
| 14:51 | amalloy | yeah, i was thinking that the other day, technomancy. someone has actually quietly updated fnparse for 1.4 |
| 14:52 | amalloy | oh hey, and he works at factual? sweet, maybe i can actually go bop him on the head if there's something i want from fnparse |
| 14:52 | technomancy | amalloy: huh; unofficial fork? |
| 14:52 | amalloy | yeah. https://github.com/joshua-choi/fnparse/network |
| 14:52 | technomancy | that's cool |
| 14:52 | technomancy | is fnparse based on parser combinators too? |
| 14:53 | amalloy | "too"? from a brief read of parsley's docs, i'd say fnparse is the only one that is |
| 14:53 | technomancy | parsatron is |
| 14:53 | amalloy | $google clojure parsatron |
| 14:53 | lazybot | [youngnh/parsatron · GitHub] https://github.com/youngnh/parsatron |
| 14:54 | technomancy | he gave a great talk at strangeloop last year |
| 15:00 | mudge | why doesn't this work: (condp some #(= kind %) |
| 15:01 | mudge | getting this error: Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq |
| 15:04 | gfredericks | mudge: the form you pasted is incomplete |
| 15:06 | mudge | gfredericks: the full code snippet is here: https://gist.github.com/4068032 |
| 15:06 | amalloy | so's the stacktrace :P |
| 15:07 | amalloy | not that this stacktrace is terribly important. the args to condp just don't make any sense here |
| 15:07 | mudge | amalloy: the stacktraces in clojure/leiningen/nrepl are not very good, is there a way to get better stacktraces in clojure? |
| 15:08 | mudge | amalloy: i think you are right |
| 15:08 | amalloy | mudge: the stacktraces are imposing if you're not used to them, but they provide a wealth of important information. one would have to be very, very careful (ie, more careful than clj-stacktrace is) to change them for the better rather than the worse |
| 15:09 | mudge | amalloy: makes sense, thanks |
| 15:35 | mudge | ls |
| 15:35 | lazybot | etc home lib lost+found mnt root selinux srv swap sys tmp var |
| 15:48 | brehaut | oh look at that, its #clojure tumbleweed season again |
| 15:48 | danlarkin | brehaut: are you coming this time? |
| 15:49 | brehaut | danlarkin: sadly the combination of international travel and buying a house prevent it |
| 15:49 | danlarkin | :/ |
| 15:49 | danlarkin | bummer |
| 15:49 | brehaut | indeed |
| 15:50 | brehaut | hopefully i'll finagle some clojure work in the next year and be able to justify it as a business expense |
| 15:50 | Clemens | help |
| 15:50 | brehaut | you'll need to be more specific |
| 15:51 | danlarkin | where do you live? |
| 15:51 | Clemens | yeah, i meant /help... |
| 15:51 | brehaut | New Zealand |
| 15:55 | danlarkin | so far! |
| 15:56 | AKFLOW | znDuff hey |
| 15:57 | brehaut | danlarkin: yup, probably not too many places that are farther |
| 16:01 | AKFLOW | are there any ruby2clj parsers??? |
| 16:01 | lazybot | AKFLOW: Yes, 100% for sure. |
| 16:02 | AKFLOW | la |
| 16:02 | brehaut | AKFLOW: what do you mean by that? |
| 16:02 | brehaut | (though the answer is probably no in anycase) |
| 16:11 | boodle | I'm having a chicken/egg problem on returning a Java.io.File as a value (works great) but also want to delete the file inside the calling function. Any way I can get a final call after a return value? |
| 16:11 | technomancy | boodle: doto |
| 16:12 | boodle | technomancy: tyvm! |
| 16:12 | technomancy | no problem |
| 16:13 | znDuff | AKFLOW: if by "parser" you mean "converter"... well, you're not going to find many straight-across code translators for _any_ nontrivial language. |
| 16:13 | callen | boodle: generally speaking anytime you need to do a bunch of things to an object in sequence, especially when interfacing with Java, doto is what I see people doing |
| 16:13 | callen | znDuff: that's not true...unless by straight-across you mean, "looks like a human wrote it" |
| 16:14 | technomancy | with a little imagination you could consider mirahc's java output human-written |
| 16:14 | technomancy | also depending on your opinion of the human race |
| 16:15 | znDuff | callen: I did say "many", as opposed to "any". |
| 16:15 | technomancy | coffeescript, stalin, parenscript |
| 16:15 | callen | coffeescript's javascript output makes sense once you understand the scope-magic they're doing. |
| 16:15 | znDuff | Notably, all of those have a built-to-purpose source language |
| 16:15 | technomancy | sorry, chicken |
| 16:16 | znDuff | ...which makes a particularly big difference when translating between the different available library sets is part of the work. |
| 16:16 | technomancy | oh, chicken and stalin |
| 16:16 | znDuff | (which is certainly the case from Ruby to Java) |
| 16:16 | callen | chicken does a damn decent job too. |
| 16:17 | mudge | what's the best way to find out of a vector contains a certain value? |
| 16:18 | Raynes | &(some #{1} [2 3 4 1 4 5]) |
| 16:18 | lazybot | ⇒ 1 |
| 16:18 | Raynes | (first (filter ..)) also works. |
| 16:21 | mudge | Raynes: looks good, thanks |
| 16:21 | callen | I usually just use first filter because that's what I do in Python anyway. |
| 16:22 | technomancy | callen: ...? |
| 16:22 | technomancy | that idiom doesn't make sense without laziness |
| 16:23 | callen | technomancy: I have a weird assortment of idioms in Python that are vaguely related to things I do in Haskell and Clojure |
| 16:23 | callen | technomancy: it's best not to take the semantics literally. |
| 16:23 | brehaut | technomancy: generaetors in python are lazy |
| 16:23 | callen | and yes, yield/generators are always there. |
| 16:24 | callen | but more realistically it has a lot more to do with my extensive abuse of maybe monads. |
| 16:24 | technomancy | oh, gotcha |
| 16:24 | callen | technomancy: the laziness isn't really key here, IMo. |
| 16:24 | callen | is there some element of the idiom I'm not understanding? I don't doubt that that could be the case. |
| 16:26 | technomancy | callen: it's just wasteful |
| 16:27 | mattmoss | technomancy: Leiningen is your baby, yes? If so, does :scope "test" on a dependency do what it sounds like -- limit that dependency to "lein test"? Or do I need to not limit the scope like that if I (run-tests) from the repl? |
| 16:27 | brehaut | technomancy: hows that different from any other python code ;) |
| 16:27 | callen | technomancy: non-set composite type presence tests in Python usually are. |
| 16:28 | amalloy | hah. fine criticism, from a user of the language that generates piles and piles of garbage instead of just modifying stuff in place, brehaut |
| 16:28 | mattmoss | ...if I *also* (run-tests) from the repl... |
| 16:28 | technomancy | mattmoss: you probably want profiles |
| 16:28 | technomancy | I have no idea why Leiningen supports :scope TBH |
| 16:28 | mattmoss | heh, ok |
| 16:28 | technomancy | someone probably talked me into it, but I forget the motivation. it's only used in pom output |
| 16:29 | mattmoss | ok, gotcha |
| 16:29 | mattmoss | thanks |
| 16:29 | technomancy | sure |
| 16:29 | brehaut | amalloy: lol. i also use python too. its not fast |
| 16:31 | kilon | unless you cheat with cython |
| 16:33 | rcg | anyone here who can help with clojars.org? |
| 16:33 | rcg | i accidentally uploaded something under a wrong name |
| 16:34 | brehaut | kilon: or my preference: F# ;) |
| 16:34 | kilon | damn lucky man, you have a preference, i still have not make up my mind :D |
| 16:35 | kilon | i think i need to frankestein some languages together |
| 16:35 | brehaut | kilon: i still write python for my day job, but i prefer other languages |
| 16:36 | kilon | nothing wrong with that, i love lisp , smalltalk and clojure |
| 16:36 | kilon | most of my coding is in python |
| 16:37 | brehaut | ive been quite excited about F#3 and fsharp.org moving toward making F# more independant of MS |
| 16:38 | kilon | haskell look scary but fun too |
| 16:38 | mattmoss | I dare you to write a web service in befunge. |
| 16:38 | brehaut | ahaha |
| 16:41 | kilon | currently trying to learn the abomination of the lisp world, elisp |
| 16:42 | brehaut | brave |
| 16:42 | kilon | and expand emacs to make it a bit more better python ide |
| 16:43 | kilon | clojure could help there too, to leverage some java libraries |
| 16:43 | kilon | since it has good emacs integration |
| 16:44 | kilon | man so many choices |
| 16:44 | kilon | i will probably end up doing nothing as always :D |
| 16:44 | brehaut | nothing is better than implementing a metaweblog backend :P |
| 16:45 | kilon | "meta" i hate that world, its always covered in mystery |
| 16:45 | kilon | *word |
| 16:45 | brehaut | this mystery is doubled by the amount of link rot involved |
| 16:45 | brehaut | its always a bad sign when wordpress is an authoritative source |
| 16:47 | brehaut | ha |
| 16:50 | brehaut | kilon: short version: implementing nothing is better than implementing a stupid thing |
| 16:51 | callen | When creating the context for various its of data in stencil templates, I find myself repeating a lot of redundant bits for the sake of kicking data backwards either to a direct template renderer or to a partial. |
| 16:51 | callen | how do I keep from having to repeatedly kick back chunks of the request context to stencil templates in a ring web app? |
| 16:59 | callen | amalloy: hate to be 'that guy', but why not Kyoto Cabinet for jiraph? |
| 17:00 | amalloy | as opposed to tokyo cabinet? i dunno, decision made long before i arrived |
| 17:00 | callen | amalloy: kyoto is generally what most people were supposed to migrate to. I don't know how compatible the APIs are. |
| 17:03 | AKFLOW | sorry ppl, I am trying to convert ruby code to clojure code, are there any scripts available ??? |
| 17:03 | lazybot | AKFLOW: How could that be wrong? |
| 17:05 | ohpauleez | AKFLOW: There are no automated scripts to convert ruby code to Clojure code that I'm aware of. The paradigms differ between Ruby and Clojure, so you're going to have to do a mental port as well more than likely |
| 17:05 | technomancy | AKFLOW: you have to use your little grey cells |
| 17:06 | AdmiralBumbleBee | if there was a script to do that, then there'd be no reason to do that |
| 17:06 | danlarkin | technomancy: +1 |
| 17:07 | AKFLOW | ok |
| 17:07 | pjstadig | i have a script |
| 17:07 | AKFLOW | ok |
| 17:07 | AKFLOW | can I get a link ???? |
| 17:07 | pjstadig | it's written in haskell though |
| 17:07 | danlarkin | yeah paul |
| 17:07 | danlarkin | share your script |
| 17:08 | technomancy | 1. find a programmer that knows Ruby and Clojure. 2. Give him the code. 3. Pay him. |
| 17:08 | technomancy | 4. Profit? |
| 17:08 | danlarkin | you forgot ???? |
| 17:08 | technomancy | danlarkin: yeah I'm not good at memes sorry |
| 17:08 | AdmiralBumbleBee | the pay him must've been the ???? |
| 17:08 | scriptor | try this script, AKFLOW, https://github.com/richhickey |
| 17:08 | AKFLOW | shure |
| 17:08 | AKFLOW | let me give it a try |
| 17:09 | callen | technomancy: there's work to be had where one can get paid to replace filthy Ruby with glorious Clojure? Sign me up. |
| 17:10 | AKFLOW | thank you |
| 17:10 | AKFLOW | really scriptor |
| 17:11 | AKFLOW | blahhh |
| 17:12 | pjstadig | AKFLOW: if a script exists to convert Ruby to Clojure, it probably means that Clojure is so similar to Ruby that it is not worth learning |
| 17:12 | pjstadig | use JRuby |
| 17:12 | scriptor | AKFLOW: on a serious note, what do you need it for? |
| 17:19 | TimMc | My wife is using a script to convert Matlab to R code. :-P |
| 17:19 | TimMc | Well, it mostly works. She has to keep adding regexen. |
| 17:20 | sunkencityryleh | ,(doc deftype) |
| 17:20 | clojurebot | "([name [& fields] & opts+specs]); Alpha - subject to change (deftype name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the curren... |
| 17:22 | sunkencityryleh | can I create a subclass of PersistentList in clojure? I'd like to subclass to change some behaviour in a protocol i'm extending for a particular case and then send in the subclass. Would that be a good or bad idea? |
| 17:23 | balint | how could I make this work: (get (dorun (for [x (range 7)] x)) 2) |
| 17:24 | brehaut | TimMc: mostly works but adding regexp sounds like the worst kind of works to me :S |
| 17:24 | brehaut | balint: how about you describe your problem first? |
| 17:24 | gfredericks | brehaut: stand back, I'm going to add some regexp |
| 17:24 | balint | it should return 2 since the sequence the for generates gets force-evaulated by dorun I'd think |
| 17:24 | balint | brehaut: :) |
| 17:24 | TimMc | brehaut: Sometimes that's all you need. |
| 17:25 | gfredericks | TimMc: wat??!! but two problems! |
| 17:25 | TimMc | inorite |
| 17:25 | balint | brehaut: my problem is that a for loop generates a "maze" in a challenge in which I then use 'get-in' to find a certain element |
| 17:25 | brehaut | so why do you need to force evaluation? |
| 17:25 | balint | the element is there but since the maze is lazily generated the get-in returns nil and my code breaks |
| 17:25 | TimMc | balint: get isn't going to work on a seq. |
| 17:26 | gfredericks | probably nth instead of get? |
| 17:26 | gfredericks | s/instead/nthstead/ |
| 17:27 | TimMc | &(get (vec (range 10)) 5) |
| 17:27 | lazybot | ⇒ 5 |
| 17:27 | TimMc | &(get (range 10) 5) |
| 17:27 | lazybot | ⇒ nil |
| 17:27 | balint | TimMc: is this the distinction between seq and coll? |
| 17:28 | TimMc | Specifically, get is for sublinear-time lookup, which seqs don't support. |
| 17:28 | balint | ah, ok |
| 17:28 | dnolen | balint: you probably want to represent the maze w/ a different data structure if you need quick access to elements in the maze. |
| 17:28 | TimMc | ~seqs and colls |
| 17:28 | clojurebot | seqs and colls is http://www.brainonfire.net/files/seqs-and-colls/main.html |
| 17:29 | balint | dnolen: I don't need it to be fast but since originally it's represented as an array of strings, get-in seemed a good choice |
| 17:29 | TimMc | get-in is correct, but you need a different data structure for it to work. |
| 17:30 | balint | that's the challenge: http://www.4clojure.com/problem/117#prob-title :) |
| 17:30 | mycelloandi | ,(doc get) |
| 17:30 | clojurebot | "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present." |
| 17:30 | TimMc | I don't know why ##(get (range 5) 2) doesn't throw an exception. |
| 17:30 | lazybot | ⇒ nil |
| 17:31 | balint | so I should probably convert the original data structure to something more amenable to quick/simple lookups |
| 17:32 | gfredericks | &(get "foo" 3) |
| 17:32 | lazybot | ⇒ nil |
| 17:32 | gfredericks | &(get :WAT 7) |
| 17:32 | lazybot | ⇒ nil |
| 17:33 | balint | &(get "foo" 2) |
| 17:33 | lazybot | ⇒ \o |
| 17:33 | gfredericks | &(get (Object.) 42) |
| 17:33 | lazybot | ⇒ nil |
| 17:33 | gfredericks | &(get (Object.) :akey) |
| 17:33 | lazybot | ⇒ nil |
| 17:33 | gfredericks | huh; |
| 17:33 | balint | gfredericks: it works for strings |
| 17:33 | mycelloandi | why does get return nil for that -- wouldn't it be better to throw an exception? |
| 17:33 | TimMc | $def get |
| 17:34 | gfredericks | maybe clojure only throws type exceptions if there's a specific interface it can require? |
| 17:34 | gfredericks | and if it's going to work for strings then that's obviously not the case |
| 17:35 | TimMc | It *does* have the contract that if the index is out of bounds, nil is returned, but that's still not really an excuse. |
| 17:35 | balint | "Returns the value mapped to key, not-found or nil if key not present." |
| 17:35 | dnolen | get doesn't ever throw, it just tests a bunch of interfaces - see RT.java |
| 17:36 | TimMc | https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L634 |
| 17:36 | TimMc | I guess that's useful if you don't know if *either* the collection or key is bad. |
| 17:36 | gfredericks | (defprotocol IGettable ...) |
| 17:36 | amalloy | dnolen! i asked a question about core.match last night, but you were gone: anyone know if there's a good way in core.match to match a seq like "at least three elements, the second of which is :foo"? i've tried ([x :foo y & more] :seq), but as of 0.2.0-alpha10 that matches even with only two elements, binding y to nil and more to () |
| 17:37 | balint | thank you guys, I'll sort this out |
| 17:38 | dnolen | amalloy: huh ... yeah just seems like a bug. perhaps I can convince people start helping me out with core.match during the conj :) |
| 17:38 | dnolen | amalloy: that should just work |
| 17:40 | dnolen | amalloy: that said, I'm pretty sure I'm going to retire seq matching |
| 17:45 | amalloy | oh no, retire seq matching? it's the only thing i use core.match for! how would i do something like that without seq matching? |
| 17:47 | dnolen | amalloy: vector matching would support the very same thing - albeit the algorithm may favor vectors perf wise. |
| 17:47 | Clemens | &*ns* |
| 17:47 | lazybot | ⇒ #<Namespace sandbox7657> |
| 17:48 | amalloy | dnolen: i'd have to do like (match (vec x) ...) rather than (match x), and then vector matching would work? that's fair enough, i suppose |
| 17:48 | amalloy | since i don't have to worry about infinite seqs for the moment |
| 17:50 | dnolen | amalloy: no change really, vector matching will probably now match on sequential, so no need to convert your data. |
| 17:50 | amalloy | oh good |
| 17:51 | dnolen | amalloy: the neat thing about seq matching was it was very optimized for seqs - so that's all that going out the door. getting rid of seq matching will eliminate a lot of surprises. people were running into a lot of weird things if they mixed vector matching /w seq matching because of interface overlap. |
| 17:54 | callen | dnolen: it's good that you're willing to remove things that didn't work out. |
| 17:54 | callen | dnolen: too many projects let the albatross just hang around their necks instead. |
| 17:54 | JamesBorden | good evening |
| 17:54 | callen | JamesBorden: good afternoon. |
| 17:55 | JamesBorden | I have a question about something I am seeing in ring.middleware.json |
| 17:55 | JamesBorden | at: https://github.com/ring-clojure/ring-json/blob/master/src/ring/middleware/json.clj |
| 17:55 | ynniv | I bet this already exists… I want to apply a series of keywords to a map, like ,(-> { :x { :y { :z 5 } } } :x :y :z) but where :x :y :z are a seq and not forms |
| 17:55 | JamesBorden | it is line 17 |
| 17:55 | ynniv | wow, that looks rather angry in colloquy |
| 17:55 | JamesBorden | [handler & [{:keys [keywords?]}]] |
| 17:55 | JamesBorden | (defn wrap-json-body |
| 17:55 | JamesBorden | "Middleware that parses the :body of JSON requests into a Clojure data |
| 17:55 | JamesBorden | structure." |
| 17:55 | JamesBorden | [handler & [{:keys [keywords?]}]] |
| 17:55 | JamesBorden | (fn [request] |
| 17:55 | JamesBorden | what is keywords? |
| 17:55 | TimMc | JamesBorden: Please don't paste to the channel -- use a pastebin such as refheap.com or gist.github.com |
| 17:56 | JamesBorden | it seems to me like it is a test for a keyname keywords maybe? |
| 17:57 | muhoo | ,(doc keyword) ;; JamesBorden |
| 17:57 | clojurebot | "([name] [ns name]); Returns a Keyword with the given namespace and name. Do not use : in the keyword strings, it will be added automatically." |
| 17:57 | brehaut | JamesBorden: if you click on the line numbers, github will update the #anchor in the url |
| 17:57 | brehaut | eh https://github.com/ring-clojure/ring-json/blob/master/src/ring/middleware/json.clj#L14-21 |
| 17:57 | JamesBorden | brehaut: thanks |
| 17:57 | dnolen | callen: I have no problem getting of stuff that doesn't work :) As usual, I just wish I had seen it earlier. |
| 17:57 | ynniv | muhoo: he's asking about a destructuring directive, not a function |
| 17:58 | metellus | ynniv: ##(get-in { :x { :y { :z 5 } } } [:x :y :z]) is that what you want? |
| 17:58 | lazybot | ⇒ 5 |
| 17:58 | callen | dnolen: hey, recognition and rectification puts you ahead of 99.9% of the crowd. Never sweat something like that. |
| 17:58 | JamesBorden | https://github.com/ring-clojure/ring-json/blob/master/src/ring/middleware/json.clj#L12 has json/parse-string |
| 17:58 | ynniv | metellus: that is *exactly* what I want |
| 17:58 | JamesBorden | which I would like to give the extra parameter "true" |
| 17:59 | metellus | great |
| 17:59 | ynniv | (inc metellus) |
| 17:59 | lazybot | ⇒ 1 |
| 18:00 | callen | (inc metellus) |
| 18:00 | lazybot | ⇒ 2 |
| 18:00 | callen | I learned something too. |
| 18:00 | ynniv | I'm also going to use :x as an example in colloquy more often |
| 18:41 | TylerGillies | whats the best way to auto download java deps in my leiningen project? |
| 18:43 | rcg | TylerGillies, are the java deps available via maven? |
| 18:43 | TylerGillies | rcg: yes |
| 18:43 | rcg | great, then you can simply specify these as dependencies in your project.clj |
| 18:44 | rcg | this works, essentially, the same way you specify clojure dependencies |
| 18:44 | Raynes | Because they're the same thing. |
| 18:45 | TylerGillies | rcg: so just [name.space "version"] ? |
| 18:45 | rcg | Raynes, ;) |
| 18:45 | rcg | TylerGillies, yep |
| 18:45 | Raynes | No. |
| 18:45 | TylerGillies | rcg: brilliant, thanks |
| 18:45 | TylerGillies | er... |
| 18:45 | TylerGillies | no? |
| 18:45 | clojurebot | no is tufflax: there was a question somewhere in there, the answer |
| 18:45 | Raynes | You need the group id and artifact id. |
| 18:45 | rcg | Raynes, ? |
| 18:45 | Raynes | What are you trying to depend on? Give me an example. |
| 18:45 | Raynes | Just one example will do. |
| 18:46 | rcg | [com.espertech/esper "4.6.0"] <- i use this for esper |
| 18:46 | TylerGillies | nothing yet, its a theoretical, i was thinking about adding one but wanted to figure out how to do it first |
| 18:46 | TylerGillies | https://github.com/fusesource/leveldbjni |
| 18:46 | TylerGillies | this is the one im thinking about |
| 18:46 | Raynes | Maven search will tell you what the group id and artifact id are. It might look like what rcg just showed. |
| 18:46 | mattmoss | Raynes: BTW, here's the basic code I'm doing with conch. Stripped of all incriminating evidence. ;) |
| 18:47 | TylerGillies | so group if the first part and artifact id is the second part? |
| 18:47 | Raynes | [org.fuseresource/fuseresource-pom "1.9"] |
| 18:47 | Raynes | Yes. |
| 18:47 | TylerGillies | ah |
| 18:47 | TylerGillies | thats what i meant |
| 18:47 | Raynes | Er. |
| 18:47 | Raynes | That's the parent. |
| 18:47 | mattmoss | Hmm, url is good too: https://gist.github.com/4068423/ |
| 18:47 | TylerGillies | i thought that those terms were synonymous |
| 18:47 | TylerGillies | my bad |
| 18:47 | Raynes | [org.fuseresource.leveldbjni/leveldbjni-project "99-master-SNAPSHOT"] for example. |
| 18:48 | Raynes | mattmoss: I refuse to look at gists out of principle. Put it on refheap and we'll talk. |
| 18:48 | TylerGillies | Raynes: thanks |
| 18:48 | TylerGillies | <dogma/> |
| 18:48 | TylerGillies | heh |
| 18:49 | mattmoss | oops, gotta run... back later |
| 18:49 | Raynes | I was kidding. |
| 18:49 | Raynes | Good stuff. |
| 19:02 | TimMc | TylerGillies: Figuring out that namespaces had nothing to do with Maven coordinates was definitely one of confusing points in my early learning of Clojure. (cc: clojure-doc folks) |
| 19:08 | TylerGillies | Raynes: [INFO] Unable to find resource 'org.fuseresource.leveldbjni:leveldbjni-project:jar:99-master-SNAPSHOT' in repository clojars (http://clojars.org/repo/) |
| 19:09 | TylerGillies | looks like its looking in clojars, and then failing |
| 19:10 | Apage43 | lein is quite noisy, and will report -every place- that it looks even if a later repo succeeds |
| 19:11 | TylerGillies | ah |
| 19:11 | TylerGillies | its still in the process |
| 19:11 | TylerGillies | i thought it teminated |
| 19:11 | TylerGillies | prolly still looking |
| 19:11 | TylerGillies | Apage43: thnx |
| 19:11 | Apage43 | yeah |
| 19:11 | technomancy | Apage43: not on master actually |
| 19:12 | Apage43 | technomancy: nice. Will make a lot of folks a lot less confused a lot of the time. |
| 19:12 | technomancy | yeah, the default you get from aether is rubbish |
| 19:16 | TylerGillies | is it normal for lein deps to hang for awhile? i got some exceptions because it couldn't find jar in clojars and then.... just hangs i think it might be working |
| 19:22 | technomancy | TylerGillies: it can happen on unstable connections |
| 19:23 | TylerGillies | technomancy: thnx |
| 19:30 | brehaut | https://twitter.com/plt_hulk/status/268508480481157120 |
| 19:31 | TylerGillies | lawl |
| 19:43 | mattmoss | Raynes: https://www.refheap.com/paste/6650 |
| 19:47 | nickik | When I use nRepl in Emacs, how can I use reuse the last expression I evaluated. |
| 19:47 | nickik | It used to be just hitting enter on the expression (in swank) |
| 19:48 | technomancy | nickik: *1 is typically used |
| 19:49 | nickik | ok, then I will have to get used to that. |
| 19:53 | nickik | technomany, ist it often the problem that I have to change some little things and then reevalute things? That I cant handly with *1. |
| 19:53 | technomancy | oh, you mean like M-p? |
| 20:02 | holo | hi |
| 20:03 | holo | i'm having a "Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string" when i remove an unneeded dependency from the namespace of a script executed with lein exec -p <script> |
| 20:04 | holo | i tried lein clean |
| 20:04 | technomancy | don't use lein exec |
| 20:05 | technomancy | it only exists because the run task used to be less powerful |
| 20:05 | TimMc | gfredericks: Looks like someone was reading the "get" discussion: http://dev.clojure.org/jira/browse/CLJ-1107 |
| 20:07 | nickik | technomany, thats what I wanted thx. |
| 20:08 | holo | technomancy, ok, i'm going to forget this debugging and run it with "run". thanks |
| 20:12 | TimMc | &(long \a) |
| 20:12 | lazybot | java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number |
| 20:12 | TimMc | &(long (int \a)) |
| 20:12 | lazybot | ⇒ 97 |
| 20:12 | TimMc | hmmmm |
| 20:33 | gfredericks | &(doc int) |
| 20:33 | lazybot | ⇒ ------------------------- clojure.core/int ([x]) Coerce to int nil |
| 20:33 | gfredericks | &(doc long) |
| 20:33 | lazybot | ⇒ ------------------------- clojure.core/long ([x]) Coerce to long nil |
| 20:34 | TimMc | Oh, looks like it is fixed in 1.5.0-beta1 |
| 20:36 | TimMc | http://dev.clojure.org/jira/browse/CLJ-977 |
| 21:19 | yedi | has anyone done anything with clojurescript and appjs? |
| 21:28 | TimMc | ~anyone |
| 21:28 | clojurebot | Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..." |
| 21:28 | TimMc | llasram: Currently working on grokking your lein-otf v2 changes. |
| 21:32 | yedi | i don't have a question, I was just curious if anyone had |
| 23:39 | TylerGillies | how do i add a resource to leiningen project to add jars? |
| 23:39 | TylerGillies | the repo i want to download from is located at http://repo.fusesource.com/nexus/content/groups/public-snapshots |
| 23:39 | TylerGillies | can i add a repo manually? |
| 23:40 | Sgeo__ | You're.... not supposed to, but I think that that's annoying, here's what I did I don't know if lein jar will actually package it properly though |
| 23:40 | Sgeo__ | https://github.com/Sgeo/clj-vp/blob/master/project.clj |
| 23:40 | Sgeo__ | I put it on resource-paths |
| 23:41 | TylerGillies | Sgeo__: thanks |
| 23:41 | Sgeo__ | yw, but... there are probably more elegant ways |
| 23:41 | Sgeo__ | But I have no idea what they are |
| 23:45 | technomancy | TylerGillies: you can add it to :repositories in project.clj |
| 23:45 | TylerGillies | technomancy: thanks |
| 23:45 | TylerGillies | i found a link but it was the wrong syntax |
| 23:45 | amalloy | huh? adding repos manually is exactly what you're supposed to do |
| 23:46 | TylerGillies | https://github.com/technomancy/leiningen/blob/master/sample.project.clj helped |
| 23:46 | Sgeo__ | I sort of thought TylerGillies was talking about adding a .jar |
| 23:46 | TylerGillies | nope |
| 23:47 | Sgeo__ | Ah, ok |
| 23:47 | TylerGillies | i added it, but its not showing when in do lein deps... odd |
| 23:48 | TylerGillies | ah there it goes n/m |
| 23:55 | TylerGillies | hrm getting: Could not find artifact org.fuseresource.leveldbjni:leveldbjni-all:jar:99-master-SNAPSHOT in fuse community snapshot (http://repo.fusesource.com/nexus/content/groups/public-snapshots) |
| 23:55 | TylerGillies | but i see it on http://repo.fusesource.com/nexus/content/groups/public-snapshots/org/fusesource/leveldbjni/leveldbjni-all/99-master-SNAPSHOT/ |
| 23:56 | Sgeo__ | Is there a way to call some arbitrary code when it's time to do dependency resolution? |
| 23:56 | Sgeo__ | Or... otherwise have the code be part of a build process? |
| 23:56 | Sgeo__ | I'm wrapping a C API with the help of JNAerator... |
| 23:57 | hiredman | there is no reason to run jnaerator more than once |
| 23:57 | Sgeo__ | If the C API changes... |
| 23:57 | antares_ | Sgeo__: using Leiningen hooks |
| 23:57 | TylerGillies | must be because of the filenames.. |
| 23:57 | TylerGillies | im assuming its because of the datestamp appended to jar filename? |
| 23:58 | Raynes | antares_: I wish you were going to the conj? |
| 23:58 | Raynes | conj. |
| 23:58 | Raynes | Question marks suck. |
| 23:59 | Raynes | I want us to argue about the priorities of the Clojure community in person. Perhaps engage in fisticuffs over a slab of meat or something. |