#clojure logs

2011-02-03

02:23amalloybrehaut: (defn pivot-with [pred seq] (let [seq (drop-while pred seq)] (take-nth 2 (partition-by (comp boolean pred) seq)))) maybe?
02:26amalloywould be my take on bartj's problem. i haven't read your version, since it sounds like you'd be sad if i did
02:30amalloyapparently all that was four hours ago
03:15brehautamalloy: oh yeah that looks a little less 'raw'
03:15brehautand you're welcome to look at my mess ;)
03:16brehautclever use of take-nth
03:18amalloybrehaut: yeah, it seemed like partition-by had to be the starting point, and from there take-nth is the only thing that made sense
03:19brehautamalloy: i think there is an argument for a loop recur version. it's kind of a `primative' operation
03:20amalloybrehaut: disagree. you can't be lazy that way
03:21amalloy&(take 10 ((fn [pred seq] (let [seq (drop-while pred seq)] (take-nth 2 (partition-by (comp boolean pred) seq))) even? (range))
03:21sexpbotjava.lang.Exception: EOF while reading
03:22amalloy&(take 10 ((fn [pred seq] (let [seq (drop-while pred seq)] (take-nth 2 (partition-by (comp boolean pred) seq)))) even? (range))
03:22sexpbotjava.lang.Exception: EOF while reading
03:22amalloyblah whatever
03:22brehaut:)
03:22amalloybrehaut: i like your docstring for pivot-on, anyway. the user knows what they're getting themselves into
03:22brehaut:)
03:23brehauti figure it pays to be clear
03:25brehauti added your version to the gist
03:31amalloy$mail bartj brehaut's gist at https://gist.github.com/808961 has been updated with a nicer version of pivot-on
03:31sexpbotMessage saved.
03:43Dranikhello all!
03:43brehautmorning Dranik
03:44Dranikdid you use defsymbol from clojure.contrib?
03:44Dranik*defsymbolmacro
03:44brehauti havent
03:44Dranik((
03:45yayitsweimorning Dranik
03:45Dranikyayitswei, morning!))
03:52Dranikhow is clojure 1.3.0-alpha4? is it stable enough for non-production code?
04:17ejacksonGood Morning Fine and Noble People
04:18ejacksonoh, and you too LauJensen :)
04:19Dranikejackson, :-)
04:55shtutgartHi, I have a trouble with appengine-magic. When saving new entity, I'm passing nil as a value of the key, and all save! and retrieve works fine, but key of retrieved entities still contains nil. Am I doing something wrong?
05:00shtutgartThere is an example: http://paste.lisp.org/+2K2Q
05:44Dranikis Konrad Hinsen around here?
06:55lpetithello
07:12babilenHi all! (If this is in some FAQ/document i did not find, just tell me) -- How do I install clojure system-wide on linux? With scripts (wrapper like "clojure") manpages and everything.
07:15raekbabilen: you usually install some build tool like leiningen or cake system-wide. they do what typical launcher scripts do in other languages.
07:16babilenraek: technomancy/leiningen?
07:16raekyep
07:16babilenraek: Ok. (I just hope that my next question is not: "How to install leiningen?" ;)
07:16raekbabilen: see instructions here: https://github.com/technomancy/leiningen
07:17babilenyeah, i found that. :)
07:17raekthere will be a deb package for leiningen eventually (dunno if it's done yet)
07:17raekbabilen: cake is even simpler to install: gem install cake
07:21babilenok, and now? "Modify the dependencies and repositories sections of your Leiningen project.clj" seems to assume that I already have a leiningen project file, for a project I don't have.
07:27raekbabilen: ah. run "lein new <project-name>" to create a project directory
07:28raekthe default project.clj file will include clojure and contrib version 1.2
07:28raekstart a clojure repl with "lein repl" and let the hacking start :)
07:30raeklein will make the src/ directory, as well as your jar depencencies (including clojure itself), will be on the classpath, so that clojure can find them
07:33raekcljr is similar tool, but lets you have one system-wide installation of clojure libs. maybe I whould have mentioned that too...
07:34raekRaynes has written an introduction to these build tools: http://blog.raynes.me/?p=48
07:35raekcljr works as long as you stick to compatible versions of every lib you have installed
07:36raekcake and lein let the projects have the versions they need without interfering with each other
07:36raeklike virtual_env in python
07:36babilenraek: Ok. Just to clarify this. Leiningen is a tool to setup self-contained projects and building them on a project-by-project basis. cljr uses a central installation, but does not necessarily install all dependencies of a project into the "project" directory and does not even necessitate that you have a "project"
07:36raekexactly.
07:36babilenok -- me thinks lein == python virtualenv and cljr == python system install now :)
07:37babilenOk, given that I'll just play with Clojure without having a project cljr might just suffice. Thanks for the pointer so far.
07:37raekas soon as you need to split your code into multiple source files, I recommend cake/lein
07:38raekbut until you need that, cljr should be fine
07:38babilenOk. Wonderful, that blog post seems to be exactly what I need/want to read right now. Thank you raek!
07:38raeknp.
07:57babilenraek: I went with cake -- Easy, elegant and nice. /me would be happy if instructions like this had been on the clojure homepage. :)
07:57fliebelraek: I think cake's global project does that better.
07:58fliebeluh, sorry, need to scroll down :P
07:58fliebelmy comment was re cjlr
07:58babilenfliebel: yes, exactly my impression.
07:59babilenfliebel: no problem, i would have been happy to read it if I haven't arrived at the same conclusion earlier.
08:00fliebelbabilen: what is your os?
08:00babilendebian linux
08:01fliebelokay. macports seems to install Clojure "system wide", meaning it places a shell script with the correct java command on your path.
08:02raekfliebel: noted.
08:03babilenyeah, i thought about working on incorporating the new upstream release into the existing debian package. but after asking in here, it is my impression that this is not really necessary and also not the preferred way in the community.
08:03khaliGHi. I'm writing my first clojure app and a bit stuck atm. I have designed my GUI using Matisse in Netbeans. Now i'm struggling with how to pass my clojure models through to the (Java) Swing code. Can anyone share some tips on this matter?
08:04fliebelkhaliG: 'clojure models'? Well, if you need to extend java classes, look at gen-class and proxy.
08:04ChousukekhaliG: I don't know anything specific but you should be able to use swing directly. What have you tried to do and how is it failing?
08:04khaliGkhaliG, the models which the GUI widgets will manipulate
08:05ChousukeI think generally such models would have to be contained in a ref or an atom, then.
08:06khaliGChousuke, Well i started with my models being Java classes but I'd rather have them be clojure code
08:06Chousukeand if you need to implement some interfaces for the java code to work with them, you can use reify and close over a ref, for example.
08:06Chousukeif you need concrete classes, then gen-class or proxy, but that's more work :/
08:07khaliGok so if i'm reading you correctly, i should write my models as java interfaces, then implement them on the clojure side? That sounds good
08:07Chousukeinterfaces are the easiest to deal with from the clojure side
08:07Chousukeso if you can use them, do so
08:08khaliGseen, thanks!
08:08chousercan you not use clojure's existing interfaces -- IPersistentMap, Ref, etc.?
08:08khaliGi dont mind, i look forward to using as much clojure code as possible, but the swing classes ive generated using netbeans will need to interact with that code somewhere -- and that's where i was stuck
08:09fliebelkhaliG: I assume you read this page? http://clojure.org/java_interop
08:09Chousukeyou might also be able to generate a "generic" model class in Java and pass refs or clojure functions to it to customise its behaviour
08:10Chousukebut since I don't know much of the actual API I'm just throwing out ideas :P
08:12khaliGfliebel, i've come across it before, let me re-read it now to see if i missed something crucial
08:42pppaulanyone use fixtures here?
08:43pppauli'm having problems with my fixtures, they run, and then my tests throw null pointer exceptions
08:43pppauli'm using a fixture that does nothing, just calls the function it is given
09:30zippy314Hi. Is (use 'clojure.contrib.duck-streams) still the preferred way to use files in clojure or do folks prefer other options?
09:31chouserzippy314: recent clojure 1.3 alphas have simiplar functionality in clojure.java.io
09:32zippy314I'm still at 1.2, so I guess I'll stick with duck-streams for slurp and spit.
09:33raekbut c.j.io has been there since 1.2, right?
09:33raekslurp and spit has been in clojure.core since 1.2
09:35raekchouser: has there been additions to c.j.io in 1.3?
09:35zippy314hmm. I get so confused about this because when I google stuff, it's hard to tell.
09:35zippy314but yah, I just found it in core. Duh.
09:36raekclojuredocs.org is very good
09:37zippy314But it doesn't look like there is anything directly in core to get a list of files of the current directory for example.
09:37chouserraek: sorry, could be. I get fuzzy on what happened in which version. :-/
09:38Raynesbabilen: Cake can do the majority of the things that cake *and* Leiningen can do. It has a 'global project' where you can specify dependencies and such, and those dependencies are used for things like 'cake repl' when it's ran outside of a project.
09:38RaynesEr, "cljr and leiningen"
09:38Dranikhow is clojure 1.3.0-alpha4? is it stable enough for non-production code?
09:39RaynesForgive me, I wont up a total of 30 seconds ago.
09:39chouserDranik: sure
09:39Dranikchouser, thanks!
09:40raekzippy314: you can call the .list method on a file to do that: (-> "path" io/file .list seq)
09:40chouserzippy314: raek is right -- Clojure 1.2 has clojure.java.io
09:40Dranikabout clojure.contrib: will it be included into clojure-contrib?
09:41raekzippy314: in general, clojure does not add a function when there is a method doing exactly the same thing (the problem is of course to find that method instead...)
09:41zippy314raek: yah! that is the problem... :-)
09:42raekzippy314: there's also file-seq in core...
09:42Raynesraek: Doesn't file-seq also work?
09:42Raynesraek: :)
09:43RaynesBow to me.
09:43raekit recursively traverses subdirs too, though...
09:44Raynesraek: At least it doesn't overuse ellipses...
09:44raekRaynes: :)
09:56zippy314why is there not-any? but not any? Seems weird.
09:57RaynesBecause some is more flexible.
09:57Raynes&(some #{'c} ['a 'b 'c 'd 'e])
09:57sexpbot⟹ c
09:58VinzentThere is should be bot for answering this question
09:59RaynesJust pretend I'm automated and it'll all work out.
10:00zippy314(blush) again the newbie here...
11:41gilechamanyone got slime-call-defun working properly? C-c C-y to insert a call to this function in the REPL?
11:55anna198Hi, I'm using lein init-script, but even using the github example I'm getting an NullPointerException
11:56anna198suggestions?
12:01mefestoanna198: are you using :repl-init-script or just :init-script ?
12:01edwI'm looking at some source and constants are surrounded by plus signs. This seems crazy. Is there some established naming convention that this is mimicing, or is it just plain evil?
12:02sritchieedw: I think the established convention is to use *constant*
12:02edwsritchie: I thought *earmuffs* are for things whose value is subject to dynamic rebinding.
12:03anna198init-script
12:03sritchieedw: oh, you're right, from the wiki: Use *earmuffs* only for things intended for rebinding. Don't use a special notation for constants; everything is assumed a constant unless specified otherwise.
12:03anna198that's the project https://github.com/zkim/leiningen-init-script
12:03mefestooh i see
12:03edwsritchie: Where's that wiki you;re referring to?
12:04sritchiehttp://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards
12:04edwsritchie: Thanks!
12:04anna198mefesto: any suggestion?
12:05sritchieedw: no problem! I guess the simple answer is "plain, unadulterated evil"
12:05edwI'm thinking of forking the clojure-zmq module to fix this.
12:05sritchieedw: I've got to go replace some earmuffs in my code
12:05mefestoanna198: sorry i misunderstood you and thought you were talking about lein's repl-init-script ... im not familiar with this project
12:06sritchiehere's an odd one -- does anyone here have any experience with GZIPInputStream?
12:06sritchieI'm comparing a stream with GZIP to a normal input stream, and they match exactly, except for the first two bytes
12:06anna198mefesto: that's ok... I'm trying to make an wrapper to my project do you know other project to do that?
12:11hiredmanedw: the plus sign thing is some kind of common lisp convention a few refugees refuse to give up
12:14sritchieso the clojure standard is -- for constants like (def map-dimensions [180 360]), no special notation
12:15hiredmandefs should be considered constants be default
12:31shortlordwhat is the idiomatic way to pick the longest collection from a collection that holds these collections? putting all the collections in a sorted map and then pick the first?
12:35arohnerI would do something like (apply max-key :count (map (fn [coll] {:coll coll :count (count coll}) mega-coll))
12:40amalloyshortlord, arohner (apply max-key count mega-coll)?
12:41arohneramalloy: even better
12:41arohnerI'd gotten in the habit of building the map, because I commonly need to pass those values around
12:41shortlordoh god, somehow totally missed max-key
12:41shortlordthx a lot
12:42amalloyarohner: as in, keep the count for every coll as well as the longest?
12:43arohneramalloy: in my app it's not count, it's probabilities, but yeah
12:43raekalso (map (fn [x] ...) coll) --> (for [x coll] ...)
12:43amalloy(apply max-key second (map (juxt identity count) mega-coll)) is an option that avoids writing an explicit (fn)
12:51__name__amalloy: you seem to like juxt :)
12:51amalloy<== official member of the juxt fan club
12:52__name__where can i apply?
12:52sritchiehey all, quizzical issue here -- take a look at this gist: https://gist.github.com/941f9523212137c3a0ed
12:52amalloy__name__: i think technomancy was the first to call it a fan club :P
12:52sritchiethe first defn works great, whereas the second pads two bytes onto the front of the input stream
12:53sritchieGZIPInputStream is doing some sort of mutation, I'm just not sure why
12:54amalloysritchie: well, that's as far as i'd gotten :)
12:54sritchieamalloy: haha, just wanted to grab the obvious points
12:55amalloysritchie: you're sure it's *adding* bytes, not removing them?
12:55amalloyyou can see http://kickjava.com/src/java/util/zip/GZIPInputStream.java.htm has it read two bytes in readHeader()
12:55sritchieamalloy: it would make sense if I mixed that up -- it's probably reading the first few bytes
12:55sritchieamalloy: yup, that's gotta be it
12:56sritchiethe adding certainly would be curious! crowded REPL syndrome
12:56amalloyheh
12:58amalloysritchie: you could wrap the input stream in a PushbackInputStream to avoid having to recreate the original stream if something goes wrong
12:59amalloybut i guess that will end up being more complicated, not less
12:59sritchieamalloy: what I'm missing in this body of functions is a proper understanding of with-open
13:00amalloysritchie: with-open simply ensures that as soon as you leave the lexical scope of with-open, the resource is closed. nothing fancier than that
13:00sritchieamalloy: I open up this stream on a byte array in one function, and create a lazy seq of pretty large blocks of bytes -- then I have to open up another stream on each of these blocks, to read floats in little endian format
13:01sritchieamalloy: so is it sufficient to call with-open every time I open a stream?
13:01amalloythis leads to problems if you lazily consume data from that stream, because by the time the seq is realized, the stream has been closed
13:01sritchieamalloy: I've been setting a call to close at the termination of each lazy seq
13:01__name__isn't lazy io generally a bad idea?
13:02amalloy__name__: you have a better way to process a 1GB file? :P
13:02__name__because you can end up with a lot of open fd
13:02__name__fair enough
13:03sritchie__name__: yeah, this is for a cascalog function that cuts a byte array into chunks, converts bytes to floats and streams it all back out --
13:03sritchieso, lazy seqs prevents the need to load everything into memory, as I don't need to actually hold on to any of this data during processing
13:04raekwhen using with-open, you are supposed to do all things that need the file inside the with-open form.
13:04amalloysritchie: how's cascalog treating you? it looked pretty interesting to me when i was starting some hadoop work, but i wound up not trying it out
13:05__name__ok
13:05__name__okay, this was not supposed to go here
13:05sritchieamalloy: it's been fantastic so far, mature enough for this project. I'm performing manipulations on NASA MODIS tiles, and generating time series from lots of smaller data chunks
13:06sritchieamalloy: cascalog let me get around this issue in hadoop of these big compound keys, with (dataset, tile, chunk, time period)
13:07sritchieamalloy: the community's not that big, as of yet, but nathan (the creator) is extremely helpful, and chris wensel of cascading is fairly active
13:07amalloythat's convenient
13:39mefestoanna198: sorry was afk. could you explain to me what you mean by wrapper project?
13:40anna198mefesto: a daemon or a init.d script sorry for my bad explanation
13:41mefestoanna198: I'm not familiar with any Clojure specific tools for that but there is this java one: http://commons.apache.org/daemon/
13:41mefestoanna198: that might help, i've never actually used it though :)
13:42anna198mefesto: I'll read about it thanks anyway =)
13:50mefestodoes anyone know of a blog post or could explain how one properly performs a release with leiningen and clojars? (i.e. no libname-1.0.0-SNAPSHOT's)
13:51mefestodo you edit the project.clj's version then perform a jar build and upload that to clojars? plus any vc tagging necessary
13:51sritchiehey all -- if I have a string like this, "2006-09-28T21:44:50.000Z", is there an easy way to define a format for that string, and destructure it based on that format?
13:51sritchiesort of the opposite of the usual use fo format
13:51sritchieof*
13:51mefestosritchie: would a regex work for you?
13:53mefesto,(let [[_ year month day] (re-find #"(\d{4})-(\d{2})-(\d{2})" "2011-02-03")] [year month day])
13:53clojurebot["2011" "02" "03"]
13:53amalloysritchie: yeah, your choices are regex or java.text.SimpleDateFormat
13:53sritchieregex it is, i think
13:54sritchiethanks, guys, that's just what I was looking for
13:54raeksritchie: Joda Time, or the clj-time wrapper could be worth checking out
13:56sritchieclj-time definitely looks like a cleaner way to go
14:11dakroneclj-time is pretty nice, been using it lately
14:31mjg123Hi folks. Whats the best way to find the first occurence of something in a vector? i.e. to implement (first-occurrence [4 6 2 0 5] 0) would give 3
14:32mjg123is there a core function that can do that?
14:34amalloymjg123: usually you "shouldn't" want to do this. scanning a vector to find an index is not a good way to get things done - what's the problem you're trying to solve?
14:34amalloy$findfn 0 [4 6 2 0 5] 3
14:34sexpbot[]
14:34lazy1mjg123: You can use keep-indexed
14:34lazy1,(first (keep-indexed #(when (= %2 2) %1) [1 2 3]))
14:34clojurebot1
14:34amalloy&(.indexOf [4 6 2 0 5] 3)
14:35sexpbot⟹ -1
14:35amalloy&(.indexOf [4 6 2 0 5] 0)
14:35sexpbot⟹ 3
14:35amalloyso .indexOf is how to do what you want, but i recommend reevaluating whether you actually want it
14:35mjg123cool
14:35mjg123I'm happy to do that, definitely.
14:36kencauseythe reason not to do that of course is that it involves a linear search, dead slow
14:36mjg123The problem I am trying to solve is the 8 queens problem. I had modelled the positions of the queens as a length-8 vector, so [1 2 3 4 5 6 7 8] would represent all the queens along a diagonal.
14:37mjg123I would start with [nil nil nil nil nil nil nil nil].
14:37shortlordis it possible to pass a form as an argument to a function without evaluating it or is that something that only macros support?
14:37brehautshortlord: you can quote it
14:37mjg123then, proceed to find the first "nil" in that vector (my original question here), then calculate possible places for the queen in that rank, and recurse from there.
14:38brehaut,(type '(fn [] 1))
14:38clojurebotclojure.lang.PersistentList
14:38shortlordbrehaut: but I'd have to quote it in the caller, right?
14:38brehautshortlord yes
14:39shortlordI'd like the caller to be able to pass something without having to quote it every time (because the caller could forget to do it)
14:39shortlordso that leaves only macros and doing it like apply and passing the function and arguments seperately, right?
14:40mjg123I guess my algorithm is OK, but if you can suggest a better way to keep the data structured then that'd be great
14:40brehautshortlord: macros are the only way to capture a form without the caller explicitly quoting it.
14:40lazy1mjg123: You can think of a queen location as number 0-7 on a column. Then the possible locations are permutations on the vector 0-7
14:41lazy1(which you can use clojure.contrib.combinatorics for)
14:42brehautshortlord: why do you want this?
14:42amalloymjg123: instead of starting with [nil nil ...], why not just start with [], and fill it as you go?
14:42mjg123:)
14:43amalloybrehaut: i've found reasons to want a "function" whose arguments are automatically quoted, which is basically what shortlord seems to want
14:44brehautreally? aside from lists i'm struggling to imagine what it would be
14:44mjg123lazy1: That's a good idea, only 8! to check
14:45mjg123amalloy: that is almost worth kicking myself for
14:45shortlordbrehaut: I need a function that only executes the passed functions, if a certain condition is met
14:45mjg123I had got stuck on the idea that the vector would *always* have 8 elements
14:46lazy1clojurebot: solve 8 queens
14:46lazy1(was worth the try)
14:46mjg123I'm using this as a kata/clojure-practise, so I'll try both ways
14:46brehautshortlord: by 'functions' you mean expressions?
14:46shortlordbrehaut: yes
14:47amalloybrehaut: DSL-y shorthand stuff. eg, the "natural" way for me to specify a player's hand for a card game is (hand aqt42 kj8 k74 3) (with an implied ordering of the suits)
14:47amalloyhaving to quote all of those, or wrap them in a string, is unnatural
14:47raekshortlord: you can let the caller send the expression wrapped in a 'delay' or 'fn'
14:48amalloyas it happens it's convenient to have that happen at compile time, but i wouldn't mind if (hand foo) expanded to (hand* 'foo)
14:48amalloybut now, afk for lunch!
14:49shortlordraek: but that would mean that the caller always has to delay manually. It could be quite tedious to find a bug caused by a call that has the delay omitted
14:49raekbut if you quote the expression, you don't capture the context of the call
14:49raekshortlord: looks like you need a macro, then
14:50raeklike the implementation of 'future' and 'future-call'
14:50raek(future foo bar baz) macro-expands into (future-call (fn [] foo bar baz))
14:51raekthe point is, if your function is inconvenient to call, you can make a macro make it look prettier
14:52bdeshamis the following considered idiomatic? (-> {:a {:b {:c 5}}} :a :b :c)
14:52raekas long as the keys are keywords (i.e. work as functions), I don't see why not
14:52brehautbdesham: use get-in
14:53brehaut,(get-in {:a {:b {:c 3}}} [:a :b :c])
14:53bdeshambrehaut: oh, nice... I think that's more what I was looking for
14:53raekget-in basically does the same thing in this case, but you can use any type for the keys
14:53brehautbdesham: it has a related function assoc-in
14:53bdeshamthe -> form certainly works, but I wanted to know what the "preferred" method was to access nested maps
14:54bdeshamyeah, I just found out about assoc-in yesterday and was amazed
14:54brehautbdesham: personally i prefer get-in because its explicit about the intent
14:54bdeshambrehaut: yeah, that makes sense
14:54bdeshamthanks raek & brehaut!
15:51brehauthv clove looks interesting
15:51hvbeen using it for a while ;)
15:53odyssomayWhat is the best way to find and replace each " ... " (block of quotes) in a string?
15:54brehautodyssomay: what do you mean by 'block of quotes'
15:54odyssomayehm
15:54odyssomay" blablabla "hello\" blablabl"
15:54odyssomayoops
15:54odyssomay" blablabla \"hello\" blablabl"
15:54brehautcan your quotes contain quotes?
15:54odyssomayI want to replace \"hello\"
15:55odyssomayyes
15:55hiredman,(doc split-with)
15:55hiredmanhmmm
15:55hiredmanping?
15:56brehautclojurebot has been a bit laggy this morning
15:56odyssomayI can look it up in the repl anyway
15:56hiredmanping?
15:56clojurebotPONG!
15:56hiredman,(doc split-with)
15:56clojurebot"([pred coll]); Returns a vector of [(take-while pred coll) (drop-while pred coll)]"
15:57hiredmannot the fastest thing in the world
15:57hiredmanif you want spead you'll want to get the byte array, scan, and bash in place
15:57hiredmanspeed
16:02odyssomayhiredman: any example of split-with? I don't really get it...
16:03hiredman,(split-with (partial = \") "hello \"world\" hello")
16:04clojurebot[() (\h \e \l \l \o \space \" \w \o \r ...)]
16:04hiredmanhmmm
16:04odyssomayI got something similar, yeah
16:04hiredman,(take-while (partial not= \") "hello \"world\" hello")
16:04odyssomayit splits the whole thing
16:04clojurebot(\h \e \l \l \o \space)
16:04amalloyhiredman: ##(split-with (complement #{\"}) "hello \"world\" hello")
16:04sexpbot⟹ [(\h \e \l \l \o \space) (\" \w \o \r \l \d \" \space \h \e \l \l \o)]
16:05amalloyor partition-by
16:05hiredmanI don't think you want partition-by
16:05hiredmanI mean, I guess you could just say every other list is something that was quoted
16:05amalloyhiredman: i suppose you're right, that would mess up ""
16:05hiredmanoh, yeah
16:06brehaut,(re-seq #"\"[^\"]*\"|[^\"]*" "hello \"world\" test")
16:06clojurebot("hello " "\"world\"" " test" "")
16:06hiredman:/
16:06brehaut,(take-nth 2 (re-seq #"\"[^\"]*\"|[^\"]*" "hello \"world\" test"))
16:06clojurebot("hello " " test")
16:06amalloybrehaut: idea stealer!
16:06brehauthehe
16:07brehautsorry
16:07brehautmonkey see monkey do
16:07brehautthats an orrible regexp though
16:07amalloybrehaut: it's nice to have someone who abuses regexes more than i do though
16:12brehautamalloy: i try to avoid it, but yes :P
16:13brehauti do try to stick to fishbowl's law though
16:14brehaut"Every regexp that you apply to a particular block of text reduces the applicability of regular expressions by an order of magnitude." – http://fishbowl.pastiche.org/2003/08/18/beware_regular_expressions/
16:14ohpauleezbrehaut: haha
16:14ohpauleezI have never seen that before
16:16brehautgot it
16:16brehaut,(apply str (take-nth 2 (map first (re-seq #"\"(\\\"|[^\"])*\"|[^\"]*" "hello \"wo\\\"rld\" test"))))
16:16clojurebot"hello test"
16:16brehautodyssomay: does that make sense?
16:17amalloybrehaut: i am concerned you may be involved in devil worship
16:19brehautPh'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
16:21LauJensenbrehaut: Are you guys trying to do something like ##(.replaceAll "Hello \"World\" - testing" "\".*\"" "")
16:21sexpbot⟹ "Hello - testing"
16:21brehautLauJensen: sssh
16:21amalloyLauJensen: brehaut has taken it on himself to handle every corner case
16:21amalloyfor no particular reason :P
16:22LauJensenamalloy: excellent :)
16:22brehautamalloy: i fear regexps and i havent learn't fnparse yet ;)
16:22amalloyLauJensen: your version will, eg, not work if there are more than two quotes in a string, and brehaut seems to even want it to understand \\\"
16:25brehautthe \\\" is so that escaped quotes in a quoted block are captured
16:26amalloybrehaut: yeah, i'm aware of *why* :)
16:26brehaut(as per odyssomay's requirments)
16:26odyssomay(seq (.split "hello \"world\" test" "\"")) works
16:26brehautamalloy: oh right, sorry :)
16:28amalloybrehaut: now make it realize that "\\\\" is *not* an escaped quote :)
16:28brehautamalloy: it does
16:28brehautoh
16:28brehauthmm
16:29odyssomayLauJensen: yes actually that's what I'm trying to do, thank you
16:29LauJensenodyssomay: np
16:30sritchiehey guys, quick question -- for a multimethod that dispatches based on type, how could I specify variadic arguments?
16:32brehautamalloy: that case also shows that i havea sublte infinite loop in my version
16:32sritchieit feels cluttered, the way I have it, but here's the gist -- https://gist.github.com/9363935ac77cc8ef2f5a
16:32sritchiethe line with the comment is where I'm not sure
16:33raekI guess the dispatch function needs to be variadic too
16:33amalloysritchie: (defmulti name (fn [& args] (type (first args))))
16:33sritchiewhich reminds me of one more -- is it idiomatic to have a multimethod call itself?
16:33raek(defmulti julian->period (fn [x & _] (type x)))
16:34sritchielet me take a peek at those, one sec
16:34raekI don't see why not
16:34amalloyraek's is better
16:35sritchiehey, haven't seen the underscore before,I like that
16:35rata_hi
16:35sritchiepresumably that's for an ignored symbol, right?
16:35raekyes.
16:35raek,((fn [x] (type x)) 1 2 3)
16:35clojurebotjava.lang.IllegalArgumentException: Wrong number of args (3) passed to: sandbox$eval47$fn
16:35raek,((fn [x & _] (type x)) 123 :foo "bar")
16:35clojurebotjava.lang.Integer
16:40sritchiehad to restart swank to get rid of the old defmulti, but it works
16:40sritchiethanks a lot
16:41solussda73p
16:41raeksritchie: yes, they behave as defonce
16:42raeksritchie: you can "reset" it by running (def julian->period nil) or (ns-unmap 'your-namespace 'julian->period)
16:42sritchieraek: good to know, wasn't sure how to undo things at the repl
16:43raekpreviously, when you reevaluated a namespace containing a defmulti, you'd lose all the method implementations
16:46mefestoany recommendations on how to perform a release with leiningen/git/clojars? i'm probably making it more compliccated then it needs to be but i was thinking: git branch release; update project.clj with version (w/out SNAPSHOT); git commit; git tag; lein jar && lein pom; upload to clojars ... ?
16:47raekthis is basically how I have done it
16:48raekexcept that I didn't make a dedicated branch for it
16:49mefestoraek: sounds good. just wanted to make sure i wasn't leaving something obvious out. thanks
16:50amalloymefesto: cake release pushes to clojars for you
16:51mefestoi guess my thoughts behind the dedicated branch was to keep from having these small release edits from polluting up my git log ...
16:52raekfair enough
16:54amalloymefesto: i think it's good to have a branch for a release, though i don't do it myself
16:56amalloybest of all is to have a "release" branch that stays alive between releases, and just merge into it, rather than a new branch every time
16:57amalloysome people like to use master for that purpose, and have "dev" or something for non-release commits. that idea appeals to me but i don't have the discipline to do it for small projects
16:57Chousukegit has a nice model
16:57Chousukemaster is the always-stable branch
16:58mefestoim the same. i'll try to be disciplined ... let's see how long it lasts :)
16:58amalloyChousuke: that is *one* model you can use
16:58amalloygit doesn't have any such model inherently
16:58Chousukereleases are tagged from it. maintenance fixes to to maint, then there's "next" for development. merging goes maint -> master -> next
16:58ChousukeI meant git.git :)
16:58Chousukeit's like a model project for others to imitate
16:59Chousukeit's fun reading just the logs too, there's a lot of information
16:59technomancyhv: looks interesting; I'll take a look
16:59amalloyChousuke: git flow is another
16:59technomancydoes it cover some of the same ground as nailgun?
16:59Chousukenot just "fix bug" or "fix breakage"
17:00edwIs there a difference between seq? and sequential? Should I care?
17:00Chousukethough maintaining such a repository takes some skill :/
17:00edwAh. I see.
17:00technomancymefesto: if you anticipate keeping two versions active at once then a branch is important, otherwise a tag might suffice
17:00Chousukeyou can always branch from a tag if you need to
17:00technomancyand you can go back and branch once you discover you need to update an old release (like clojure 1.2.1)
17:01raek,(map (juxt seq? sequential?) [[1 2 3] {:a 1, :b 2} '(1 2 3) (seq [1 2 3]) (lazy-seq [1 2 3])])
17:02clojurebot([false true] [false false] [true true] [true true] [true true])
17:05mefestowell i just pushed to github. would be interested in some feedback if anyone has a few mins: https://github.com/mefesto/wabbitmq
17:05mefestoit's a simple clojure wrapper for rabbitmq 2.2.0
17:58mattmitchellnot sure what i'm doing wrong here... when i run this code:
17:58mattmitchell(defrecord Page [filename])
17:58mattmitchell(Page. "site/www/index.html")
17:58mattmitchellI get: java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol (models.clj:3)
18:00brehautmattmitchell: i dont know what you are doing wrong either; that works fine for me
18:01brehautmattmitchell: can you eval *clojure-version*
18:01odyssomayHow can I take every second element in a list?
18:01brehautodyssomay: (drop 1 (take-nth 2 my-list))
18:01odyssomayEx In '(1 2 3 4) I want '(1 3)
18:01brehautoh
18:01brehautthats even easier
18:01odyssomayhmm?
18:02brehaut,(take-nth [1 2 3 4])
18:02clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$take-nth
18:02brehautwhoops
18:02odyssomayoops
18:02brehaut,(take-nth 2 [1 2 3 4])
18:02clojurebot(1 3)
18:02odyssomaynice, thanks
18:07odyssomaythis is how I tried doing it: http://pastebin.com/Gv1mm092 :D
18:09brehautodyssomay: just for the sake of; (defn take-nth-ish [n s] (map first (partition n s)))
18:10brehautor, the amalloy way: (def take-nth-pf (comp (partial map first) partition))
18:13amalloybrehaut: cute
18:13brehaut:)
18:14odyssomayhehe
18:14amalloyodyssomay: your recur form is indented weird; it's hard to read. usually all the arguments should line up with the first argument
18:15odyssomayamalloy: sorry, I agree. It's enclojure style ;)
18:15amalloyblugh
18:15odyssomayhah
18:17mattmitchellbrehaut: *clojure-version*
18:17mattmitchell{:major 1, :minor 2, :incremental 0, :qualifier ""}
18:18brehautmattmitchell: likewise. i copied your code and ran it in my repl and it ran exactly as expected
18:18mattmitchellweird
18:18amalloymattmitchell: my guess would be that you are getting the exception somewhere else
18:18mattmitchellok, i'll try a fresh repl env instead of my project
18:18amalloywhat is on line 3 of models.clj?
18:18mattmitchellbrehaut: yeah probably
18:19mattmitchellamalloy: (defprotocol Fileable
18:19mattmitchell "A simple protocol for a static resource (file/image etc.)"
18:19mattmitchell (load-from-file [self] "Loads the resource at :path"))
18:22amalloymattmitchell: weird
18:22rata_mattmitchell: that misses the [field ...] part I think
18:22rata_mmm... no... it's a protocol
18:22rata_confused by the prior defrecord
18:28joshua__Nobody?
18:30ohpauleezjoshua__: What was your question?
18:30amalloyjoshua__: so far you haven't said anything
18:30joshua__Oh.
18:31joshua__I asked if there was a standardized way to deal with users in compojure.
18:31joshua__Well, I thought I asked that at least.
18:31amalloyjoshua__: with distaste. users are so yucky
18:33ohpauleezhaha
18:34joshua__amalloy, scary
18:34joshua__amalloy, so should I add a record to mongodb with user name and password with like a 'logged in as this user' variable added to the session of someone who logs in?
18:36amalloywell, whatever you do don't store a password in plain text
18:37joshua__I have to hash it right? and than I hash it again when I also hash when a user tries to log on.
18:38joshua__Sorry, I'll start reading what I type before sending it.
18:38joshua__Oh, by the way, college started again!
18:38ohpauleezjoshua__: I'm pretty neurotic, I so I do a user, and email, and password collections/tables
18:38ohpauleezand normalize
18:38ohpauleezall passwords SHA-256 or stronger
18:38ohpauleezpassword links to email, email links to user
18:38ohpauleezuser never links directly to password
18:40joshua__Why can't user link to password?
18:40ohpauleezjoshua__: The idea is that if you lose or compromise any single collection, you don't give up all Personal Identifying Information
18:40ohpauleezand you can mostly recover from it
18:42ohpauleezAgain, most people don't roll systems this way, but I think it's pretty smart, and it makes dealing with the lawyers easy (if you're a data driven startup or a data driven app_
18:42ohpauleez)
18:42Deranderseems to me that the odds of breaching a single collection and not breaching anything else are astronomically low
18:42joshua__Could you do the same thing by having a :passwords collection with user/password and than having a :users collection that has everything else for the user?
18:43joshua__Oh, this isn't standard practice?
18:44ohpauleezDerander: Really?
18:44Deranderthat's how it seems to me. I can envision circumstances where it happens
18:44ohpauleezUsing frameworks and smart access to the DB, I think that Injection attacks are hard enough, and when security holes do slip it, it usually only exposes a table or two
18:44ohpauleezor a collection or two
18:45hvtechnomancy: yes it is similar to nailgun to some extent, except I used AF_UNIX instead of TCP sockets to make it fast and secure. also there is FD passing which let's you give the terminal's stdin, stdout, stderr to the service (e.g. to clojure). I cannot remember if nailgun passed env vars to the service, but clove does (clove-clojure even binds it to clojure.core/*env*, so you can just do things like (*env* "PATH"), *pwd*, etc.)
18:45ohpauleezMongo is a little harder because you can execute mostly arbitrary js in some circumstances
18:45DeranderI'm having trouble envisioning an injection that would only work on a single collection, but I'm sure it exists
18:47Derander on the other hand, how far do you want to go?
18:47Deranderwhy not keep the passwords on another server or something?
18:47hvohpauleez: who do you handle lost/"forgotten" passwords?
18:48ohpauleezhv: the password links to the email
18:48ohpauleezso you can still reset
18:48ohpauleezwithout knowing the actual user
18:49hvcool. that's smart.
18:49Deranderwhy not store half of the password hashed in one collection?
18:49Deranderand half in another
18:50ohpauleezDerander: Now you're making me look soft. or foolish. :)
18:50Deranderwell, there is a line somewhere
18:50DeranderI see your argument
18:50joshua__why are they in the same database?
18:50hvjoshua__: they don't need to
18:50ohpauleezDerander: My point is, if you have startup, and you have PII, it's the first thing you need to square away with lawyers
18:51ohpauleezthe setup I described is a little overkill, but it also keeps everyone happy
18:51ohpauleezand doesn't suffer too much performance
18:51Derandernot familiar with the laws
18:51joshua__ohpauleez, I don't need any personally identifiable information, does that mean this is overkill for me?
18:52Deranderohpauleez: my perspective is that a certain point you're fucked. I tend to draw that line at "executing code"
18:52ohpauleezif you're building a little hobby site or the service isn't indexing data on a particular user, you can do whatever you want, just hash the passwords
19:01technomancyyou want bcrypt
19:01technomancyhttp://codahale.com/how-to-safely-store-a-password/
19:16brehaut(inc technomancy)
19:16sexpbot⟹ 7
19:17brehautmany minutes late, but thats a great reference
20:23brehauthow frequently is the clj-dev ml request for member ship queue cleaned out?
20:26_user_ She was right. The women who’d been naturally well-endowed before were
20:26_user_ notoriously reluctant to get the shot. The world had changed, for sure.
20:26_user_ A woman with a double D chest, or even a double E could blend in easily
20:26_user_ at this point. The ones who started out with nothing for the most part
20:26_user_ found the extra breast growth a wonderful life enhancement and boost to
20:26_user_ their self-esteem. A fun adventure. But a woman who grew up
20:27_user_ self-conscious of her large bosom—as was common with many women a D cup
20:27_user_ or larger—always worried about attracting the wrong kind of attention,
20:27_user_ or being thought of as a bimbo; the fact that the world had changed
20:27_user_ around them did nothing to remove their ingrained trepidations and
20:27_user_ ‘body issues’.
20:27_user_ And Kelly’s sunny testimonial to the contrary, larger-busted women were
20:27_user_ by no means immune to Efema’s effects. One cup size or less was
20:27_user_ definitely the exception to the rule. Two to three cup sizes of growth
20:27_user_ was considered the norm. And while no one was at risk of the seven cup
20:27_user_ sizes of growth that Sarah had been made to endure, some women
20:27_user_ experienced four or more jumps in size, even on the new accelerated
20:27_user_ eight week formula.
20:27clojurebotCool story bro.
20:27_user_ Tracy and her kind needed to be vaccinated against breast cancer. That
20:27_user_ was the bottom line. But she had good reason to doubt she’d be as
20:27_user_ ‘lucky’ as her friend Kelly.
20:27_user_ “A natural-born double D will probably wind up an F or a G cup. Or
20:27_user_ larger. But so what?!” Sarah asked hypothetically. “Tracy’s a big
20:27_user_ crybaby if you ask me. So what if she winds up a G cup. Or an H cup for
20:27_user_ that matter? Walk a mile in my K cups, honey. Then lets talk.”
20:27_user_ A car pulled up outside and two car doors slammed shut. Dean jumped up
20:27_user_ and peeked out the closed curtains. “It’s my mom and dad.” They were
20:27_user_ making one of their notorious unannounced pop-in visits.
20:27_user_ Sarah got up and padded into the back bedroom to get a clean shirt. She
20:27_user_ could hear John and Brenda at the front door while she was still
20:28_user_ standing there in her bra staring at her closet. She grabbed a button
20:28_user_ up top, snaked her arms into its short sleeves and made quick work of
20:28_user_ the buttons, though pulling a shirt together across the apex of her
20:28_user_ bust was always a careful consideration. Her buttons were always coming
20:28_user_ loose and needed to be sewn back on all the time. She checked herself
20:28_user_ in the full length mirror, applying a quick dash of lipstick to help
20:28_user_ distract from dark circles under her eyes.
20:28_user_ “Where’s that Sarah?” she could hear Brenda asking loudly from the
20:28_user_ living room.
20:28_user_ “Right here.” Sarah said as she emerged from the bedroom looking more
20:28_user_ put-together than Dean could remember seeing her in almost a week.
20:28_user_ Brenda extended her arms to her daughter in law and embraced her and
20:28_user_ kissed her on the mouth. Sarah suppressed a tiny orgasm, tensing her
20:28_user_ loins. John and Dean looked on dumbly as their wives pressed their
20:28_user_ boobs into each other and held the embrace.
20:28_user_ “How’ve you been? We haven’t seen you in weeks.” Brenda asked
20:28_user_ cheerfully, aware probably of the little thrill she’d just given Sarah.
20:28_user_ She held her daughter-in-law at arms length but grasped her hands,
20:28_user_ interlocking fingers with hers, not letting go. As always, Mrs. Sutton
20:28_user_ helped herself to a lingering apprising view of her Sarah’s incredible
20:28_user_ 34 Ks.
20:28_user_ “I’m good. We’re good.” Sarah said with a weak smile.
20:28_user_ “You look tired dear.” Brenda responded with a concerned scowl.
20:28_user_ “Brenda!” John Sutton shouted, admonishing his characteristically rude
20:29_user_ wife.
20:29_user_ “Mom…” Dean echoed his dad’s sentiments.
20:29_user_ “I know! I know!” Sarah admitted she did look tired. She confessed
20:29_user_ she’d been sleeping terribly lately.
20:29_user_ “You look beautiful as ever.” Mrs. Sutton reassured her.
20:29_user_ “Oh, I don’t know about that. I could use a good night’s sleep.” Sarah
20:29_user_ blushed, ashamed slightly at being forced to talk about her sex life in
20:29_user_ front of Dean’s parents.
20:29_user_ The Sutton’s knew full well what she meant by that comment. They could
20:29_user_ all see the bags under Sarah’s eyes, and the general fatigue that
20:29hiredmanhuh
20:29_user_ seemed to settle around her narrow shoulders.
20:29_user_ “You look like you’ve lost weight. Have you lost weight?” Brenda asked.
20:29_user_ Sarah sighed.
20:29_user_ “Mom, come on.”
20:29_user_ She did look like she’d lost weight, mainly in her face. Her once plump
20:29_user_ cheeks and soft chin looked harder these days. Were it not for the
20:29_user_ enormous tits bursting the seams of her tiny top one would say she
20:29_user_ looked malnourished. To make matters worse her hair was dirty and
20:29_user_ getting longer and at the moment was not particularly fetching.
20:29_user_ “I don’t think so. I haven’t weighed myself recently.”
20:29_user_ “Well you look beautiful” Brenda concluded, shaking Sarah’s hand in
20:29_user_ hers until her thin arms bounced against the sides of her boobs.
20:29_user_ “So what brings you guys by?”
20:29_user_ “Oh, we were just in the neighborhood and thought we’d stop by. After
20:30_user_ we missed out on lunch this morning.” Brenda gave a sideways glance at
20:30technomancy~botsnack
20:30_user_ John and elbowed Dean as she passed by and walked toward the kitchen.
20:30_user_ She knew about Dean and Sarah’s frequent mid-day trists. It was Sarah
20:30_user_ that had told her about them.
20:30_user_ “They don’t mind you taking off early of a morning?” John asked, taking
20:30_user_ a seat on the couch.
20:30_user_ Dean sat back in his chair and grabbed the TV remote, turning the
20:30_user_ volume down.
20:30_user_ Sarah overhead John’s comment as she helped Dean’s mother find
20:30_user_ something to drink. Brenda spied the food-stained tee shirt in the sink
20:30_user_ but said nothing.
20:30_user_ “So yeah, what ever happened with Olivia today? You never told me.”
20:30hiredmansorry, when I saw the flooding my first instinct was to kill the bot incase it was somehow related
20:30_user_ Sarah voice rang out from the kitchen.
20:30_user_ It occurred to Dean just now that his mom and dad would be coming in to
20:30hiredman~botsnack
20:30_user_ the gym for their regular workouts. They’d wonder what was up when he
20:30clojurebotthanks; that was delicious. (nom nom nom)
20:30_user_ wasn’t there. He’d have to tell them eventually. But he wasn’t ready to
20:30_user_ tell the family he’d lost his job.
20:30_user_ “Oh, yeah. She wanted to straighten some stuff out with the schedule.
20:30_user_ We’re overstaffed. Not enough hours for all these new trainers.”
20:30_user_ “Overstaffed?” John asked.
20:30_user_ “Oh you know the usual. Everyone wants more hours. Most of these
20:30technomancythe botsnacks must flow</blue-eyes>
20:31brehautwhat does the botsnack do?
20:31technomancyit's like a scooby snack
20:32hiredmanit makes you anthropomorphize to the bot
20:32hiredman~clojurebot
20:32clojurebotclojurebot is a multimap
20:32hiredman~clojurebot
20:32clojurebotclojurebot is amazing
20:32hiredmanbleh
20:32technomancyclojurebot: would you do it for ... three botsnacks?
20:32clojurebotCool story bro.
20:32technomancy...
20:32hiredman~botsnack
20:32clojurebotthanks; that was delicious. (nom nom nom)
20:58mattmitchelli'm following this article: http://debasishg.blogspot.com/2010/09/domain-models-thinking-differently-in.html
20:59mattmitchelland tried the macro he posted, which uses redef. But redef doesn't exist.
20:59mattmitchellAnyone know where redef is?
20:59hiredmanI recommend against ever doing anything you see in a blog post
21:00hiredmanredef sounds horrid
21:00hvhiredman: not even http://bc.tech.coop/blog/ ?
21:00mattmitchellhiredman: ?
21:00hiredmanyes
21:01brehautmattmitchell: the implication that people who blog about clojure generaelly dont know what they are talking about and are advocating crazy
21:01hiredmanmattmitchell: top level defs are best thought of as single assignment constants
21:01mattmitchellhiredman: i see
21:02technomancybc.tech.coop has some particularly bad advice about setting up slime
21:02mattmitchellhiredman: "redef" does sound bad you're right. i'm just trying things out though.
21:03sritchieright before he introduces redef: "Weeee .. it's a macro :)"
21:04hiredmana. there is no reason for it to be a macro b. the idea of "re-defining" something is flawed
21:04hiredmanc. you read about it in a blog post
21:04hiredmanthe damning evidence mounts
21:05technomancyyeah, get it right the first time; honestly.
21:05mattmitchellok let me ask you all... i'm in the process of setting up "models" for my application. what's the best way to design models in clojure? I have a basic page model i'm starting with.
21:06mattmitchella page pulls in content from a file. i need to be able to save, update and delete these "pages".
21:06hvumm, what is a "model"? as in model/view/controller ?
21:07hiredmanI think you are better off with a set of limited protocols you can extend to the objects you have holding your data
21:07mattmitchellhiredman: ok yeah i started looking at protocols tonight.
21:08brehautmattmitchell: think more like you would design an SQL schema than an OO network
21:08dnolenmattmitchell: start with maps (models/data/whatever) and regular functions. then maybe you'll decide you need multimethods for polymorphism.
21:09dnolenmattmitchell: I'd recommend against protocols when you're modeling.
21:09dnolenlots of limitations, and it's much more tedious.
21:09hiredmantedious in what way?
21:09dnolenI'd reach for them when a) you have a real design, b) if you actually need the performance.
21:09mattmitchelldnolen: that's how i began, until i googled, and found that awesome article :)
21:09dnolenhiredman: more code, more design.
21:10technomancyyeah, nothing you've said so far hints towards needing polymorphism
21:11mattmitchellnothing complex at this point. a "page" accepts a filename, loads the content, knows how to save/update/delete etc.. that's about it.
21:11brehauta lot of the polymorphism you'll end up using is through parametric polymorphism and hofs rather than switch-on-type, which is different enoguh from what people with a lot of OO experience may not even recognise as polymorphic
21:12hiredmanI find multimethods much more tedious
21:12mattmitchellbrehaut: sorry, what is hofs?
21:12brehauthigher order functions
21:12hiredmanyou can't deal with a set of multimethods as a single unit
21:12mattmitchellbrehaut: ahh ok
21:12dnolenmattmitchell: doesn't even sound like you need a model. just some functions. your.ns.page/load, your.ns.page/update, etc.
21:12technomancynamespaces can bundle units of multimethods
21:13mattmitchelldnolen: true, seems like the simplest too
21:13technomancyeven better: namespaces can bundle units of functionality; whether they are all multimethods or some are regular fns is an implementation detail
21:13hiredmantechnomancy: right, but that hardler ever makes a nice clean interface
21:13hiredmanhardly
21:13technomancythe only strike against multimethods is they got a lot less convenient when defonce semantics were introduced to them
21:14hiredmantechnomancy: I could come argue this at your table
21:14technomancyhiredman: yeah, why don't you say that to my face?
21:14brehautmattmitchell: this is a long paper but its chock full of insights http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf
21:14hiredmantechnomancy: if I did then who would make emacs work when I break it?
21:15technomancyhiredman: talk to the M-x butterfly
21:16mattmitchellbrehaut: wow that's some serious readin'. thank you, i'll dig in.
21:17brehauttechnomancy: rofl
21:19hiredmanhttp://groups.google.com/group/clojure/browse_thread/thread/83ad2eed5a68f108?hl=en
21:20hiredmanit amazes me how convoluted people can make things
21:20brehauthiredman: at least he recognises it
21:20dnolenmattmitchell: word of advice, just do the simplest thing. OO brainwashes people into over-engineering, wasting time generalizing. Prolly cause OO code is painful to refactor, FP code less so.
21:21hiredmanbrehaut: he parrots "eval is evil" but then does this whole crazy concat thing which has nothing to do with anything
21:22brehautoh sure, hes neck deep in crazy
21:22mattmitchelldnolen: excellent thanks for the advice
21:22hiredman'(Person. "Peter" 18) vs. (concat [(symbol "Person.")] ["Peter"] [18])
21:23hiredmanI dunno why he just doesn't create a factory function
21:24brehautif he's a noob maybe he thinks he is supposed to mash a bunch of lists together and then do some metaprogramming ?
21:24brehautout of fear that anything else isnt lisp?
21:24hiredmanI don't know
21:24hiredmanit's just bleh
21:25hiredmanlike, you want to build a record from names that resolve to values, but you want to delay the binding of the names to values till runtime
21:26hiredmananyway, I will stop raving
21:47mattmitchellwould anyone recommend using clojure as a yaml config alternative? i have a yaml file that defines db connection info etc.
21:47brehautmattmitchell: does it only need to be used by clojure?
21:47mattmitchellbrehaut: actually yes
21:48brehautthen yes
21:48mattmitchellbrehaut: i mean, a developer will edit etc.. but the only the *using* it is clojure
21:48brehauti have a project.settings clj namespace i use. but you could easily use read to load a file
21:49brehautid lean toward a namespace until you know you need a more dynamic config system
21:49mattmitchellbrehaut: cool. i'll give it a try.
21:49brehautas its trivial to reload in the repl and you probably wont need to reload it in production. remember: simple is good
21:51mattmitchellbrehaut: simple is good. reading that paper now :)
21:51pdkwait what
21:51brehautmattmitchell: i would encourage you to wathc mark mcgranaghan's "one ring to bind them" presentation btw. its a exemplifies how using clojure core datatypes and functions makes life easier
21:51pdkthis guy is blabbering making dynamic records
21:51pdkand he doesn't know about apply
21:51brehautpdk easy on the noobs; crazy or not they are still noobs
21:52hiredmanat work we have a config system build on reading config.clj files from the classpath and merging together the clojure maps they contain
21:56pdkoh shi
21:56brehauthiredman: do you use the reader explicity or just require it?
21:59hiredmanbrehaut: hmmm?
21:59hiredmanthe clojure reader?
21:59brehautyeah
22:00hiredmanwe use the reader explicitly, it's not meant to be a namespace, there are no defs, the file just contains { … }
22:00brehautah sure that makes sense
22:03mattmitchellhiredman: so i'm doing just a (def settings (load "myconfig.clj")) -- myconfig.clj contains a simple hash-map. Is that about it?
22:04hiredmanif that works for you, keep in mind load will eval code, not just read datastructures
22:04mattmitchellhiredman: ok thanks
22:07technomancyhiredman: pretty sure that's what we do
22:07technomancysince we need config files to be able to uniquify tmp dirs and such
22:08hiredmanI know
22:08hiredmanand I think it's kind of nuts to do that in a config (but kind of handy)
22:09technomancynuts and handy often go together
22:09brehautmattmitchell: http://clojuredocs.org/clojure_core/clojure.core/read
22:10hiredmanload happens to resolve the classname via the classpath, which read doesn't, and is handy
22:11hiredmanwell, classname, filename whatever
22:12mattmitchellso read, just reads data structures without evaluating the code (possibly function calls) etc.?
22:13mattmitchellwell, returns the "next" data structure in the stream. ok i see.
22:13hiredmanthere is this eval reader form, the existence of which is not really advertised
22:13hiredmanwhich causes some evaluation to happen at read time
23:01zakwilsonI am trying to decide between using Rails for a new website, or Clojure and an ad-hoc collection of libraries. Rails would be easy, but I like Clojure better than Ruby and ClojureQL looks ilke like it might be a really nice way to interact with a database
23:05gfrlogzakwilson: I have found clojureql to be exactly as much fun as you are expecting it to be
23:08zakwilsongfrlog: I'm watching the screencast now and it's looking very appealing. I've done web stuff in Clojure before, but never with a database. My new project is going to involve a bunch of joins, and this looks like a nicer way to do it than the Rails OO way.
23:15gfrlogyeah. I did a bunch of complex joiny things with it. It worked pretty well. I love the clojure-style immutability much better than active record
23:16gfrlogand it's not terrible like cc.sql
23:16gfrlogI had a hitch or two, but Lau was quite helpful
23:17zakwilsonI think I'll go the Clojure route then. Rails might be easier short-term, but I don't like OO.