2011-01-22
| 00: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 |
| 00:19 | Eugene_ | paul grahm... |
| 00:19 | Eugene_ | that was a long time ago though |
| 00:20 | Eugene_ | there arent much opening for innovation anymore for a few people to do |
| 00: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 |
| 00:20 | amalloy | Eugene_: you're right, all the good programs have already been written |
| 00:21 | Eugene_ | i think its more realistic to push existing forward |
| 00:21 | hoggarth | how do i flatten a list? |
| 00:21 | hoggarth | (max (1 2)) |
| 00:21 | hoggarth | i want |
| 00:21 | hoggarth | (max 1 2) |
| 00:21 | brehaut | ,(apply max '(1 2)) |
| 00:21 | clojurebot | 2 |
| 00:22 | mefesto | ,(flatten '(max (1 2))) |
| 00:23 | clojurebot | (max 1 2) |
| 00: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 |
| 00:24 | brehaut | amalloy: i think you are right :) |
| 00:24 | mefesto | hah :) |
| 00:24 | hoggarth | thanks guys |
| 00:25 | brehaut | nurries |
| 00:28 | doubleagent | Any information on handling clojureql exceptions? Doesn't seem to be anything in tests/* or the website. |
| 00: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 |
| 00:31 | doubleagent | brehaut, thanks. |
| 00:31 | brehaut | doubleagent: it may be worth looking for information on clojure.contrib.sql and exception handling? |
| 00:32 | hoggarth | ima need to try again |
| 00:32 | hoggarth | how do i get the max value of a seq? |
| 00:33 | hoggarth | ,(max (range 5) |
| 00:33 | clojurebot | EOF while reading |
| 00:33 | hoggarth | ,(max (range 5)) |
| 00:33 | brehaut | ,(apply max (range 5)) |
| 00:33 | clojurebot | (0 1 2 3 4) |
| 00:33 | clojurebot | 4 |
| 00:33 | mefesto | ,(reduce max [1 2 3 4]) |
| 00:33 | clojurebot | 4 |
| 00:33 | mefesto | (max (range 5)) |
| 00:33 | mefesto | oops :) |
| 00:34 | brehaut | hoggarth: apply is afunction that takes a function a seq of arguments |
| 00:34 | brehaut | hoggarth: it returns the result of that function applied to the seq of arguments |
| 00: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) |
| 00:40 | hoggarth | thanks guys! |
| 00:40 | hoggarth | euler #3 |
| 00:41 | hoggarth | ,(apply max (filter #(zero? (rem 600851475143 %)) (range 1 (Math/sqrt 600851475143)))) |
| 00:41 | clojurebot | java.lang.ExceptionInInitializerError |
| 00:41 | amalloy | ie, it treats the last argument as a sequence, and "expands" it |
| 00:42 | amalloy | &(range 1 (double 10)) |
| 00:42 | sexpbot | ⟹ (1 2 3 4 5 6 7 8 9) |
| 00:42 | amalloy | &(range 1 2,5) |
| 00:42 | sexpbot | ⟹ (1) |
| 00:42 | amalloy | &(range 1 2.5) |
| 00:42 | sexpbot | ⟹ (1 2) |
| 00:42 | amalloy | hey, i didn't know that worked. neat |
| 00:43 | brehaut | huh the types of the range are curious |
| 00:43 | mefesto | hmm |
| 00:43 | mefesto | &(range 1 5 0.5) |
| 00:43 | sexpbot | ⟹ (1 1.5 2.0 2.5 3.0 3.5 4.0 4.5) |
| 00:43 | brehaut | &(range 1.0 10) |
| 00:43 | sexpbot | ⟹ (1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0) |
| 00:43 | brehaut | mefestos example shows the particular oddity |
| 00:44 | amalloy | brehaut: makes sense though |
| 00:44 | brehaut | amalloy: it does |
| 00:48 | doubleagent | my solution to #3 leverages a couple of massive functions |
| 00:48 | doubleagent | and then boils down to a one-liner |
| 00:49 | hoggarth | i'm new to clojure, so i spent at least twenty minutes figuring out how to sqrt |
| 00:50 | brehaut | the only euler solution i bothered to keep is for #18 |
| 00:50 | brehaut | hoggarth: do you know about clojuredocs.org? |
| 00:51 | hoggarth | i do now |
| 00:51 | hoggarth | so far i've found this the most useful |
| 00:51 | hoggarth | http://clojure.github.com/clojure/clojure.core-api.html |
| 00:52 | brehaut | hoggarth: thats a more canonical resource, but, clojuredocs has a great cheatsheat and more examples |
| 00:53 | hoggarth | so the api has examples in curl |
| 00:53 | hoggarth | http://api.clojuredocs.org/ |
| 00:53 | hoggarth | how about with clojure? |
| 00:53 | mefesto | oh that's cool. i didn't know they had a json api |
| 00:54 | mefesto | hoggarth: probably need some combo of clj-apache-http and clojure.contrib.json |
| 00:55 | mefesto | then you could grab it with something like: (http/get url :as :json) |
| 01:21 | gtech | what do you guys use for debugging clojure? |
| 01:25 | gtech | code |
| 01:26 | brehaut | a repl + prn |
| 01:26 | brehaut | but im not a tool using simian |
| 01:27 | gtech | heh what's simian? |
| 01:27 | zanes | Moneky. |
| 01:27 | zanes | *Monkey |
| 01:27 | zanes | He's making a joke. |
| 01:27 | gtech | and prn? |
| 01:27 | gtech | ah I see |
| 01:28 | brehaut | dinner calls anyway |
| 01:28 | brehaut | later |
| 01:28 | gtech | what is prn, and how do you deal without having any sort of line numbering in the stack traces? |
| 01:31 | amalloy | gtech: prn is println, but with formatting to make it easy for computers to read, rather than humans |
| 01:32 | amalloy | and all my stack traces have line numbers |
| 01:32 | amalloy | that doesn't make them a lot more useful, tbh :P |
| 01:32 | gtech | I get (NO SOURCE FILE: 0) |
| 01:33 | gtech | ah that's really tedious |
| 01: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 |
| 01: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? |
| 01:34 | amalloy | what are you using to get a repl? |
| 01:35 | gtech | clojure.jar |
| 01:35 | gtech | should I use lein instead? it seems a lot slower |
| 01:35 | amalloy | gtech: so doing it by hand from the command line, like java -cp clojure.jar clojure.repl or something? |
| 01: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 |
| 01:36 | zanes | Am I doing something wrong here? |
| 01:36 | gtech | yeah, I have it running in emacs through the inferior-lisp command |
| 01:36 | amalloy | zanes: depending on a really old version of clojure-contrib |
| 01:36 | amalloy | last time i saw this, someone was running labrepl, which has a transitive dependency path to it |
| 01: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. |
| 01:37 | amalloy | zanes: labrepl depends on foobar, foobar depends on 1.1.0 |
| 01: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 |
| 01:37 | zanes | amalloy: Ah, I see the path. leiningen-run 0.3 is the culprit. |
| 01:38 | gtech | I was using that so I could attatch with jswat, which never quite worked either |
| 01:38 | amalloy | gtech: lein isn't slower, as far as i know |
| 01:38 | gtech | would it be preferable? and why? |
| 01:38 | amalloy | and using lein (or cake, which i prefer) will manage your dependencies and make your life generally much easier |
| 01:38 | gtech | cool, alright I'll pick up cake |
| 01:39 | amalloy | then just $ cake repl will get you a repl |
| 01:39 | gtech | so you normally use println and CDT for debugging? |
| 01:39 | amalloy | gtech: i'm embarrassed to admit that i mostly use println :P |
| 01:39 | amalloy | cdt is great but the learning curve was a bit steep for me |
| 01:40 | gtech | haha okay |
| 01:40 | zanes | This is weird. I thought usage of leiningen-run was pretty widespread? |
| 01:41 | gtech | so where do I put the cdt code though? |
| 01:42 | gtech | I mean I can throw the require in but where is the repl going to look for that package? |
| 01:42 | amalloy | gtech: this is exactly what cake and lein do for you |
| 01:43 | gtech | kk so read through the cake documentation and all my fears will be quelled/ |
| 01:43 | amalloy | http://georgejahad.com/clojure/emacs-cdt.html |
| 01:44 | gtech | amalloy: sweet thansk |
| 01: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 |
| 01:44 | amalloy | before the various cake commands do their work, they go fetch the required libraries from maven |
| 03:11 | gtech | amalloy: do you use the cake repl? for some reason in emacs whenever I make a malformed statement the repl becomes unresponsive |
| 03:11 | amalloy | gtech: i use it on occasion, but usually swank/slime |
| 03:12 | amalloy | i think i'm using clojure-mode from elpa, and swank-clojure from...maybe also elpa? i can check |
| 03:14 | amalloy | no, looks like i installed swank-clojure myself |
| 03:19 | amalloy | i never tried to get M-x slime to work, fwiw; i just use cake swank and M-x slime-connect |
| 05: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) |
| 05:24 | kumarshantanu | or maybe just on how to make an existing java class extend Clojure's map protocol (if IPersistentMap is a protocol) |
| 05:47 | hoeck | ,(bean "foo") |
| 05:47 | clojurebot | {:empty false, :class java.lang.String, :bytes #<byte[] [B@36b1bb>} |
| 05:48 | hoeck | kumarshantanu: ^ |
| 05:49 | hoeck | kumarshantanu: but bean returns a new map only |
| 06:03 | robonobo | What is the best lib for trig functions (cos, sin arcsin, ...)? Just use the java ones? |
| 06:06 | Mimisbrunnr | robonobo: I think so yes |
| 06:06 | Mimisbrunnr | but don't hold me to it |
| 06:06 | Mimisbrunnr | wiat |
| 06:06 | Mimisbrunnr | isn't there a clojure math package |
| 06:07 | Mimisbrunnr | in contrib |
| 06:07 | Mimisbrunnr | check clojure.contrib.math |
| 06:07 | Mimisbrunnr | should be in there |
| 06:07 | clojurebot | Cool story bro. |
| 06:07 | Mimisbrunnr | clojure.contrib.math |
| 06:07 | Mimisbrunnr | Common math functions for Clojure's numeric tower. |
| 06:07 | Mimisbrunnr | yeah |
| 06:07 | Mimisbrunnr | cheers |
| 06:08 | robonobo | nope |
| 06:08 | robonobo | only numeric ones |
| 06:08 | robonobo | i did find a lib (clojure.contrib.generic.math-functions), but it seems to be dead |
| 06:08 | robonobo | i'll use Math/sin |
| 08:16 | Gigaroby | guys I need a hand with a macro |
| 08:16 | Gigaroby | I need it to perform a (partial % item) |
| 08:16 | Gigaroby | on every function in the form |
| 08:19 | Gigaroby | so if I give the function something like (mymacro [item myitem] (foo arg (bar arg))) => ((partial foo item) arg ((partial bar item) arg))) |
| 08:31 | raek | Gigaroby: so this would affect the first thing in every list? |
| 08:31 | Gigaroby | raek: just if the first thing is a function |
| 08:32 | raek | so you want to handle special forms and macros differently? |
| 08:32 | raek | in some simple cases, 'doto' might do what you want |
| 08:33 | raek | or even '->' |
| 08:33 | raek | but I guess you want to insert the first argument in arbitrarily nested epressions |
| 08:33 | Gigaroby | raek: mmm the problem is the calls are going to be nested I guess |
| 08: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) |
| 08:36 | raek | there are probably some other "less magic" way of solving the problem |
| 08:37 | Gigaroby | like ? |
| 08:37 | raek | what problem are you trying to solve? |
| 08:38 | raek | your question was about how to implement one specific solution. there might be more ways of solving the problem. |
| 08:38 | Gigaroby | raek: I'm just trying to do something like with-open |
| 08:39 | fliebel | I found zippers to be very useful for doing this kind of macro magic in a readable and concise manner. Just sayin' |
| 08:39 | Gigaroby | but the binding is gonna be the first arg of every function |
| 08:39 | raek | (let [item ..., i #(partial % item)] ((i foo) arg ((i bar) arg))) ; one solution without macros |
| 08:41 | raek | so the results of the expressions are not threaded together (like with ->) nor discarded (like with doto)? |
| 08:42 | Gigaroby | raek: not quite the same thing |
| 08:42 | Gigaroby | raek: but I may just found a solution I just gotta work on it |
| 08: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 |
| 08:46 | raek | like: (mymacro [item myitem] (!foo arg (!bar arg))) => (let [item myitem] (foo item arg (bar item arg))) |
| 08:49 | pani_ | ... |
| 08:52 | Gigaroby | raek: good idea but |
| 08:53 | Gigaroby | raek: I have to define the function with ! in front of it or I just put it into it when I call the macro |
| 08:54 | kumarshantanu | repeat question: how can i make a java object behave as a map? |
| 09:04 | raek | kumarshantanu: bean |
| 09:04 | raek | Gigaroby: just in the maco, was my original thought |
| 09:05 | Gigaroby | raek: good idea really I'm working to see what I can do |
| 09:05 | Gigaroby | raek: is like the first real macro I try to do |
| 09:06 | raek | also, you don't need to call partial, since you can inject the argument directly |
| 09:13 | robonobo | hi everyone |
| 09:13 | robonobo | 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 |
| 09:14 | robonobo | it gives the error ""nth not supported on this type: Symbol |
| 09:14 | raek | robonobo: you need to write the method signature too |
| 09:15 | robonobo | raek: what do you mean? |
| 09:16 | robonobo | ah, found it |
| 09:16 | raek | the forms inside the proxy form should look like (methodName [arg-foo arg-bar] ...code...) |
| 09:16 | raek | you put the code directly in it |
| 09:16 | robonobo | yes |
| 09:16 | robonobo | it should have been (proxy [javax.swing.event.MouseInputAdapter] [] (.mouseClicked [event] (println "foo"))) |
| 09:17 | raek | also, I don't think you should have the dot in there |
| 09:17 | raek | I first though that was a method *call* |
| 09:20 | robonobo | raek: it gives an error if i do ...event MouseInput... in stead of woth a dot |
| 09:20 | robonobo | s/woth/with |
| 09: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 | robonobo | 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 | raek | (eval '(+ 1 2)) |
| 10:39 | raek | syntax-quote will make all symbols namespace qualified. that will break for example let forms |
| 10:40 | shortlord | raek: nice, thx :) |
| 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:15 | raek | shortlord: yes it should. |
| 11:16 | raek | 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 | shortlord | 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 | raek | do evaluates the expressions and returns the value of the last one |
| 11:19 | raek | 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 | pdk | 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 | pdk | 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 | shortlord | 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 | shortlord | 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 | pdk | (eval function-name) |
| 11:32 | pdk | it's only going to return the value of the symbol function-name you passed it |
| 11:32 | pdk | eval expects you to put in a form |
| 11:32 | pdk | 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 | pdk | 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 | pdk | 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 | raek | 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 | shortlord | 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 | dnolen | 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 | raek | 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 | raek | 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 | raek | ,(println "side-effect") |
| 12:07 | clojurebot | side-effect |
| 12:07 | raek | ,(do (println "side-effect") 123) |
| 12:07 | clojurebot | side-effect |
| 12:07 | clojurebot | 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 | shortlord | 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 | raek | use doseq there instead |
| 12:11 | raek | for creates a lazy sequence |
| 12:12 | raek | the steps of a lazy sequence are delayed until they are neede |
| 12:12 | raek | 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 | raek | 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 | clojurebot | 1 |
| 12:15 | clojurebot | 2 |
| 12:15 | clojurebot | 3 |
| 12:15 | clojurebot | 4 |
| 12:15 | clojurebot | 5 |
| 12:15 | clojurebot | 6 |
| 12:15 | clojurebot | 7 |
| 12:15 | clojurebot | 8 |
| 12:15 | clojurebot | 9 |
| 12:15 | clojurebot | 10 |
| 12:15 | raek | aw |
| 12:15 | clojurebot | 11 |
| 12:15 | clojurebot | 12 |
| 12:15 | clojurebot | 13 |
| 12:15 | clojurebot | 14 |
| 12:15 | clojurebot | 15 |
| 12:15 | clojurebot | 16 |
| 12:15 | clojurebot | 17 |
| 12:15 | clojurebot | 18 |
| 12:15 | clojurebot | 19 |
| 12:15 | clojurebot | 20 |
| 12:15 | clojurebot | 21 |
| 12:15 | clojurebot | 22 |
| 12:15 | clojurebot | 23 |
| 12:15 | clojurebot | 24 |
| 12:15 | clojurebot | 25 |
| 12:15 | clojurebot | 26 |
| 12:15 | clojurebot | 27 |
| 12:15 | clojurebot | 28 |
| 12:15 | clojurebot | 29 |
| 12:15 | clojurebot | 30 |
| 12:15 | clojurebot | 31 |
| 12:15 | clojurebot | (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 | technomancy | just make sure they're present in source not just from repo.technomancy.us |
| 13:04 | technomancy | mattrepl: for eval-in-project you can just assoc onto the project arg or hook the leiningen.classpath/get-classpath function |
| 13:04 | technomancy | 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 | raek | &(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 | raek | pauldoo: do you use leiningen? |
| 13:18 | raek | (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 | raek | 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 | T0mmy | spreading Christa's cunt ever wider in its wake. Both of her hands came |
| 14:21 | T0mmy | down to grip the base of his cock as she looked down in disbelief. At |
| 14:21 | T0mmy | least six inches were outside of her now, and she had taken him nearly all |
| 14:21 | T0mmy | the way before. Curt opened his eyes and stared in disbelief. He was |
| 14:21 | T0mmy | growing even faster this time! His cumming continued to make him buck |
| 14:21 | T0mmy | like a bronco as his shaft grew ever more horse-like. Thicker and longer |
| 14:21 | T0mmy | -twined with huge, thick veins- his erection plowed into Christa's tight |
| 14:21 | T0mmy | bush like a dog trying to fit into a rabbit hole. |
| 14:21 | T0mmy | "Ahhh! Curt! Omigod ... you're goin' too ... far!" |
| 14:21 | T0mmy | Drastically, Curt tried to pull himself out of Christa before he |
| 14:21 | T0mmy | hurt her. Her moaning and bucking were intense and -just before he could- |
| 14:21 | T0mmy | he felt himself hit a massive climax. Rigid, he watched as his cock |
| 14:21 | T0mmy | rocketed upwards in size, spreading her cunt lips and making her squeal |
| 14:21 | T0mmy | half in pain, half in ecstasy. His balls pumped and churned as they lay |
| 14:21 | T0mmy | heavy on his thighs. In shock he looked at them, tangled in their mass of |
| 14:21 | T0mmy | pubic hair. Each was larger than a large grapefruit! His shaft had to be |
| 14:21 | T0mmy | at least three and a half inches across and nearly sixteen inches long! |
| 14:21 | T0mmy | The spasm began to fade, but the tingling in his balls remained. Orgasm |
| 14:21 | T0mmy | subsiding, Curt felt his body grow limp in its wake. |
| 14:21 | T0mmy | Slowly, Christa pulled off of him and slumped next to him on her |
| 14:21 | T0mmy | bed. |
| 14:21 | T0mmy | His massive rod stood up from his midsection like a bent flagpole. |
| 14:21 | T0mmy | Gobs of his cum dripped from Christa's stretched cunt as she panted for |
| 14:21 | T0mmy | breath and rubbed her delicate hands over Curt's chest. Opening her eyes, |
| 14:22 | T0mmy | she glanced at Curt's waist and shook her head slowly. "God, Curt... I |
| 14:22 | T0mmy | don't believe it." She smiled, and nuzzled the smaller man's neck -her |
| 14:22 | T0mmy | glistening breasts pressing against his chest. "Th' bigger th' better, |
| 14:22 | T0mmy | I've always said... I don't think I've Ever been this turned-on!" |
| 14:22 | T0mmy | 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 | C-Keen | 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 | C-Keen | 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 | pauldoo | 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 | peregrine81 | I'm trying to setup a two dimensional data structure to represent a game board |
| 15:43 | peregrine81 | 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 | mefesto | 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 | mefesto | peregrine81: this seems to work: http://pastie.org/1488141 |
| 15:56 | mefesto | err maybe not |
| 15:58 | mefesto | 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 | mefesto | 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 | mefesto | then do (make-board 1 15) |
| 16:02 | mefesto | if i understand correctly |
| 16:03 | peregrine81 | well i mean [1 1], [1 2], [1 3] |
| 16:04 | peregrine81 | all possible permutations of the sets |
| 16:24 | peregrine81 | mefesto: I got it to work by replacing the range 1 5 with my for x 1 2 3 4 5... |
| 16:24 | peregrine81 | 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 | mefesto | Raynes: i haven't been too active on here lately. i heard that there was some working going on with tryclojure? |
| 16:28 | mefesto | how's that stuff going? |
| 16:28 | Raynes | mefesto: apgwoz redesigned the site and it's using my own sandboxing library now. |
| 16:29 | Raynes | 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 | Raynes | 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 | Raynes | The possibility of clashes is fairly small. |
| 16:35 | mefesto | cool stuff |
| 16:36 | mefesto | is the sandbox part of the tryclojure project or separate? |
| 16:36 | Raynes | Separate: http://github.com/Raynes/clojail |
| 16:36 | Raynes | 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 | Raynes | The actual tutorial can be added after the fact. |
| 18:36 | N8Dawg | Hello |
| 18:37 | N8Dawg | I'm not sure of the correct etiquette for this channel for please forgive me if i appear rude |
| 18:37 | N8Dawg | i had a clojure question... |
| 18:38 | N8Dawg | If I put the following into the REPL: |
| 18:38 | N8Dawg | (defmacro test1[] (clojure.core/partial + 1)) |
| 18:38 | N8Dawg | (println ((test1) 1)) |
| 18:38 | N8Dawg | I get: #<CompilerException java.lang.ExceptionInInitializerError (scratch2.clj:434)> |
| 18:38 | technomancy | you didn't say simon says |
| 18:39 | technomancy | anyway, you want defn instead of defmacro |
| 18:39 | mefesto | N8Dawg: you need to quote |
| 18:39 | mefesto | 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 | N8Dawg | 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 | mefesto | 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 | raek | http://tomfaulhaber.github.com/autodoc/ |
| 19:42 | raek | http://fogus.me/fun/marginalia/ |
| 20:26 | devn | https://gist.github.com/791715 |
| 20:26 | devn | Is it possible to do something like this? (oops, "(commands)" shouldnt be in quotes. |
| 20:26 | devn | ) |
| 20:27 | devn | I want to split out the condp, but (condp = cmd) needs to be evaluated in the context of the let |
| 20:30 | devn | Any ideas? |
| 20:37 | devn | 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 | devn | extracting* |
| 20:53 | Raynes | You're describing the problem in a very bizarre and confusing way. |
| 20:53 | Raynes | I think I get what you want here. |
| 20:53 | Raynes | 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 | Raynes | 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 | devn | I will agree it is "weird" |
| 20:56 | devn | I'm just trying for clean code. |
| 20:56 | devn | 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 | technomancy | 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 |