#clojure log - Sep 05 2011

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

0:30 srid: how do I tell `(sh ...)` to print everything to stdout/stderr (parent process's file handles)? http://richhickey.github.com/clojure-contrib/shell-out-api.html -- I'm trying to use this in cake tasks, and it seems silly to buffer the output of a long running command.

0:36 Tcepsa: srid: Seems like (binding ...) might be able to help, but that's really just a guess...

1:07 amcnamara: srid: I believe you can pass *out* to sh's in keyword, something along the lines of (sh :out *out*)

1:07 http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/*out*

1:07 err, out keyword

1:30 how can I extend a type to be callable? clojure.lang.IFn isn't a protocol

1:33 ambrosebs_: clojure.lang.IFn has "invoke"

1:33 hmm

1:34 not a protocol?

1:34 amcnamara: nope, its an interface

1:37 ambrosebs_: tried something like this? https://github.com/clojure/core.match/blob/master/src/main/clojure/clojure/core/match/core.clj#L636

1:38 I wasn't aware that IFn was an interface, but I think that works

1:38 has IFn changed for 1.3?

1:46 amcnamara: interfaces can only be used (protocols may be used here as well) when initially defining a type, if extending an existing type only protocols may be used

1:46 from my understanding this is due to something called the expression problem

1:47 ambrosebs_: amcnamara: ah I see

1:47 that makes sense

1:48 doesn't sounds possible

1:48 amcnamara: :(

1:48 ambrosebs_: :(

2:03 amalloy: amcnamara: you can't cause an already-existing type to become callable as a function

2:03 amcnamara: bummer

2:04 amalloy: what type do you want to call, anyway?

2:04 amcnamara: more of a thought experiment

2:05 I was trying to extend strings to be functions of map keys

2:05 ("a" {"a" 1}) -> 1

2:05 keyword-like

2:07 amalloy: if you're curious, you can't do this because it would be a performance disaster

2:07 to make IFn a protocol

2:08 amcnamara: understandable, would be neat if there were a protocol equivalent though

2:08 PFn

2:10 amalloy: amcnamara: i have great news for you. you can write PFn yourself, and use it yourself! :P

2:11 amcnamara: I wouldn't even know where to start digging around the evaluator

2:21 amalloy: curiously, do you know why IFn has so many prototypes?

2:21 amalloy: ugh

2:21 so that we can pretend to java that we're statically-typed

2:22 amcnamara: interesting

2:22 amalloy: (anyway, performance, basically. there can't really be any other excuse for code like that)

2:22 amcnamara: yeah, looking at the code for keyword, very tedious

2:23 amalloy: that's weird. i wonder why Keyword doesn't extend AFn, which should hide away that nonsense

2:26 amcnamara: perhaps so that keywords can't be apply'd

2:30 the applyhelper in AFn is also pretty nasty

4:06 dbushenko: hi all!

4:19 TheMoonMaster: Is penumbra dead?

4:20 khaliG: hm fleetdb embedded allows duplicates between sessions.. weird

4:24 michaelr525: hey!!

4:25 khaliG: michaelr525, hey

4:26 michaelr525: what's up in clojure land?

4:27 :)

4:30 khaliG: hm nm, I was using init-persistent rather than load-persistent

4:57 amcnamara: 5am, time for bed. night all.

5:20 robermann: have you any news about "SICP in Clojure" project? According to its status (http://sicpinclojure.com/?q=content/current-status) it seems quite dead...

5:20 squidz: Why should I choose clojure over scala when scala has static typing, which is for me a plus

5:21 and if sicp-clojure is dying, that is also bad, as I wanted to learn clojure and sicp at the same time :(

5:22 michaelr525: hehe

5:23 squidz: dynamic typing is much better imho

5:24 squidz: michaelr525: why is that? I am a java programmer so I am used to it. Plus i think it could provide performance and quality improvements

5:25 michaelr525: squidz: you can learn clojure and sicp even better by continuing the project yourself

5:25 squidz: michaelr525: That's an idea

5:25 michaelr525: squidz: well, i am a programmer of many languages and i preffer dynamic typing

5:26 squidz: why?

5:26 clojurebot: squidz: because you can't handle the truth!

5:26 michaelr525: can you?

5:26 squidz: not sure

5:26 blow my socks off

5:27 michaelr525: well, types always get in your way instead of helping you. that's my experience

5:27 Chousuke: the problem isn't just having static typing or not having it.

5:27 squidz: Chousuke: ... go on...

5:28 Chousuke: Rich has several times expressed interest in a predicate-based "type" system for Clojure. Of course, such a thing is far from easy to implement as it must be completely optional

5:28 michaelr525: what's that?

5:28 Chousuke: but if implemented it would be more powerful than most type systems.

5:28 squidz: why would it have to be optional?

5:28 Chousuke: squidz: because you don't want to force people to use it

5:29 typing gets in the way sometimes

5:29 michaelr525: basically a system for reasoning about code using arbitrary predicates, not just types

5:29 squidz: in my opinion it should be implemented and forced muahaha.

5:30 robermann: $cd doc

5:30 lazybot: clojure.contrib.repl-utils/*local-javadocs*: http://clojuredocs.org/v/330

5:30 clojure.contrib.gen-html-docs/generate-documentation-to-file: http://clojuredocs.org/v/331

5:30 clojure.contrib.repl-utils/add-local-javadoc: http://clojuredocs.org/v/332

5:30 michaelr525: squidz: C# went half way towards programmers when they added the `var' keyword

5:30 Chousuke: there are static type systems that are good but most only harm you.

5:30 like Java's

5:30 it's baaaaaaaaad

5:30 michaelr525: Types are still there but they are infered most of the time

5:30 robermann: which project give you 'cd''s beahviour?

5:31 Chousuke: Haskell's type system is pretty good but I can see it getting in the way at times

5:31 squidz: I can't imagine how static typing could get in the way???

5:31 lazybot: squidz: How could that be wrong?

5:31 Chousuke: You need a lot of really complicated type trickery to enable things that are straightforward in dynamic languages

5:31 MasseR: /la/win 32

5:32 Chousuke: squidz: are you kidding me? How does Java's static typing not get in the way?

5:32 squidz: Ive never seemed to have a problem with it, but then again it's all i'm really used to

5:32 Chousuke: or in general, any sort of static typing without type inference = headache

5:32 khaliG: michaelr525, have you looked at Qi?

5:33 Chousuke: squidz: you're perhaps used to only doing things that are natural within the confines of Java's type system

5:33 which isn't a lot

5:34 it's entirely possible to have much better static typing in a much more expressive language, too (again, Haskell)

5:34 michaelr525: khaliG: what's that?

5:35 khaliG: michaelr525, http://www.lambdassociates.org/qilisp.htm

5:35 Chousuke: but even then it gets in the way; With static typing, you can't write "incomplete" programs quite as easily and test code as you write it.

5:35 michaelr525: khaliG: should I?

5:35 khaliG: michaelr525, yep! it's got a lot of cool ideas :)

5:35 Chousuke: in a dynamic language it is not an issue if you leave a function unimplemeted, as long as you don't call it

5:36 so you can switch focus to something more important.

5:36 michaelr525: khaliG: one day.. when i get some free time.. (currently all free time goes to IRC chats;)

5:36 khaliG: haha!

5:36 Chousuke: it's also easy to experiment with different sorts of inputs to different functions as you have no rigid typing requirements

5:38 squidz: yes but that doesnt seem very formal. In math you have to have a domain defined for functions for example. You can just stick whatever you want in there and see what happens

5:38 Chousuke: programming isn't math

5:38 squidz: maybe it seems like a restriction

5:38 but i think it could be

5:38 programming math that is

5:39 scottj: math has side effects?

5:39 squidz: but that goes into other philosophical questions that are maybe too distracting

5:39 khaliG: i think the better question is, does scala do static typing well?

5:40 Chousuke: it does it kind of like haskell I think

5:40 squidz: khaliG: that could be a dealbreaker for sure

5:40 Chousuke: except it has to work with Java

5:40 which obviously complicates matters

5:41 java's type system is dumb :P

5:41 khaliG: the reason I mention Qi is because i've heard there is a port to clojure on the way, and it does static typing rather well ;)

5:42 scottj: khaliG: I don't think a clojure port has been started

5:42 khaliG: I think shen is targeting other platforms first

5:42 khaliG: scottj, oh? i was just reading an older google groups post where someone was attempting it - but i can't find the github for some reason :/

5:43 scottj: Rich mentioned that cljs with type checking by gclosure might be the first static typing version of clojure

5:44 squidz: scottj: So do you know if that is a goal that he wants?

5:45 scottj: squidz: like Chousuke said, Rich welcomes tools that help prevent errors, but he doesn't want it to prevent you from doing something that's correct just because it can't prove it's correct

5:46 squidz: seems reasonable enough. Does he get on this channel often?

5:46 or at all

5:47 scottj: not often any more

5:50 squidz: I would like to contribute to the project if I could, but I dont know anything about writing languages

5:50 I'll at least make a start by learning clojure and reading through sicp

5:50 michaelr525: khaliG: scheme and js first, that's what written on Qi's site

5:51 scottj: squidz: very few people contribute to the language itself, most things are done in libraries

5:52 squidz: which libraries?

5:52 scottj: squidz: are we still talking static typing?

5:52 squidz: no I mean in general right now

5:52 scottj: http://www.clojure-toolbox.com/

5:53 squidz: ah okay you mean libraries for clojure

5:53 scottj: oh by project you meant sicp in clojure?

5:54 squidz: no I meant the language itself

5:54 but I guess that working on libraries would do just as much benefit if not more

5:54 scottj: oh well in that case see contrib

5:54 squidz: What kind of libraries do you suppose are in need or would be most beneficial right now?

5:56 for example, Ive heard that compujure is pretty good, so that probably takes care of webdevelopment

5:56 scottj: squidz: I don't know, most big areas are well covered probably a specific need you have or improvements to an existing library

5:57 first things first, learn clojure :)

5:57 squidz: yeah lol

5:58 but I learn by doing

5:58 works wonders for motivation

6:05 https://github.com/getwoven/infer looks interesting

6:06 ejackson: squidz: a lot of that should be in incanter, I think.

6:07 squidz: yeah, I also just thought it would possibly be better if the combined a few projects.

6:07 but easier said than done

6:43 ejackson: I see you contributed to incanter

6:49 robermann: squiz: In my opinion, pragmatically speaking, static typing is very useful when reworking on legacy code if the code isn't well encapsulated: in these cases the compiler can really save you good time. "static typing"'s usefulness is not a language property.

6:59 ilyak: hi *

6:59 I have a map-of-something

6:59 And I do (if (contains? map-of-something key) (some-fn (get map-of-something key))

6:59 What's the idiomatic way?

7:00 some-fn function does side-effects

7:01 michaelr525: seems right to me, but I'm a noob

7:02 you can use when instead of if here, since you have no else

7:03 ,doc

7:03 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>

7:03 michaelr525: ,doc contains?

7:03 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>

7:03 michaelr525: ,(doc contains?)

7:03 clojurebot: "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."

7:04 ilyak: ,(contains? :a {:a 5})

7:04 clojurebot: false

7:04 ilyak: oops, I guess I should use something else?

7:04 ,(contains? '(:a 5) {:a 5})

7:04 clojurebot: false

7:04 ilyak: wtf, what for is contains? on maps?

7:04 michaelr525: ,(:a {:a 5})

7:04 clojurebot: 5

7:05 ilyak: oops, wrong order

7:05 ,(contains? {:a 5} :a)

7:05 clojurebot: true

7:05 ilyak: right

7:05 sorry for confusion

7:05 michaelr525: I actually have string keys

7:05 michaelr525: doesn't matter

7:07 ilyak: ,("something" {"something" "crazy"})

7:07 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>

7:08 ilyak: nowp

7:09 michaelr525: ah, you mean for that

7:10 Netpilgrim: ,({"something" "crazy"} "something")

7:10 clojurebot: "crazy"

7:11 michaelr525: cool

7:16 raek: ilyak: you can also use if-let: (if-let [val (get m key)] (do-something val) (do-something-else)) or (if-let [[_ val] (find m key)] (do-something val) (do-something-else)) if you use nil as a key

7:17 ilyak: raek: cool, but i'm considering adding some kind of helper into my util.clj

7:42 lnostdal_: so odd .. i'm getting "no transaction running", but the code and functions called is within a (dosync ..)

7:43 and the stack-trace has an earlier frame; clojure.lang.LockingTransaction.runInTransaction(LockingTransaction.java:231)

7:45 oh, wait .. i've got some add-watch thing triggering .. hm

7:47 ok, so those run in arbitrary threads unless i'm mutating the ref within an agent (?) .. parsing the doc-string here :)

8:07 khaliG: is there a nicer way to write - (map #(get %1 "name") (db/query ...))

8:19 ilyak: khaliG: Who controls db/query?

8:19 'cause the best way is (map :name (db/query ...)) but you have to make db/query use keywords

8:19 wunki: in Python there is a "try -> except -> else" , how could I write this in clojure?

8:20 khaliG: right, fleetdb doesn't use keywords so i've got a string rather than keyword :/

8:20 ilyak: wunki: What does else do in python's try?

8:21 wunki: if there is *no* exception, it winds up at else

8:21 khaliG: that sounds dumb

8:22 wunki: ilyak: http://docs.python.org/tutorial/errors.html#handling-exceptions

8:22 khaliG: why not put the code that would go in the else after everything else inside the try block, same effect?

8:23 agz: how I type-hint vector of float vectors ???

8:23 lazybot: agz: Yes, 100% for sure.

8:23 wunki: khaliG: you are right.. totally missed that..

8:23 khaliG: oh i wasn't having a go at you, at python instead :P

8:27 ilyak: so you should use (do (try (catch )) (else-code))

8:27 or not :)

8:27 what do you want to return?

8:28 that is The question for clojure snippet

10:22 simard: I'm interested in numerical performance with clojure (ie.: calculating a sequence of matrix operations in reasonable time). Can anyone point me to some resource about this ? Is it realistic to expect such performance from clojure ? I'm comparing a naive implementation of a 1-dimensional FDTD algorithm in clojure with one in octave, and the time of execution difference is around an order or magnitude, maybe more.

10:23 obviously, behind octave are copious amounts of specialized libraries..

10:29 Netpilgrim: simard: I really have no clue about this subject, but I assume the authors of Incanter (http://incanter.org/) would know something about this.

10:33 * zilti is studying the scalaz api and feels like he never learnt how to program at all...

10:36 simard: Netpilgrim: thank you I'll have a look to it

10:38 Netpilgrim: Would the use of reduce at https://gist.github.com/1195103 be considered idiomatic, of would a loop be considered better style?

10:40 BTW: I like Gist well enough but their monospace font is one of the worst to distinguish between ones and a small Ls.

10:41 s/a small/small/

10:51 Kototama: hi

10:51 can someone tell me what's wrong with the deployment of my compojure project http://paste.lisp.org/display/124485 ?!

10:51 "java.lang.ClassNotFoundException: org.mortbay.jetty.Server" :-) ?!

10:55 robermann: maybe a JVM version problem

11:00 Kototama: by the way they have refactored the code: http://wiki.eclipse.org/Jetty/Getting_Started/Porting_to_Jetty_7/Refactoring

11:01 Kototama: ah!

11:01 i'll try jetty6

11:02 robermann: check this too: http://stackoverflow.com/questions/2451572/jetty-7-mysql-config-java-lang-classnotfoundexception-org-mortbay-jetty-webap

11:02 bah, sometimes I don't understand the Java designers :) !

11:03 Kototama: exactly what I thought when fighting with streams today

11:04 robermann: renaming whole packages !

11:04 Kototama: well seems the project is part of eclipse now

11:04 the naming convention with enterprise name is odd

11:15 lnostdal_: i really don't understand how dosync and add-watch relate.. the add-watch callbacks are queued up and executed at the end of a transaction -- and run in arbitrary threads?

11:20 raek: lnostdal_: they are executed after the transaction has completed

11:20 maybe you are looking for validators?

11:20 they are executed when the transaction is about to finnish

11:25 Kototama: robermann: what is strang is that the test app from compojure works

11:25 i mean the example project

11:27 lnostdal_: raek, ok

11:28 raek: ,(doc add-watch)

11:28 clojurebot: "([reference key fn]); Alpha - subject to change. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any p...

11:30 robermann: Kototama: this one https://github.com/weavejester/compojure-example? Are you creating a WAR via lein ring uberwar?

11:36 Kototama: yes

11:42 seems better if i do not include ring.middleware.keyword-params, and ring.adapter.jetty!

11:42 now the apps is starting but without css

11:48 i got a (mp/wrap-multipart-params

11:48 (POST "/files" {params :params session :session}

11:48 (upload-file (get params "lkif-file") session)))

11:48 in my routes

11:48 but the POST goes to http://localhost:8080/files

11:49 whereas the app is in the localhost:8080/theapp

11:49 how can I make these routes relatives?

11:50 hum maybe it's a problem with the javascript loading a "/files" url :s

11:50 robermann: mmm (POST "/" ?

11:51 the "/" should be referred to the root context

11:51 Kototama: this http://paste.lisp.org/display/124488

11:52 ok then it's a problem with the use of the jquery load method which does not refer to this context

11:53 robermann: I think so

11:53 Kototama: is there a way to make it context aware :-) ?

11:55 robermann: by the way, check this: https://github.com/mmcgrana/ring/blob/f2ca099a6102da4e080a29e0a00e208a152debba/ring-jetty-adapter/src/ring/adapter/jetty.clj#L1 it imports some org.mortbay.jetty.* classes, that supposedly does not exist in your classpath

11:56 (because they have renamed it)

11:56 Kototama: yep thanks!, that was the origin of the problem

11:58 robermann: for jquery, I can only refer you to http://stackoverflow.com/questions/313434/problem-setting-path-to-jquery-in-mvc-app

12:01 Kototama: ok thanks

12:22 robermann: I was noting that genclass.clj and core.clj are both in the same namespace clojure.core. So you can have different files in the same namespace, right? One create it via ns , the others modules go into it by in-ns

12:22 amcnamara: o/

12:23 robermann: Is this a way for splicing many features in several structured files, keeping the same namespace?

12:31 manutter: drat, trying to set up clojure-mode.el on a new system, and marmalade-repo.org is down. :(

12:54 nizze: Hi!

12:54 I'm trying to implement map fuction.

12:54 What am I doing wrong here?

12:54 http://pastebin.com/Wrkxc5J6

12:54 The TCO appears to be working differently than I expected

12:55 ilyak: nizze: s/concat/cons?

12:56 nizze: Why so?

12:56 ilyak: Also, (=) would likely delazify the coll

12:56 Which you probably don't want

12:57 And also it might be an O(N) operation

12:57 Better use (not-empty)

12:57 nizze: because (f (first coll)) probably returns a scalar

12:57 and concat works on seq*

12:58 what you did is a flat-map

12:58 which is useful but distinct thing

13:11 squidz: whats the best clojure tutorial out there right now?

13:16 nizze: ilyak: Thanks!

13:17 Hmm what the difference between flat-map and map?

13:18 Chousuke: nizze: you can't use recur like that anyway

13:18 nizze: Chousuke: Really?

13:18 I assume the recur is not in the tail position

13:18 Chousuke: recur must be in a tail position. ie. it can't be a parameter to any function

13:19 nizze: Okay.

13:19 Chousuke: for an easy non-lazy implementation of map, use a vector as the accumulator

13:19 and add things to that

13:20 the lazy implementation is not much harder, but you'll have to understand lazy-seq and use "real" recursion, instead of recur

13:23 nizze: Chousuke: okay. I assume as a newbie that I do not have to know about lazy seqs

13:23 Chousuke: nizze: well, you can get away with not knowing how to make your own directly but it's not that hard

13:23 nizze: I've been doing some Haskell so I know what lazy means.

13:23 Okay

13:24 Thanks a ton for your help

13:25 Chousuke: the idea is that you make a function that returns sequence in such a way that it conses an item to a lazy seq that is determined by calling the function recursively

13:25 eg (defn ones [] (cons 1 (lazy-seq (ones))))

13:26 lazy-seq is a macro that defers the evaluation of the recursive call so you don't get an infinite loop... unless you try to evaluate a call to (ones)

13:26 without using take or something, that is

13:27 you can think of it as lazy-seq returning a "fake" seq that, when you actually need its item, evaluates the code you gave it. (the recursive call, that is)

13:28 nizze: WOLO


13:28 WOW!

13:29 Paul Graham was not wrong about LISP

13:30 Chousuke: I think you can actually do (defn ones [] (lazy-seq (cons 1 (ones)))) too for extra laziness

13:31 where you don't even get the first 1 until you force it

13:31 it's not magical, but it's sometimes sort of hard to see where the laziness is needed so that you don't end up with infinite loops :)

13:35 nizze: Chousuke: Clojure seems the most thought out language that I've ever tried

13:35 and it seems that it's turtles all the way down as well, something I loved about Smalltalk

13:36 Thranks

13:36 *Thanks

13:45 robermann: clojurebot: commands

13:45 clojurebot: paredit commands is http://mumble.net/~campbell/emacs/paredit.html

14:18 wunki: how would I check if a value is a boolean?

14:21 gtrak``: wunki, primitive or boxed type?

14:22 wunki: gtrak``primitive?

14:22 (or (true? var) (false? var))

14:22 or is that just stupid :)

14:32 gtrak``: ,(true? (Boolean. true))

14:32 clojurebot: false

14:32 gtrak``: wunki, you tell me :-)

14:33 where are you getting the boolean from?

14:33 wunki: input from a .json

14:34 gtrak``: so the json parser is going to do the right thing, probably

14:34 wunki: gtrak`` yes, it creates a true/false correctly

14:34 gtrak``: as long as it's not creating new Boolean instances, it looks like true? and false? will do the right thing

14:35 and true? and false? use clojure's identical function to check, so there's no extra behavior for non-booleans as far as I can tell

14:36 wunki: gtrak`` thanks, will implement it this way

14:37 gtrak``: they should seriously remove that constructor from java

14:39 wunki: another rookie question, why should I use `do` https://gist.github.com/9f42f01ba7135b287777

14:40 raek: wunki: defn (and fn) has an "implicit do", so you don't need to write that explicitly

14:41 in certain cases, you do need 'do', like in an if expression

14:41 or in other places where you can only write one expressoin

14:41 wunki: raek: ah, clicked, thanks

14:41 gtrak``: raek, thanks, didn't know that about fns

14:42 raek: most special forms (where it makes sense) behave this way

14:42 gtrak``: wunki, it's for imperative-style, the do block returns the result from the last member

14:42 raek: as a convenvience

14:46 wunki: last question for today (promise), I'm currently building function like this: https://gist.github.com/1e97f9e61f5f0964c2a3

14:47 would you do it like that?

14:48 gtrak``: looks good to me

14:49 try it

14:50 wunki: gtrak`` I'm already using it like this, to keep it "DRY" I'm performing some validations on the arg's this way. It works.. but wasn't sure if it could be improved

14:50 gtrak``: there's some preconditions support available for that

14:51 http://blog.fogus.me/2009/12/21/clojures-pre-and-post/

14:55 wunki: gtrak`` thanks for the tip, instapapered :)

14:56 I'm releasing all my code (for epis.to) this week, will post it in the channel when done

15:01 Netpilgrim: wunki: For some reason pre and post conditions do not work when attached to protocol implementations inside a defrecord. They are just ignored, which makes it even more annoying.

15:01 wunki: Just as an BTW because it's not mentioned in Fogus' article.

15:01 wunki: Netpilgrim: I'm going to need to read more about it, because what you said just whooshed by...

15:02 Netpilgrim: wunki: No problem. I just got bitten by it the other day, so I wanted to spread the word. :)

15:03 wunki: Netpilgrim: thanks, I have jolted down your comment for future reference :)

15:03 gtrak``: Netpilgrim, you could probably use an extra layer of (fn [] to fix that, right?

15:04 Netpilgrim: gtrak``: Perhaps. I'll try. For the moment I'm not working on the code because it was part of a procrastination effort.

15:05 gtrak``: And so is hanging out in this channel. :)

15:06 gtrak``: it's good to procrastinate useful things

15:07 Netpilgrim: gtrak``: That's what I keep telling myself. But it can get out of hand, as in “You have to cram for an exam? That's the perfect time to start learning a new programming language”.

15:07 gtrak``: story of my life :-)

15:08 it gives you a good breadth of knowledge

15:10 Netpilgrim: gtrak``: True, but I've reached a point where getting a degree has become really more important than accumulating more tangential knowledge.

15:11 gtrak``: That being said I still think that learning a functional language, and Clojure in particular, will be worth the time. I just have to schedule better.

15:11 wunki: is it possible to catch an exception with :type "x" ?

15:12 gtrak``: wunki, not sure what you mean?

15:13 wunki: I'm raising an exception with :type :invalid

15:13 now I would like to catch only that exception

15:14 gtrak``: you are explicitly throwing that exception?

15:14 generally you catch a specific exception by using a specific class for each exception, or you can add a field to your exception class to help you distinguish, then re-throw ones you can't do anything with

15:15 wunki: gtrak`` I'm raising them like here: http://mmcgrana.github.com/2010/08/clojure-rest-api.html

15:15 middle of the page, `raise :type :not-found` etc.

15:16 gtrak``: ah, that's specific to clojure.contrib.condition

15:16 there's also error-kit

15:17 wunki: I'm just copying everything I see on the web, trying to get it to work. Going pretty good this far. But I lack some serious knowledge

15:17 like how to catch a specific :type

15:17 gtrak``: http://richhickey.github.com/clojure-contrib/condition-api.html

15:18 handler-case does it

15:18 michaelr525: hey!

15:19 squidz: is it normal that after evaluating lisp from within emacs, the output isnt put to my slime-repl, but instead the mini-buffer?

15:21 and when I compile using C-c C-k, it gives me a compilation finished message in minibuffer, but there is no output to be found

15:40 anybody ever experience something similar or know why?

15:44 amcnamara: squidz: you're probably compiling not evaluating

15:45 for me, C-x C-e evaluates in slime (I think this is the default, though I may have changed it at some point)

15:45 squidz: amcnamara: when I use C-x C-e it does the same

15:45 amcnamara: are you running slime or an inferior lisp?

15:46 err slime/swank

15:47 squidz: yes its running

15:47 amcnamara: odd

15:47 try evaluating (+ 1 1)

15:48 or something with non-nil output

15:48 squidz: it evaluates it, but it only outputs it to the minif buffer in the very bottom, instead of in my slime-repl clojure buffer

15:49 amcnamara: yeah, that's to be expected, it should still be accessible to your slime environment though

15:49 try this: (def a "aoeu") c-x c-e, then in slime repl enter a

15:49 squidz: hmm I wonder why it doesnt seem connected

15:52 yeah that works

15:52 recognizes it

15:53 amcnamara: slime eval and slime-repl eval have the same environment (swank) but different output streams

15:54 squidz: is that by default'ß

15:54 ?

15:56 amcnamara: yeah, I know there's a way for slime to eval to the slime-repl but I don't remember the shortcut

15:57 also probably depends on how you installed slime and clojure-mode, I know elpa does a lot of configuration for you; my setup doesn't use elpa though

15:57 squidz: either did I

15:58 amcnamara: may be worth taking a look if that's the behaviour you want

16:00 squidz: no, this will be fine. Just wanted to make sure that this is the expected behavior

16:02 amcnamara: that's how mine works, that's also the behaviour I prefer

16:02 to each their own

16:15 * Nocab is looking into clojure and using eclipse + send to repl to test-drive things

16:15 Nocab: are there any simple ways to comment out lots of lines

16:15 amcnamara: &(doc comment)

16:15 lazybot: ⇒ "Macro ([& body]); Ignores body, yields nil"

16:15 Netpilgrim: Nocab: (comment <all your lines>)

16:16 Nocab: right. but Im coming from a VS-as-IDE sorta background. where CTRL K-C would comment whatever was chosen, in whatever construct whatever file you had open had for comments

16:16 similarly CTRL K-U to uncomment

16:17 I was wondering if eclipse had anything similar

16:18 I -can- manually move to the start, add the (comment and go to the end and add a ), or for each line prefix it with ;

16:18 I was just looking for somethiing slightly more automatic, using the intelligence of the editor instead of my fingers :P

16:18 * amcnamara never hacked clojure in eclipse

16:18 Nocab: ah well

16:18 I tried cljr

16:18 but I couldnt copy & paste things OUT from it

16:19 and that was a deal-killer. made experimenting and taking out the good code to a .clj file somewhere cumbersome

16:19 Netpilgrim: Nocab: IIRC Eclipse has this feature and if you have installed Clojure support (Counterclockwise?) it should work, though probably by adding lots of ;; in front of the lines.

16:19 Nocab: Maybe emacs would have been OK, but Ive been trying to get into eclipse (for android-dev) so I figured eclipse for clojure would be OK as well :)

16:20 Netpilgrim: thanks. guess ILl google more. just figured someone in here would know off hand

16:21 amcnamara: Nocab: I think many people would like to hear more about clojure dev in eclipse, consider writing a blog post about it.

16:22 at least _I_ would be interested

16:24 Netpilgrim: Could someone with slime experience help me with an encoding problem? describe-coding-system shows UTF-8 all the way but if I put non-Latin1 characters in my code, slime-eval-last-expression outputs “Coding system iso-latin-1-unix not suitable for …”.

16:25 Nocab: amcnamara: uhm. Ill have to disappoint you

16:25 I let my blog rot and die

16:25 and I cant be bothered to setup a new one ;)

16:26 amcnamara: bummer.

16:29 Nocab: I used to have 10 domains and sites and way too many projects

16:29 I just overdid it and now I have almost nada ;)

16:30 anyway, the closest Ive come to starting up any website related things right now is documenting whatever thing I work on in a public Google Docs document ;)

16:30 and I guess for the purpose of your enlightment, I wouldnt be able to contrast clojure in eclipse to other things, seeing as Im pretty new to clojure overall

16:34 Tcepsa: Micah: Have you tried C-/ in Eclipse? I think that's how you can comment multiple lines in Java, but I don't remember whether it works with Clojure...

16:35 whoops. s/Micah/Nocab ($#@% autocorrect...)

16:39 Nocab: Tcepsa: just tried it

16:39 and was to -comment- on it here :P

16:40 my comment: what an ass and US-centric keybinding

16:40 gtrak``: Nocab, if you use emacs and paredit, you type '(comment CTRL-RIGHTARROW' and you're done

16:40 Nocab: there is no way to do that here without pressing shift as well

16:40 gtrak``: thanks. I am still consideirng going the emacs route

16:41 because eclipse takes like 20 seconds to start. on a core i7 with 12 GBs of ram

16:43 gtrak``: you can get pretty useful with emacs in a couple of days

16:46 amcnamara: emacs is hugely configurable, which is particularly useful for me because I don't use a qwerty keyboard, normal shortcuts are usually inconvenient for me

16:46 I love emacs

16:48 Netpilgrim: I have found out that I have to also set the slime connection encoding to UTF-8 (it defaults to Latin1). But if I follow the instructions on the swank-clojure github page and try to evaluate an expression with Unicode characters, swank throws a runtime exception (http://pastebin.com/nV4tX4JE).

16:49 Has anyone swank-clojure running with UTF-8?

16:49 * Nocab tries doing evil unicode stuff in emacs

16:49 Nocab: s/emacs/eclipse/

16:49 lazybot: <Nocab> tries doing evil unicode stuff in eclipse

16:51 Nocab: and that worked

16:52 Netpilgrim: Nocab: I don’t know what kind of REPL you have in Eclipse, but it's probably not slime/swank, is it?

16:58 Nocab: no idea

16:58 it came with clounterclockwise

16:58 I highlight code in the editor and press ctrl-alt-s and it gets run in the repl

17:00 ah well. Im off

17:04 simard: sorry to ask that (I like lein), but is there a way to reduce the latency whenever I type "lein xyz" ? As an example, it takes 5 seconds between "lein run" and the actual run of my smallest program.

17:09 gtrak``: is it possible to set flags in project.clj and read them in the app?

17:09 ordnungswidrig: simard: cake addresses this. It keeps a running jvm which it connects to

17:10 gtrak``: simard, there's a lein int for that

17:12 anyway, I want to enable a behavior during development, and disable it during build, what's the right way to do that? (specifically, a cache)

17:13 simard: ordnungswidrig: oh so that delay is the JVM starting up.. makes sense

17:15 ordnungswidrig: gtrak``: I use a dynamic var in a config namespace: org.foo.project.config *env*

17:16 gtrak``: do you have to switch it on and off manually? that's a pain

17:22 Netpilgrim: Netpilgrim: Quick update on my encoding problem: Apparently the last swank-clojure release doesn’t have UTF-8 support yet. I overlooked that the github page defaults to the master branch.

17:22 balint: how do I print something to stderr?

17:23 I thought this would work: (binding [*out* *err*] (print "This went to std. error"))

17:23 but it does not

17:25 michaelr525: re

17:26 ordnungswidrig: gtrak``: default is :prod, for development I redefine it at the reply to :dev

17:26 balint: I think it's the wrong way: (binding [*err* *out*] (print "foo"))

17:27 gtrak``: ordnungswidrig, I think until I figure it out, I'm just going to use hg's shelve and unshelve to make it simpler

17:27 ordnungswidrig: balint: sorry, that was wrong

17:27 mudge: I want to set *out* to a file, how would I do that?

17:27 ordnungswidrig: balint: do you use the plain repl or swank?

17:28 mudge: basically I want all *out* to go into a file and not to the console

17:28 balint: ordnungswidrig: plain repl

17:28 gtrak``: mudge, you can use >

17:28 that would be the way to do it in the spirit of unix

17:29 ordnungswidrig: (with-open [f (clojure.java.io/writer "foo.txt")] (binding [*out* f] (print "foo")))

17:29 balint: what is the value that *out* and *err* give you?

17:29 balma: maybe the repl redirects it for line editing and so on

17:30 balint: user=> *out*

17:30 #<OutputStreamWriter java.io.OutputStreamWriter@494b6bed>

17:30 mudge: gtrak, I am calling my program from within a java program with (.exec (Runtime/getRuntime) "command"), and unix redirection won't work with that

17:30 balint: user=> *err*

17:30 #<PrintWriter java.io.PrintWriter@b3e75a5>

17:30 ordnungswidrig: balint: how do you know, it goes to out, not err?

17:30 balint: it does not go anywhere

17:31 ordnungswidrig: I use it like this: ./clj1.2-repl.sh foo.clj 2>/tmp/clojure.out

17:31 and the file I'm writing to is empty

17:32 mudge: how do i set *out* to point to a file and not the console?

17:32 ordnungswidrig: balint: that's not the repl but (binding [*out* *err*] (print "foo")) should do it

17:32 balint: ordnungswidrig: hmm, that's what I had and it did not print it anywhere

17:33 ordnungswidrig: mudge: l pasted a snipped just 3min ago.

17:33 balint: maybe the clj script does some file handle redirection=

17:33 ?

17:34 mudge: ordnungswidrig: ah thanks, but that is a local thread binding, I want to set *out* on the root var binding

17:35 balint: ordnungswidrig: sorry, you were right. I created a clj that does just the above and it works

17:35 ordnungswidrig: Is *out* defined as dynamic?

17:35 balint: ordnungswidrig: thank you very much for your help

17:35 ordnungswidrig: balint: you're welcome

17:35 mudge: ordnungswidrig: good questions

17:35 ordnungswidrig: mudge: why must you bind it globally?

17:38 icey: i have a map that i'd like to add a key to if the key doesn't exist... is conj the correct form for this? i.e. (conj {:owner 2} {:title "stuff"}) == {:title "stuff" :owner 2} and (conj {:owner 2} {:title "stuff" :owner 33}) == {:title "stuff" :owner 33}

17:38 testing at the repl insinuates this works, but i just want to make sure i'm not going to hurt myself doing it this way

17:38 mudge: ordnungswidrig: because I want any output of my program to write to a file (and there are parts of my program I can't control)

17:38 ordnungswidrig: mudge: that sounds terrifying :)

17:39 mudge: I'd go with (System/setOut my-file-print-stream)

17:39 mudge: ordnungswidrig: thanks, trying that

17:40 ordnungswidrig: mudge: this would even work with java code using System/out. You'd need a permission in a SecurityManager enabled environment, though.

17:42 balint: ordnungswidrig: interesting, it works if I use println but it does not work with print

17:43 ordnungswidrig: balint: I suppose the stream is not flushed. Try (flush)

17:44 mudge: ordnungswidrig: thanks, working on it

17:48 balint: ordnungswidrig: and you are right again :)

17:49 mudge: balint: it's working for me when I set System/setErr, but not for System/setOut

17:49 i also flushed

17:49 balint: mudge: so you can't use *out* ?

17:50 with the binding form above?

17:50 mudge: no, this isn't working: (System/setOut (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))

17:50 but this works for stdErr: (System/setErr (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))

17:52 I don't know why it works for stdErr and not for stdOut

17:53 balint: icey: you can also use (assoc your_map :owner 2)

17:53 although that would "overwrite" any existing keys

17:54 icey: balint: actually, i think that makes more sense since i am using dissoc elsewhere to exclude stuff from the map. i can plan around overwriting values since it would consistently do that

17:55 thanks :)

17:55 mudge: balint: what code did you use with System/setOut ?

17:56 balint: mudge: no code, my code is just that much: (binding [*out* *err*] (print "foo") (flush))

17:56 icey: maps are themselves functions which return the value belonging to the passed key

17:57 mudge: balint, okay

17:57 balint: (def m {:song "i feel loved"}) (m :song) => "i feel loved" (m :year) => nil

17:57 that can be pretty useful

18:03 ordnungswidrig: good night everyone

18:03 jblomo: is there a way to compile clojurescript from more than one directory?

18:43 gtrak``: jblomo, symlinks?

18:44 without a dependency system, you have to do it the low-tech way... put all your common code in one place

19:02 scottj: what is the purpose of this intrinsics commit? https://github.com/clojure/clojure/commit/e92978783e1ba7ac0e2617fdabfed576209d7fa4

19:06 jblomo: you mean other than putting the other places on the classpath and requiring them?

19:31 mudge: System/setOut isn't working for me, it just creates an empty file

19:31 Anyone know how to make System/setOut work in clojure?

19:37 ndimiduk: mudge: https://github.com/nathanmarz/cascalog/blob/master/src/clj/cascalog/playground.clj#L35

19:40 mudge: thanks ndimiduk: i want to send output to a file, not *out*, or make *out* go to a file

19:54 Tcepsa: mudge: Does your code have a single entry point?

19:57 mudge: Tcepsa, yes

20:01 Tcepsa: mudge: I was going to suggest that you just wrap that in a (binding ...) like ordnungswidrig had suggested, but that won't redirect third party output; it would only route the output from your code to the file.

20:03 mudge: Tcepsa, right

20:03 odd thing is that this works for *err* (System/setErr (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))

20:04 but this doesn't work for *out*: (System/setOut (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))

20:04 Tcepsa: mudge: Have you tried them each individually, or did you do them both at the same time?

20:05 mudge: Tcepsa: tried them individually

20:05 Tcepsa: hmmm...

20:06 mudge: looking at the difference between *out* and *err*: *out* is A java.io.Writer object representing standard output for print operations.

20:06 Defaults to System/out

20:07 and *err* is A java.io.Writer object representing standard error for print operations.

20:07 Defaults to System/err, wrapped in a PrintWriter

20:08 user317: i am new to how clojure/java deal with packages and dependencies, is there a way to get lein to pull https://github.com/ztellman/lamina automagically?

20:11 Tcepsa: mudge: Does it create the file if it doesn't already exist when you try to do setOut?

20:12 mudge: (Possibly after attempting to print something to it?)

20:12 mudge: Tcepsa: it creates a new empty file, and in fact (.println System/out "data") will output to the file, but code such as (print "datadd") will not output to the file

20:13 Tcepsa: it seems like System/out and *out* are separate, if I change System/out, it doesn't seem to change *out*

20:14 user317: you can upload lamina to Clojars and then use the lein deps command to install the library into clojure projects. that's one way to do it

20:14 Tcepsa: mudge: Oh, that's a great catch! Yes, that's almost certainly what is going on. I bet if you made a call to a third party lib that used System.out.println it would go into the file

20:15 mudge: Tcepsa: yes! that's probably why it is working for *err*, because my third party software is writing to System/err, not to *err*

20:17 Tcepsa: I mean this works: (System/setErr (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))

20:17 because my third program is writing to System/err and not to *err*

20:17 i am starting to think it is not possible to change *out* and *err*

20:17 Tcepsa: mudge: So I think what you'll need to do is somehow remind *out* to that new System/out _after_ you call setOut

20:18 s/remind/rebind

20:18 lazybot: <Tcepsa> mudge: So I think what you'll need to do is somehow rebind *out* to that new System/out _after_ you call setOut

20:18 mudge: Tcepsa: yea

20:18 user317: mudge, thanks, whats clojars, lamina is not my work though

20:19 mudge, looks like this there already :)

20:19 Tcepsa: (I'm trying to do that now, but getting a ClassCastException... still working on it)

20:19 mudge: lamina might be on clojars. Clojars is where clojure libraries are kept and where Clojar libraries are installed from.http://clojars.org/

20:20 Tcepsa: great!

20:27 Tcepsa: how's it going?

20:27 Tcepsa: mudge: Okay, I think I got it working!

20:28 mudge: really!?

20:28 do you have a gist?

20:28 Tcepsa: mudge: At your entry point, first call setOut

20:28 mudge: yes

20:28 Tcepsa: mudge: (No gist, but it is pretty straightforward)

20:29 mudge: okay

20:29 what's next?

20:30 Tcepsa: After that, do (binding [*out* (java.io.PrintWriter. System/out)] (everything-else ...))

20:31 Where everything else is the rest of your entry point code, so that e

20:31 all of your code will run with the new binding

20:32 mudge: okay, trying it

20:33 Tcepsa: Odd... (printing

20:33 bah, tablet keyboard is annoying...

20:34 Odd... (println ...) works but (print ...) doesn't seem to show up

20:34 mudge: Tcepsa: make sure that you flush

20:34 Tcepsa: Doesn't seem to help

20:35 It's like it just eats it; subsequent printlns come out but the text from the print is apparently gone. ~frown~

20:38 Ah, if you flush within the same binding it seems to work, but not if you use different binding calls. That is weird.

20:38 mudge: hmm

20:39 Tcepsa: The good news for you is that since all of your code should be called from inside that one binding, you should be fine as long as you flush before leaving it...

20:39 mudge: Tcepsa: yep

20:40 Tcepsa: it looks like binding *out* and *err* to the same file overwrites each other

20:40 Tcepsa: oh wait, nevermind, i just didn't bind *err* yet

20:40 let me try

20:40 it is working with *out*

20:40 Tcepsa: Yes, that's why I asked whether you were trying them both at the same time or individually; I thought perhaps that err was just getting a lock on the file or something

20:41 mudge: yea, i'm going to try them both on the same file now

20:41 Tcepsa: Ah, ok, looking forward to seeing whether that works

20:41 Also, Ia

20:43 I suspect opening a file with that particular FileOutputStream constructor may truncate the file, discarding anything that had previously been in it

20:44 mudge: yea, i wonder if there is an append mode, it looks like it is overwriting

20:45 yea, overwriting

20:46 Tcepsa: Yes, see the javadoc for FileOutputStream

20:46 And now I need to go AFK. Hopefully that will be enough to get you past this hump at least!

20:47 mudge: yea, thanks Tcepsa!

20:47 yes, i see that there is

20:48 tried, it, they are working together now

21:45 ambrosebs: is there a trick to adding a new test file to clojure (core)? mvn test doesn't seem to pick up a new file at clojure.test-clojure.fn

21:50 found it

22:19 ShereKahn: Hi guys, was just wondering if clojure supports a (loop ..... recur) form in the middle of another (loop recur) with diferent parameters ?

22:20 that would be inner loop inside an outer loop

22:20 tomoj: given (defn fst [& [x]] x) and (defn snd [& [_ x]] x), does e.g. (map-indexed (juxt fst (comp f snd)) coll) make sense? or is there a better way without those?

22:20 (for [[i s] (map-indexed vector coll)] [i (f s)]) has occurred to me

22:22 brehaut: ShereKahn: like #(loop [x 5] (when (< 0 x) (prn x) (loop [y x] (when (< 0 y) (prn y) (recur (dec y)))) (recur (dec x))))

22:22 ShereKahn: yes... but more complext

22:22 brehaut: ShereKahn are you wanting mutual recursion?

22:23 ShereKahn: no

22:23 actually its some kind of parser

22:24 inner loop would match pattern*

22:24 were outer loop is actually going over a lost of pattenrs

22:24 amalloy: $google fnparse

22:24 lazybot: [brehaut.net: Start Parsing in Clojure: fnparse] http://brehaut.net/blog/2011/fnparse_introduction

22:24 jblomo: where'd def- go in 1.3?

22:25 ShereKahn: tried fn parse, does not match my needs actually, It's more a template based system I have in mind.

22:28 devn: ShereKahn: what are you looking for?

22:41 gtrak``: how do you change the working directory in a repl?

22:45 amalloy: gtrak``: that's not possible on the jvm

22:45 gtrak``: ah... damn

22:45 well symlinks to the rescue

22:46 trying out clojurescript

22:47 user317: so i am trying to use this lamina package, and i have (:use [lamina channel lazy-channel-seq]) in my namespace, and [lamina "0.4.0-beta2-SNAPSHOT"] in my project

22:48 but when i run lein it tells me it cant find lamina/channel__init.class

22:48 ShereKahn: devn: I am trying to parse the outputs of some commands from a device.

22:48 scottj: jblomo: don't think def- was ever in core, just defn-. there was a thread about it core ppl thought meta syntax was sufficient

22:49 ShereKahn: the basic Idea I got was to split the commands into tokens

22:49 and have a list of patterns I would like to match

22:49 by tokens I mean splitting on blank and non word chars

22:50 jblomo: scottj: ^:private you mean? sounds good

22:50 user317: nm, i think i just forgot to run lein deps

22:50 brehaut: ,(re-seq #\w+" "a list of tokens")

22:50 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unsupported character: \w+>

22:50 ShereKahn: in the patterns, I would have the full literal "group" "informatio"

22:50 brehaut: ,(re-seq #"\w+" "a list of tokens")

22:50 clojurebot: ("a" "list" "of" "tokens")

22:50 ShereKahn: brehaut, precisely

22:50 scottj: jblomo: yeah

22:52 ShereKahn: but when there is somethingI would like to extract, in the patterns, I would have a list with like (:group-number #"\d+)

22:52 jblomo: scottj: are you scottjad?

22:52 scottj: jblomo: yeah, thanks for the response on gh

22:52 ShereKahn: which would read the nuber and add it to a map

22:52 so far so good.

22:52 but then the problems comes when I would need to match "sub-pattenrs"

22:53 that is a map, with a new list of patterns.

22:53 and I would need to match it either once

22:53 or multiple times

22:53 jblomo: scottj: np, i think i have a solution to the settings question using macros in clojruescript

22:53 should be up tonight

22:54 scottj: cool

22:54 ShereKahn: this is where I am trying to loop multiple times to parse the sub-rule

22:54 hence the original question.

22:54 but it seems I have troubles when I have multple levels of sub-rules.

22:55 So I was wondering whether loop (..... (loop ,,,, recur) recur) Was actually some construct that would work

22:56 brehaut: ShereKahn: thats exactly what my snippet did

22:57 ShereKahn: brehaut: correct me if i am wrong but your snippet is just breaking up a string into its tokens. I am speaking based on that list of tokens and a list of patterns to do some extractions

22:58 brehaut: ShereKahn: you asked if you could put a loop recur into a loop recur, and thats what i showed. i dont break up strings

22:59 perhaps instead of going off into the woods, you could step back from what you are doing show some example input and output and get some feedback on less iterative approachs to your problem

23:00 ShereKahn: brehaut, well actually sorry, the first snipped showed that.

23:07 Tcepsa: ShereKahn: I don't think it is possible to have nested loops like that in the same function, but if you put the inner loop in a separate function and then call that function from the outer loop, I think you can achieve the effect you are talking about.

23:09 ShereKahn: here's my code, with examples for the templates and the data I try to parse :

23:09 Tcepsa: ShereKahn: Th

23:09 ShereKahn: http://pastebin.com/U6xk4Yya

23:10 Sorry it's crude, but it's my first real project using clojure ...

23:11 I was thinking of scratching that all together, and re-write it using a ref or something so that I could have state, but that so un-lispy ...

23:15 brehaut: about as unlispy as a 38 line function ;)

23:16 ShereKahn: hehe :)

23:16 yeah I guess so :)

23:16 brehaut: there shouldnt be any need to store state in a ref however

23:17 and the only tricky thing with using fnparse to consume this is going to be the indentation rules

23:18 ShereKahn: the thing is, I have a couple of different outputs of the same type, that is why I tried to use patterns to match things rather than the full machinery of fn parse,

23:19 in the end all I need is a map with the values inside with some structure

23:20 Tcepsa: I'll admit that I am not able to follow exactly what each part is doing, so this might be a stupid question, but could you replace either or both loops with a map/reduce constrct

23:20 brehaut: thats no excuse for doing it that hard way :P nobody awards macho points

23:20 ShereKahn: and with fn-parse, I could not find an easy way to match the first line and extract the # at the end of the line... but again I did not spend hours on fn-parse... so maybe there is an easy way

23:20 well I would welcome any advise of doing it simpler.

23:20 :)

23:21 brehaut: im at work at the moment so i cant dive in to a complicated solution sorry

23:22 ShereKahn: and for the map/reduce... don't think it's possible given I have 2 lists to traverse in parallel, one where I might need to repeat the paterns multiple times (thikn .* on regexp)

23:25 So the initial Idea is that the parser returns a vector of 2 entriees , first is a map of transformed tokens, second is the remaining tokens to be read.

23:25 the tricky part is actyally when I have a template inside a template, that I will repeat zero or multiple time

23:26 that's where a state might have helped me I think,

23:26 to make sure I recur with the right pattern.

23:26 anyway thanks for your help guys ...

23:27 Tcepsa: Good luck!

23:36 user317: hmm, i m not getting something about how :use works, i have (:use [lamina]) but i am getting: Caused by: java.io.FileNotFoundException: Could not locate lamina__init.class or lamina.clj on classpath:

23:40 tbatchelli: is it possible to conditionally import a namespace with 'ns'? (e.g. to import certain namespaces depending on whether particular library is in the classpath), or resorting to the namespace primitives is the way to go?

23:50 icey: how many people were at the conj last year?

23:51 scottj: ~200

23:51 clojurebot: Huh?

23:51 icey: wow, that's a pretty good number

Logging service provided by n01se.net