#clojure logs

2011-09-05

00:30sridhow 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.
00:36Tcepsasrid: Seems like (binding ...) might be able to help, but that's really just a guess...
01:07amcnamarasrid: I believe you can pass *out* to sh's in keyword, something along the lines of (sh :out *out*)
01:07amcnamarahttp://clojure.github.com/clojure/clojure.core-api.html#clojure.core/*out*
01:07amcnamaraerr, out keyword
01:30amcnamarahow can I extend a type to be callable? clojure.lang.IFn isn't a protocol
01:33ambrosebs_clojure.lang.IFn has "invoke"
01:33ambrosebs_hmm
01:34ambrosebs_not a protocol?
01:34amcnamaranope, its an interface
01:37ambrosebs_tried something like this? https://github.com/clojure/core.match/blob/master/src/main/clojure/clojure/core/match/core.clj#L636
01:38ambrosebs_I wasn't aware that IFn was an interface, but I think that works
01:38ambrosebs_has IFn changed for 1.3?
01:46amcnamarainterfaces 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
01:46amcnamarafrom my understanding this is due to something called the expression problem
01:47ambrosebs_amcnamara: ah I see
01:47ambrosebs_that makes sense
01:48ambrosebs_doesn't sounds possible
01:48amcnamara:(
01:48ambrosebs_:(
02:03amalloyamcnamara: you can't cause an already-existing type to become callable as a function
02:03amcnamarabummer
02:04amalloywhat type do you want to call, anyway?
02:04amcnamaramore of a thought experiment
02:05amcnamaraI was trying to extend strings to be functions of map keys
02:05amcnamara("a" {"a" 1}) -> 1
02:05amcnamarakeyword-like
02:07amalloyif you're curious, you can't do this because it would be a performance disaster
02:07amalloyto make IFn a protocol
02:08amcnamaraunderstandable, would be neat if there were a protocol equivalent though
02:08amcnamaraPFn
02:10amalloyamcnamara: i have great news for you. you can write PFn yourself, and use it yourself! :P
02:11amcnamaraI wouldn't even know where to start digging around the evaluator
02:21amcnamaraamalloy: curiously, do you know why IFn has so many prototypes?
02:21amalloyugh
02:21amalloyso that we can pretend to java that we're statically-typed
02:22amcnamarainteresting
02:22amalloy(anyway, performance, basically. there can't really be any other excuse for code like that)
02:22amcnamarayeah, looking at the code for keyword, very tedious
02:23amalloythat's weird. i wonder why Keyword doesn't extend AFn, which should hide away that nonsense
02:26amcnamaraperhaps so that keywords can't be apply'd
02:30amcnamarathe applyhelper in AFn is also pretty nasty
04:06dbushenkohi all!
04:19TheMoonMasterIs penumbra dead?
04:20khaliGhm fleetdb embedded allows duplicates between sessions.. weird
04:24michaelr525hey!!
04:25khaliGmichaelr525, hey
04:26michaelr525what's up in clojure land?
04:27michaelr525:)
04:30khaliGhm nm, I was using init-persistent rather than load-persistent
04:57amcnamara5am, time for bed. night all.
05:20robermannhave you any news about "SICP in Clojure" project? According to its status (http://sicpinclojure.com/?q=content/current-status) it seems quite dead...
05:20squidzWhy should I choose clojure over scala when scala has static typing, which is for me a plus
05:21squidzand if sicp-clojure is dying, that is also bad, as I wanted to learn clojure and sicp at the same time :(
05:22michaelr525hehe
05:23michaelr525squidz: dynamic typing is much better imho
05:24squidzmichaelr525: why is that? I am a java programmer so I am used to it. Plus i think it could provide performance and quality improvements
05:25michaelr525squidz: you can learn clojure and sicp even better by continuing the project yourself
05:25squidzmichaelr525: That's an idea
05:25michaelr525squidz: well, i am a programmer of many languages and i preffer dynamic typing
05:26squidzwhy?
05:26clojurebotsquidz: because you can't handle the truth!
05:26michaelr525can you?
05:26squidznot sure
05:26squidzblow my socks off
05:27michaelr525well, types always get in your way instead of helping you. that's my experience
05:27Chousukethe problem isn't just having static typing or not having it.
05:27squidzChousuke: ... go on...
05:28ChousukeRich 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
05:28michaelr525what's that?
05:28Chousukebut if implemented it would be more powerful than most type systems.
05:28squidzwhy would it have to be optional?
05:28Chousukesquidz: because you don't want to force people to use it
05:29Chousuketyping gets in the way sometimes
05:29Chousukemichaelr525: basically a system for reasoning about code using arbitrary predicates, not just types
05:29squidzin my opinion it should be implemented and forced muahaha.
05:30robermann$cd doc
05:30lazybotclojure.contrib.repl-utils/*local-javadocs*: http://clojuredocs.org/v/330
05:30lazybotclojure.contrib.gen-html-docs/generate-documentation-to-file: http://clojuredocs.org/v/331
05:30lazybotclojure.contrib.repl-utils/add-local-javadoc: http://clojuredocs.org/v/332
05:30michaelr525squidz: C# went half way towards programmers when they added the `var' keyword
05:30Chousukethere are static type systems that are good but most only harm you.
05:30Chousukelike Java's
05:30Chousukeit's baaaaaaaaad
05:30michaelr525Types are still there but they are infered most of the time
05:30robermannwhich project give you 'cd''s beahviour?
05:31ChousukeHaskell's type system is pretty good but I can see it getting in the way at times
05:31squidzI can't imagine how static typing could get in the way???
05:31lazybotsquidz: How could that be wrong?
05:31ChousukeYou need a lot of really complicated type trickery to enable things that are straightforward in dynamic languages
05:31MasseR/la/win 32
05:32Chousukesquidz: are you kidding me? How does Java's static typing not get in the way?
05:32squidzIve never seemed to have a problem with it, but then again it's all i'm really used to
05:32Chousukeor in general, any sort of static typing without type inference = headache
05:32khaliGmichaelr525, have you looked at Qi?
05:33Chousukesquidz: you're perhaps used to only doing things that are natural within the confines of Java's type system
05:33Chousukewhich isn't a lot
05:34Chousukeit's entirely possible to have much better static typing in a much more expressive language, too (again, Haskell)
05:34michaelr525khaliG: what's that?
05:35khaliGmichaelr525, http://www.lambdassociates.org/qilisp.htm
05:35Chousukebut 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.
05:35michaelr525khaliG: should I?
05:35khaliGmichaelr525, yep! it's got a lot of cool ideas :)
05:35Chousukein a dynamic language it is not an issue if you leave a function unimplemeted, as long as you don't call it
05:36Chousukeso you can switch focus to something more important.
05:36michaelr525khaliG: one day.. when i get some free time.. (currently all free time goes to IRC chats;)
05:36khaliGhaha!
05:36Chousukeit's also easy to experiment with different sorts of inputs to different functions as you have no rigid typing requirements
05:38squidzyes 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
05:38Chousukeprogramming isn't math
05:38squidzmaybe it seems like a restriction
05:38squidzbut i think it could be
05:38squidzprogramming math that is
05:39scottjmath has side effects?
05:39squidzbut that goes into other philosophical questions that are maybe too distracting
05:39khaliGi think the better question is, does scala do static typing well?
05:40Chousukeit does it kind of like haskell I think
05:40squidzkhaliG: that could be a dealbreaker for sure
05:40Chousukeexcept it has to work with Java
05:40Chousukewhich obviously complicates matters
05:41Chousukejava's type system is dumb :P
05:41khaliGthe 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 ;)
05:42scottjkhaliG: I don't think a clojure port has been started
05:42scottjkhaliG: I think shen is targeting other platforms first
05:42khaliGscottj, 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 :/
05:43scottjRich mentioned that cljs with type checking by gclosure might be the first static typing version of clojure
05:44squidzscottj: So do you know if that is a goal that he wants?
05:45scottjsquidz: 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
05:46squidzseems reasonable enough. Does he get on this channel often?
05:46squidzor at all
05:47scottjnot often any more
05:50squidzI would like to contribute to the project if I could, but I dont know anything about writing languages
05:50squidzI'll at least make a start by learning clojure and reading through sicp
05:50michaelr525khaliG: scheme and js first, that's what written on Qi's site
05:51scottjsquidz: very few people contribute to the language itself, most things are done in libraries
05:52squidzwhich libraries?
05:52scottjsquidz: are we still talking static typing?
05:52squidzno I mean in general right now
05:52scottjhttp://www.clojure-toolbox.com/
05:53squidzah okay you mean libraries for clojure
05:53scottjoh by project you meant sicp in clojure?
05:54squidzno I meant the language itself
05:54squidzbut I guess that working on libraries would do just as much benefit if not more
05:54scottjoh well in that case see contrib
05:54squidzWhat kind of libraries do you suppose are in need or would be most beneficial right now?
05:56squidzfor example, Ive heard that compujure is pretty good, so that probably takes care of webdevelopment
05:56scottjsquidz: I don't know, most big areas are well covered probably a specific need you have or improvements to an existing library
05:57scottjfirst things first, learn clojure :)
05:57squidzyeah lol
05:58squidzbut I learn by doing
05:58squidzworks wonders for motivation
06:05squidzhttps://github.com/getwoven/infer looks interesting
06:06ejacksonsquidz: a lot of that should be in incanter, I think.
06:07squidzyeah, I also just thought it would possibly be better if the combined a few projects.
06:07squidzbut easier said than done
06:43squidzejackson: I see you contributed to incanter
06:49robermannsquiz: 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.
06:59ilyakhi *
06:59ilyakI have a map-of-something
06:59ilyakAnd I do (if (contains? map-of-something key) (some-fn (get map-of-something key))
06:59ilyakWhat's the idiomatic way?
07:00ilyaksome-fn function does side-effects
07:01michaelr525seems right to me, but I'm a noob
07:02michaelr525you can use when instead of if here, since you have no else
07:03michaelr525,doc
07:03clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>
07:03michaelr525,doc contains?
07:03clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>
07:03michaelr525,(doc contains?)
07:03clojurebot"([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'."
07:04ilyak,(contains? :a {:a 5})
07:04clojurebotfalse
07:04ilyakoops, I guess I should use something else?
07:04ilyak,(contains? '(:a 5) {:a 5})
07:04clojurebotfalse
07:04ilyakwtf, what for is contains? on maps?
07:04michaelr525,(:a {:a 5})
07:04clojurebot5
07:05ilyakoops, wrong order
07:05ilyak,(contains? {:a 5} :a)
07:05clojurebottrue
07:05ilyakright
07:05ilyaksorry for confusion
07:05ilyakmichaelr525: I actually have string keys
07:05michaelr525doesn't matter
07:07ilyak,("something" {"something" "crazy"})
07:07clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
07:08ilyaknowp
07:09michaelr525ah, you mean for that
07:10Netpilgrim,({"something" "crazy"} "something")
07:10clojurebot"crazy"
07:11michaelr525cool
07:16raekilyak: 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
07:17ilyakraek: cool, but i'm considering adding some kind of helper into my util.clj
07:42lnostdal_so odd .. i'm getting "no transaction running", but the code and functions called is within a (dosync ..)
07:43lnostdal_and the stack-trace has an earlier frame; clojure.lang.LockingTransaction.runInTransaction(LockingTransaction.java:231)
07:45lnostdal_oh, wait .. i've got some add-watch thing triggering .. hm
07:47lnostdal_ok, so those run in arbitrary threads unless i'm mutating the ref within an agent (?) .. parsing the doc-string here :)
08:07khaliGis there a nicer way to write - (map #(get %1 "name") (db/query ...))
08:19ilyakkhaliG: Who controls db/query?
08:19ilyak'cause the best way is (map :name (db/query ...)) but you have to make db/query use keywords
08:19wunkiin Python there is a "try -> except -> else" , how could I write this in clojure?
08:20khaliGright, fleetdb doesn't use keywords so i've got a string rather than keyword :/
08:20ilyakwunki: What does else do in python's try?
08:21wunkiif there is *no* exception, it winds up at else
08:21khaliGthat sounds dumb
08:22wunkiilyak: http://docs.python.org/tutorial/errors.html#handling-exceptions
08:22khaliGwhy not put the code that would go in the else after everything else inside the try block, same effect?
08:23agzhow I type-hint vector of float vectors ???
08:23lazybotagz: Yes, 100% for sure.
08:23wunkikhaliG: you are right.. totally missed that..
08:23khaliGoh i wasn't having a go at you, at python instead :P
08:27ilyakso you should use (do (try (catch )) (else-code))
08:27ilyakor not :)
08:27ilyakwhat do you want to return?
08:28ilyakthat is The question for clojure snippet
10:22simardI'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:23simardobviously, behind octave are copious amounts of specialized libraries..
10:29Netpilgrimsimard: I really have no clue about this subject, but I assume the authors of Incanter (http://incanter.org/) would know something about this.
10:36simardNetpilgrim: thank you I'll have a look to it
10:38NetpilgrimWould the use of reduce at https://gist.github.com/1195103 be considered idiomatic, of would a loop be considered better style?
10:40NetpilgrimBTW: I like Gist well enough but their monospace font is one of the worst to distinguish between ones and a small Ls.
10:41Netpilgrim s/a small/small/
10:51Kototamahi
10:51Kototamacan someone tell me what's wrong with the deployment of my compojure project http://paste.lisp.org/display/124485 ?!
10:51Kototama"java.lang.ClassNotFoundException: org.mortbay.jetty.Server" :-) ?!
10:55robermannmaybe a JVM version problem
11:00robermannKototama: by the way they have refactored the code: http://wiki.eclipse.org/Jetty/Getting_Started/Porting_to_Jetty_7/Refactoring
11:01Kototamaah!
11:01Kototamai'll try jetty6
11:02robermanncheck this too: http://stackoverflow.com/questions/2451572/jetty-7-mysql-config-java-lang-classnotfoundexception-org-mortbay-jetty-webap
11:02robermannbah, sometimes I don't understand the Java designers :) !
11:03Kototamaexactly what I thought when fighting with streams today
11:04robermannrenaming whole packages !
11:04Kototamawell seems the project is part of eclipse now
11:04Kototamathe naming convention with enterprise name is odd
11:15lnostdal_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:20raeklnostdal_: they are executed after the transaction has completed
11:20raekmaybe you are looking for validators?
11:20raekthey are executed when the transaction is about to finnish
11:25Kototamarobermann: what is strang is that the test app from compojure works
11:25Kototamai mean the example project
11:27lnostdal_raek, ok
11:28raek,(doc add-watch)
11:28clojurebot"([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:30robermannKototama: this one https://github.com/weavejester/compojure-example? Are you creating a WAR via lein ring uberwar?
11:36Kototamayes
11:42Kototamaseems better if i do not include ring.middleware.keyword-params, and ring.adapter.jetty!
11:42Kototamanow the apps is starting but without css
11:48Kototamai got a (mp/wrap-multipart-params
11:48Kototama (POST "/files" {params :params session :session}
11:48Kototama (upload-file (get params "lkif-file") session)))
11:48Kototamain my routes
11:48Kototamabut the POST goes to http://localhost:8080/files
11:49Kototamawhereas the app is in the localhost:8080/theapp
11:49Kototamahow can I make these routes relatives?
11:50Kototamahum maybe it's a problem with the javascript loading a "/files" url :s
11:50robermannmmm (POST "/" ?
11:51robermannthe "/" should be referred to the root context
11:51Kototamathis http://paste.lisp.org/display/124488
11:52Kototamaok then it's a problem with the use of the jquery load method which does not refer to this context
11:53robermannI think so
11:53Kototamais there a way to make it context aware :-) ?
11:55robermannby 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:56robermann(because they have renamed it)
11:56Kototamayep thanks!, that was the origin of the problem
11:58robermannfor jquery, I can only refer you to http://stackoverflow.com/questions/313434/problem-setting-path-to-jquery-in-mvc-app
12:01Kototamaok thanks
12:22robermannI 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:22amcnamarao/
12:23robermannIs this a way for splicing many features in several structured files, keeping the same namespace?
12:31manutterdrat, trying to set up clojure-mode.el on a new system, and marmalade-repo.org is down. :(
12:54nizzeHi!
12:54nizzeI'm trying to implement map fuction.
12:54nizzeWhat am I doing wrong here?
12:54nizzehttp://pastebin.com/Wrkxc5J6
12:54nizzeThe TCO appears to be working differently than I expected
12:55ilyaknizze: s/concat/cons?
12:56nizzeWhy so?
12:56ilyakAlso, (=) would likely delazify the coll
12:56ilyakWhich you probably don't want
12:57ilyakAnd also it might be an O(N) operation
12:57ilyakBetter use (not-empty)
12:57ilyaknizze: because (f (first coll)) probably returns a scalar
12:57ilyakand concat works on seq*
12:58ilyakwhat you did is a flat-map
12:58ilyakwhich is useful but distinct thing
13:11squidzwhats the best clojure tutorial out there right now?
13:16nizzeilyak: Thanks!
13:17nizzeHmm what the difference between flat-map and map?
13:18Chousukenizze: you can't use recur like that anyway
13:18nizzeChousuke: Really?
13:18nizzeI assume the recur is not in the tail position
13:18Chousukerecur must be in a tail position. ie. it can't be a parameter to any function
13:19nizzeOkay.
13:19Chousukefor an easy non-lazy implementation of map, use a vector as the accumulator
13:19Chousukeand add things to that
13:20Chousukethe lazy implementation is not much harder, but you'll have to understand lazy-seq and use "real" recursion, instead of recur
13:23nizzeChousuke: okay. I assume as a newbie that I do not have to know about lazy seqs
13:23Chousukenizze: well, you can get away with not knowing how to make your own directly but it's not that hard
13:23nizzeI've been doing some Haskell so I know what lazy means.
13:23nizzeOkay
13:24nizzeThanks a ton for your help
13:25Chousukethe 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:25Chousukeeg (defn ones [] (cons 1 (lazy-seq (ones))))
13:26Chousukelazy-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:26Chousukewithout using take or something, that is
13:27Chousukeyou 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:28nizzeWOLO
13:28nizze
13:28nizzeWOW!
13:29nizzePaul Graham was not wrong about LISP
13:30ChousukeI think you can actually do (defn ones [] (lazy-seq (cons 1 (ones)))) too for extra laziness
13:31Chousukewhere you don't even get the first 1 until you force it
13:31Chousukeit'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:35nizzeChousuke: Clojure seems the most thought out language that I've ever tried
13:35nizzeand it seems that it's turtles all the way down as well, something I loved about Smalltalk
13:36nizzeThranks
13:36nizze*Thanks
13:45robermannclojurebot: commands
13:45clojurebotparedit commands is http://mumble.net/~campbell/emacs/paredit.html
14:18wunkihow would I check if a value is a boolean?
14:21gtrak``wunki, primitive or boxed type?
14:22wunkigtrak``primitive?
14:22wunki(or (true? var) (false? var))
14:22wunkior is that just stupid :)
14:32gtrak``,(true? (Boolean. true))
14:32clojurebotfalse
14:32gtrak``wunki, you tell me :-)
14:33gtrak``where are you getting the boolean from?
14:33wunkiinput from a .json
14:34gtrak``so the json parser is going to do the right thing, probably
14:34wunkigtrak`` yes, it creates a true/false correctly
14:34gtrak``as long as it's not creating new Boolean instances, it looks like true? and false? will do the right thing
14:35gtrak``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:36wunkigtrak`` thanks, will implement it this way
14:37gtrak``they should seriously remove that constructor from java
14:39wunkianother rookie question, why should I use `do` https://gist.github.com/9f42f01ba7135b287777
14:40raekwunki: defn (and fn) has an "implicit do", so you don't need to write that explicitly
14:41raekin certain cases, you do need 'do', like in an if expression
14:41raekor in other places where you can only write one expressoin
14:41wunkiraek: ah, clicked, thanks
14:41gtrak``raek, thanks, didn't know that about fns
14:42raekmost special forms (where it makes sense) behave this way
14:42gtrak``wunki, it's for imperative-style, the do block returns the result from the last member
14:42raekas a convenvience
14:46wunkilast question for today (promise), I'm currently building function like this: https://gist.github.com/1e97f9e61f5f0964c2a3
14:47wunkiwould you do it like that?
14:48gtrak``looks good to me
14:49gtrak``try it
14:50wunkigtrak`` 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:50gtrak``there's some preconditions support available for that
14:51gtrak``http://blog.fogus.me/2009/12/21/clojures-pre-and-post/
14:55wunkigtrak`` thanks for the tip, instapapered :)
14:56wunkiI'm releasing all my code (for epis.to) this week, will post it in the channel when done
15:01Netpilgrimwunki: 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:01Netpilgrimwunki: Just as an BTW because it's not mentioned in Fogus' article.
15:01wunkiNetpilgrim: I'm going to need to read more about it, because what you said just whooshed by...
15:02Netpilgrimwunki: No problem. I just got bitten by it the other day, so I wanted to spread the word. :)
15:03wunkiNetpilgrim: thanks, I have jolted down your comment for future reference :)
15:03gtrak``Netpilgrim, you could probably use an extra layer of (fn [] to fix that, right?
15:04Netpilgrimgtrak``: Perhaps. I'll try. For the moment I'm not working on the code because it was part of a procrastination effort.
15:05Netpilgrimgtrak``: And so is hanging out in this channel. :)
15:06gtrak``it's good to procrastinate useful things
15:07Netpilgrimgtrak``: 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:07gtrak``story of my life :-)
15:08gtrak``it gives you a good breadth of knowledge
15:10Netpilgrimgtrak``: True, but I've reached a point where getting a degree has become really more important than accumulating more tangential knowledge.
15:11Netpilgrimgtrak``: 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:11wunkiis it possible to catch an exception with :type "x" ?
15:12gtrak``wunki, not sure what you mean?
15:13wunkiI'm raising an exception with :type :invalid
15:13wunkinow I would like to catch only that exception
15:14gtrak``you are explicitly throwing that exception?
15:14gtrak``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:15wunkigtrak`` I'm raising them like here: http://mmcgrana.github.com/2010/08/clojure-rest-api.html
15:15wunkimiddle of the page, `raise :type :not-found` etc.
15:16gtrak``ah, that's specific to clojure.contrib.condition
15:16gtrak``there's also error-kit
15:17wunkiI'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:17wunkilike how to catch a specific :type
15:17gtrak``http://richhickey.github.com/clojure-contrib/condition-api.html
15:18gtrak``handler-case does it
15:18michaelr525hey!
15:19squidzis it normal that after evaluating lisp from within emacs, the output isnt put to my slime-repl, but instead the mini-buffer?
15:21squidzand 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:40squidzanybody ever experience something similar or know why?
15:44amcnamarasquidz: you're probably compiling not evaluating
15:45amcnamarafor me, C-x C-e evaluates in slime (I think this is the default, though I may have changed it at some point)
15:45squidzamcnamara: when I use C-x C-e it does the same
15:45amcnamaraare you running slime or an inferior lisp?
15:46amcnamaraerr slime/swank
15:47squidzyes its running
15:47amcnamaraodd
15:47amcnamaratry evaluating (+ 1 1)
15:48amcnamaraor something with non-nil output
15:48squidzit evaluates it, but it only outputs it to the minif buffer in the very bottom, instead of in my slime-repl clojure buffer
15:49amcnamarayeah, that's to be expected, it should still be accessible to your slime environment though
15:49amcnamaratry this: (def a "aoeu") c-x c-e, then in slime repl enter a
15:49squidzhmm I wonder why it doesnt seem connected
15:52squidzyeah that works
15:52squidzrecognizes it
15:53amcnamaraslime eval and slime-repl eval have the same environment (swank) but different output streams
15:54squidzis that by default'ß
15:54squidz?
15:56amcnamarayeah, I know there's a way for slime to eval to the slime-repl but I don't remember the shortcut
15:57amcnamaraalso 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:57squidzeither did I
15:58amcnamaramay be worth taking a look if that's the behaviour you want
16:00squidzno, this will be fine. Just wanted to make sure that this is the expected behavior
16:02amcnamarathat's how mine works, that's also the behaviour I prefer
16:02amcnamarato each their own
16:15Nocabare there any simple ways to comment out lots of lines
16:15amcnamara&(doc comment)
16:15lazybot⇒ "Macro ([& body]); Ignores body, yields nil"
16:15NetpilgrimNocab: (comment <all your lines>)
16:16Nocabright. 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:16Nocabsimilarly CTRL K-U to uncomment
16:17NocabI was wondering if eclipse had anything similar
16:18NocabI -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:18NocabI was just looking for somethiing slightly more automatic, using the intelligence of the editor instead of my fingers :P
16:18Nocabah well
16:18NocabI tried cljr
16:18Nocabbut I couldnt copy & paste things OUT from it
16:19Nocaband that was a deal-killer. made experimenting and taking out the good code to a .clj file somewhere cumbersome
16:19NetpilgrimNocab: 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:19NocabMaybe 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:20NocabNetpilgrim: thanks. guess ILl google more. just figured someone in here would know off hand
16:21amcnamaraNocab: I think many people would like to hear more about clojure dev in eclipse, consider writing a blog post about it.
16:22amcnamaraat least _I_ would be interested
16:24NetpilgrimCould 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:25Nocabamcnamara: uhm. Ill have to disappoint you
16:25NocabI let my blog rot and die
16:25Nocaband I cant be bothered to setup a new one ;)
16:26amcnamarabummer.
16:29NocabI used to have 10 domains and sites and way too many projects
16:29NocabI just overdid it and now I have almost nada ;)
16:30Nocabanyway, 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:30Nocaband 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:34TcepsaMicah: 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:35Tcepsawhoops. s/Micah/Nocab ($#@% autocorrect...)
16:39NocabTcepsa: just tried it
16:39Nocaband was to -comment- on it here :P
16:40Nocabmy comment: what an ass and US-centric keybinding
16:40gtrak``Nocab, if you use emacs and paredit, you type '(comment CTRL-RIGHTARROW' and you're done
16:40Nocabthere is no way to do that here without pressing shift as well
16:40Nocabgtrak``: thanks. I am still consideirng going the emacs route
16:41Nocabbecause eclipse takes like 20 seconds to start. on a core i7 with 12 GBs of ram
16:43gtrak``you can get pretty useful with emacs in a couple of days
16:46amcnamaraemacs 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:46amcnamaraI love emacs
16:48NetpilgrimI 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:49NetpilgrimHas anyone swank-clojure running with UTF-8?
16:49Nocabs/emacs/eclipse/
16:49lazybot<Nocab> tries doing evil unicode stuff in eclipse
16:51Nocaband that worked
16:52NetpilgrimNocab: I don’t know what kind of REPL you have in Eclipse, but it's probably not slime/swank, is it?
16:58Nocabno idea
16:58Nocabit came with clounterclockwise
16:58NocabI highlight code in the editor and press ctrl-alt-s and it gets run in the repl
17:00Nocabah well. Im off
17:04simardsorry 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:09gtrak``is it possible to set flags in project.clj and read them in the app?
17:09ordnungswidrigsimard: cake addresses this. It keeps a running jvm which it connects to
17:10gtrak``simard, there's a lein int for that
17:12gtrak``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:13simardordnungswidrig: oh so that delay is the JVM starting up.. makes sense
17:15ordnungswidriggtrak``: I use a dynamic var in a config namespace: org.foo.project.config *env*
17:16gtrak``do you have to switch it on and off manually? that's a pain
17:22NetpilgrimNetpilgrim: 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:22balinthow do I print something to stderr?
17:23balintI thought this would work: (binding [*out* *err*] (print "This went to std. error"))
17:23balintbut it does not
17:25michaelr525re
17:26ordnungswidriggtrak``: default is :prod, for development I redefine it at the reply to :dev
17:26ordnungswidrigbalint: I think it's the wrong way: (binding [*err* *out*] (print "foo"))
17:27gtrak``ordnungswidrig, I think until I figure it out, I'm just going to use hg's shelve and unshelve to make it simpler
17:27ordnungswidrigbalint: sorry, that was wrong
17:27mudgeI want to set *out* to a file, how would I do that?
17:27ordnungswidrigbalint: do you use the plain repl or swank?
17:28mudgebasically I want all *out* to go into a file and not to the console
17:28balintordnungswidrig: plain repl
17:28gtrak``mudge, you can use >
17:28gtrak``that would be the way to do it in the spirit of unix
17:29ordnungswidrig(with-open [f (clojure.java.io/writer "foo.txt")] (binding [*out* f] (print "foo")))
17:29ordnungswidrigbalint: what is the value that *out* and *err* give you?
17:29ordnungswidrigbalma: maybe the repl redirects it for line editing and so on
17:30balintuser=> *out*
17:30balint#<OutputStreamWriter java.io.OutputStreamWriter@494b6bed>
17:30mudgegtrak, I am calling my program from within a java program with (.exec (Runtime/getRuntime) "command"), and unix redirection won't work with that
17:30balintuser=> *err*
17:30balint#<PrintWriter java.io.PrintWriter@b3e75a5>
17:30ordnungswidrigbalint: how do you know, it goes to out, not err?
17:30balintit does not go anywhere
17:31balintordnungswidrig: I use it like this: ./clj1.2-repl.sh foo.clj 2>/tmp/clojure.out
17:31balintand the file I'm writing to is empty
17:32mudgehow do i set *out* to point to a file and not the console?
17:32ordnungswidrigbalint: that's not the repl but (binding [*out* *err*] (print "foo")) should do it
17:32balintordnungswidrig: hmm, that's what I had and it did not print it anywhere
17:33ordnungswidrigmudge: l pasted a snipped just 3min ago.
17:33ordnungswidrigbalint: maybe the clj script does some file handle redirection=
17:33ordnungswidrig?
17:34mudgeordnungswidrig: ah thanks, but that is a local thread binding, I want to set *out* on the root var binding
17:35balintordnungswidrig: sorry, you were right. I created a clj that does just the above and it works
17:35ordnungswidrigIs *out* defined as dynamic?
17:35balintordnungswidrig: thank you very much for your help
17:35ordnungswidrigbalint: you're welcome
17:35mudgeordnungswidrig: good questions
17:35ordnungswidrigmudge: why must you bind it globally?
17:38iceyi 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:38iceytesting 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:38mudgeordnungswidrig: 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:38ordnungswidrigmudge: that sounds terrifying :)
17:39ordnungswidrigmudge: I'd go with (System/setOut my-file-print-stream)
17:39mudgeordnungswidrig: thanks, trying that
17:40ordnungswidrigmudge: this would even work with java code using System/out. You'd need a permission in a SecurityManager enabled environment, though.
17:42balintordnungswidrig: interesting, it works if I use println but it does not work with print
17:43ordnungswidrigbalint: I suppose the stream is not flushed. Try (flush)
17:44mudgeordnungswidrig: thanks, working on it
17:48balintordnungswidrig: and you are right again :)
17:49mudgebalint: it's working for me when I set System/setErr, but not for System/setOut
17:49mudgei also flushed
17:49balintmudge: so you can't use *out* ?
17:50balintwith the binding form above?
17:50mudgeno, this isn't working: (System/setOut (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))
17:50mudgebut this works for stdErr: (System/setErr (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))
17:52mudgeI don't know why it works for stdErr and not for stdOut
17:53balinticey: you can also use (assoc your_map :owner 2)
17:53balintalthough that would "overwrite" any existing keys
17:54iceybalint: 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:55iceythanks :)
17:55mudgebalint: what code did you use with System/setOut ?
17:56balintmudge: no code, my code is just that much: (binding [*out* *err*] (print "foo") (flush))
17:56balinticey: maps are themselves functions which return the value belonging to the passed key
17:57mudgebalint, okay
17:57balint(def m {:song "i feel loved"}) (m :song) => "i feel loved" (m :year) => nil
17:57balintthat can be pretty useful
18:03ordnungswidriggood night everyone
18:03jblomois there a way to compile clojurescript from more than one directory?
18:43gtrak``jblomo, symlinks?
18:44gtrak``without a dependency system, you have to do it the low-tech way... put all your common code in one place
19:02scottjwhat is the purpose of this intrinsics commit? https://github.com/clojure/clojure/commit/e92978783e1ba7ac0e2617fdabfed576209d7fa4
19:06scottjjblomo: you mean other than putting the other places on the classpath and requiring them?
19:31mudgeSystem/setOut isn't working for me, it just creates an empty file
19:31mudgeAnyone know how to make System/setOut work in clojure?
19:37ndimidukmudge: https://github.com/nathanmarz/cascalog/blob/master/src/clj/cascalog/playground.clj#L35
19:40mudgethanks ndimiduk: i want to send output to a file, not *out*, or make *out* go to a file
19:54Tcepsamudge: Does your code have a single entry point?
19:57mudgeTcepsa, yes
20:01Tcepsamudge: 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:03mudgeTcepsa, right
20:03mudgeodd thing is that this works for *err* (System/setErr (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))
20:04mudgebut this doesn't work for *out*: (System/setOut (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))
20:04Tcepsamudge: Have you tried them each individually, or did you do them both at the same time?
20:05mudgeTcepsa: tried them individually
20:05Tcepsahmmm...
20:06mudgelooking at the difference between *out* and *err*: *out* is A java.io.Writer object representing standard output for print operations.
20:06mudgeDefaults to System/out
20:07mudgeand *err* is A java.io.Writer object representing standard error for print operations.
20:07mudgeDefaults to System/err, wrapped in a PrintWriter
20:08user317i 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:11Tcepsamudge: Does it create the file if it doesn't already exist when you try to do setOut?
20:12Tcepsamudge: (Possibly after attempting to print something to it?)
20:12mudgeTcepsa: 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:13mudgeTcepsa: it seems like System/out and *out* are separate, if I change System/out, it doesn't seem to change *out*
20:14mudgeuser317: 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:14Tcepsamudge: 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:15mudgeTcepsa: yes! that's probably why it is working for *err*, because my third party software is writing to System/err, not to *err*
20:17mudgeTcepsa: I mean this works: (System/setErr (PrintStream. (FileOutputStream. "/home/nick/jobboard/log.txt")))
20:17mudgebecause my third program is writing to System/err and not to *err*
20:17mudgei am starting to think it is not possible to change *out* and *err*
20:17Tcepsamudge: So I think what you'll need to do is somehow remind *out* to that new System/out _after_ you call setOut
20:18Tcepsas/remind/rebind
20:18lazybot<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:18mudgeTcepsa: yea
20:18user317mudge, thanks, whats clojars, lamina is not my work though
20:19user317mudge, looks like this there already :)
20:19Tcepsa(I'm trying to do that now, but getting a ClassCastException... still working on it)
20:19mudgelamina might be on clojars. Clojars is where clojure libraries are kept and where Clojar libraries are installed from.http://clojars.org/
20:20mudgeTcepsa: great!
20:27mudgeTcepsa: how's it going?
20:27Tcepsamudge: Okay, I think I got it working!
20:28mudgereally!?
20:28mudgedo you have a gist?
20:28Tcepsamudge: At your entry point, first call setOut
20:28mudgeyes
20:28Tcepsamudge: (No gist, but it is pretty straightforward)
20:29mudgeokay
20:29mudgewhat's next?
20:30TcepsaAfter that, do (binding [*out* (java.io.PrintWriter. System/out)] (everything-else ...))
20:31TcepsaWhere everything else is the rest of your entry point code, so that e
20:31Tcepsaall of your code will run with the new binding
20:32mudgeokay, trying it
20:33TcepsaOdd... (printing
20:33Tcepsabah, tablet keyboard is annoying...
20:34TcepsaOdd... (println ...) works but (print ...) doesn't seem to show up
20:34mudgeTcepsa: make sure that you flush
20:34TcepsaDoesn't seem to help
20:35TcepsaIt's like it just eats it; subsequent printlns come out but the text from the print is apparently gone. ~frown~
20:38TcepsaAh, if you flush within the same binding it seems to work, but not if you use different binding calls. That is weird.
20:38mudgehmm
20:39TcepsaThe 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:39mudgeTcepsa: yep
20:40mudgeTcepsa: it looks like binding *out* and *err* to the same file overwrites each other
20:40mudgeTcepsa: oh wait, nevermind, i just didn't bind *err* yet
20:40mudgelet me try
20:40mudgeit is working with *out*
20:40TcepsaYes, 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:41mudgeyea, i'm going to try them both on the same file now
20:41TcepsaAh, ok, looking forward to seeing whether that works
20:41TcepsaAlso, Ia
20:43TcepsaI suspect opening a file with that particular FileOutputStream constructor may truncate the file, discarding anything that had previously been in it
20:44mudgeyea, i wonder if there is an append mode, it looks like it is overwriting
20:45mudgeyea, overwriting
20:46TcepsaYes, see the javadoc for FileOutputStream
20:46TcepsaAnd now I need to go AFK. Hopefully that will be enough to get you past this hump at least!
20:47mudgeyea, thanks Tcepsa!
20:47mudgeyes, i see that there is
20:48mudgetried, it, they are working together now
21:45ambrosebsis 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:50ambrosebsfound it
22:19ShereKahnHi guys, was just wondering if clojure supports a (loop ..... recur) form in the middle of another (loop recur) with diferent parameters ?
22:20ShereKahnthat would be inner loop inside an outer loop
22:20tomojgiven (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:20tomoj(for [[i s] (map-indexed vector coll)] [i (f s)]) has occurred to me
22:22brehautShereKahn: like #(loop [x 5] (when (< 0 x) (prn x) (loop [y x] (when (< 0 y) (prn y) (recur (dec y)))) (recur (dec x))))
22:22ShereKahnyes... but more complext
22:22brehautShereKahn are you wanting mutual recursion?
22:23ShereKahnno
22:23ShereKahnactually its some kind of parser
22:24ShereKahninner loop would match pattern*
22:24ShereKahnwere outer loop is actually going over a lost of pattenrs
22:24amalloy$google fnparse
22:24lazybot[brehaut.net: Start Parsing in Clojure: fnparse] http://brehaut.net/blog/2011/fnparse_introduction
22:24jblomowhere'd def- go in 1.3?
22:25ShereKahntried fn parse, does not match my needs actually, It's more a template based system I have in mind.
22:28devnShereKahn: what are you looking for?
22:41gtrak``how do you change the working directory in a repl?
22:45amalloygtrak``: that's not possible on the jvm
22:45gtrak``ah... damn
22:45gtrak``well symlinks to the rescue
22:46gtrak``trying out clojurescript
22:47user317so 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:48user317but when i run lein it tells me it cant find lamina/channel__init.class
22:48ShereKahndevn: I am trying to parse the outputs of some commands from a device.
22:48scottjjblomo: don't think def- was ever in core, just defn-. there was a thread about it core ppl thought meta syntax was sufficient
22:49ShereKahnthe basic Idea I got was to split the commands into tokens
22:49ShereKahnand have a list of patterns I would like to match
22:49ShereKahnby tokens I mean splitting on blank and non word chars
22:50jblomoscottj: ^:private you mean? sounds good
22:50user317nm, i think i just forgot to run lein deps
22:50brehaut,(re-seq #\w+" "a list of tokens")
22:50clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unsupported character: \w+>
22:50ShereKahnin the patterns, I would have the full literal "group" "informatio"
22:50brehaut,(re-seq #"\w+" "a list of tokens")
22:50clojurebot("a" "list" "of" "tokens")
22:50ShereKahnbrehaut, precisely
22:50scottjjblomo: yeah
22:52ShereKahnbut when there is somethingI would like to extract, in the patterns, I would have a list with like (:group-number #"\d+)
22:52jblomoscottj: are you scottjad?
22:52scottjjblomo: yeah, thanks for the response on gh
22:52ShereKahnwhich would read the nuber and add it to a map
22:52ShereKahnso far so good.
22:52ShereKahnbut then the problems comes when I would need to match "sub-pattenrs"
22:53ShereKahnthat is a map, with a new list of patterns.
22:53ShereKahnand I would need to match it either once
22:53ShereKahnor multiple times
22:53jblomoscottj: np, i think i have a solution to the settings question using macros in clojruescript
22:53jblomoshould be up tonight
22:54scottjcool
22:54ShereKahnthis is where I am trying to loop multiple times to parse the sub-rule
22:54ShereKahnhence the original question.
22:54ShereKahnbut it seems I have troubles when I have multple levels of sub-rules.
22:55ShereKahnSo I was wondering whether loop (..... (loop ,,,, recur) recur) Was actually some construct that would work
22:56brehautShereKahn: thats exactly what my snippet did
22:57ShereKahnbrehaut: 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:58brehautShereKahn: you asked if you could put a loop recur into a loop recur, and thats what i showed. i dont break up strings
22:59brehautperhaps 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:00ShereKahnbrehaut, well actually sorry, the first snipped showed that.
23:07TcepsaShereKahn: 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:09ShereKahnhere's my code, with examples for the templates and the data I try to parse :
23:09TcepsaShereKahn: Th
23:09ShereKahnhttp://pastebin.com/U6xk4Yya
23:10ShereKahnSorry it's crude, but it's my first real project using clojure ...
23:11ShereKahnI 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:15brehautabout as unlispy as a 38 line function ;)
23:16ShereKahnhehe :)
23:16ShereKahnyeah I guess so :)
23:16brehautthere shouldnt be any need to store state in a ref however
23:17brehautand the only tricky thing with using fnparse to consume this is going to be the indentation rules
23:18ShereKahnthe 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:19ShereKahnin the end all I need is a map with the values inside with some structure
23:20TcepsaI'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:20brehautthats no excuse for doing it that hard way :P nobody awards macho points
23:20ShereKahnand 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:20ShereKahnwell I would welcome any advise of doing it simpler.
23:20ShereKahn:)
23:21brehautim at work at the moment so i cant dive in to a complicated solution sorry
23:22ShereKahnand 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:25ShereKahnSo 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:25ShereKahnthe tricky part is actyally when I have a template inside a template, that I will repeat zero or multiple time
23:26ShereKahnthat's where a state might have helped me I think,
23:26ShereKahnto make sure I recur with the right pattern.
23:26ShereKahnanyway thanks for your help guys ...
23:27TcepsaGood luck!
23:36user317hmm, 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:40tbatchelliis 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:50iceyhow many people were at the conj last year?
23:51scottj~200
23:51clojurebotHuh?
23:51iceywow, that's a pretty good number