#clojure logs

2011-02-19

00:01halgarican someone help me with an issue with lein?
00:01rata_amalloy: sorry, but then how do you know how many groups there are that have a repeated lastname?
00:01rata_halgari: ask
00:02halgariI have a bog-standard project.clj file. When I do lein-deps it says it can't find org.clojure:clojure:jar:1.2.0 and that I need to install it manually
00:02halgariis that normal? I created the project.clj via lein new.
00:04rata_amalloy: it should depend on n, the number of people that have a particular lastname (let's call it m) and the total number of people (let's call it P)
00:05rata_halgari: I haven't seen that before
00:06amalloyrata_: are you sure you have to handle the issue of double names? treat one of them as most-meaningful, or treat them as two separate people, or whatever
00:06halgarirata_ yeah, I'm on windows, but I downloaded lein, and did a lein self-install. That ran fine. From there I can't seem to get lein to do a thing
00:08rata_amalloy: even with just one name, it should depend on n, m and P
00:09rata_halgari: could you post the output in a gist?
00:09scottjhalgari: lein was buggy on windows in the past but I would guess that feature should work
00:10halgariI have this question also posted on SO (http://stackoverflow.com/questions/5048911/lein-spitting-out-weird-errors) I was just hoping someone here may have a quick answer. Anyway, the errors are on SO
00:15rata_amalloy: because if I have n=3, m=3 and P=5, there are 5 ways over 10 to have a name repeated, but if I have P=6, I have then 7 ways over 20
00:16amalloyi've lost track of what m, n, and p are
00:17rata_n is the number people that make a group, m is the number of people that have a particular lastname and P is the total population
00:17rata_amalloy: ^
00:18amalloyrata_: p is only interesting at the end, for turning counts into ratios
00:18amalloyfor working with n and m, you can use the formula i gave earlier
00:19rata_halgari: weird error anyway... you should ask technomancy, but he's not here right now
00:19halgarirata_ : okay, thanks
00:29rata_amalloy: but p is important to count the number of groups, because a group is considered as positive when the lastname is repeated once, that is, when two of the n people have the same lastname
00:30rata_(when two at least)
00:31robinkIs there a Clojure function that takes n arguments at the beginning and then applies them to the result of applying the previous (or first argument) to a list? Like (recurse 1 2 [[1 2 3] [4 5 6] [7 8 9]]) to yield 6?
00:32robinkDoing ((vec-of-vecs 1) 2) is a bit weird to me.
00:32amalloyrobink: i think that's a little too vaguely defined
00:32robinkamalloy: Sorry
00:32greghso something like iterative function application?
00:32robinkI actually don't want to do anything fancy, I just want C-style addressing of a faux 2d array.
00:32robinkgregh: That's probably more along the lines of what I want.
00:32brehaut,(get-in [[1 2 3] [4 5 6] [7 8 9]] [1 2])
00:32clojurebot6
00:33robinkbrehaut: Thanks!
00:33amalloythat works for nested maps and such; for the more general case you described to begin with i think you mean either reduce or iterate
00:34shachafHmm, robink.
00:37robinkamalloy: Gotcha, looks like reduce would be what I'd need in that case.
00:39amalloyright. for example, get-in is actually implemented as ##(reduce get [[1 2 3] [4 5 6] [7 8 9]] [1 2])
00:39sexpbot⟹ 6
00:41robinkWhich is probably the most compact form you could put it in.
00:42amalloyindeed
00:42robinkamalloy: Thanks
00:44pdki was wondering if it had that for a while
00:45pdki was like "god why isn't there nth and get for nested structures"
00:46robinkI'm too hung up on C-style indexing and the OO syntax of being able to go array.slice(0).slice(1) to do (get-in [[1 2] [3 4]] [0 1]) to get 2.
00:48amalloyrobink: there are various mechanisms to do stuff "like that" in clojure as well
00:48amalloy&(-> [[1 2 3] [4 5 6] [7 8 9]] (get 1) (get 1))
00:48sexpbot⟹ 5
00:49robinkAha!
00:50pdkcourse yknow
00:51amalloyrobink: the -> operator is actually a macro that restructures your code: ##(macroexpand-all '(-> [[1 2 3] [4 5 6] [7 8 9]] (get 1) (get 1)))
00:51sexpbot⟹ (get (get [[1 2 3] [4 5 6] [7 8 9]] 1) 1)
00:51pdk(-> array (.slice 0) (.slice 1)) = array.slice(0).slice(1) now :p
00:51pdkwhen i read the docstrings for -> and ->> they made no sense
00:51pdkthen seeing a code example was like
00:51robinkAha!
00:51pdkOMG I MUST USE THIS EVERYWHERE
00:51robinkheh
00:51pdkone of the rubs is that documentation is still spotty
00:52pdkterse at best in docstrings
00:52amalloy$google clojuredocs
00:52sexpbotFirst out of 357 results is: ClojureDocs - Community-Powered Clojure Documentation and Examples
00:52sexpbothttp://clojuredocs.org/
00:52pdkwell
00:52pdkAND THAT
00:52robinkI suppose the best way to notate the fact that you can call a vec as a function (or as though it was one) is just to have a nested eval (([[1 2] [3 4]] 1) 0)
00:53pdk,(-> [[1 2] [3 4]] (get 1) (get 0))
00:53clojurebot3
00:53pdki'd say that's probably a bit more explicit
00:54robinkpdk: Except you're calling get on the vec and the index is the first argument, rather than calling 1 on the vec and then calling 0 on the resulting vec.
00:55robinkI'm sorry, the index is the second argument.
00:55amalloyi often forget i can treat a vector as a function. like, i know it's true, but i rarely think of using it
00:55amalloypart of this is that i don't deal with indexes very often
00:56pdkequivalent result though so
00:56scottjand I think you're more likely to get an exception when treating vector as function
00:58robinkscottj: So there's a special case with a vector, in that there isn't some core identity function associated with the type, but rather something bound to vectors in the interpreter?
00:58amalloyrobink: that is incorrect
00:58amalloythere is an IFn interface, which any type can implement in order to be treated as a function
00:59brehaut,(ifn? [])
00:59clojurebottrue
01:00scottjall I meant is ([] 1) vs (get [] 1) and (let [a nil] (a 1)) vs (let [a nil] (get a 1))
01:00robinkamalloy: Gotcha.
01:01robinkSorry, should've been amalloy, brehaut: Gotcha.
01:02amalloyit's okay, brehaut is used to being upstaged by my immense charisma
01:02robinkheh
01:05brehautits true
01:06brehautamalloy also cleans up my messes
01:06amalloyand boggles at your haskell
01:07amalloyspeaking of which, robink, when you're ready to have your mind really blown, google for rosetta clojure fibonacci
01:07robinkscottj: Gotcha
01:07robinkamalloy: OK
01:08brehautamalloy: i dont think the haskelly one is on rosettacode
01:09amalloybrehaut: i meant speaking of boggling, not speaking of haskell. not very clear, i suppose
01:09brehautoh right
01:09robinkThe one I'm seeing (on rosettacode.org) has it do a lazy seq.
01:09robinkWhich is really cool.
01:10amalloyrobink: pretty much everything in clojure is a lazy seq
01:10brehautthats the sensible lazy seq version
01:11brehautthers also a datarecursive version ;)
01:12robinkbrehaut: Woah
01:15scottjI'm so glad rich didn't stop with this: (defn ^:static fib ^long [^long n] (if (>= (long 1) n) (long 1) (+ (fib (dec n)) (fib (- n (long 2))))))
01:16brehautthat has some unecessary coercions doesnt it?
01:17foxupahi
01:17scottjbrehaut: maybe now, but it was written before all the prim work was where it's at now or even merged in 1.3 master
01:17brehautoh right
01:18foxupai'm trying to install clojure to work with emacs but when running M-x slime, I get an error: failed to download clojure jars.
01:18scottjfoxupa: use lein, run lein swank, run M-x slime-connect in emacs
01:19foxupahow do i run lein swank? (i'm sorta new to emacs)
01:19scottjfoxupa: do you have lein?
01:19foxupanope
01:19scottjhttps://github.com/technomancy/leiningen
01:21scottjfoxupa: so install lein, then lein plugin install swank-clojure "1.3.0-SNAPSHOT", then run lein new projectname ; cd projectname ; lein swank then go to emacs and M-x slime-connect
01:22amalloyscottj: isn't it just "lein install", ie no plugin? i think technomancy gave the same wrong instructions the other day then corrected himself
01:23scottjbtw if you just want to try out clojure eclipse may be better option, you'll also have to make sure you're NOT running latest slime
01:23scottjamalloy: not sure, always install manually was just going based on README, maybe outdated.
01:24foxupaok i got the git code but I can't get it to install with lein self-install (complains about not being able to download the jar file)
01:24scottjI'd guess install is for installing the current project in maven and plugin install is for installing it in lein's plugin dir
01:24amalloyand i use cake
01:25amalloybut you'ore right, it certainly seems like install must do what you say :P
01:25foxupai can't get lein to install... it complains that it can't find clojure.main
01:25foxupai already have clojure installed via aptitude from ubuntu
01:26scottjfoxupa: git code? did you clone? I don't think you need to
01:26scottjanother option is to just use inferior-lisp mode in emacs, what's your goal, to use clojure or slime?
01:27foxupause clojure
01:27foxupai guess i don't need anythign fancy, i just want to be able to work with clojure in emacs they way i work with scheme
01:28scottjwell, have you run clojure from command line?
01:28foxupayes
01:28scottj(setq inferior-lisp-program "whatevercommand you run") M-x inferior-lisp
01:28scottjmaybe
01:29scottjsorry if I'm leading you down a wrong path :)
01:30amalloyfoxupa: throw away the aptitude version of clojure, it could conceivably be getting in the way and certainly isn't helping
01:30scottjI would double check that you followed the lein install instructions correctly bc it is nice to have when using other clojure projects
01:31scottjor you could give cake a try
01:32foxupanm I think I will stick to my current setup
01:32amalloyfoxupa: you might find http://blog.raynes.me/?p=48 useful
01:32foxupai use eclipse with clojure plugin and then use emacs+
01:33foxupabut thanks for the help, and that blog seems liek a good rea
01:33foxuparead*
01:45seancorfield_am i a heretic for not liking emacs?
01:46amalloyseancorfield_: depends. how hard have you tried?
01:46slyrusyes
01:46slyrusyes
01:47seancorfield_i used it years and years ago - it was amazing back then... but it feels the same today and other options have advanced dramatically
01:47seancorfield_i think it was the mid-80's when i first used emacs
01:48scottjwell it's definitely not the same today as it was in mid 80s :)
01:49seancorfield_really scottj? how has it changed? seriously... i installed it recently and it felt just the same as it did 25 years ago
01:49amalloyseancorfield_: i wrote a blog post about this too, since you were bugging me to blog
01:49dnolenseancorfield: one of the main reasons I still use it now is that it supports developing in many different programming languages *very* well: SML, Prolog, Haskell, Racket. Can't say that about many text editors.
01:50amalloyhttp://hubpages.com/hub/Why-old-text-editors-are-still-great
01:50scottjseancorfield_: well the basic idea is still the same, but most of the popular packages did not exist back then: magit, slime, ido, tramp, hippie, anything, org, etags, anything-complete
01:50seancorfield_dnolen: that's as maybe but other language support is actually irrelevant :)
01:51dnolenseancorfield_: it's certainly makes it easier to work through Rich Hickey's bookshelf.
01:51seancorfield_:) ok
01:51dnolenwhich may or may not be irrelevant
01:52seancorfield_i guess i've gotten very used to eclipse now
01:52seancorfield_it supports every language i use and it feels more integrated
01:52amalloyseancorfield_: eclipse is fab for java
01:52seancorfield_it runs servers and understands the jee / jvm stack
01:52seancorfield_well, yeah, and so is clojure :)
01:52amalloyand rates about the same "tolerable" as emacs does for php
01:53amalloybut for lisps, emacs will always win
01:53rata_seancorfield: what do you have in eclipse that's not in emacs? (beside the general slowness of eclipse)
01:53seancorfield_i think that holds lisp languages back
01:53seancorfield_one of the biggest complaints i see about lisp is emacs
01:54seancorfield_if we want clojure to be accepted by the mainstream, it means embracing mainstream IDEs, regardless of what you think of them
01:54scottjrata_: well eclipse has a nicer debugging interface, and a more normal ui
01:54dnolenseancorfield_: I'm certainly not advocating that people use Emacs in order to learn Clojure.
01:54seancorfield_you won't get java devs to use emacs
01:54scottjclojure has always done a good job of embracing the big IDEs
01:55scottjI mean, clojure's eclipse plugin is arguably as good as scala's
01:55amalloyyeah, clojure has ccw, emacs, and textmate
01:55scottjin my experience better
01:55amalloywhat's not to like
01:55rata_scottj: but the more normal ui is very expensive to use (in terms of time)
01:55scottjand from like year 1 it supported netbeans
01:55seancorfield_my main project is a mix of three languages - which all run on the jvm
01:56seancorfield_the reality is that it's very, very hard to get people to switch IDEs
01:57rata_seancorfield: yes, but a clojure plugin is available in (almost?) any java IDE
01:57scottjclojure ppl generally aren't trying to, and for other lisps, it's probably important to recognize many of them predate the popular ides
01:58rata_intellij, netbeans and eclipse
01:58scottjand some of them have powerful ide's of their own
01:59seancorfield_i know, i'm just saying that pushing emacs is very off-putting for people outside the clojure/lisp community
01:59seancorfield_luckily we do have a solution for "every" IDE
01:59seancorfield_but the constant pushing of swank / emacs has a tendency to derail clojure newbies
02:00seancorfield_instead, we should focus on offering them clojure in whatever IDE they already use
02:00scottjI think most ppl agree with you on that and have structured the getting started pages accordingly
02:01rata_yes, I think so too
02:02scottjre eclipse v emacs, since I think that's a more interesting topic, intellisense or whatever it's called is cool and all, but does it even work with clojure code, like in the repl?
02:03scottj(. foo aTAB/ctrl-space/whatever-it-is)?
02:04seancorfield_scottj: im not sure that even matters? it's really about welcoming n00bs and saying sure, use your favorite IDE, rather than waxing lyrical about emacs / swank every time
02:05seancorfield_i guess i've just been reading too many essays about why lisp has never become really mainstream :(
02:05amalloyseancorfield_: of course it matters. if IDE features didn't matter, we'd all use notepad
02:05scottjseancorfield_: oh yeah, I'm not arguing that point, I'm interested in discussing your advanced alternatives
02:05seancorfield_amalloy: no, it's really about what ppl are used to
02:06scottjI wouldn't rate emacs very high on as a reason lisp didn't take off since emacs itself has taken off
02:06seancorfield_if someone uses notepad (really?) then they should be welcomed that they can use notepad to write clojure
02:06seancorfield_scottj: i never said they were advanced - i don't think eclipse is better than emacs (or vice versa)
02:07scottjother than ppl not writing blog posts about how awesome notepad+clojure is, I don't see how they aren't being welcomed
02:07seancorfield_it's just the attitude
02:07seancorfield_scottj: no, really, emacs has _not_ taken off
02:07seancorfield_i don't know anyone outside the lisp community who uses emacs
02:08dnolenseancorfield_: Scala, Haskell ?
02:08scottjthere are lots of ppl in here who use vim/eclipse, are they unwelcome?
02:08scottjseancorfield_: are you kidding me? I know tons of programmers/sysadmins/whatever outside lisp who use it
02:08scottjtons of scientists/math peeps
02:09seancorfield_that's not mainstream
02:09dnolenseancorfield_: Clojure is never going to be more popular then Java. Perhaps it can eventually get to Ruby levels of success.
02:09scottjon linux I'd say emacs is mainstream
02:10seancorfield_scottj: that may have been true five years ago... not now
02:10seancorfield_dnolen: you may be right but i'd _love_ to see clojure do more than that
02:13Adamantdnolen: now or in 5-10 years
02:14AdamantJava is on the way down
02:14seancorfield_Adamant: true, but other JVM languages will most likely fill that space...
02:15Adamantseancorfield_: like what? Scala and Clojure are the only real long-term contenders
02:16seancorfield_IF they are approachable
02:16Adamanteven the guy who wrote Groovy said he wouldn't do it again now that those two are out
02:16dnolenIt took Ruby and Python 15-20 years to get to where they are now. As awesome as Clojure is, these things take time. How many people out there even know what Functional Programming is,
02:16dnolenhttp://research.microsoft.com/apps/pubs/default.aspx?id=141506
02:16Adamantseancorfield_: true, but there's more or less a formula for that at this point
02:16dnolennovember 2010 ^
02:17seancorfield_i agree, but that doesn't mean folks will flock to scala/clojure... and frankly scala is way more approachable to java devs even tho' clojure is a MUCH better language IMO
02:18scottjwhat's cool about clojure is it has a very vibrant community/library despite having an insignificant market share. I suspect that will continue.
02:18seancorfield_ruby only got where it is because of rails... and python really doesn't stand alone... the applications drive that...
02:19seancorfield_scottj: i agree clojure has a great community but we have to be careful to avoid the lisp syndrome :)
02:20Adamantavoiding Lisp syndrome is good, modeling good behavior in other communities is even better
02:21Adamanteveryone trying to promote a new language should look at the way the Haskell community operates and behaves, IMO
02:21Adamantwhatever your opinion on Haskell the language
02:22scottjexplain how you think they operate
02:24Adamantavoid assuming negative intent from new contributors until proven otherwise. hit trolls with patient explanations instead of fury. be nice to all newbies, even their questions aren't the best. have room for a very broad spectrum in the community. tinker with how the community works now and then.
02:26Adamanthave a social expectation of reasonable behavior from everyone involved, from top to bottom, mod/compiler hacker to noob, and stick with it.
02:29rata_Adamant: I think the clojure community does a very good job regarding that as well, with some few exceptions
02:29Adamantrata_: yes, I certainly wouldn't accuse the Clojure community of being bad at any of those
02:29AdamantI probably wouldn't be here if it was
02:30rata_me too
02:31rata_I started (in lisp) with CL but run away from the language mainly because of the community
02:31seancorfield_i think the clojure community is way more welcoming than the haskell community (and i like haskell)
02:31AdamantI use Haskell as an example because they seemed to be doing it very early on, have done it consistently well, and it's made a huge impact in their long-term viability
02:31seancorfield_the first real community i got involved with was the c++ community
02:31Adamantseancorfield_: possible. I like Haskell too but they aren't perfect, none of us are.
02:31seancorfield_haskell is relatively new
02:31seancorfield_:)
02:31Adamantwell, early 1990's
02:32Adamantbut the language was reborn with monads
02:32Adamantthat was 2000-sh
02:32Adamant*ish
02:32seancorfield_my first exposure to FP was back in the early/mid 80's
02:32Adamantah, what language
02:33Adamantmine was SICP
02:33seancorfield_sasl and miranda were 'hot' then... i created SURE as part of my research work... prof turner (miranda) later said he wished i'd written it up :)
02:33Adamantnice!
02:34Adamantnever heard of SURE, will need to look it up
02:34seancorfield_i built a lispkit interpreter based on henderson's book, and then built SURE on top of that
02:34seancorfield_my university used it as their teaching language for five or so years
02:36rata_amalloy: may I come back to the combinatorics topic? there are some things I didn't understand
02:46dnolenheh, https://docs.google.com/present/view?id=0AS8emH3-FLt3ZGRtbWJyOGdfMTFmcDZkcTk2cw&hl=en
02:46dnolennice to see we're not the only one that struggle to optimize our code. many of the same issues.
02:46dnolenfrom the Northeast Scala Conf
02:52brehautthere are some amazing gotchas in there
03:04Null-ADoes clojure support lazy strings?
03:04Null-AI have a lazy seq of chars, and I want to pass it to re-seq, as a string, to get a new lazy seq
03:09chouserNull-A: If you implement CharSequence on top of that lazy seq of chars, you may be able to get what you want.
03:10Null-Achouser: hm i'll take a look
03:12chouserthe Java regex stuff works on CharSequence, iirc, which is an interface you can implement using reify
03:12Null-Achouser: *nods* testing now :)
03:12Null-Athis seems like something that should be in clojure api
03:15chouserlooks like you'll have to lie about the length in order to avoid realizing the entire lazy seq up front
03:15Null-Achouser: yah I was just thinking about that
03:16Null-Ainfinite it is :-/
03:17Null-Achouser: I bought your book btw, a couple months ago
03:17Null-Ai'm friends with nathan marz
03:18chouserNull-A: thanks! Excellent fellow, that Marz.
03:18Null-A:) he's having a workshop this saturday
03:18Null-Aon cascalog
03:21chouserwell, this seems to work as long as your input sequence really is infinite
03:21chouser(defn charseq [s] (reify java.lang.CharSequence (charAt [_ i] (or (first (drop i s)) \0)) (length [_] Integer/MAX_VALUE) (subSequence [_ a b] (charseq (take (- b a) (drop a s)))) (toString [_] (apply str s))))
03:22chouserbut something gets messed up if you walk past the end of a non-inf seq
03:22chouserand I should go to bed rather than figure it out. So, good luck!
03:28Null-Ak thanks
03:28Null-AI tried coding something but got classcast exception, i'll try yours
04:38Null-Achouser: re-seq 's implementation is O(F(charsequenc.length)) :( When you run it on the charseq CPU goes to 100%
04:39Null-Achouser: My re-seq was just tokenizing, so I reimplemented it with partition-by
05:32chris780Hi, I'm pretty new to clojure and I'm having a problem with Leiningen, is this an OK place to ask for a little help :)
05:33raekchris780: go ahead :)
05:35chris780Excellent, thanks. I'm trying to initialise a project with appengine-magic. I've used lein new to create the structure and added [appengine-magic "0.3.3"] to the dependencies, when I use lein deps it doenloads them. However, despite downloading them and putting them in the classpath, it doesn't see the new lein tasks provided. Is there something I can do to get more debug out of this or is there anything else I need to do?
05:37midschris780: did you add them to :dev-dependencies?
05:37chris780ah, no, only to my :dependencies
05:38chris780now I see my mistake
05:38chris780thanks a lot!
05:39chris780brilliant that worked. Silly noob, arn't I :)
09:14midswhat pattern do you use to name your test functions?
10:24gfrlog,(take 5 (repeatedly (partial swap! (atom 0) inc)))
10:24clojurebot(1 2 3 4 5)
10:25gfrlogso if I find myself wanting to call (send) but then also block until the function is finished executing, that means I'm probably doing something wrong, right?
10:28gfrlogit all started when I was using side effects inside swap!...
10:37schaf__can someone point me to a download link for the emacs refcard?
10:37pdkgfrlog you may want to consider iterate in that case as well
10:37schaf__its metioned here, http://www.gnu.org/software/emacs/ but i'd like topost a direct link
10:37pdk,(take 5 (iterate inc 0))
10:37clojurebot(0 1 2 3 4)
10:38gfrlogpdk: I agree. I was just trying to be clever actually.
10:38gfrlogIn my code the (partial swap! (atom 0) inc) part came in quite handy
10:38pdklast time i posted a code sample with an atom and doseq in it here
10:38pdkamalloy beat me with a switch!
10:39TimMc,(defn foo [^Flibber e] 5)
10:39clojurebotDENIED
10:39TimMc^ Anyway, it's interesting that I can use nonexistent types for hinting (when you aren't dealing with a surly bot.)
10:41gfrlog,(let [foo (fn [^Flibber e] 5)] (foo "tomas"))
10:41clojurebot5
10:41gfrlogTimMc: it just won't let you def stuff
10:41TimMc,(let [foo (fn [^Flibber e] (.nothing 5))] (foo "tomas"))
10:42clojurebotjava.lang.IllegalArgumentException: No matching field found: nothing for class java.lang.Integer
10:42TimMc,(let [foo (fn [^Flibber e] (.nothing e))] (foo "tomas"))
10:42clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: Flibber
10:42gfrlogah ha
10:42TimMcIt's only when you try to call methods on a bad hint that it yells at you.
10:42gfrlog,(let [foo (fn [^Flibber e] (.substring e 2))] (foo "tomas"))
10:42clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: Flibber
10:42gfrlog,(.substring "tomas" 2)
10:43clojurebot"mas"
10:43gfrlogeven if the method exists on the real object
10:44TimMcI ran into this in my own code. I had an empty (pending) function that had the hint ^MouseMoveEvent in its argument list, and I only noticed today that there is no such class.
10:44gfrlognot yet
10:46TimMcheh
10:48gfrlog,(let [MouseMoveEvent String, foo (fn [^MouseMoveEvent e] (.substring e 2))] (foo "tomas"))
10:48clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: MouseMoveEvent
10:48gfrlogdang
10:48gfrlogI wonder if Ruby lets you do that
10:48TimMcNo such luck.
10:48raekyou can turn (set! *warn-on-reflection* true) if you want the compiler to notify you when it can't resolve the method call to a direct one (and would need a type hint to do so).
10:48TimMcYou're stuck with the existing classnames.
10:49TimMcraek: In this case, it's not even trying to resolve a classname.
10:50TimMcI wouldn't call it a bug, just... surprising.
10:50gfrlog,(let [rich-hickey clojure.core] (rich-hickey/+))
10:50clojurebotjava.lang.ClassNotFoundException: clojure.core
10:50TimMcheh
10:51raek(my idea was that you can use *warn-on-reflection* to tell when the compiler actually needs the type hints)
10:51gfrlogdoes clojure gain anything by abstracting null to nil? Is there any abstraction or is it just a renaming?
10:52raekit's just a renaming
10:52gfrlograek: any idea what the thought process is there? seems needlessly confusing
10:53gfrlogmaybe he didn't want to imply the JVM implementation...
10:55luciangfrlog: nil is more lispy
10:55gfrloglucian: I can accept that.
10:55lucianit's also one letter shorter
10:56gfrlogI wonder how many keystrokes it has saved me
10:56lucianalthough looking at first and last (which btw i love), i don't think it was a major concern
10:56raekgfrlog: I would suspect that it's a traditional name (but does Scheme use null for this?)
10:56gfrlogfirst and last like the functions?
10:56gfrlog,(doc second)
10:56clojurebot"([x]); Same as (first (next x))"
10:57gfrlog,(doc second-to-last)
10:57clojurebotHuh?
10:57gfrlogoh well
10:57pdkyou could do (last (drop n x))
10:57pdksay (last (drop 1 x)) = (second-to-last x)
10:58pdk(doc drop-last)
10:58clojurebot"([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"
10:58pdkcorrection
10:58pdk(last (drop-last 1 x))
10:58pdkor skip the 1 and just use x as an argument
10:58lucianraek: scheme has no null in the same sense as java. it has '()
10:59gfrlog,(= nil '())
10:59clojurebotfalse
10:59gfrlog,(vector nil '() false [] #{} {})
10:59clojurebot[nil () false [] #{} {}]
10:59gfrlogso much nothingness
10:59gfrlog,(vector nil '() false [] #{} {} "")
10:59clojurebot[nil () false [] #{} {} ""]
11:00pdk(map true? [nil '() false [] #{} {}])
11:00pdk,(map true? [nil '() false [] #{} {}])
11:00clojurebot(false false false false false false)
11:00gfrlog,(keyword "")
11:00clojurebot:
11:00gfrlog,(symbol "")
11:00pdkalso note you don't need to quote a list with nothing in it
11:00gfrlogpdk: fascinating
11:00pdkso () and '() behave the same
11:00gfrlogdid clojurebot just break on the empty symbol?
11:00pdkand just return themselves
11:01gfrlog,(println "I'm still here")
11:01clojurebotI'm still here
11:01pdkit sandboxes stuff each time you send a code line i think
11:01gfrlog,(str "Happy" (symbol "") "okay")
11:01clojurebot"Happyokay"
11:01gfrlog,(class (symbol ""))
11:01clojurebotclojure.lang.Symbol
11:01gfrlog,(vector nil '() false [] #{} {} "" (keyword "") (symbol ""))
11:01clojurebot[nil () false [] #{} {} "" : ]
11:02pdktrying (symbol "") in a local repl just prints a blank line
11:02gfrlogso there's an empty symbol at the end of that vector, it's just really skinny
11:02pdkso it probably said nothing since the response line was empty
11:02gfrlogrig7ht
11:02gfrlogright*
11:02gfrlog,(println "")
11:02gfrloginteresting
11:03gfrlog,(fn [])
11:03clojurebot#<sandbox$eval1527$fn__1528 sandbox$eval1527$fn__1528@1303a7a>
11:04pdkit never prints out the code of a fn or whatever literally unless you ask, just a reference to it and its internal symbol
11:04gfrlogyeah
11:05gfrlogdoes a function carry its source code in the metadata or something?
11:05raekno
11:06pdkif i recall cl at least has a macro to print the code to a given function
11:06pdkdunno about clojure
11:06pdkclojure does have macroexpand and macroexpand-1 at any rate
11:06raekbut a var does contain metadata for source file and line number
11:06gfrlogI wrote a persistent memoization function once. Used a macro to extract the name of the function, but had to clear the database manually whenever I changed the code
11:07gfrlogcould have also examined the src with the macro I suppose
11:07gfrlogthen use that in the database
11:07pdkclojure has a macro out of the box to memoize a fn
11:07gfrlogyou just mean (memoize), right?
11:07gfrlog,(doc memoize)
11:07pdkp much
11:07clojurebot"([f]); Returns a memoized version of a referentially transparent function. The memoized version of the function keeps a cache of the mapping from arguments to results and, when calls with the same a...
11:07pdkthere's also defn-memo somewhere in contrib
11:07gfrlogI wanted persistence
11:07pdkgranted
11:08gfrlogso I did (defmacro defn-memoized...)
11:08raekfunction objects do not have names, but vars do
11:08gfrlogright
11:14TimMcSo (some f xs) will get me the first true output of f... what if I want the first input for which f returns true?
11:14TimMcAch, first filter
11:20gfrlogwhat was I going to ask?
11:20gfrlogoh right
11:20gfrlog,(doc update-in)
11:20clojurebot"([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new...
11:20gfrlogis there a function that does this but for just one level?
11:20gfrlog(defn update [m k f & args] (update-in m [k] f & args))
11:20gfrloglike that
11:21gfrlogsexpbot: help
11:21sexpbotYou're going to need to tell me what you want help with.
11:22gfrlogsexpbot: what can you do?
11:22sexpbotIt's AWWWW RIGHT!
11:22gfrlogsexpbot: help commands
11:22sexpbotgfrlog: http://github.com/Raynes/sexpbot/wiki/Commands
11:22gfrlogsexpbot: awesome thanks
11:28TimMcgfrlog: You don't like the extra set of square brackets?
11:29gfrlogTimMc nosir
11:29gfrlognor the extra hyphen, "i", and "n"
11:30TimMcheh
11:32TimMc(assoc m k (apply f args))?
11:34gfrlogTimMc: no I think you'd have to (assoc m k (apply f (m k) args))
11:34TimMcOh! Right.
11:34gfrlogwhich is more repetition than I'd like
11:35gfrlogI don't like specifying the map and key twice; so I'd use update-in first
11:35TimMcI guess you'll just have to def'ine it.
11:36gfrlogyeah; it's a hassle to maintain your own utils though.
11:36TimMcReally?
11:36gfrlogacross projects...
11:36TimMcah
11:36gfrloganother one I'm a fan of is map-from-fn
11:37TimMcHm?
11:37simardis it possible to have a (for..) that updates each variable at every iteration ? ie.. not a nested for
11:37gfrlog(fn [ks f] (into {} (map (juxt identity f) ks)))
11:38gfrlogsimard: do you have an example of what you're trying to do?
11:38TimMcsimard: loop?
11:38TimMcwait, nvm
11:39simardloop could do but I like the way for collects automatically elements
11:39raeksimard: making you own lazy sequence (the recursive call would "update" the variables)
11:39simardgfrlog: I want to access to elements of a grid diagonally
11:40simardso I made an (at-xy [x y g]) function
11:40TimMcsimard: You want to walk through multiple seqs at the same time?
11:40simardand now I want to return a diagonal
11:40raek(but this is equivalent to the loop approach mentioned by TimMc, modulo laziness)
11:40TimMc(for [[x y] (map vector (range ...) (range ...))] ...)
11:41TimMc(does that make sense?)
11:41simardnot quite yet hehe
11:41gfrlogthere's gotta be an easier way to do the diagonal thing
11:41simardwait yes it does..
11:41gfrlogsimard: this is a 2d vector?
11:41raeksimard: (for [i (range ..)] (at-xy i i g)) ?
11:41simardgfrlog: it's a 2d list
11:42gfrlograek's idea is what I was thinking of
11:42simardraek: that's what I'm doing, but actually instead of i i I need to calculate x and y from one of the two, say x
11:42raekor maybe (for [i (range ...)] (-> g (nth i) (nth i)))
11:42simardI wasn't clear enough
11:42simardI didn't mean only the main diagonal
11:43simardANY diagonal
11:43simardin any direction
11:43simardthat's why I need to do the for on two variables at the same time
11:43simardTimMc: your solution might well be what I want
11:44raekI'm thinking of something like (for [i (range ..), :let [[x y] (coord-fn i)]] (at-xy x y g))
11:44gfrlogI think you could use for with x and compute the y based on what diagonal you want
11:44simardgfrlog: I'm doing that already, but it's harder to understand
11:45raekwhere coord-fn is a function that returns a [x y] coordinate pair from an index
11:45simardie, understand what does on with the other coordinate by reading the code
11:45gfrlogI wonder if there's a way to define a function on pairs
11:45simards/does/goes/
11:45sexpbot<simard> ie, understand what goes on with the other coordinate by reading the code
11:45gfrloglike applying [inc dec] to [x y]
11:45simardgfrlog: that would be even neither
11:45simardneater
11:46gfrlog(defn diagonal-step [[f1 f2] [x y]] [(f1 x) (f2 y)])
11:46raekI think (for [[x y] (map vector (range ...) (range ...))] ...) is equivalent to (map (fn [[x y]] ...) (range ...) (range ...))
11:46gfrlogthen you could use iterate and take-while
11:47gfrlogas in (take-while coordinate-valid? (iterate (partial diagonal-step [inc dec]) [x y])))
11:48raekneat.
11:48gfrlogthx
11:49simardyou could even name is planar-step instead of diagonal now ;)
11:49simards/is/it/
11:49sexpbot<simard> you could even name it planar-step instead of diagonal now ;)
11:49simardhum I'm have a hard time with spelling today
11:49simardwow
11:49gfrlogsexpbot is amazing
11:49simardagain..
11:49gfrlogs/sexpbot/clojurebot/
11:49sexpbot<gfrlog> clojurebot is amazing
11:49gfrlogsexpbot: you said it
11:50TimMcCan I get = like in Java?
11:50TimMcI want actual object identity.
11:50gfrlog,(doc identical?)
11:50clojurebot"([x y]); Tests if 2 arguments are the same object"
11:50TimMcnice
11:50gfrlog,(identical? 8 (+ 4 4))
11:50clojurebottrue
11:50gfrlog,8M
11:50clojurebot8M
11:51gfrlog,(identical? 8M (+ 4M 4M))
11:51clojurebotfalse
11:51gfrlogcool
11:51gfrlogI feel like identical is a weird name for that...
11:51gfrlogthough it does sound etymologically like "identity" so maybe I'm just wrong
11:54gfrlogmaybe it's because of phrases like "identical twins"
12:06edoloughlinIs there a less expensive way of adding to the start of a vector than (vec (cons :a [1 2 3])) ?
12:10raekedoloughlin: no. do you happen to need to add at one end and remove from the other?
12:12gfrlogfinger trees?
12:13edoloughlinraek: No, just add to the start.
12:13edoloughlinraek: Thanks.
12:15gfrlogedoloughlin: maybe assemble it backwards or use lists instead?
12:15gfrlogdepends on what you have to do with it...
12:15edoloughlingfrlog: Backwards. That's an idea!
12:28simardif I need a function to have access to a local variable of the caller without passing it explicitly as an argument, my best bet is using letfn ?
12:28simard(ie, do a closure ?)
12:32khaliGi called filter on a map and wound up with a sequence of [key val] vectors. Whats the best way to turn this back into a map?
12:36ChousukekhaliG: (into {} yourseq)
12:37khaliGchouser, pretty. thanks!
12:39raeksimard: yes. a function of some kind (anonymous, let'ed, partial application) is fine
12:40khaliGincidentally is my use of filter as good as it can be, (filter (fn [[k v]] v) map) for non-nils?
12:40Chousukesimard: the function won't have access to any locals in the caller's scope unless the function was also generated in the caller's scope though.
12:41ChousukekhaliG: use val instead
12:41Chousukeie. (filter val ...) :P
12:41khaliGlets see
12:41Chousukeyour function basically does that
12:41khaliGthat's magic
12:43simardChousuke: so that means there's no way to write the body of that function outside the called, ie.: I think it would be cleaner (ie more readable) if that body was elsewhere)
12:44simards/called/caller/
12:44sexpbot<simard> Chousuke: so that means there's no way to write the body of that function outside the caller, ie.: I think it would be cleaner (ie more readable) if that body was elsewhere)
12:44Chousukesimard: the you'll need to pass the things as a parameter
12:44bmhIs there an efficient way to partition matrices in incanter?
12:44Chousukesimard: you can of course make a function that makes a function and then just do (let [whatever (make-fn thething)] (whatev
12:45Chousukeer, oops
12:45Chousukepressed enter by accident but you get the idea
12:45simardyeah, so passing the argument only at function creation..
12:45khaliGhow does val do the same thing, (val [:b 2]) is invalid :/
12:45simardmakes sense !
12:46ChousukekhaliG: val works on map entries
12:46ChousukekhaliG: which is what you have when you filter a map
12:46Chousukethey just happen to look like vectors :)
12:46khaliGoh wow, i see
12:46khaliGso much to learn
12:46khaliG:)
12:46Chousukesecond works too
12:47Chousukeon both vectors and map entries
12:47khaliGok i use filter another place, same thing except its (not v), can val be used here too?
12:47Chousukeyou can use (complement val) I guess
12:48Chousukeor remove instead of filter.
12:48khaliGoh yea, remove makes sense
12:48Chousukechoices, choices...
12:49khaliGactually i see a better way to write both, using group-by and val
13:33simardI want to do (f '((1 2 3) (4 5 6))) -> (1 2 3 4 5 6), what function should I use ?
13:34simardhum apply concat
13:34ejacksonsimard: or flatten
13:42khaliGugh, sometimes i really miss mutation :(
13:43khaliGive managed to avoid it by rebinding the same var inside sometimes etc, but now i really need it, i think
13:49dnolenNotes on Continuation-Passing Style in Clojure, http://dosync.posterous.com/continuation-passing-style-in-clojure
13:50khaliGthis might be a stupid question, but can you write inline java code somehow?
13:53TimMckhaliG: Why would you want to?
13:53TimMcI find Clojure to be the best way to write Java, personally.
13:54TimMcAnyway, you can always write some .java files and talk with them from Clojure.
13:54khaliGTimMc, because i cant write this purely functionally, i have six variables that i need to reason with and assign the correct value
13:55TimMcWell, you *can* still use mutation -- use (do ...) and the -> and .. macros liberally.
13:55TimMcThat seems to work just fine for mutation-oriented computation.
13:56khaliGhm is there a place i can read an example? sorry i'm lost :/
13:58TimMckhaliG: Here is a very small example of using Java GUI libs: https://github.com/timmc/CS4300-HW3/blob/master/src/timmcHW3/gui.clj#L90
14:00TimMcIs there an idiom for replacing or updating the last element of a vector?
14:01TimMcnvm, I need to do more than that.
14:02khaliGTimMc, i guess i'm looking for a SET! method
14:02TimMcThere are refs.
14:02khaliGi dont see how do or -> helps that need
14:02TimMcAre you trying to mutate Java objects or modify Clojure variables?
14:02khaliGclojure ones
14:03TimMchttp://clojure.org/refs or maybe atoms.
14:03scottjor often a big let with "reassignment" is used
14:05TimMcOh yeah, I've used that too.
14:05khaliGyea same, but its limited
14:05scottjkhaliG: but there's nothign wrong with writing part of your app in java
14:06scottjyou write it in a separate java class file and then put it where your build tool expects it
14:07khaliGwe're talking about a single function here though :/
14:07TimMckhaliG: Can you give more info about what you are writing?
14:07khaliGTimMc, let me write it up and paste, one minute please
14:09TimMcAs for my own problem... I have a vector of vectors, and I want to add a value to the last inner vector. If the outer vector is empty, I want to make a new inner one to conj onto the end.
14:09TimMcOne approach I was going to take was to do a combo of peek and pop, alter the peek'd value, and conj it back on to the result of pop.
14:10TimMcThe problem with this approach is that pop throws an exception with the empty vector instead of returning nil or something.
14:10TimMcSo, any suggestions?
14:11scottjthere's only two levels of vectors right?
14:12khaliGhttp://clojure.pastebin.com/mrzLLDMT
14:12TimMcscottj: Right.
14:13TimMcI could write (defn pop-lax [v] (if (seq v) (pop v) [])) but was wondering about alternatives.
14:15tomojhow do new inner vectors get there after the first?
14:16simardis it possible to do something like that ? (let [fibs (lazy-cat [1 2] (map + fibs (rest fibs)))])
14:16simardie.. define fibs only for the scope of the let
14:19ihodessimard: look at let-fn
14:19ihodesmake that letfn
14:19TimMctomoj: Here's what I have written: https://gist.github.com/835284
14:20ihodessimard: equivalently, you could (let [my-fn (fn [x] x)] body)
14:20TimMcEach call to append-vertex! should add a point to the last inner vector, or if the outer vector is empty, conj on a new inner vector just containing the new point.
14:21scottjihodes: I think he's wondering if there are issues with lazy seqs getting gced
14:22ihodesscottj: just noticed he wrote fibs and not fns, sigh. haha
14:22tomojTimMc: ok, but how do you ever have more than one inner vector? just curious
14:22simardscottj: yes, that's indeed the initial reason why I'm trying a let, but the problem right now is not being able to reference fibs from within the definition of fibs :S
14:22ihodessimard: in that case, yes, that works. but letfn will solve the reference issues :)
14:22TimMctomoj: Repeated calls to append-vertex!.
14:23simardihodes: thanks :)
14:23tomojbut if append-vertex! always conjs to the last inner vector..
14:23tomojwon't it create the one inner vector and then just conj onto it forever?
14:23ihodessimard: sorry, i'm being confusing. what i said with letfn should solve your issue *goes off to not talk anymore*
14:23TimMcOh! Sorry. There are other functions for that.
14:24TimMcOr rather, will be.
14:25tomoj"userdata" seems like a strange name to me
14:26TimMctomoj: I have a several global refs, one of which contains the user's data -- the values of that ref get shoved into undo and redo buffers.
14:27TimMcProgram state and view state are kept in other data structures.
15:12markskilbeckHow can I get the index at which an element appears in a collection?
15:15Scriptormarkskilbeck: check out http://groups.google.com/group/clojure/browse_thread/thread/3f23f91ed6eb57c5
15:16stuartsierramarkskilbeck: `map-indexed` and `some`
15:16Scriptordoesn't `some` only return true/nil?
15:17DespiteItAllsome returns the value found
15:17markskilbeck,(doc some)
15:17clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence,...
15:18Scriptorit seems to just reutrn the result of the predicate call
15:19markskilbeckHm, yeah
15:19khaliGerm, contains? always returns false on a list? :s
15:20brehautkhaliG: contains? tells you if a given key exists in a collection
15:20brehautlists arent keyed
15:20brehautand vectors are keyed by their index
15:20brehaut,(contains? [:a :b :c] 1)
15:20clojurebottrue
15:20brehaut,(contains? [:a :b :c] :a)
15:20khaliGthat's pretty useless :/
15:20clojurebotfalse
15:21brehautkhaliG: no, its just not the function you are looking for
15:22khaliGthere isn't such a function is there? i've read .contains might work
15:22brehaut,(.contains [:a :b :c] :a)
15:22clojurebottrue
15:22markskilbeckstuartsierra: not quite sure how that would look.
15:23brehautkhaliG: if you are used to other dynamic languages, clojure might seem a bit weird because its core functions are much more precise in their meaning ussually
15:23khaliGbrehaut, just the names are counterintuitive
15:24Patrick-DCWhich library do you guys think is the best for building GUIs in Clojure?
15:24brehautkhaliG: the doc functions is always close by ;)
15:24khaliGPatrick-DC, i'm using mig-layout and swing, works pretty good
15:25Patrick-DCThanks!
15:25Patrick-DCHow do the windows look?
15:25Patrick-DCLike, you know how Tk looks awful in Gnome?
15:26Patrick-DCBut GTK+ looks awesome
15:26stuartsierramarkskilbeck: (some identity (map-indexed (fn [i x] (when (pred x) i)) the-sequence))
15:26khaliGPatrick-DC, they look ok, depending on the look-and-feel, you can choose one you like.
15:26Patrick-DCWhile Tk looks okay in Windows
15:26Patrick-DCSweet
15:26brehautPatrick-DC: swing does have a native gtk look and feel
15:27Patrick-DCAwesome, thank you very much for your advice
15:27Patrick-DCIs it easy to tune the look and feel for different platforms?
15:27khaliGyep, check out nimbus which looks nice on windows and linux
15:27brehautPatrick-DC: it defaults to platform native
15:28Patrick-DCThanks brehaut
15:28brehautPatrick-DC: like all cross platform toolkits you have your work cut out actually making it look good on all the platforms
15:28brehaut(one platform is easy)
15:28Patrick-DChaha
15:28khaliGwhy would you want it to look good? motif all the way!
15:28Patrick-DC(haha '(one platform is easy))
15:29Patrick-DC(? (look-good (in (motif) (windows))))
15:30khaliGit looks like motif, i wouldn't say good, but i like it
15:30khaliGif you're into that retro look :)
15:31Patrick-DCwhich (motif or swing) would you surmise has better facilities for alpha compositing?
15:31Patrick-DCLike transparency of layered windows and stuff
15:31khaliGno you misunderstood, motif is one particular look and feel that is available, that's all
15:32Patrick-DCahh, okay
15:32Patrick-DCso can it do compiz, too?
15:33brehautPatrick-DC: i dont know what it looks like in linux but https://github.com/mattdw/space-clock
15:35brehautalthough i notice that it has no project stuff at all. it might be a clj 1.0 project
15:36Patrick-DCi'm using using ubuntu with gnome and compiz, and the clock is awesome except it has no window border
15:36Patrick-DCsorta minimalistic
15:36brehautok i thought it might have had a window border
15:36brehautas a bug in linux
15:37brehautPatrick-DC: its really old code; dont use it as a guide! but it shows you that you can easily do compoisited stuff in linux with swing
15:37Patrick-DChaha thanks! how can you compile the clock to an applet and make it run in a browser?
15:37brehauti have no idea
15:38Patrick-DCI just started learning clojure, but I've been learning common lisp for a few months
15:38Patrick-DChmmmm, I'm going to find out how
15:58rata_hi
16:09khaliGhttp://clojure.pastebin.com/wwpArn6K
16:09khaliGif someone can see how to write this functionally please give me a hint
16:13tomojI think you're probably going to have to do a better job than your code at explaining what you're doing
16:14rata_how do you divide a j.m.BigInteger?
16:15khaliGtomoj, it would be much clearer in C or java :/
16:15boborata_: http://download.oracle.com/javase/1.5.0/docs/api/java/math/BigInteger.html#divide(java.math.BigInteger)
16:16rata_khaliG: what are you trying to do?
16:16rata_that code seems like you're trying to write C in clojure
16:16khaliGi'm trying to solve for an unknown value
16:17tomojkhaliG: that implementation would be much clearer, sure
16:17rata_khaliG: you're trying to solve what?
16:18tomojyour code still wouldn't say anything about what you're actually doing, I predict :)
16:20khaliGi start with a map of values, solve the unknowns (nils) using the knowns, and then return a map with the unknowns filled in, if possible
16:20rata_khaliG: how do you compute the unknowns?
16:20khaliGi have an equation
16:21khaliGarithmetic one, its very simple
16:21khaliGsee the paste before that (column on the left side of the page)
16:22khaliGyes it took me 2 hours to do this.. would have taken 2 minutes in a non-functional language :/
16:23rata_bobo: .divide returns a BigInteger, which is not exact... also I don't know if the number I want to divide is a BigInteger or not, so I'd have to put an (if (instance? ...) ...) there, which seems a bit dirty
16:23bobooh :-/
16:26rata_khaliG: why do you have those numbers in a map instead of a vector?
16:27khaliGrata_, no particular reason, just what i'm used to
16:27rata_ok
16:27khaliGbut that might help, i guess?
16:35TimMckhaliG: I think I see what to do...
16:36khaliGTimMc, lets hear it
16:36TimMcLet me get a better picture of what this function does.
16:36khaliGsure thing
16:36TimMcEach if statement is checking if certain keys are set
16:37rata_khaliG: http://clojure.pastebin.com/WxrEi1fR
16:37TimMcand then if so, computing the value for a dependent key.
16:37khaliGrata_, ooh, damn, that is good
16:38khaliGTimMc, see rata's paste, its much clearer
16:38TimMcAh! It is an over-specified set of values.
16:39khaliGnot quite because this will fail if at least 2 are not knowns
16:39khaliGyou'd have to catch that somehow
16:39TimMcYou can e.g. compute the value of any of A B or C if the other 2 are known.
16:39khaliGcorrect
16:39rata_khaliG: I supposed there are not two unknows for each formula
16:40khaliGrata_, fair enough, im getting these values from user input so they might not have provided them
16:40rata_mmmm... that doesn't make sense
16:40tomojso it's an equation solver?
16:40khaliGtomoj, yep
16:41rata_how do you compute two unknows from one known?
16:41rata_I used the info in the comments
16:41khaliGyou dont, you just dont do anything
16:41rata_ah ok
16:42TimMckhaliG: Wrap the cond in a check to see if exactly one is nil, otherwise return all the values unchanged.
16:42rata_then (if (= (count (filter nil? [lbm bw bf])) 1) (I lbm bw bf) (do-nothing))
16:42khaliGthat makes sense
16:42rata_probably (do-nothing) is [lbm bw bf]
16:43rata_khaliG: but please, for something that doesn't require mutability, don't use mutability
16:44khaliGrata_, i totally agree, i just couldnt see a way to do it without mutation
16:44khaliGbut now i can, that's much better
16:45rata_;)
16:45tomojwill the equations ever change?
16:45tomojis it safe to assume that each variable only appears once in an equation?
16:46khaliGthey wont change, and yes safe to assume so
16:46rata_even when there's probably a better way to write that, as I hardcoded the formula for each quantity... I imagine there's a way to do some symbolic computation from the original formula to get the other two formulae
16:46khaliGrata_, i would like that very much, would be nicer. i think you can do it in Qi using pattern matching, for example
16:47khaliG(but i haven't tried, and dont know the language just know it has that facility)
16:50rata_khaliG: I don't see how pattern matching would do it
16:50khaliGnot just pattern matching, i think it does unification too
16:50khaliGbut i'm not 100% sure on it
16:52pdkneeds more prolog semantics
17:04joshua__Is Clojure going to be participating in the Google Summer of Code?
17:17Dranikhi all
17:18Dranikhow to test whether the item is a kind of list/sequence or just a single value?
17:18gregh,(list? '(1))
17:19clojurebottrue
17:19Dranik,(list? 1)
17:19clojurebotfalse
17:19Dranikgregh, thanks!
17:20rata_Dranik: seq? is for sequences
17:29dsantiagoWhat does an InvocationTargetException mean? I'm getting one from like 30 lines deeper than my code and I'm not sure what I should be looking for.
17:38greghsee http://download.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/InvocationTargetException.html - it's an exception that wraps another exception, so look for an exception thrown by whatever you're trying to call
17:46CozeyHello. I try to use multimethods to write some db-specific code. To do this I have specific.clj with defmultis, and postgresql.clj, etc with defmethods. from postgresql.clj et al. i :use 'specific' namespace. Then I'd like to be able to 'use' or 'require' these methods from other namespaces. how should i ccomplish this?
17:47Cozeyif I (require 'specific), will the defmthods in 'postgresql namespace be loaded and available?
17:47Cozeyif I try to require all of the depenencies, i get some AssertionError in reload.clj
18:32dsantiagoThanks gregh
19:10CozeyGood morning
19:11CozeyCan one spread multimethods between different namespaces, like here: https://gist.github.com/835525 ?
19:12guille_hi
19:13guille_which slime version is appropiate to use swank? I can't get it to work with HEAD, do I need a patched one?
19:14scottjguille_: 605f930
19:15guille_scottj: is that rev from the repo at common-lisp.net or boinkor.net?
19:16scottjguille_: url = http://github.com/technomancy/slime.git
19:17guille_ok, thanks
19:17kencauseyguille_: recommended: http://groups.google.com/group/clojure/browse_thread/thread/c178bed30fd9d704/7d2aa20a38ad18a1?lnk=gst&amp;q=new+installation#7d2aa20a38ad18a1
19:17dnolenCozey: yes, but you need to get rid of your circular dependency.
19:18Cozeydnolen: Ok, say I remove (:require a) from m.clj
19:18Cozeybut then a.clj's defmethods will not be loaded into scope and hence will not work
19:18guille_those of you using CL too, how do you deal with the different versions of slime when you're using both environments?
19:19scottjguille_: I use the same version of slime with cl and clj
19:20dnolenCozey: it will not work in m.clj no. But why is that an issue?
19:21Cozeywell I'd have to write (use 'm 'a)
19:21Cozeyand if I add another implementation file b.clj (with defmethods for :b) I'll have to change it to
19:21Cozey(use 'm 'a 'b) in all files which use them
19:22dnolenCozey: such is life. sorting out circular dependencies is much much worse that such little inconveniences.
19:22Cozey;-))
19:22Cozeythis is a kind of a zen answer ya know
19:23guille_nice. g'night
19:23dnolenCozey: my experience with circular deps in C and Python has been horrible enough to be happy with Clojure's behavior.
19:24CozeyI know what You mean, but I'm not sure if I get the usefulness of multimethods, if you must keep them in one namespace
19:24dnolenCozey: you do not need to keep them in one name space.
19:24Cozey(or more, but still you have to enumerate them when requiring, so it's the same)
19:25Cozeybut perhaps the kind of dynamism I'm thinking of would destroy the functional nature of clojure..
19:27scottjwhat if you use defmethod m/foo ?
19:28dnolenCozey: adding a few here and there seems fairly common - print-method for example.
19:30Cozeybut still I need to require the adding namespaces before using my print extension
19:30Cozeywhat if I did a defmethod in an in-ns of namespace which holds the demultis?
19:35dnolenCozey: of course you need to add the namespace. multimethods are functions. What you're talking about is action at a distance. require the namespace and get on with it I say :)
19:36CozeyOk, You persuaded me! Now I need to figure out how to run cake with (use :verbose)
19:36Cozeyso I can figure out where this pesky cycle is (i guess i created another one while trying to solve this)
19:56simardcould someone explain me how this works, ie. it seems like seq is defined recursively with itself, is that correct ? (def seq (fn seq [coll] (. clojure.lang.RT (seq coll))))
20:18dnolensimard: defn isn't defined at that point, that's why it's defined that way.
20:19rata_dnolen: I think simard talks about the immediately recursive (seq coll)
20:21dnolenrata_: that's a method call.
20:21rata_then shouldn't it be (.seq coll)?
20:21dnolenrata_: it's calling the seq method on clojure.lang.RT
20:25rata_aha! I didn't know that way of calling a method http://clojure.org/java_interop#dot
21:58joshua__Anyone know whether or not Clojure is going to be a participating organization or used in Google Summer of Code? I'm thinking of applying.
21:59dnolenjoshua__: LispNYC is trying to be a GSoC org again, and they clearly seem interested in hearing Clojure projects.
22:02joshua__dnolen: Thanks, looking into that now.
22:12brehautjoshua__: find some area of rails, django etc that doesnt have a suitable equivlant in ring and build that?
22:12joshua__brehaut, good idea, I'll look into that.
22:13brehautjoshua__: start with the ring wiki, it'll give you a good idea of whats covered
22:14joshua__This one? https://github.com/mmcgrana/ring/wiki
22:14brehautthats the one
22:14brehauthttps://github.com/mmcgrana/ring/wiki/Libraries has a bunch of 3rd party features
22:15brehautyou could also ask on the ring-clojure mailing list
22:15dnolenjoshua__: last time LispNYC + GSoC came up, rhickey was hoping that someone would tackle either Datalog or Predicate Dispatch.
22:16joshua__Can you give me some links to read about either of those?
22:16joshua__Or both.
22:17dnolenhttp://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.37.6735
22:18dnolenhttp://people.cis.ksu.edu/~xou/formalmethodsnetworking/datalog.pdf
22:18dnolenthere's a Datalog in contrib, but I think it could a optimization pass or a different approach entirely.
22:19dnolenPredicate Dispatch could fall out of fast Datalog.
22:19dnolenjoshua__: might be useful to ask on the dev list for ideas as well if you're on that.
22:20joshua__dnolen, I'm not, but I suppose I should join it
22:20brehautjoshua__: have you signed a contributer agreement?
22:20joshua__No.
22:20brehautyou'll want to do that as well then
22:20joshua__I'm willing to though.
22:21joshua__Yea.
22:21brehauti dont think you can joing the dev ML unless you have
22:21brehautwhich reminds me i need to try to resubscribe now that my CA has been receieved
22:23qedAnyone have any thoughts on refactoring a function-map with a nested condp so that both can be updated via a ref or an atom? https://gist.github.com/835627
22:31joshua__dnolen: Looking at the datalog paper feels a little like looking at a brick wall. They are talking about mathematical systems I haven't actually heard of. Do you think I'd stand a chance of implementing it properly if I was persistent?
22:31brehautjoshua__: my experience with summer internships is that you can do a surprising amount that you would never have believed before you did it
22:33joshua__brehaut, Have you done a GSoC?
22:34brehautjoshua__: not a google one; i did an NZ government funded one for a small buisness
22:35joshua__brehaut, nice
22:38simardjoshua__: with proper supervision from a more experienced person, I agree with what brehaut said, it can be surprisingly productive
22:38simardif left on your own though it might feel as your are stuck sometimes, which you are :)
22:38joshua__Alright. I'm definitely willing to give it a shot.
22:38brehautthat being said, if you are very weak at logical stuff, then perhaps be careful of biting of datalog ;)
22:39joshua__I've never done anything in prolog or anything like that.
22:39simardjoshua__: this is what an intership is about hehe
22:39simardand don't you fall into that trap of always thinking "I never did that before"
22:39brehautjoshua__: ive never done anything in the domain of any of my day jobs before i started at those jobs either
22:40simardbrehaut: right on :)
22:40simardjoshua__: interships are also about building confidence
22:41joshua__Alright. I'm trying to find where Rich mentions his being interested in Datalog right now.
22:42joshua__I'll be reading through that paper in my free time at school trying to get a handle on this...
22:49joshua__Apparently one way I could go about this is by making a wrapper fir IRIS Reasoner.
22:53DespiteItAllIsn't there a way in leiningen dependencies to say you just want the newest version, whatever it is?
22:55qedI did GSoC for Plan9 (Inferno OS) in 2007
22:56joshua__dnolen, Are you sure that Rich isn't satisfied with the Datalog in contrib?
22:56qedIt was a little weird; my advisor (forgetting the terminology they use) was largely absent, didn't provide much in the way of guidance, etc.
22:57qedjoshua__: ive heard talk about leveraging datalog in clojure from several people who seemed to be familiar with something rich had been asking about or pondering w/r/t datalog
22:57qedi dont know if it's that he's not satisfied, per se
22:58qedid ask chouser about it if i were you
23:00joshua__qed: kk will do
23:14simardhow do I make a function that can be 'Indexed' ?
23:14simardI'd like a way to do (nth my-func 5).. not sure if that's a good idea in itself though :)
23:14simardwhere my-func is a function of n, as in a mathematical expression returning a number from its position
23:15simard(say, the triangle numbers sequence)
23:15spewnsimard: Why can't you do (my-func 5)?
23:16brehautsimard: perhaps explain why you want this indirect function calling operation?
23:17DespiteItAllmap the function to (range), then call nth, damn the performance
23:17simardI don't have a "good reason", really just that I'd like a mathematical sequence to feel as a sequence..
23:18simardor some kind of blurry vague reason :)
23:18brehautsimard: if you want to make it feel like a sequence, perhaps return a sequence?
23:18simardI'm unclear how to do that, because the sequence does not depend only on the last number in the sequence, but also on the position
23:19simardie it's not definable recursively, I think
23:19simardor is it
23:20simardoh well it appears it is: (def triangle-nums (map #(/ (* % (+ % 1)) 2) (iterate inc 1)))
23:29pdkwhen writing a multimethod do i have to actually add a case to catch and return :default in the dispatch fn
23:29pdkor is it implicit that any return value of the dispatch fn will be caught by a :default method if it isn't by any other of the defined methods
23:29brehautits implicit
23:30pdkokay
23:33spewnWhy does (def foo "bar" :baz) fail with "Too many arguments to def" on 1.2.0?
23:35brehautspewn: because in spite of what the docs say, def in 1.2 doesnt accept a doc string without meta
23:37spewnWhat about the code I saw in Compiler.java? Added after 1.2 was released?
23:37brehauti dont, but i guess so
23:38scottjwhat does :baz part of that def mean?
23:39brehautscottj: its just a value to bind foo too
23:40scottjoh I didn't realize "bar" was a docstring
23:41spewnbrehaut: It looks like the code for docstrings in def was written on April 14, 2010, but not committed to master until October 12, 2010, with 1.2 being released in August 2010.
23:41anthony__There isn't any inherent issue with using Clojure with Java 7, is there?
23:41anthony__I'm getting this error: Cannot cast java.nio.file.StandardWatchEventKind$StdWatchEventKind to [Ljava.nio.file.WatchEvent$Kind;
23:42anthony__But StandardWatchEventKind has: private static class StdWatchEventKind<T> implements WatchEvent.Kind<T>
23:42anthony__Am I missing something simple?
23:48ekoontzwhat emacs do people use with clojure
23:48ekoontzcarbon emacs is version 22
23:49ekoontzapparently you need 24?
23:49ekoontzper http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Emacs
23:49ekoontztrying https://github.com/technomancy/emacs-starter-kit
23:49brehautekoontz: i used technomancy's emacs starter kit
23:49ekoontzcool thx brehaut
23:50brehautand i used exactly the versions of things it suggested (and removed my cromulent .emacs config to make doubly certain)
23:50ekoontzcromulent lol
23:50brehautmay it embiggen your vocabulary
23:50ekoontzhehe
23:51anthony__Ignore my last question...it's because the Java method is variadic. ugh
23:55ekoontzbrehaut: what emacs do you use if i may ask?
23:55brehautekoontz: the one recommended by emacs-starter-kit
23:55TeXnomancyekoontz: 23 is recommended; http://emacsformacosx.com
23:55TeXnomancycarbon is pretty old
23:56ekoontzthanks TeXnomancy :)
23:56brehautyeah im using 23.2.1
23:56ekoontzi like the web site sticker : "no extras! no nonsense"
23:57brehautthat doesnt explain M-x butterfly
23:57simardwhat's the difference if any between (def triangles (concat [0] (map + triangles (iterate inc 1)))) and (def triangles (lazy-cat [0] (map + triangles (iterate inc 1))))
23:57simardthe lazy-cat doesn't seem necessary as (iterate) already makes it lazy, right ?