#clojure logs

2010-12-23

00:05joshua__I'm using congomongo and I have a database with one record in it. Calling destroy! on that one record isn't doing anything.
00:05joshua__Thoroughly confused.
00:07amalloyjoshua__: you call destroy!, not on a record, but on a where clause, is my recollection
00:07amalloya consequence of this is that (destroy! {}) will delete the whole database
00:08amalloyi mean, i guess a record evaluates to a where clause that identifies itself perfectly, so maybe that ought to work
00:09scottjon old congomongo I think you could do (destroy! :collection {})
00:09joshua__I figured that out just a second ago =).
00:09joshua__amalloy, you right.
00:10joshua__amalloy, the problem for me was that the examples didn't show a where clause they showed an object and as it turned out that object was simple enough that you could use it as the where clause safely.
00:11joshua__amalloy, but my object was a bit more complicated
00:11joshua__amalloy, so if I used the object as the where clause it didn't delete anything.
00:11joshua__amalloy, deleting based on the key of the item I wanted to delete worked though
00:12joshua__$(doc destroy!)
00:12joshua__&(doc destroy!)
00:12sexpbotjava.lang.Exception: Unable to resolve var: destroy! in this context
00:13joshua__oh wells
00:28ossarehlo all
00:32bhenryam i doing something wrong or can i really not use cake without having ruby?
00:39tomojany gloss users around? trying to figure out how to encode [[1 2 3] [4 5 6] [7 8 9] [10 11 12]] as "4,1,4,7,10,2,5,8,11,3,6,9,12", where the "4" at the beginning is a length prefix
00:40tomojand actually, each tuple position has a different type, so you get one length prefix and then three lists of that length of different types
00:41amalloytomoj: have you tried writing a function to do that in clojure, before worrying about how to do it with gloss?
00:41tomojno, it's too late
00:41amalloy?
00:41tomojbut that's fairly easy
00:42tomoj&((fn [v] (cons (count v) (apply mapcat vector v))) [[1 2 3] [4 5 6] [7 8 9] [10 11 12]])
00:42sexpbot⟹ (4 1 4 7 10 2 5 8 11 3 6 9 12)
00:43amalloytomoj: and with such a function, you could give gloss a less complicated structure, right? just ask it to send all those numbers?
00:44tomojhmm
00:44joshua__What is gloss?
00:44tomojhttps://github.com/ztellman/gloss/wiki
00:44tomojI could use a function like that to compile a new frame dynamically upon receiving the length prefix
00:44tomojbut that would be slow
00:45amalloytomoj: well, i've barely even looked at gloss, so i'm mostly just trying out ideas to see if any of them stick
00:56amalloytomoj: you said the tuples have different types - those types are known at compile time, right?
00:56tomojyes
01:11amalloytomoj: it doesn't look possible to me without compiling a new frame on receipt. the gloss repetition primitives assume that they'll either have a built-in prefix, or will be allowed to consume everything it sees
01:11tomojright
01:11tomojI have cooked up something with header that seems to do the trick
01:11amalloyif the variance in sizes is small, you could precompile all the frames that you might need
01:11tomojright
01:12amalloytomoj: really? i'd like to see it, if you don't mind
01:12tomojhttps://gist.github.com/0d834768928c7e484b38
01:13amalloyah. yeah, that's all i could come up with too
01:13tomojthen I call it like (tuple-list :int16 coordinate :byte :byte) to generate a codec which encodes a list of tuples like <coord, byte, byte> into a short-prefixed list of all coords, then bytes, then bytes
01:15amalloyright
01:17tomojunfortunately I can't see how to make a coordinate codec that splits up bytes
01:17tomojI think someday gloss/aleph/lamina will be pure awesome
01:20amalloytomoj: like have 4-bit numbers, you mean?
01:20tomojexactly
01:21tomojI guess it's fairly easy with a custom Reader/Writer implementation
01:41tomojs/I think someday // s/will be/are/
01:49amalloycan someone help me understand the timing and execution-ordering, during syntax-quote/macro/eval stuff? https://gist.github.com/752664 is a brief example of something that seems like it "should" work but doesn't
01:55zvrbaok, i like the ideas behind the JVM and clojure, but i can't stand Javas crappy OO-API. is there a Clojure library that makes, at least, I/O and conversions as simple as in C?
01:55zvrbai'm talking about fopen/fgets/atoi/sprintf/sscanf/..
01:56zvrbai don't want to spend an afternoon plowing through java docs just to open a file.
02:03amalloyzvrba: clojure.java.io isn't bad
02:05amalloybut you won't find fgets
02:05zvrbais there a better-formatted documentation than http://richhickey.github.com/clojure/clojure.java.io-api.html
02:06amalloyhttp://clojuredocs.org/clojure_core/clojure.java.io/reader is probably worse-formatted for quick reference, but has example usages and stuff
02:06zvrbaoh
02:06zvrbanice
02:07ngwnice
02:07ngwdidn't know that
02:07amalloyhttp://clojure.org/cheatsheet can be useful to find out what name to use for a function you're thinking of
02:07amalloybut it doesn't have clojure.java.io, just the core stuff
02:08zvrbaok, that cheat sheet is one of the best i've seen :-)
02:09zvrbanow. i've started to write some small programs in common lisp. and i'd like to learn some lisp-like language.
02:09zvrbawhat would be the advantage of "switching" to clojure, if any?
02:10zvrbaor.
02:10amalloyzvrba: well, it's better. duh :)
02:10zvrbaamalloy: :) in what way?
02:10zvrbabtw, does emacs slime work equally well with clojure as with CL?
02:10zvrba(note: i'm using windows)
02:10amalloyzvrba: quite well, but not equally well
02:11zvrbaa year ago I tried to use netbeans/eclipse/jetbrains plugin for clojure, and none worked well.
02:13amalloyzvrba: clojure has more convenient names and syntaxes for almost everything; this really adds up over time. it's also very nice to (a) run anywhere java runs, and (b) be able to use any java library. the community is friendlier...
02:15amalloyit leans very heavily on functional programming and lazy sequences, which leads to some amazing conclusions, but it has good support for non-functional, mutable stuff for when a functional style would be unnecessarily tangled
02:15zvrbaamalloy: can you give a concrete example of more convenient names?
02:15zvrbaright, i wanted to get my hands more dirty with functional progrmaming.
02:16zvrbai guess clojure is better for that; it's way too easy to fall back to imperative style in CL
02:16amalloywell, it's been a while since i've used CL. but i seem to recall that CL's syntax for a hash-map is something like (hash-map 1 a 2 b) or something?
02:16zvrbayou mean, hash literals?
02:16amalloyyeah
02:16zvrbai don't know, didn't need that yet :)
02:16amalloyheh
02:17zvrbai've written just small pieces of code in CL, no serious big projects
02:17amalloywell okay, even just lists/vectors
02:17zvrbai see that clojure is not uniform -- sometimes I have to use [], and sometimes ()
02:17zvrbait seems kinda ugly and that I have to learn special cases of when to use what
02:17amalloyzvrba: i was about to get into that, actually. you will realize that it's "get to"
02:18zvrba"get to"? I didn't get that :)
02:18amalloyyou "get to use" [] intead of()
02:18zvrbaah, so I can choose which i will use?
02:19amalloyif you want a list of a, 1, and the symbol 'c in CL, you have to write (list a 1 'c); that's available in clojure, but far more usual is [a 1 'c]
02:19zvrbaah
02:19zvrbaone thing that annoyed me in CL: '(1 2 3) is a literal list that can be modified at run-time
02:19zvrba[a 1 'c] is literal list, but can it be modified at run-time?
02:19amalloyzvrba: hardly anything can be modified at runtime
02:20zvrbaand is there a difference between (list a 1 'c) and [a 1 'c] ?
02:20zvrba(in CL, (list a 1 'c) *always* generates a new list)
02:20zvrba(whereas '(a 1 c) is a "singleton", in the lack of a better name)
02:20amalloyzvrba: there is! (list a 1 'c) is a linked list of cons cells; [a 1 'c] is a magic clojure data structure with fast random access as well as fast appends to the end
02:21amalloywell, i say "appends". like most clojure things, you don't actually change the vector, you just get out a new structure that's different
02:21zvrbamhm
02:21zvrbadoes Clojure also accept '(a 1 c) syntax?
02:21amalloyyeah
02:21zvrbagoodie
02:22amalloybut that doesn't get you the value of a; it gets you the symbol a, just like CA
02:22amalloyCL
02:22zvrbai know
02:22zvrbaor
02:22amalloy&(reduce + (map inc [1 2 3]))
02:22sexpbot⟹ 9
02:22zvrbauh
02:22amalloyis an example of something you can express much more succinctly and naturally in clojure than in CL
02:23zvrbai'd like to start with clojure, but I hesitate because I don't really want to mess with standard java API, but i must if i want to do anything useful :/
02:23zvrbai seriously personally think that Java API is an abomination and an example of how NOT to design software
02:23zvrbaamalloy: ah, function names are self-evaluating?
02:23zvrbano need for quoting?
02:24amalloyzvrba: mmmm, something in between
02:24amalloyclojure has one namespace that contains both functions and variables/locals/whatever
02:24amalloyso you don't have to use #' to specify which you mean
02:25zvrbaok
02:25zvrbawhich IDE is most stable?
02:25amalloyzvrba: meh. i like emacs
02:25zvrba:)
02:25amalloyit's most popular, but eclipse is getting traction
02:26zvrbadoes "apropos" and "describe" work?
02:26zvrbai don't want to use eclipse.
02:26zvrbaperiod :)
02:26amalloyzvrba: i don't know
02:26zvrbaok, when you write (reduce ..) do you get sensible names as hints in the status-row?
02:26amalloyzvrba: yeah, eldoc works
02:26zvrbawhen I used CLISP, all I got was (reduce arg0 arg1..) which was totally useless
02:27zvrbawith ClozureCL I get sensible names, e.g. (reduce function seq ...)
02:27zvrbaok, that was useful to know
02:27amalloywhen i write (reduce ..), the minibuffer reads ([f coll] [f val coll])
02:27zvrbagood, that's what I was interested in :)
02:28zvrbado you use it under linux or windows?
02:28zvrbaany hints about emacs setup?
02:28amalloyubuntu 10.04
02:29Rayneshttp://www.assembla.com/wiki/show/clojure/Getting_Started_with_Emacs
02:29amalloyah, thanks Raynes
02:31RaynesIt's a tiny bit outdated though. The elisp binaries for Clojure stuff are in phil's own repo.
02:32RaynesNewer versions anyway.
02:32zvrbaok, thanks
02:33amalloyzvrba: you can do a lot of stuff without having to call java libraries, if that bothers you, especially as a lot of them have clojure wrappers already
02:36amalloyi usually use the java builtins for things like strlen, but clojure.string contains equivalent stuff if you prefer
02:37zvrbai'd prefer wrappers around Java APIs for common stuff, yes
02:40amalloy&(count "a string") ; treats the string as a sequence of characters
02:40sexpbot⟹ 8
02:45zvrbawhat is leiningen ?
02:46amalloyzvrba: a build/dependency tool to save you from java
03:45amalloyzvrba: find anything you like?
03:50zvrbaamalloy: haven't started yet. real-life chores, heh. i think i'll go with emacs.
04:53LauJensenMorning all
04:54raekNingmor Lau
05:28dsophmm it seems that (string (http-agent "http://foo&quot; :method "POST" :connect-timeout 100)) hangs forever
05:42AWizzArddsop: I also was using http-agent until recently. But this lib was stopped, and I suggest you to better switch to the Apache HTTP Client.
05:42dsopAWizzArd: hmm k
05:43dsopwhy do they stop libs in contrib?
05:43AWizzArddsop: because a http client is a complex tool. It takes months and months to develop a feature rich one that is also stable.
05:44RaynesWhy switch to apache-http-client direction? Check out clj-http. It's a nice wrapper and is designed similarly to ring.
05:44midsRaynes: I don't think clj-http allows you to set timeout values though
05:45RaynesThere is no shorted of Clojure HTTP clients though. Might be one that does.
05:46dsopRaynes: afaik clj-http doesnt work on appengine
05:48AWizzArdRaynes: a wrapper is fine, but it still needs something substantial under the hood. This would be the Apache client, or maybe the one from JBoss.
05:48AWizzArdAnd the question is: does a wrapper significantly increase your productivity?
05:49RaynesNot having to read Java docs and learn a new Java API certainly does. At least for me. Nonetheless, if clj-http and clj-apache-http don't support timeouts, then there isn't much of a choice in the matter.
05:50AWizzArdThose wrappers can indeed help, for the most basic tasks. One will read a few minutes the docs and can start. Reading the Java docs might require the double time, such as 8 minutes vs 4.
05:50AWizzArdAnd for 20 minute projects this is a big win.
05:52AWizzArdBut for real applications you have needs such as specifying that you can accept gziped replies, cookie management, NTLM Authentication, etc.
05:53RaynesMy point is that Clojure is more accessible to Clojure programmers. If there is a Clojure library/wrapper library that does what you need, I wouldn't see the purpose of using a Java API directly unless there was some real need for it. Readers of your code will thank you.
05:54dsopI prefer clojure wrappers over java interopt
05:54sandGorgonwhile invoking lucene from clojure, I get back a TermEnum, which is a custom enumerator class with prev and next. Now I need to run a map on this TermEnum - which I can do because clojure " Don't know how to create ISeq from". How do I solve this ?
05:54AWizzArdDifficult to answer this in general.
05:55sandGorgons/can/cant/
05:55sexpbot<sandGorgon> while invoking lucene from clojure, I get back a TermEnum, which is a custom enumerator class with prev and next. Now I need to run a map on this TermEnum - which I cant do because clojure " Don't know how to create ISeq from". How do I solve this ?
05:55AWizzArdWrappers have their own set of advantages and disadvantages.
05:55raeksandGorgon: you could make your own lazy seq
05:55AWizzArdI prefer what makes me more productive. This can be a wrapper, but this can also be the original API.
05:56sandGorgonraek, i thought something like that was the answer - any examples on that ?
05:56_mstsandGorgon: I usually do something like this: (take-while identity (repeatedly #(when (.next terms) (.term terms))))
05:56_mst(where terms is your TermEnum)
05:56raek(defn term-seq [t] (when t (cons t (term-seq (.next t)))))
05:57raeksandGorgon: assuming .next returns nil when there are no next thing
05:57raek(defn term-seq [t] (lazy-seq (when t (cons t (term-seq (.next t))))))
05:57raekI meant...
05:58raekit isn't very lazy without the lazy-seq part... :-)
05:59sandGorgonraek, ok.. good starting point. I'll figure it out from that - thanks!
06:10raeksandGorgon: I just peeked into the javadocs for TermEnum. it turns out .next does not return a new thing, but changes the object in-place. so you cannot use my approach
06:10raekalso, that class is deprecated
06:12sandGorgonraek, oh ? thanks for doing that
06:14sandGorgonraek, the java code was something like "while(terms.next()){ Term term = terms.term();} . Why does in-place affect your code ?
06:20raekmy snippet incorrectly assumed that terms.next would return a new "terms" object, rather than a boolean
06:21raek(defn term-seq [terms] (lazy-seq (when (.next terms) (cons (.term terms) (term-seq terms)))))
06:21raekthis would work
06:22raekthe resulting seq is also thread safe, if term-seq is the only thing that gets the terms instance
06:23raekbut the underlying terms object is not
06:23raekso clojure fixes it :-)
06:34sandGorgonraek, awesome - thanks !
06:47AWizzArddsop, Raynes: the clj-http wrapper looks good and clean. The timeouts can still be set up through the API. The wrapper wraps the Apache HTTP Client.
06:48RaynesAWizzArd: Right. I figured that timeouts could be set *somehow*.
06:48dsopAWizzArd: I try it, but as said I ran into troubles using a couchdb wrapper that uses clj-http because some stuff was forbidden on appengine
06:48dsopso I hvae to check if clj-http works on appengine
06:50AWizzArdAh okay, I missed the appengine part.
06:50AWizzArdBut doesn't the appengine offer you a http client?
06:50dsopyes kindof
06:50dsopbut I prefer getting a clojure version :)
06:51AWizzArdWell, the Apache Client seems to work. So in principle clj-http should too.
07:33dsopAWizzArd: just as a side note: http client v4 doesnt work on appengine out of the box
07:38fliebelmorning
07:49DranikI'm using swank-clojure. Trying to C-x, C-e on (println "Hello, World!") but nothing happens. How can I evaluate a clojure form?
07:50mrBlissDranik: println returns nil, so you won't see the "Hello, World!"
07:51AWizzArddsop: not nice
07:51DranikmrBliss, so which command should I use?
07:52mrBlissDranik: I don't think there is a version of print that also returns the string, but if you're just checking if C-x C-e works, you can just eval "Hello World"
07:52DranikmrBliss, Bingo!! :-)
08:13raekDranik: when evaluating (println "Hello, World!"), the text appears in the repl buffer (*slime-repl clojure*)
08:26fliebelWhat do the WP bloggers among you use to highlight Clojure? (or embed gists)
08:29Raynesfliebel: Syntaxhighligher works well.
08:29Raynesfliebel: Look for the "Syntaxhighlighter Advanced" or whatever plugin.
08:30fliebelRaynes: I found evolved, if that's what you mean.
08:30RaynesYeah, that's it.
08:30RaynesI use it.
08:30fliebel*checks some code on Raynes site*
08:32fliebelRaynes: The only code I see is a rather ugly darkblue and has needless scrollbars :( But it seems it does Clojure just fine.
08:33fliebel*do
08:33fliebelno wait
08:33fliebeloh, whatever
08:33cemerickfliebel: WP.com has clojure highlighting baked in
08:34Raynesfliebel: All of that can be changed on the settings page.
08:34fliebelcemerick: I'm self hosting. But I think what Raynes mentioned is the same they use.
08:34cemerickyeah, probably
08:35fliebelcemerick: long live automation :) I'm planning to set up a multisite to manage sites for my clients as well. I fear some of them might be running WP 2.3 or something like that ;)
08:36cemerickI self-hosted WP for a couple of years. It seems like you really need to know php and the security bits around it to make it work well.
08:37cemerickThe pain associated with always having to carefully port (necessary) tweaks given a new version of WP was what really pushed me off of it.
08:38fliebelcemerick: I know those :) What kind of tweaks? 'official' tweaks(plugins) are fairly consistent across versions as far as I know.
08:39cemerickfliebel: I'm sure I don't remember. This was years ago.
08:40fliebelcemerick: Good for you, if you can live with WP.com ;)
08:42cemerickDoes it have downsides I don't know about?
08:43RaynesThe only time I ever had to touch PHP was to define a couple of documented constants in the config file when I moved the site to new servers.
08:48Gigarobyguys is there any function to map every value of a list with a increasing number --> (index ("a" "b")) => ((0 "a") (1 "b"))
08:49GigarobyI do know how to implement it but I was just wondering if there is any alredy made
08:50mrBlissGigaroby: clojure.contrib.seq/indexed but I thought map-indexed also existed
08:50fliebelGigaroby: I was also about to suggest map-indexed
08:50GigarobymrBliss, thanks but I do need the not-map indexed
08:50Raynes&(keep-indexed vector ["a" "b" "c" "d"])
08:50sexpbot⟹ ([0 "a"] [1 "b"] [2 "c"] [3 "d"])
08:51mrBlisshttp://clojuredocs.org/clojure_core/clojure.core/map-indexed
08:51fliebelRaynes: keep will trow out nil values.
08:51Raynesfliebel: Who needs 'em
08:51fliebel&(keep-indexed vector ["a" "b" "c" nil "d"])
08:51sexpbot⟹ ([0 "a"] [1 "b"] [2 "c"] [3 nil] [4 "d"])
08:51Raynes;)
08:51fliebelhm
08:52Raynesfliebel: It doesn't because the result of the function will never be nil.
08:52RaynesNonetheless, I guess map-indexed works just as well: ##(map-indexed vector ["a" "b" "c" "d"])
08:52sexpbot⟹ ([0 "a"] [1 "b"] [2 "c"] [3 "d"])
08:53Gigarobythe first was fine thanks cause then I need to pass it to a (every? #(not= %1 %2) (whatever))
08:56raek&(map vector (range) ["a" "b" "c" "d"])
08:56sexpbot⟹ ([0 "a"] [1 "b"] [2 "c"] [3 "d"])
08:56Gigarobyturned out I need map cause I need to start from a number different from 0
08:57Gigarobystill thank you guys
08:58raekif you just destructure the vector and pass the parts to a function, it can make sense to replace 'vector' with the consuming function
08:59sandGorgoni'm calling a function within a function - but the functions are defined separately. can I access the variables of the parent function from within the nested function's body ?
09:00raeka function that is created inside another can do that
09:01sandGorgonraek, actually I have a filter that is being used, which needs to access the variables of the parent function. but I cant pass more than one variable to a filter function right ?
09:03raekyou could do something like this: (defn filter-divisible [n coll] (filter (fn [x] (zero? (mod x n))) coll))
09:04sandGorgonof course ... i was hoping there was a better way.
09:04raekthe anonymous function remebers (closes over) the environment where it was created
09:06raekif you have a complex function defined elsewhere you would like to use, you can "adapt it" with an anonymous function:
09:06raek(defn divisible [x n] (zero? (mod x n)))
09:06raek(defn filer-divisible [n coll] (filter #(divisible? % n) coll))
09:06Dranikraek, well, my *slime-repl clojure* does not show anything...
09:07raekDranik: for me, it appears _above_ the "user>" prompt
09:07Dranikit just prints the input line like USER>
09:08sandGorgonraek, what was your syntax - what is it doing exactly ?
09:08Dranikraek, yeah, that is supposed to be so. But my slime does not show it
09:08Dranikhow did you prepare your emacs?
09:08raek#(divisible? % n) is the same as (fn [%] (divisible? % n))
09:08raek% is just a symbol
09:09raek#(...) is just syntactic sugar for the fn form
09:09raekDranik: what happens if you eval the println in the repl?
09:09Dranikuser> (println "Hello, World!")
09:09DranikHello, World
09:10raekand ewhen evaluating that in another buffer, nothing happens? (besides the minibuffer displaying "nil" for a second)
09:11raeksandGorgon: that reader macro is documented here: http://clojure.org/reader
09:11sandGorgonraek, oh .. now I see what you have done. just one question : are "divisible" and "divisible?" interchangeable ?
09:12raekoh. no... that's just a typo :-)
09:13raekDranik: also, is clojure-mode activated for that other buffer?
09:13Dranikraek, how to activate it?
09:13Dranikbcs something is happening when i press c-x, c-e
09:13raekM-x clojure-mode
09:13Dranikbut definietely not what I supposed
09:13raekshould happen automatically for .clj files
09:14raekDranik: it could be that you are evaluating emacs-lisp...
09:14Dranikyep
09:14Dranikclojure-mode was activated
09:14raekI tested this with my very basic emacs setup (clojure-mode, slime and slime-repl from ELPA)
09:14Dranikthe same
09:15raeknote that only the output of print* works this way
09:15raekthe return value is not displayed in the repl
09:16raekI usually enter what I want to evaluate in repl
09:16raekand use C-M-x or C-x C-e just for reevaluating definitions
09:30Gigarobyis there any way to get this (some = <stuff>)
09:30Gigarobyreturn faolse
09:30Gigaroby*false instead of nil
09:31bhenryGigaroby: wrap it in boolean
09:32bhenry,(boolean (some #{1} [2 3 4]))
09:32clojurebotfalse
09:33Gigarobythanks
10:11Gigaroby(defn pair-equal? [[x y]] (= x y)) is that [[x y]] a valid destruct ?
10:13chouseryep
10:13Gigarobyty
12:10karthik6_any body is from india
12:33LajlaYes
12:33Lajlaany body is from india
13:16dnolen*unchecked-math* is nifty when you need it.
14:53gju_hey
14:54gju_how can i execute code sequentially?
14:54technomancygju_: wrap it in a "do" form
14:54gju_oh.
14:55gju_sec, i try. :)
15:00gju_well... i guess it works. but i have another question.
15:00gju_when i use a method that doesn't return a value but instead changes one of its parameters. how do i express that in clojure?
15:01technomancyall functions return values. sometimes that value is nil.
15:01gju_in this case its RandomAccessFile's read method which expects a buffer
15:01gju_wel... yes ok. but do you know what i mean?
15:02technomancynot really. are you having trouble calling the .read method on a RandomAccessFile instance?
15:02gju_yes.
15:03gju_i try it like this
15:03gju_(. file read buffer 0 3)
15:03gju_but it says that "buffer" is unresolvable in this context
15:03gju_but i actually don't know any better.
15:05technomancygju_: you'll need to construct a byte array for that; something like (make-array Byte/TYPE 1000)
15:15gju_works. nice. thanks.
15:15gju_looks weird tho...
15:21gju_maybe someone could give me some suggestions:
15:22gju_http://pastie.org/1401445
15:23amalloygju_: (let) has an implicit do, and allows multiple bindings
15:24amalloyso you could write (let [x 1 y 2] (stuff) (more stuff))
15:25gju_ok
15:25amalloythere's also the handy-dandy doto macro: ##(macroexpand '(doto file (.seek 10) (.read buffer)))
15:25sexpbot⟹ (let* [G__9287 file] (dot G__9287 seek 10) (dot G__9287 read buffer) G__9287)
15:25gju_ah
15:25gju_i guess i know what it does...
15:25gju_sequences of method calles to a specific object?
15:26amalloyyeah, though technically it's more general than that
15:27amalloyi assume you're coming from a lisp background; clojure's = returns true or false, not t or nil
15:28gju_i played with cl a litte in the past. so yeah kinda.
15:33amalloygju_: so https://gist.github.com/1f671546d31182bc746c is probably how i would write it. the -> stuff at the end is a matter of taste; i don't think it's substantially better than the way you did it, but i'm putting it there to expose you to ->
15:35amalloy&(macroexpand-all '(-> buffer String. (.equalsIgnoreCase "TAG")))
15:35sexpbot⟹ (let* [obj-class__6346__auto__ (clojure.core/class (new String buffer))] (let* [temp__3586__auto__ (clojure.core/some (if (clojure.core/map? clojail.core/tester) (let* [map__9304 clojail.core/tester map__9304 (if (clojure.core/seq? map__9304) (clojure.core/apply cloj... http://gist.github.com/753516
15:36amalloyoh god. i forgot the . calls turn into a huge mess when macroexpanding in sexpbot
15:36amalloyignore that, gju_ :P
16:06programbleanyone know how easy/hard it is to use Slick2d with clojure?
16:20programbleis there a project.clj spec anywhere?
16:30lrennprogramble: https://github.com/technomancy/leiningen/blob/master/sample.project.clj
16:30lrennprogramble: that's about the closest thing there is.
16:31programblefound that before you said it but thanks
16:31programbleand that kinda sucks :\
16:31programblei think i found what i needed though
16:36technomancyprogramble: what's wrong with it?
16:37programbleit isn't exactly documentation
16:37programbleand i think cake might have some extra ones that it has no docs for
16:37technomancysure, can't help you there.
16:58amalloyprogramble: what info are you looking for? i use technomancy's sample for reference
16:59programbleamalloy: nah i'm good, needed to know how to add another maven repo
17:00amalloysounds like you found it anyway, but https://github.com/amalloy/clojopts/blob/master/project.clj#L7
17:01programblegrrr my internets broke
17:02programble:\
17:02programblemy router responds to pings and has port 80 open but i can't access its page
17:07anthony_I'm trying to integrate clojure with SWT. On a MenuItem, you set the accelerator using setAccelerator, which takes an int parameter, such as SWT.MOD1 + 'A' (SWT.MOD1 is an int). I'm having trouble casting a char to an int in clojure, though. Am I missing something simple?
17:07amalloy&(int \A)
17:07sexpbot⟹ 65
17:08amalloyanthony_: that's what you want, right?
17:08anthony_That's exactly what I want. I'm ashamed of myself. Thanks.
17:08amalloywelcome
17:14anthony_I'm sure I have something fundamentally wrong. If I put this into the REPL: '(1 (+ 2 3) 4) why do I get (1 (+ 2 3) 4) instead of (1 5 4) ? I didn't quote the inner parenthesis. Is there any way to get it to return the list (1 5 4) ?
17:15amalloyanthony_: ' quotes an entire form. you probably want ##[1 (+ 2 3) 4]
17:15sexpbot⟹ [1 5 4]
17:15amalloyer...i guess ## there might be confusing. that's just to tell sexpbot to eval, not part of the code
17:16anthony_Gotcha. So I just use [ ] ?
17:16amalloyyeah, [] is the vector syntax, which is used for most non-lazy data structures
17:16anthony_I didn't think about using a vector instead. I think that will work for me.
17:17anthony_Okay, thanks. I have almost no Lisp exposure, but the little I do have has me always wanting to use lists when I shouldn't. :)
17:17amalloyheh
17:17amalloyit's very handy to have a non-quoting literal syntax for lists, for exactly the reason you describe
17:19anthony_Definitely. I'm beginning to see the benefits of code and data being represented the same.
17:23DeranderI really need to write my lispruby
17:23DeranderI want to see if that works at all
17:44raekanthony__: if you really want a list, you can construct it with ##(list 1 (+ 2 3) 4)
17:44sexpbot⟹ (1 5 4)
17:44raekvectors also has such a function: ##(vector 1 (+ 2 3) 4)
17:44sexpbot⟹ [1 5 4]
17:45raekso a literal vector is very much like a call to 'vector', but a literal list does not behave this way
17:46raekbut as amalloy said, [] is the usual way to do it
17:48arohnerdoes anyone have any good tools for measuring cache misses? I'm not familiar with the tools available on OSX & JVM
18:04programble_how do you do a float literal in clojure?
18:07cemerickprogramble_: you don't, AFAIK. ints and doubles are given priority. For interop purposes, you can use (float …)
18:07tonylprogramble_: as far as i know there isn't
18:07cemerick,(class (float 5.0))
18:07clojurebotjava.lang.Float
18:08programble_that worked
19:41anomehi there
20:26rata_hi all
20:31rata_what was that?
20:31Raynes$google netsplit
20:35amalloyRaynes: sexpbot dropped too
20:35rata_I have a performance problem with clojure... I've written a app that iterates and has a similar cost per iteration until 30 mins running... after that it loses the linear relation between number of iterations or steps and time
20:35rata_Raynes: yes, but I've search for it by myself =)
20:35Raynesamalloy: I never would have guessed.
20:36Raynes;)
20:37amalloyrata_: probably not cleaning up all the memory you're using
20:37amalloyand after ~30min it runs out of real memory and starts swapping everything
20:37rata_and looking for the reason why after a certain number of steps it becomes slower, I used visualvm and it says sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run is using up to a 68% of the time
20:37rata_ok... so how can I clean up all the memory I'm using?
20:38amalloy_rata_: make sure not to keep references (direct or indirect) to objects you don't need. that's all it takes to get the gc to do the cleanup. afk now though
20:39rata_amalloy_: but the gc is doing its task correctly... I doesn't throw an out of memory execptioin
20:39rata_*exception
20:40rata_should I use a more aggressive gc?
20:40rata_is the sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run method related to the GC?
20:41rata_(I'm not using RMI in my app)
20:42rata_the problem seems to be that the GC can do its work, but it does it slowly
20:52rata_amalloy_: ^
20:55amalloyrata_: i would guess that ConnectionHandler is delegating to your app and isn't really using up much cpu itself, but this isn't an area i know a lot about
20:59rata_mmm ok
21:05rata_what's a good GC for persistent data structures?
21:57rata_still wondering what are good GC options for a clojure app in which there is a huge record that contains several nested persistent data structures and changes constantly
23:11rata_count is strict, right?