#clojure log - Jan 22 2011

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

0:19 amalloy: Eugene_: one of the articles i read that convinced me to try lisp was one in which the author founded his own company and was able to react more quickly to market changes than the competition because his language was better than theirs. getting a job isn't always necessary

0:19 Eugene_: paul grahm...

0:19 that was a long time ago though

0:20 there arent much opening for innovation anymore for a few people to do

0:20 amalloy: and clojure has good interop with java; if you're working on java and can solve a problem faster in clojure, you can do that and then dress it up pretty so it acts like java

0:20 Eugene_: you're right, all the good programs have already been written

0:21 Eugene_: i think its more realistic to push existing forward

0:21 hoggarth: how do i flatten a list?

0:21 (max (1 2))

0:21 i want

0:21 (max 1 2)

0:21 brehaut: ,(apply max '(1 2))

0:21 clojurebot: 2

0:22 mefesto: ,(flatten '(max (1 2)))

0:23 clojurebot: (max 1 2)

0:24 amalloy: heh. both correct answers to hoggarth's question, but i suspect brehaut is answering the question that was *intended* and mefesto is answering the question actually asked

0:24 brehaut: amalloy: i think you are right :)

0:24 mefesto: hah :)

0:24 hoggarth: thanks guys

0:25 brehaut: nurries

0:28 doubleagent: Any information on handling clojureql exceptions? Doesn't seem to be anything in tests/* or the website.

0:30 brehaut: doubleagent: i havent seen any. It appears (in my experience anyway) that in general its just letting the underlying server specific exceptions percolate up to the caller

0:31 doubleagent: brehaut, thanks.

0:31 brehaut: doubleagent: it may be worth looking for information on clojure.contrib.sql and exception handling?

0:32 hoggarth: ima need to try again

0:32 how do i get the max value of a seq?

0:33 ,(max (range 5)

0:33 clojurebot: EOF while reading

0:33 hoggarth: ,(max (range 5))

0:33 brehaut: ,(apply max (range 5))

0:33 clojurebot: (0 1 2 3 4)

0:33 4

0:33 mefesto: ,(reduce max [1 2 3 4])

0:33 clojurebot: 4

0:33 mefesto: (max (range 5))

0:33 oops :)

0:34 brehaut: hoggarth: apply is afunction that takes a function a seq of arguments

0:34 hoggarth: it returns the result of that function applied to the seq of arguments

0:40 amalloy: hoggarth: brehaut is simplifying a little there. (apply f a b s), supposing that s is a vector like [1 3 4], is equivalent to (f a b 1 3 4)

0:40 hoggarth: thanks guys!

0:40 euler #3

0:41 ,(apply max (filter #(zero? (rem 600851475143 %)) (range 1 (Math/sqrt 600851475143))))

0:41 clojurebot: java.lang.ExceptionInInitializerError

0:41 amalloy: ie, it treats the last argument as a sequence, and "expands" it

0:42 &(range 1 (double 10))

0:42 sexpbot: ⟹ (1 2 3 4 5 6 7 8 9)

0:42 amalloy: &(range 1 2,5)

0:42 sexpbot: ⟹ (1)

0:42 amalloy: &(range 1 2.5)

0:42 sexpbot: ⟹ (1 2)

0:42 amalloy: hey, i didn't know that worked. neat

0:43 brehaut: huh the types of the range are curious

0:43 mefesto: hmm

0:43 &(range 1 5 0.5)

0:43 sexpbot: ⟹ (1 1.5 2.0 2.5 3.0 3.5 4.0 4.5)

0:43 brehaut: &(range 1.0 10)

0:43 sexpbot: ⟹ (1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)

0:43 brehaut: mefestos example shows the particular oddity

0:44 amalloy: brehaut: makes sense though

0:44 brehaut: amalloy: it does

0:47 * doubleagent looks @ project euler code

0:48 doubleagent: my solution to #3 leverages a couple of massive functions

0:48 and then boils down to a one-liner

0:49 hoggarth: i'm new to clojure, so i spent at least twenty minutes figuring out how to sqrt

0:50 brehaut: the only euler solution i bothered to keep is for #18

0:50 hoggarth: do you know about clojuredocs.org?

0:51 hoggarth: i do now

0:51 so far i've found this the most useful

0:51 http://clojure.github.com/clojure/clojure.core-api.html

0:52 brehaut: hoggarth: thats a more canonical resource, but, clojuredocs has a great cheatsheat and more examples

0:53 hoggarth: so the api has examples in curl

0:53 http://api.clojuredocs.org/

0:53 how about with clojure?

0:53 mefesto: oh that's cool. i didn't know they had a json api

0:54 hoggarth: probably need some combo of clj-apache-http and clojure.contrib.json

0:55 then you could grab it with something like: (http/get url :as :json)

0:58 * hoggarth clones https://github.com/dakrone/cd-client.git

1:21 gtech: what do you guys use for debugging clojure?

1:25 code

1:26 brehaut: a repl + prn

1:26 but im not a tool using simian

1:27 gtech: heh what's simian?

1:27 zanes: Moneky.

1:27 *Monkey

1:27 He's making a joke.

1:27 gtech: and prn?

1:27 ah I see

1:28 brehaut: dinner calls anyway

1:28 later

1:28 gtech: what is prn, and how do you deal without having any sort of line numbering in the stack traces?

1:31 amalloy: gtech: prn is println, but with formatting to make it easy for computers to read, rather than humans

1:32 and all my stack traces have line numbers

1:32 that doesn't make them a lot more useful, tbh :P

1:32 gtech: I get (NO SOURCE FILE: 0)

1:33 ah that's really tedious

1:34 amalloy: gtech: i get that for eval'd code, but calls to functions that were defined in actual source files (rather than directly in the repl) should have line numbers

1:34 gtech: I understand you use (require <package-name>) to use a package, but say you have the source code on the machine, where would you put that code?

1:34 amalloy: what are you using to get a repl?

1:35 gtech: clojure.jar

1:35 should I use lein instead? it seems a lot slower

1:35 amalloy: gtech: so doing it by hand from the command line, like java -cp clojure.jar clojure.repl or something?

1:36 zanes: I'm attempting to run lein deps on a project and it's complaining about a missing artifact: org.clojure:clojure-contrib:jar:1.1.0-master-SNAPSHOT

1:36 Am I doing something wrong here?

1:36 gtech: yeah, I have it running in emacs through the inferior-lisp command

1:36 amalloy: zanes: depending on a really old version of clojure-contrib

1:36 last time i saw this, someone was running labrepl, which has a transitive dependency path to it

1:37 zanes: amalloy: The project appears to be depending on 1.2.0. I'm unclear on why I'm getting an error for 1.1.0-master-SNAPSHOT.

1:37 amalloy: zanes: labrepl depends on foobar, foobar depends on 1.1.0

1:37 gtech: amalloy: I have a bash script java -server \ -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888 \ -cp /home/gtech/opt/clojure/clojure.jar clojure.main

1:37 zanes: amalloy: Ah, I see the path. leiningen-run 0.3 is the culprit.

1:38 gtech: I was using that so I could attatch with jswat, which never quite worked either

1:38 amalloy: gtech: lein isn't slower, as far as i know

1:38 gtech: would it be preferable? and why?

1:38 amalloy: and using lein (or cake, which i prefer) will manage your dependencies and make your life generally much easier

1:38 gtech: cool, alright I'll pick up cake

1:39 amalloy: then just $ cake repl will get you a repl

1:39 gtech: so you normally use println and CDT for debugging?

1:39 amalloy: gtech: i'm embarrassed to admit that i mostly use println :P

1:39 cdt is great but the learning curve was a bit steep for me

1:40 gtech: haha okay

1:40 zanes: This is weird. I thought usage of leiningen-run was pretty widespread?

1:41 gtech: so where do I put the cdt code though?

1:42 I mean I can throw the require in but where is the repl going to look for that package?

1:42 amalloy: gtech: this is exactly what cake and lein do for you

1:43 gtech: kk so read through the cake documentation and all my fears will be quelled/

1:43 amalloy: http://georgejahad.com/clojure/emacs-cdt.html

1:44 gtech: amalloy: sweet thansk

1:44 amalloy: i'm actually not sure if cdt works this way, but in general cake projects have a project.clj file defining (among other things) the libraries on which your project depends

1:44 before the various cake commands do their work, they go fetch the required libraries from maven

3:11 gtech: amalloy: do you use the cake repl? for some reason in emacs whenever I make a malformed statement the repl becomes unresponsive

3:11 amalloy: gtech: i use it on occasion, but usually swank/slime

3:12 i think i'm using clojure-mode from elpa, and swank-clojure from...maybe also elpa? i can check

3:14 no, looks like i installed swank-clojure myself

3:19 i never tried to get M-x slime to work, fwiw; i just use cake swank and M-x slime-connect

5:22 kumarshantanu: hi, can anybody point me to an example on how to turn a java object into a map? e.g. :foo may lead to (.getFooFromFactory javaobj)

5:24 or maybe just on how to make an existing java class extend Clojure's map protocol (if IPersistentMap is a protocol)

5:47 hoeck: ,(bean "foo")

5:47 clojurebot: {:empty false, :class java.lang.String, :bytes #<byte[] [B@36b1bb>}

5:48 hoeck: kumarshantanu: ^

5:49 kumarshantanu: but bean returns a new map only

6:03 robonobo: What is the best lib for trig functions (cos, sin arcsin, ...)? Just use the java ones?

6:06 Mimisbrunnr: robonobo: I think so yes

6:06 but don't hold me to it

6:06 wiat

6:06 isn't there a clojure math package

6:07 in contrib

6:07 check clojure.contrib.math

6:07 should be in there

6:07 clojurebot: Cool story bro.

6:07 Mimisbrunnr: clojure.contrib.math

6:07 Common math functions for Clojure's numeric tower.

6:07 yeah

6:07 cheers

6:08 robonobo: nope

6:08 only numeric ones

6:08 i did find a lib (clojure.contrib.generic.math-functions), but it seems to be dead

6:08 i'll use Math/sin

8:16 Gigaroby: guys I need a hand with a macro

8:16 I need it to perform a (partial % item)

8:16 on every function in the form

8:19 so if I give the function something like (mymacro [item myitem] (foo arg (bar arg))) => ((partial foo item) arg ((partial bar item) arg)))

8:31 raek: Gigaroby: so this would affect the first thing in every list?

8:31 Gigaroby: raek: just if the first thing is a function

8:32 raek: so you want to handle special forms and macros differently?

8:32 in some simple cases, 'doto' might do what you want

8:33 or even '->'

8:33 but I guess you want to insert the first argument in arbitrarily nested epressions

8:33 Gigaroby: raek: mmm the problem is the calls are going to be nested I guess

8:35 raek: if you're going to check whether the argument is a function, I think the easiest way is to check whether it is a special form or a macro (both those can be known at compile time)

8:36 there are probably some other "less magic" way of solving the problem

8:37 Gigaroby: like ?

8:37 raek: what problem are you trying to solve?

8:38 your question was about how to implement one specific solution. there might be more ways of solving the problem.

8:38 Gigaroby: raek: I'm just trying to do something like with-open

8:39 fliebel: I found zippers to be very useful for doing this kind of macro magic in a readable and concise manner. Just sayin'

8:39 Gigaroby: but the binding is gonna be the first arg of every function

8:39 raek: (let [item ..., i #(partial % item)] ((i foo) arg ((i bar) arg))) ; one solution without macros

8:41 so the results of the expressions are not threaded together (like with ->) nor discarded (like with doto)?

8:42 Gigaroby: raek: not quite the same thing

8:42 raek: but I may just found a solution I just gotta work on it

8:45 raek: one way to make the argument insertion more explicit could be to have the symbols of the functions of interest carry a special mark

8:46 like: (mymacro [item myitem] (!foo arg (!bar arg))) => (let [item myitem] (foo item arg (bar item arg)))

8:49 pani_: ...

8:52 Gigaroby: raek: good idea but

8:53 raek: I have to define the function with ! in front of it or I just put it into it when I call the macro

8:54 kumarshantanu: repeat question: how can i make a java object behave as a map?

9:04 raek: kumarshantanu: bean

9:04 Gigaroby: just in the maco, was my original thought

9:05 Gigaroby: raek: good idea really I'm working to see what I can do

9:05 raek: is like the first real macro I try to do

9:06 raek: also, you don't need to call partial, since you can inject the argument directly

9:13 robonobo: hi everyone

9:13 i'm trying to make a JPanel respond to a louseclick on it, but "(proxy [javax.swing.event.MouseInputAdapter] [] (.mouseClicked event (println "foo")))" doesn't seem to work

9:14 it gives the error ""nth not supported on this type: Symbol

9:14 raek: robonobo: you need to write the method signature too

9:15 robonobo: raek: what do you mean?

9:16 ah, found it

9:16 raek: the forms inside the proxy form should look like (methodName [arg-foo arg-bar] ...code...)

9:16 you put the code directly in it

9:16 robonobo: yes

9:16 it should have been (proxy [javax.swing.event.MouseInputAdapter] [] (.mouseClicked [event] (println "foo")))

9:17 raek: also, I don't think you should have the dot in there

9:17 I first though that was a method *call*

9:20 robonobo: raek: it gives an error if i do ...event MouseInput... in stead of woth a dot

9:20 s/woth/with

9:20 sexpbot: <robonobo> raek: it gives an error if i do ...event MouseInput... in stead of with a dot

10:09 IvarTJ: Will clojure.jar be a dependency to compiled clojure classes?

10:10 robonobo: IvarTJ: if i'm not mistaken it will be

10:10 just like you need to include 3rd party java libs to run your java apps

10:15 IvarTJ: I might have to freshen up my familiarity with Java, but hopefully it is possible to compile clojure code to a single jar file with mostly just the JVM as a dependency concern for end users.

10:19 raek: IvarTJ: yes. a so called "uberjar". leiningen has a "lein uberjar" command for that.

10:29 IvarTJ: Ah, thanks, Leiningen looks useful.

10:36 shortlord: let's say I want to write a function that executes other expressions, if a certain condition is true. How should I pass the expression to the executing function? syntax-quoted?

10:38 raek: shortlord: if you pass it to eval, just make the expression code look like any other code you would have written

10:38 (eval '(+ 1 2))

10:39 syntax-quote will make all symbols namespace qualified. that will break for example let forms

10:40 shortlord: raek: nice, thx :)

10:53 why is there a difference between (do (eval expr) true) and (do (eval expr))? Shouldn't the eval expression be evaluated in both cases?

11:15 raek: shortlord: yes it should.

11:16 side-effects in lazy sequeces are delayed until they are needed, though

11:17 shortlord: raek: oh, I thought 'do' was explicitly created to execute expressions with side effects

11:18 what should I use instead of do to execute the side effects in every case?

11:18 raek: clojure is not a lazy in general. only sequences can be lazy.

11:19 do evaluates the expressions and returns the value of the last one

11:19 shortlord: what do you eval?

11:20 pdk: [10:53] <shortlord> why is there a difference between (do (eval expr) true) and (do (eval expr))? Shouldn't the eval expression be evaluated in both cases?

11:20 it is

11:20 shortlord: raek: a call to a function that itself calls a function which alters a ref

11:20 raek: anyway, to force side-effects of lazy sequences, 'dorun', 'doall' and 'doseq' can be used

11:20 pdk: do only returns the value of the last expression evaluated in it under the assumption that the rest are inducing side effects instead

11:21 that's its raison d'etre pretty much

11:21 shortlord: pdk: but that would mean that my function (which has side effects) should be executed, but nothing is happening

11:21 raek: shortlord: could you paste the code you are evaling somewhere?

11:22 shortlord: as soon as I remove the 'true' in the block, (do (eval expr)) returns a value (which is meaningless) and when I check the ref, it is changed

11:22 raek: ok, just a sec

11:23 raek: shortlord: one common laziness gotcha is to use 'map' instead of 'doseq'

11:28 shortlord: raek: https://gist.github.com/791217

11:30 dnolen: shortlord: why do you feel the need to use eval instead of just calling those functions normally?

11:31 shortlord: dnolen: I want to execute them only if the condition in the execute2a function is met

11:31 just passing them to the execute function would already evaluate the argument, wouldn't it?

11:32 pdk: ,(eval 1)

11:32 clojurebot: DENIED

11:32 dnolen: shortlord: you can pass the function without executing it

11:32 raek: shortlord: you can pass code around as functions.

11:32 pdk: if you write something like

11:32 (eval function-name)

11:32 it's only going to return the value of the symbol function-name you passed it

11:32 eval expects you to put in a form

11:32 so if i wanted eval to actually run function-name

11:32 dnolen: ((fn[f] (f 1)) inc)

11:32 pdk: i'd write (eval (function-name))

11:32 dnolen: ,((fn[f] (f 1)) inc)

11:32 clojurebot: 2

11:33 dnolen: shortlord: ^

11:33 pdk: which is completely redundant since (function-name) will do the same thing, wrapping it in eval doesn't cause it to be evaluated when it normally wouldn't be in that circumstance

11:33 shortlord: ah

11:34 pdk: e.g. if i write (if (true? some-var) 1 (eval 2))

11:34 it still won't run (eval 2) either way if the condition in the if was met to begin with

11:34 raek: shortlord: if you stick a # in front of the call, it will become an anonymous function which will perform that call when you invoke it

11:34 dnolen: shortlord: You will probably never need eval. Plus it's dog slow as it triggers compilation.

11:35 pdk: so in this case the evals as they're being used in the code you posted won't do what you intended them to do

11:35 and you'll get the same result as you intended anyway by saying (expr) vs (eval (expr))

11:40 shortlord: pdk: just removing eval and using (expr) instead causes the same behaviour as before, without 'true' in the 'do' expr, it runs the function with side effects, as soon as I put the 'true' back into the 'do' block, there is nothing happening anymore

11:44 raek: shortlord: I think a more common pattern would be to make a predicate function, perhaps (players-turn? player) and let the caller use it in an ordinary if expression

11:45 if, unlike the usual functions, is a special forms and has special rules for argument evaluation

11:46 dnolen: shortlord: https://gist.github.com/791233/7665ef44cba0fb853bbea2dce99ef6fd7509eae7

11:48 shortlord: dnolen: but does that still work, if you put the (f) into a (do ... (f) ... true) ?

11:48 because that's where it breaks for me

11:49 dnolen: shortlord: I'm not convinced you're seeing what you're think your seeing. (f) will get executed and true will be returned as the value.

11:49 shortlord: if you wrap that in a do like you've shown ^

11:50 raek: ,(println "hello")

11:50 clojurebot: hello

11:50 raek: ,(do (println "hello") true)

11:50 clojurebot: hello

11:50 shortlord: dnolen: well, that's the problem. (f) is not executed. I'll paste the source code with your modified version

11:50 clojurebot: true

11:51 dnolen: shortlord: why do you *think* it's not being executing. that is what proves to you that it doesn't *seem* to be executing.

11:51 shortlord: raek: the problem is that there are a lot of different calls that are only allowed if that predicate is met and that I need to return true and false, so wrapping everything in execute would be easier

11:53 raek: shortlord: you can use preconditions for ensuring that. (defn foo [player] {:pre [(players-turn? player)]} (...do stuff...))

11:53 shortlord: which function do you pass as 'f'?

11:56 pdk: dang where are these sorts of tricks documented

11:57 raek: pdk: pre- and postconditions?

11:57 dnolen: ,((fn [f] (do (println (f 1)) true)) inc)

11:57 clojurebot: 2

11:57 shortlord: raek, pdk: https://gist.github.com/791243

11:57 clojurebot: true

11:58 dnolen: shortlord: ^ your understanding of do is not right, that's a side-effect and returning true

12:00 shortlord: dnolen: I thought the whole purpose of do was to induce side-effects?

12:00 Chousuke: you don't need it for them

12:00 dnolen: shortlord: what I mean is that your claim "do is not executing my function" is unlikely.

12:01 raek: the purpose of do is to be able to evaluate multiple expressions in the place of one

12:01 Raynes: The purpose of do is to allow for you to do more than one thing in a place where only one thing is expected. For example (if true (do (println "1") 1) ..). We can't print and return 1 without the do.

12:02 shortlord: raek, Raynes: well, but println is a side-effect, isn't it? pure functions that just return values would be useless in a do statement, because only the last value is returned, right?

12:03 raek: yes. having a pure function in any other place than the last is useless

12:05 the side-effects of a non-pure function happens when the function invocation is evaluated

12:05 shortlord: so I don't see where my understanding of 'do' is wrong. I have looked at the special forms page on clojure.org, but the explanation of 'do' is very short and it seems that my usage of it should be ok in this situation

12:05 clojurebot: c'est bon!

12:06 shortlord: raek: so that means that somehow by putting 'true' into my code, the function does not get invoked anymore?

12:06 dnolen: shortlord: no. that function will be invoked.

12:07 raek: no. it should be invoked. what makes you think it isn't?

12:07 ,(println "side-effect")

12:07 clojurebot: side-effect

12:07 raek: ,(do (println "side-effect") 123)

12:07 clojurebot: side-effect

12:07 123

12:08 shortlord: raek: in the gist I've linked, I am checking the value of the ref after every call to execute, in the case where 'true' is not in the code, the ref changes, as soon as I put 'true' back in, the ref is not altered anymore, even though it should be

12:09 apart from removing 'true', nothing is changed, the current-player is still the same, the dice-no is still the same, etc.

12:09 dnolen: shortlord: then there is a bug somewhere else

12:10 shortlord: I can toggle the change of the ref by adding and removing 'true', I have checked it several times, the behaviours without a true is expected, as soon as the true is reintroduced, nothing happens anymore

12:11 raek: shortlord: you are using for

12:11 use doseq there instead

12:11 for creates a lazy sequence

12:12 the steps of a lazy sequence are delayed until they are neede

12:12 in this case, they were forced by the repl printing them

12:12 dnolen: ,(let [x (ref [])] (do (dosync (alter x conj 1)) [x true]))

12:12 clojurebot: [#<Ref@f7cbd1: [1]> true]

12:13 raek: doseq has the same syntax as for, but is used when you want to cause side-effects, rather than returning a lazy sequence

12:13 so, steps in lazy sequences are not guaranteed to be executed when the lazy sequence is created.

12:14 shortlord: raek: oh god, you are right! thx so much, it works now :)

12:15 raek: ,(take 3 (for [i (range 100)] (do (println i) i)))

12:15 clojurebot: 0

12:15 1

12:15 2

12:15 3

12:15 4

12:15 5

12:15 6

12:15 7

12:15 8

12:15 9

12:15 10

12:15 raek: aw

12:15 clojurebot: 11

12:15 12

12:15 13

12:15 14

12:15 15

12:15 16

12:15 17

12:15 18

12:15 19

12:15 20

12:15 21

12:15 22

12:15 23

12:15 24

12:15 25

12:15 26

12:15 27

12:15 28

12:15 29

12:15 30

12:15 31

12:15 (0 1 2)

12:15 dnolen: hah

12:15 raek: yeah, ranges come in chunks of 32...

12:15 dnolen: bitten by chunked

12:15 raek: sorry for that

12:18 dedeibel: :)

13:02 phenom_: anyone running aquamacs 2.1 ?

13:02 technomancy: zanes: sure (re: esk bugs)

13:03 just make sure they're present in source not just from repo.technomancy.us

13:04 mattrepl: for eval-in-project you can just assoc onto the project arg or hook the leiningen.classpath/get-classpath function

13:04 depends on what you're trying to do

13:11 pauldoo: (doc separate)

13:11 clojurebot: Gabh mo leithscéal?

13:12 technomancy: awesome... ran into a bug that only occurs when *err* is rebound to not spit anything out. =\ how are you supposed to debug that?

13:12 pauldoo: (what's the syntax for clojurebot?)

13:13 raek: ,(doc separate)

13:13 clojurebot: Gabh mo leithscéal?

13:13 pauldoo: ok - what does that mean? it doesn't do contrib?

13:14 raek: dunno

13:14 &(doc separate)

13:14 sexpbot: java.lang.Exception: Unable to resolve var: separate in this context

13:14 mattrepl: technomancy: thanks

13:14 raek: the bots probably don't have that namespace use'd

13:14 pauldoo: hehe ok

13:14 technomancy: mattrepl: what are you adding?

13:14 LauJensen: arbscht: Its been a week since you said the Weekly REPL would come out - Whats up ?

13:15 raek: I'd recommend clojuredocs.org

13:15 mattrepl: technomancy: the crane plugin adds <project>/crane to the classpath

13:15 pauldoo: raek: that's where I got it from, but I'm having real trouble figuring the syntax for my use/require. (havn't used anything form contrib yet)

13:16 technomancy: mattrepl: for all tasks or just some?

13:16 pauldoo: it's in clojure.contrib.seq / clojure.contrib.seq-utils <--- what's the difference?

13:17 technomancy: any reason it couldn't just be resources/crane?

13:17 IvarTJ: Presumably the arguments in the clojure documentation marked with question marks are optional.

13:17 raek: pauldoo: (ns your-ns (:use [clojure.contrib.seq :only (separate)]))

13:17 mattrepl: technomancy: more than just crane-specific. though maybe not all.. e.g, would want to add it for swank task

13:17 pauldoo: raek: and if I'm not using a ns yet?

13:17 technomancy: mattrepl: you would need a hook for that then

13:17 raek: pauldoo: (use '[clojure.contrib.seq :only (separate)])

13:18 pauldoo: java.io.FileNotFoundException: Could not locate clojure/contrib/seq__init.class or clojure/contrib/seq.clj on classpath: (NO_SOURCE_FILE:0)

13:18 raek: same syntax, except you write use as a symbol instead of a keyword, plus you have to quote the whole thing.

13:18 pauldoo: do you use leiningen?

13:18 (or cake)

13:18 pauldoo: raek: nop, just a repl so far

13:18 raek: pauldoo: then you need to include the contrib jar file in the classpath

13:18 mattrepl: technomancy: yeah, that was the reason for using handler before. robert.hooke is useful

13:19 raek: how you do that depends on how you start clojure

13:19 technomancy: the handler arg would only work for tasks you defined anyway

13:19 pauldoo: raek: hm ok - perhaps that's my problem. I thought the jEdit clojure repl had contrib already in

13:19 raek: I recommend using lein or cake as soon as you need to have your code in more than one source file *or* as soon as you need an external jar

13:20 pauldoo: raek: okidoke - I'll take a look at lein

13:20 raek: https://github.com/technomancy/leiningen

13:20 if you create a new project, the project.clj file will include contrib by default.

13:21 pauldoo: raek: I think I already have it installed via macports. it has been on my list to try out for a while

13:21 mattrepl: technomancy: oh, that's right. I already have a hook in lein-crane for that purpose, had forgot

14:20 T0mmy: Centimeter by centimeter he watched his cock grow thicker,

14:21 spreading Christa's cunt ever wider in its wake. Both of her hands came

14:21 down to grip the base of his cock as she looked down in disbelief. At

14:21 least six inches were outside of her now, and she had taken him nearly all

14:21 the way before. Curt opened his eyes and stared in disbelief. He was

14:21 growing even faster this time! His cumming continued to make him buck

14:21 like a bronco as his shaft grew ever more horse-like. Thicker and longer

14:21 -twined with huge, thick veins- his erection plowed into Christa's tight

14:21 bush like a dog trying to fit into a rabbit hole.

14:21 "Ahhh! Curt! Omigod ... you're goin' too ... far!"

14:21 Drastically, Curt tried to pull himself out of Christa before he

14:21 hurt her. Her moaning and bucking were intense and -just before he could-

14:21 he felt himself hit a massive climax. Rigid, he watched as his cock

14:21 rocketed upwards in size, spreading her cunt lips and making her squeal

14:21 half in pain, half in ecstasy. His balls pumped and churned as they lay

14:21 heavy on his thighs. In shock he looked at them, tangled in their mass of

14:21 pubic hair. Each was larger than a large grapefruit! His shaft had to be

14:21 at least three and a half inches across and nearly sixteen inches long!

14:21 The spasm began to fade, but the tingling in his balls remained. Orgasm

14:21 subsiding, Curt felt his body grow limp in its wake.

14:21 Slowly, Christa pulled off of him and slumped next to him on her

14:21 bed.

14:21 His massive rod stood up from his midsection like a bent flagpole.

14:21 Gobs of his cum dripped from Christa's stretched cunt as she panted for

14:21 breath and rubbed her delicate hands over Curt's chest. Opening her eyes,

14:22 she glanced at Curt's waist and shook her head slowly. "God, Curt... I

14:22 don't believe it." She smiled, and nuzzled the smaller man's neck -her

14:22 glistening breasts pressing against his chest. "Th' bigger th' better,

14:22 I've always said... I don't think I've Ever been this turned-on!"

14:22 Curt returned her smile and kissed Christa gently on the cheek.

14:23 cobol_expert: brilliant

14:24 jamiltron: Man, what a time to pull up my IRC window and see what I've missed.

14:59 C-Keen: hi there!

15:00 Do I need to build clojure myself from sources with a jdk-1.5? I used lein to install clojure stable (I think) on a x86 openbsd 4.7 machine

15:01 pdk`: http://openports.se/lang/clojure C-Keen

15:02 C-Keen: (2010-12-09) Package added to openports.se,

15:02 that is too new pdk`

15:02 pauldoo: I've installed leiningen from macports, and getting really big errors from "lein deps" on a simple "hello world" project: https://gist.github.com/791409

15:03 does leiningen need maven? Does it work ok with the default os x version of maven, or should I install another version from macports?

15:42 peregrine81: hey all when I run this code i get the error as shown in the pasteie http://pastie.org/1488103

15:42 I'm trying to setup a two dimensional data structure to represent a game board

15:43 I'm not quite certain as to why I cannot use a vector as a key for a hash-map

15:45 mefesto: ,{[1 2] :a}

15:45 clojurebot: {[1 2] :a}

15:46 mefesto: i'm not sure where the error is coming from but i don't think this code is doing what you intend

15:46 peregrine81: okay...

15:46 mefesto: nothing is updating your board since it's immutable

15:47 peregrine81: oh that makes sense

15:47 mefesto: 'for acts like python's list comprehension

15:47 peregrine81: should I be creating a new map and merging it with board?

15:48 mefesto: ,(for [x (range 5) y (range 5)] [x y])

15:48 clojurebot: ([0 0] [0 1] [0 2] [0 3] [0 4] [1 0] [1 1] [1 2] [1 3] [1 4] ...)

15:49 peregrine81: ,(range 1 4)

15:49 clojurebot: (1 2 3)

15:51 mefesto: maybe something like: (into {} (map (fn [[x y z] [[x y] z])) (range 1 5) (range 1 5) (make-percept)))

15:51 where make-percept creates your Percept with the default values

15:51 peregrine81: cool, lemme give that a shot

15:51 mefesto: that might not be the best way ... im just recovering from a nap :)

15:56 peregrine81: this seems to work: http://pastie.org/1488141

15:56 err maybe not

15:58 peregrine81: ok updated: http://pastie.org/1488141

15:59 peregrine81: mefesto: it did! thanks a ton

15:59 qbg: Clojure 1.3 needs to be released so we can improve the shootout benchmarks

15:59 peregrine81: so the issue was I was trying to assoc something that did not exist.

16:00 mefesto: yeah pretty much

16:00 well the results of your assoc were being thrown away

16:00 peregrine81: mefesto: it kind of works. I wanted to use for so I could get 11 12 13 14....

16:02 mefesto: updated again: http://pastie.org/1488141

16:02 then do (make-board 1 15)

16:02 if i understand correctly

16:03 peregrine81: well i mean [1 1], [1 2], [1 3]

16:04 all possible permutations of the sets

16:24 mefesto: I got it to work by replacing the range 1 5 with my for x 1 2 3 4 5...

16:24 mefesto: thanks for your help!

16:24 mefesto: np :)

16:26 Raynes: mefesto: You're on a roll.

16:27 mefesto: Raynes: i'm sure my streak will end soon :)

16:28 Raynes: i haven't been too active on here lately. i heard that there was some working going on with tryclojure?

16:28 how's that stuff going?

16:28 Raynes: mefesto: apgwoz redesigned the site and it's using my own sandboxing library now.

16:29 Somebody said they were working on an interactive tutorial a while back, but I never heard anything more from that

16:29 mefesto: looking at it now. looks good. you guys using compojure?

16:29 Raynes: moustache

16:30 Not for any particular reason. The site is very simple.

16:31 mefesto: is it a separate java process per session?

16:31 Raynes: No.

16:32 mefesto: is it possible for different users to redef each others vars or that's what your sandboxing handles?

16:34 Raynes: mefesto: Each user gets a different namespace.

16:34 The possibility of clashes is fairly small.

16:35 mefesto: cool stuff

16:36 is the sandbox part of the tryclojure project or separate?

16:36 Raynes: Separate: http://github.com/Raynes/clojail

16:36 amalloy and I's project.

16:53 mefesto: Raynes: pretty cool. on each request it re-executes upto the last 5 lines of text?

16:54 Raynes: Right.

17:04 mefesto: Raynes: you guys still looking for people to help out?

17:19 Raynes: mefesto: Sorry, had to run off.

17:20 mefesto: np, just been reading the code

17:20 Raynes: mefesto: There isn't very much else that needs to be done. The only thing left is an interactive tutorial, and that would be Javascript stuff.

17:26 mefesto: oic, and you say that's the part that may or may not be currently addressed?

17:29 Raynes: mefesto: Right.

17:30 mefesto: has someone already written up the outline of the tutorial and it's just a matter of JavaScripting it or both?

17:32 Raynes: mefesto: We need a system like tryhaskell.org's. As a matter of fact, one could probably just steal most of it's code, since it uses the same Javascript console as I do.

17:32 The actual tutorial can be added after the fact.

18:36 N8Dawg: Hello

18:37 I'm not sure of the correct etiquette for this channel for please forgive me if i appear rude

18:37 i had a clojure question...

18:38 If I put the following into the REPL:

18:38 (defmacro test1[] (clojure.core/partial + 1))

18:38 (println ((test1) 1))

18:38 I get: #<CompilerException java.lang.ExceptionInInitializerError (scratch2.clj:434)>

18:38 technomancy: you didn't say simon says

18:39 anyway, you want defn instead of defmacro

18:39 mefesto: N8Dawg: you need to quote

18:39 err... or not even use a macro like technomancy says :)

18:39 N8Dawg: I understand defn works, but i need a macro in this instance

18:39 surely a macro "should" be able to retrurn a function

18:40 mefesto: (defmacro test1 [] `(partial + 1))

18:48 N8Dawg: *duh* you're right it executes result of macro inline, it cant execute partial by definition

18:55 mefesto: Raynes: I'm trying to run tryclojure locally but am getting an error when call 'use: http://pastie.org/1488569

18:56 i've copied the example.policy to ~/.java.policy

19:20 scode: What is the current idiomatic way to generate API docs for clojure code? (I.e., which API doc generator is the de facto standard, if any?)

19:41 raek: scode: autodoc is used by many projects. marginalia is a new interesting tool too (I really like it myself).

19:42 http://tomfaulhaber.github.com/autodoc/

19:42 http://fogus.me/fun/marginalia/

20:26 devn: https://gist.github.com/791715

20:26 Is it possible to do something like this? (oops, "(commands)" shouldnt be in quotes.

20:26 )

20:27 I want to split out the condp, but (condp = cmd) needs to be evaluated in the context of the let

20:30 Any ideas?

20:37 I've updated https://gist.github.com/791715 and need to run out for a bit, please feel free to edit the gist with any suggestions. Cheers!

20:46 Raynes: devn: Your question makes very little sense to me.

20:52 devn: Raynes: heh, you can't break out the condp from inside the let just by extract it as a def

20:53 extracting*

20:53 Raynes: You're describing the problem in a very bizarre and confusing way.

20:53 I think I get what you want here.

20:53 You want the condp bound to commands to be executed in the context of the let.

20:54 devn: right. I thought that was pretty clear from the example I gave above

20:54 Raynes: My suggestion is to not do that. Sure you don't want a global dynamic earmuffed var that you can rebind with binding?

20:54 devn: like with alter-var-root or something?

20:54 Raynes: devn: The example was very clear, but the explanation of the example wasn't.

20:55 Well, that wouldn't actually work either, because commands would already have been evaluated. You've got me there.

20:55 devn: my apologies for the confusion

20:55 Raynes: Shouldn't commands be a function if it needs arguments?

20:56 devn: it seems to me the only way to fix this is to rewrite condp

20:56 Raynes: Or rewrite commands, since what you're trying to do is weird.

20:56 devn: :)

20:56 I will agree it is "weird"

20:56 I'm just trying for clean code.

20:56 I gotta run I'll be on in a few

20:57 Raynes: :p

21:06 zoldar: hello, I have problem with leinigen compiling my clojure source to .class files - in my previous project everything worked fine. At the current one, when I do 'lein compile', 'classes' directory remains empty. 'lein jar/uberjar' packs just .clj files from project's src directory. What may be the cause of that?

21:28 technomancy: zoldar: leiningen won't AOT anything unless you tell it which namespaces you want

21:29 zoldar: with gen-class ?

21:29 technomancy: you need to specify it in project.clj

21:30 zoldar: ah

21:30 technomancy: try "lein help sample" if you have a recent version

21:30 in particular the :aot part

21:30 zoldar: ok, thanks

21:31 technomancy: you can also do "lein compile :all" for a sanity check, but if you're using gen-class then :aot in project.clj is a good idea

21:41 zoldar: :aot did it for me, thanks again

Logging service provided by n01se.net