#clojure logs

2011-09-11

00:43michaelr525hello!
00:52mtbeedeewhat does it mean when a function has a - in front of it?
00:52mtbeedeelike (defn -main [] ...)
00:56michaelr525It's a prefix used when you pre-compile a class, I don't remember what it's use exactly but you can read about it here: http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html
01:00michaelr525mtbeedee: ^^^
01:30mtbeedeethanks
01:50jamiltronI'm trying to get penumbra to work. I've cloned the penumbra repo and have tried running the examples, but I am getting a java.lang.UnsatisfiedLinkError: org.lwjgl.DefaultSysImplementation.getPointerSize()I (slate.clj:9) error. Anyone have any experience with this?
01:53jamiltronI really have little working knowledge of java, but I've tried stuffing the lwjgl.jar in /usr/java/packages/lib/ext which is what shows up when I ran (System/getProperty "java.ext.dirs")
01:54Chousukeis it the correct architecture? sounds like JNI stuff
01:55jamiltronI am not sure. In the java/lib directory there's also a amd64 folder.
01:55jamiltronIt looks like it contains liblwjgl64.so stuff
01:58jamiltronSearching that error seems to have people talking about "natives" and making sure lwjgl.jar is added to the classpath, of which mine is.
02:01jrabbitwhats the simplest way to get the current time/date?
02:05jlijrabbit: (.getTime (java.util.Date.)) perhaps
02:05jlitime in milliseconds since epoch, I believe
02:08jrabbitah I guess i should check the java docs then
02:10jlijrabbit: actually, there's also the clj-time library
02:10jliit let's you say (now)
02:10jlilets*
02:10jlihttps://github.com/hgiddens/clj-time
02:10jrabbithm that mgiht be useful
02:14miwillhitehi - I'm pretty new to clojure and graph data structures…anyone know of any good resources for working with graphs in clojure?
02:15miwillhiteI have noticed that clojure.contrib has some graph functions, but its not clear to me exactly where to start
02:15wiseenis there a simple way to get a unique value that I can use as a map key ? something like new Object() that I can use as a token
02:16hiredmanjava.util.UUID
02:16jrabbitjli: date-clj seems to be a better fit but thanks!
02:16jrabbitway better than using the java stuff
02:17wiseenhiredman, isn't that overkill ? and I would like it to work on clojurescript... I just need a value that's unique - but since clojure checks equality of primitives not identity I'm stuck
02:18wiseenlike in python I could do a = object() b = object() c = {a: 1, b: 2}
02:19wiseenin clojure (let [a {} b {}] {a 1 b 2}) says duplicate key
02:19wiseenis there a "object" primitive
02:19hiredman,(Object.)
02:19clojurebot#<Object java.lang.Object@18a774d>
02:19hiredman,(Object.)
02:19clojurebot#<Object java.lang.Object@58c90f>
02:20wiseenoh ok, and for javascript/clojurescript as well ?
02:20hiredmanno idea
02:20wiseenk will figure out tnx
02:21jlimiwillhite: there's clojure.contrib.graph. I also heard of loom today https://github.com/jkk/loom
02:22miwillhitecool, I'll check it out thanks
03:28dark_srcjust setup slime / swank in emacs... cool stuff.
03:31dark_srcanyone knows how to select a bunch of lines in emacs and run it?
03:32dark_srci can exec one line cx ce but no luck with no luck with multiple lines
03:32hiredmanC-c C-c
03:33hiredmanwell run the toplevel form the cursor is in
03:33VinzentAlso C-c C-r for region
03:33hiredmanalthough C-x C-e should also run multiple lines
03:33dark_srcyeah i saw http://www.pchristensen.com/slimecommands.pdf
03:34dark_srchow can run something like (println "line 1") \n (println "line 2")
03:37VinzentC-SPC C-M-f C-M-f C-c C-r
03:38dark_srcVinzent: got it. Marked the region and c-c c-r thanks
03:38Vinzentnp
03:39dark_srcone more thing. there is any way to clear the slime output before execution
03:40dark_src?
03:41VinzentC-c C-o?
03:41dark_srcC-c C-o is undefined
03:42VinzentTry it in the repl buffer
03:46dark_srcVinzent: it doesn't work so well. it only clears the last few lines of output.
03:46Vinzentyep; C-c M-o for the whole buffer
03:48dark_srcVinzent: cool. thanks works! only that its little painful to toggle between the source and the repl everytime :(
03:49dark_srcin case you haven't guessed I am a emacs newbie and figuring things out myself.
03:49dark_srcVinzent: is there a way to bind the toggle and buffer clear to some key
03:51Vinzentdark_src, you can do something like (fset 'my-clear-repl [?\C-c ?\C-j ?\C-c ?\M-o ?\C-x ?\C-o]), and then bind 'my-clear-repl to the key of your choice
03:53dark_srclet me try it
03:58dark_srcVinzent: how does swank work. I need to start lein swank on the project and then connect to it
03:58dark_src?
03:59VinzentVinzent, yes, $ lein swank, then M-x slime-connect. With durendal you can do it with the single command: durendal-jack-in
04:01Vinzenthm, btw C-c C-j is probably non-standard binding
04:01dark_srcVinznet: how do ppl do this right now. I am sure there is a easier way
04:04VinzentYpu can bind durendal-jack-in to whatever key you want (e.g. I have it on the C-c o). What can be easier than hitting one keystroke? :)
04:52khaliGis there a normal lisp cond somewhere? I have more than one form and don't want to use (let [] ...)
04:54hiredmando
04:54khaliGheh
04:54khaliGthat's dumb :/
04:54hiredmando
04:54hiredmanhttp://clojure.org/special_forms#Special%20Forms--%28do%20exprs*%29
04:55khaliGno
04:57khaliGhey lets cripple cond in a way that makes it like a if .. great idea :o
05:12thorwilkhaliG: how do clojure an "normal lisp" cond differ?
05:12khaliGthorwil, one is useful the other one is broken
05:13thorwilthat's a non answer. i'm honestly wondering what the difference is
05:14khaliGthorwil, http://www.lispworks.com/documentation/HyperSpec/Body/m_cond.htm - basically you have an implicit do in the non-test form
05:15khaliGthorstadt, with the clojure one you have to put an explicit do or a let with an empty binding
05:16thorwilah, so with the clojure cond you save one pair of () if you need a single expression for a case, but at the cost of having to use do otherwise
05:16khaliGthorwil, yep. i have no idea why they made such a bizarre choice - i guess it makes for easier toy examples of cond but useless in practice
05:18thorwilwell, it reduces the behavior to the minimum, avoiding am implicit do. you call it broken, i think i will call it clean :)
05:18khaliGit isn't clean though because for any nontrivial use of code you have more clutter!
05:18khaliGs/code/cond
05:18lazybot<khaliG> it isn't clean though because for any nontrivial use of cond you have more clutter!
05:19khaliGthorwil, why stop there? put explicit do's all over the place. for loop, when, etc
07:45peteriserinsShouldn't curl -d X POST <query-string> <url> be equivalent to (clj-http.client/post <url> {:query-string <url>})? I found a mismatch https://gist.github.com/1209484.
07:46peteriserinssorry that's curl -X POST -d <query-string> <url>
08:11tufflaxkhaliG thorwil just create whatever you want with a macro!
08:14thorwiltufflax: i suppose he asked if there's a common lisp style cond available for not having to write it himself ;)
08:15tufflaxi like clojurs cond better than cls :p
08:21bsteuberI don't care about implicit do, but what I dislike about cond is readability of indented code given larger expressions
08:22tufflaxhm what do you mean? is it particularly bad with conds?
08:24bsteubertufflax: I mean like that: https://gist.github.com/1209511
08:25bsteuberhard to see what's the conditionals
08:25bsteuberuh a paren missing - but you get the point
08:25tufflaxyeah
08:25bsteuberso usually in longer expressions like these, I use comments for improving readability
08:26bsteuberbut then a cond* with an additional level of parens seems more sane
08:26bsteuberwhich might come with implicit do for free
08:28tufflaxhm, have not had that problem yet. but it does seem a bit icky
08:37khaliGbsteuber, exactly right
08:38khaliGthe clojure cond should really be a cond* and the cond should be whats cond on every single other lisp ..
08:40Vinzentbut clojure is not every single other lisp... Clojure is special!
08:40bsteuberwell not sure, sometimes the short one is just fine
08:41bsteuberand yes, being similar to other lisps was never one of clojure's design goals
08:41bsteuberbut I'll use some cond* for my more complicated stuff from now on :)
08:42khaliGi think that's rich considering a lot of the clojure hype revolves around "look we're lisp and it's so cool" :)
09:01TimMckhaliG: Meh, it's a syntactic difference within the paren paradigm.
09:04TimMcThe fact that you can define your own cond is... telling.
09:06khaliGTimMc, it makes no sense though
09:06khaliGthe only thing it achieves is giving outsiders the view that there are less parens - as if that's any good reason to make a language choice :/
09:06Chousukebsteuber: I tend to use commas if I have long cond expressions
09:07Chousukejust as a visual marker
09:08khaliGtimb_, at the cost of clarity for the actual person writing code in the language
09:08khaliGTimMc, even
09:10bsteuberChousuke: yes I used ;;;; in between, but it still doesn't look that nice to me
09:10TimMckhaliG: I thought it would annoy me, but it hasn't.
09:11TimMcI'm guessing it was just a personal decision by Rich -- he didn't like the extra grouping parens, so he nuked 'em.
09:11khaliGTimMc, sounds like a funny kind of design decision - sigh
09:14TimMcEh, when you write a new language... it's good to be king. :-P
09:15TimMc"commas are whitespace" doesn't bother you more?
09:15Chousukebsteuber: it'd help if indentation didn't ignore the commas
09:15Chousukecommas being whitespace is a genius feature
09:15Chousukeit means you don't need extra syntax to allow for better readability.
09:16Chousukeyou have a character that can be used as a visual cue wherever you find it appropriate
09:18ChousukekhaliG: the original parens in CL were there because you wanted an implicit do. In clojure you almost never want that so the additional grouping is pretty pointless.
09:18Chousukeeven if it might help legibility in some cases
09:19Chousukein most cases it's just extra noise
09:19khaliGit's not extra noise adding extra commas and explicit dos?
09:19Chousukeit is, but it's optional extra noise
09:19khaliGit's far more obscuring
09:20Chousukeadded there whenever it's needed
09:20khaliGdoesnt make sense
09:20Chousukeand using do explicitly is a good thing anyway
09:20Chousukesince it warns the reader that you have side-effects
09:20Chousukeit makes a lot of sense
09:20khaliGyou use cond because when/if aren't enough - which means you need more functionality like that of the traditional cond
09:21khaliGall clojure cond does is make for neat one liner cond test/exp pairs - which isn't that common anyway
09:21Chousukebut clojure is a functional language. You don't need do most of the time.
09:21khaliGha
09:21Chousukeand when you do, it's good that it's explicit
09:21khaliGthat whole java library thing makes the nonfunctional stuff pretty important
09:21Chousukefor the reason I stated
09:21clojurebotSomething weird that I noticed: & (use '[clojure.contrib.json :as json]) & &| (json/pprint-json nil) |&
09:21lazybotjava.lang.Exception: No such namespace: json
09:22khaliGbut i guess if you're doing a lot of clojure4 problems then you dont need a proper cond :)
09:22ChousukeI don't see what's improper about Clojure's cond
09:22khaliGok brb blog post
09:22Chousukethe lack of grouping is a difference, but it's not like it makes Clojure's cond any worse
09:35TimMclazybot: Why did you respond to that?
09:37TimMcdoes that mean I can: &(+ 1 2)
09:37TimMcGuess not.
09:38Bronsaprobably &| (+ 1 2) |&
09:38lazybot⇒ 3
09:38Bronsayes
09:40TimMcHuh. Why is that available when ##(+ 1 2) works just fine?
09:40lazybot⇒ 3
09:41TimMcPerhaps an existing trigger.
11:56dnolengfrlog: instance?
11:59pdk,(instance 1 Integer)
11:59clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: instance in this context, compiling:(NO_SOURCE_PATH:0)>
11:59pdk,(= (type 1) Integer)
11:59clojurebotfalse
11:59pdk,(= (class 1) Integer)
11:59clojurebotfalse
12:00dnolen,*clojure-version*
12:00clojurebot{:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"}
12:00pdk,(juxt (class type) 1)
12:00clojurebot#<core$juxt$fn__3805 clojure.core$juxt$fn__3805@408add>
12:00pdk,((juxt (class type) 1))
12:00clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn>
12:00pdkffs
12:00pdk,[(type 1) (class 1)]
12:00clojurebot[java.lang.Long java.lang.Long]
12:00pdkwell there ya go i guess
12:05TimMc,((juxt [class type] 1))
12:05clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector>
12:06TimMc,((juxt class type) 1)
12:06clojurebot[java.lang.Long java.lang.Long]
12:07TimMc,(instance? Long 1)
12:07clojurebottrue
12:08TimMcclass is probably the more appropriate one here
12:20ikrHi all. What's a proper shortening for (rest (rest (rest a-sequence)))?
12:20dnolen,(drop 3 [1 2 3 4])
12:20clojurebot(4)
12:21ikrdnolen: super. Thanks!
12:25Vinzent(nth (iterate rest [1 2 3 4]) 3) is longer, but closer to the original ;)
12:31ikrVinzent: OK, got it. Thanks.
12:44dnolenwow, ClojureScript actually makes JavaScript prototypes useful.
12:52skelternetdnolen, how so? tell me more
12:53dnolenskelternet: the compiler namespaces everything for you. so you even modify natives w/o fear.
12:54dnolenprototypes are JavaScript most powerful feature but interoperability reasons nobody extends natives.
12:54dnolenwhich is crippling for productivity.
12:54skelternetI only visit js on occasion. I've read through "JavaScript the good parts" . My impression is that it is powerful in the sense you can build good things, but it is very much up to you to not write your foot off.
12:54skelternetnatives being the base-level prototypes?
12:55dnolenskelternet: compared to Clojure, JS looks like caveman stuff.
12:55dnolenand I've been writing JS now for 6 years.
12:55dnolenskelternet: yes
12:55dnolenObject, Array, Element, CSSStyleDeclaration, XMLHttpRequest etc
12:56jblomoi'm getting odd errors compiling clojurescript in advanced mode: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableSet
12:56jblomoseems to be triggered by setting up a DiagnosticGroups in the closure compiler: options.setWarningLevel(DiagnosticGroups.NON_STANDARD_JSDOC
12:57skelternetmy recollection from Hickey's presentation is that advanced mode is more aggressive about removing code it thinks will not be called
13:00dnolenbeing able call seq on CSSStyleDeclaration cause we extend-type'd to ISeqable is just too awesome
13:14troussanquestion for compiler gurus: (deftype t [__f]) throws verification error in 1.3-beta3. If you remove one of the leading underscores it works fine. Under 1.2 it compiles without errors. Should I open a ticket?
13:29jamiltronI'm kind of interested in learning penumbra and opengl with Clojure. The only downside is I have very minimal opengl experience (some basic pyOpenGL stuff) so I'm not sure where I should start.
13:33pandeiro_how do i require a clojurescript file so I can use and test its functions at the cljs repl?
13:34jblomopandeiro_: (require '[clojurescript.file :as file])
13:34jblomo(file/functions stuff)
13:36pandeiro_jblomo: that's giving me an error in the cljs repl i have going... the file has to be in the same dir as the repl was started from?
13:37jblomothe file name is determined by the namespace, so
13:38jblomohow are you running a repl?
13:38pandeiro_in emacs as a shell, from the dir that my cljs file is in
13:41pandeiro_I get a use of undeclared Var cljs.user/require ... something must be very wrong?
13:41jblomooh.. yea :)
13:42jblomoI recommend downloading leiningen and using `lein repl`
13:42jblomothat will get you setup for making a full project as well
13:43jblomoit also has emacs integration features, though I'm not familiar with them
13:43pandeiro_yeah i am using lein for clojure but i wasn't sure it would be useful for clojurescript projects... i'll give it a try
13:45jblomooh i see, so your clojurescript isn't compiled yet?
13:51pandeiro_jblomo: i have compiled it actually without problems using a clojure repl but i am still pretty clueless trying to use the cljs repl
13:52Bronsatroussan: i am not a Compiler guru but that looks like a bug
13:52jblomopandeiro_: yea, i haven't had much experience with the repl specifically
13:52pandeiro_dont know how i missed this:
13:52pandeiro_https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments
13:53pandeiro_but i am gonna take a look now and hopefully it will sort me out
13:53pandeiro_thanks for the help
14:27Nocabso
14:27Nocabto me (cond) seems very much like case
14:27Nocabare there any particular distinctions I should be aware of? :)
14:28gfrlogI did not know there was such a thing as case.
14:28Nocab(case boo :case1 moo :case2 foo ) ; etc
14:28Nocabto me that reads like cond
14:29hugodcase expressions have to be compile time literals, I believe
14:29gfrlogI'm reading the case docs, and it seems like it is used just for literals
14:29Nocabah ok
14:29gfrlogwhich is presumably purely for optimization
14:29gfrlog"Unlike cond and condp, case does a constant-time dispatch, the
14:29gfrlog clauses are not considered sequentially."
14:30Nocabright right
14:30Nocabgfrlog: what command do you do to get those docs?
14:30NocabI know I have it written somewhere in this clojure book, but I can remember where :P
14:30gfrlog,(doc case)
14:30clojurebot"([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are not evaluated. They must be compile-time literals, and need not be quoted. If the expression is equal to a test-constant, the corresponding result-expr is returned. A single default expression can foll...
14:30gfrlogand when you're extra curious, ##(doc source) is also a good function
14:30lazybotjava.lang.Exception: Unable to resolve var: source in this context
14:31gfrlogokay my point was that source is a good function too, so you could call (source case)
14:31gfrloglazybot is uncooperative
14:31Nocabgfrlog: well that was easy. thanks :)
14:31gfrlogNocab: np
14:37thorwil(interpose " " (models/article-slugs)) gives me the space separated list that i want, but i can't figure out how to get that into a string. it either stays a lazyseq, or i get the name of the lazyseq as string
14:37gfrlogthorwil: try (apply str my-coll)
14:38gfrlogor more efficiently...
14:38gfrloguse clojure.string/join instead of interpose
14:39faust45hi guy's
14:39gfrloghi faust45
14:40thorwilgfrlog: works and good pointer, thanks!
14:40gfrlogthorwil: np
14:44bsteuberI'm trying to get a cljs browser repl up and running
14:44faust45can any one suggest, i try using Lucene in Clojure http://www.friendpaste.com/79QwiQGbbdMTVw05POAABf but got error java.lang.ClassNotFoundException: RAMDirectory. (db.clj:20)
14:45bsteuberbut somehow a) the repl promt is shown before I open the browser window and b) it hangs after any input
14:45gfrlogbsteuber: first step is don't misunderstand the concept like I did and think you're supposed to be able to use a repl from within your browser :)
14:45bsteuberany ideas?
14:45gfrloghmm
14:46bsteubergfrlog: I thought it's like brepl, so a repl running in a shell whose outputs are in the browser
14:46bsteuberor at least side effects
14:46gfrlogbsteuber: right
14:46gfrlogbased on your following comment I didn't need to say anything
14:46gfrlogyou don't have a second browser-repl-tab open do you?
14:47bsteubernope
14:47bsteuberso even if I have none I already get the promt
14:47gfrlogand you're not using Netscape 3?
14:47hugodbsteuber: a) is correct, b) probably your (repl/connect "http://localhost:9000/repl&quot;) line isn't being loaded by what require you are doing on the web page
14:47bsteubertried stable chromium and firefox
14:47gfrlogokay well you've exhausted all my ideas then
14:51Mohikanerhmm this questions just came into my mind, will clojure work with java 1.7? or openjdk? right now i'm still on 1.6
14:51gfrlogMohikaner: http://twitter.com/#!/stuartsierra/status/110046298383712257
14:51gfrlogthat's all I know :)
14:52gfrlogalso that I use openjdk-6 for clojure all the time, if that's what you were asking
14:52Mohikanerah good to know thanks
14:53bsteuberhugod: I'm fairly confident it is, because an iframe with some xhr connection was created
14:55hugodbsteuber: and no browser console errors, I take it
14:58bsteubernope
14:59bsteuberweird, I did it in a fresh minimalistic setup and it works
14:59bsteuberso I must have done something wrong with hiccup or other stuff
15:35mjg123,(let [A true B false] (and A B))
15:35clojurebotfalse
15:36mjg123good. How can I get the same effect if A and B are defined in a map, as in {'A true 'B false} ?
15:36mjg123it looks like I could use with-bindings, but I can't figure it out
15:37tufflax,(let [{:keys [a b]} {:a true :b false}] (and a b))
15:37clojurebotfalse
15:37tufflaxis one way
15:37tufflax:P
15:38mjg123that's interesting
15:39tufflax,(let [{:symbols [a b]} {'a true 'b false}] (and a b))
15:39clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form: :symbols>
15:39tufflax,(let [{:syms [a b]} {'a true 'b false}] (and a b))
15:39clojurebotfalse
15:40mjg123thanks
15:41troussanmjg123: form more than two : (every? (fn [[k v]] v) {'a true 'b false})
15:42tufflaxisn't (fn [[k v]] v) simply val?
15:43troussancorrect
15:43tufflax,(map val {a true})
15:43clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
15:43tufflax,(map val {:a true})
15:43clojurebot(true)
15:45mjg123for context, I'm trying to write truth-tables, something: (table [A,B] (and A B)) - so I can't take shortcuts with the boolean logic...
15:46mjg123I have a fn which creates all the inputs, am trying to work out how to do the bindings so I can evaluate the final column.
15:47solussdhow can I make this not cause a stack overflow for large numbers? (defn ! [x] (if (zero? x) 1 (apply * ((juxt identity #(! (dec %))) x))))
15:47tufflax'for' might be useful
15:47tufflax,(for [a [true false] b [true false]] [a b (and a b)])
15:47clojurebot([true true true] [true false false] [false true false] [false false false])
15:49mjg123yep - exactly :)
15:50mjg123problem 48 of the 99 lisp problems: http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html
15:51tufflaxsolussd try to save the value of (! (dec x)) in an accumulator
15:52tufflaxsolussd read SICP ;)
15:53bsteuberhugod: it seems the problem is having the out directory being served by jetty
15:53bsteuberif I directly open the html from disk it works fine, but if I I use the served version it breaks
15:54mdeboard(some #{"l"} '("l" "h" "c"))
15:54mdeboard,(some #{"l"} '("l" "h" "c"))
15:54clojurebot"l"
15:55mdeboardIs there an idiomatic way of checking for membership in a collection besides this?
15:55hugodbsteuber: out of interest, was the path to out specified relative to the html file?
15:55bsteuberyes
15:56bsteuberbut it should be same both ways because the html file lies in public
15:56tufflaxmdeboard i can't think of any. why? is there something wrong with that one?
15:57mdeboardThat's the question I was trying to get the answer to myself :P Apparently the answer is "no"
15:59tufflaxmjg123 btw in those problems "define operator precedence as usual" is not something you want to do i think, unless purely for the exercise :p
15:59tufflaxi mean, normally
16:00tufflax(i'm aware that these _are_ exercises)
16:01mjg123you mean the infixing? A or B instead of (or A B) ?
16:01tufflaxyes
16:02mjg123Yeah - I don't mind about that so much. Am happy if I can call (table [A B C] (or A (and B C)))
16:02tufflaxit might be a fun exercise but there isn't much point to it i think (but you shouldn't trust me completely)
16:03mjg123it's a good exercise (for me) because the truth-table itself seems to need a non-trivial macro
16:03mjg123but I'm not getting anywhere particularly fast - although I *am* learning stuff :)
16:06TimMc,(contains? #{nil 1 2} nil)
16:06clojurebottrue
16:06TimMc,(#{nil 1 2} nil)
16:06clojurebotnil
16:07TimMcmdeboard: If you have a set, contains? will work. (contains? checks for keys, not values)
16:07TimMcAnd then there is always the Java Collections API.
16:08TimMc,(.indexOf [3 4 nil 5] nil)
16:08clojurebot2
16:10tufflaxmjg123 yeah the truth table seems to be a good one
16:11mdeboardTimMc: Thanks. I'm just looking for a way to validate user input
16:12TimMcOK. Just note that nil can be a special case for memebership.
16:12bsteuberhugod: lol, all I needed to do was restarting jetty :)
16:13bsteuberso I guess it didn't reflect all changes to the public dir
16:13mdeboardTimMc: What do you mean?
16:13tufflax,(some #{1} ())
16:13clojurebotnil
16:14TimMcmdeboard: .indexOf and contains? can both tell you if nil was found in the collection. Using sets as functions cannot.
16:14tufflax,(some #{nil} [nil])
16:14clojurebotnil
16:15mdeboardTricky
16:15TimMcThis is the price of "soft booleans" or whatever they're called.
16:16TimMcThey are hepful 99.999% of the time, though. :-)
16:16mdeboardI think for this extra credit problem for Computing II it ought to suffice :P
16:18tufflaxit is a course in a school and u get to use clojure? i wish i was able to
16:19TimMctufflax: I was able to do that in 2 classes in my senior year at Northeastern University.
16:19TimMcThe Computer Architecture prof was a little grumpy about it, being a solid C guy.
16:20tufflaxproblem 1) automatic judges that don't understand clojure. problem 2) manual judges that don't understand clojure
16:20TimMcComp Graphics was wide-open, though.
16:22tufflaxbut for my upcoming master's thesis i'm not gonna settle for less! i don't know what i'm gonna do yet but i have a feeling that i'm going to want to do it in clojure
16:23hugodbsteuber: do you add public/js (or wherever out is) to your classpath? (just trying to figure out how to make the repl work nicely)
16:25TimMctufflax: Do it!
16:25TimMcAny ideas for topics yet?
16:25tufflaxnope, but i have read mostly theoretical sc and ai
16:26tufflaxs/sc/cs/
16:26lazybot<tufflax> nope, but i have read mostly theoretical cs and ai
16:27tufflaxso i'm sure i can come up with something that fits
16:29mdeboardtufflax: The extra credit is, "Rewrite this in another language"
16:29tufflaxmdeboard perfect :p
16:29mdeboardHe didn't specify any other restrictions on language choice :P
16:29seancorfieldQ about deftype - can you have an optional field?
16:30mdeboardunfortunately I'm unbelievably rusty with clojure :-\
16:35mdeboardDoes the question mark have any special significance at the end of a function name, e.g. (is-valid?) ?
16:36tufflaxno, just part of the name
16:36gfrlogmdeboard: it's idiomatic to mark the function as a predicate
16:36mdeboardok
16:36mdeboardgotcha
16:36gfrlogseancorfield: I, who have little authority to speak on the matter, doubt it.
16:38gfrlogtufflax: as a resident of sc, I find your most recent typo rather thought-provoking.
16:38tufflaxoh yeah? :p
16:39gfrlogI can't decide what it ought to mean though.
16:40seancorfieldgfrlog: yeah, i'm looking at data.priority-map which is defined via deftype and needs to support metadata... the 1.2 compatible way seems to be an optional ctor arg based on the current code
16:40mdeboardIs there a fix for read-line not working as expected in the slime repl
16:44bsteuberhugod: I'm using noir's default structure, so resources/public/js
16:44bsteuberand resources/public will automatically be served by noir
16:45hugodseancorfield: don't you just implement IObj?
16:46hugodbsteuber ok, does load-file work from the repl then?
16:52gfrlogthe gclosure documentation is a little quirky... :/
16:54bsteuberhugod: in theory yes, but you need the stuff on the class-path I guess
16:57TimMcmdeboard: I woud go with valid?, since the is- is kind of redundant when there's a question mark.
16:58TimMcBut it's just a name.
17:00mdeboardTimMc: No, I agree, good point.
17:00TimMcisValid is how Java would do it -- lacking question marks for names. :-P
17:02gfrloghugod: is that where cljs puts metadata?
17:04mdeboardIsit legit to 'initialize' loop with no args, e.g. (loop [] ... )
17:04gfrlogmdeboard: totally
17:04mdeboardOh, ok.
17:04gfrlogI think that's the normal way to do a while(true) sort of thing. Presumably it's for side effects.
17:04mdeboardOk, that's exactly what I'm using it for, main loop of this thing
17:05hugodgfrlog: re seancorfield's question on metadata for deftype
17:05gfrlogmdeboard: I've done that dozens of times, and every single line of my code has been personally signed off on by Rich Hickey.
17:05mdeboardOk, I'm going to copy-paste that into a comment in the code
17:06mdeboard :P
17:06gfrlogs/been personally signed off on/never been looked at/
17:06lazybot<gfrlog> mdeboard: I've done that dozens of times, and every single line of my code has never been looked at by Rich Hickey.
17:06mdeboardhahaha
17:06gfrlogsorry, I make that typo all the time
17:06mdeboardToo late
17:07gfrlogis this site the best for gclosure docs? http://closure-library.googlecode.com/svn/docs/class_goog_graphics_AbstractGraphics.html
17:08gfrlogit seems to be missing the top-level functions in each package. Or at least I don't know where to find them.
17:15troussanseancorfield: looks like compiler inserts __meta field for deftype and defrecord. may be 1.2 was ignoring it when generating the constructor
17:19dnolentroussan: compiler should not insert __meta for deftype, only defrecord.
17:26troussandnolen: thats true. I was looking at emit-defrecord
17:27gfrlogI found out last night that cljs only allows one :require in a (ns) declaration
17:28dnolengfrlog: the list of things like that is long ;)
17:28gfrlogI bet
17:28dnolenbut what is there is awesome
17:29mjg123someone mind helping my macro-fu?
17:29mjg123https://gist.github.com/1210153
17:30gfrlogmjg123: what's this macro supposed to do?
17:31mjg123there's an example in the code (which I just updated with expected output)
17:31gfrlogso the point of it being a macro is so that the second arg doesn't need a (fn [x] ...) wrapper?
17:31mjg123yep
17:32mjg123and, I ought to be able to infer the list of boolean inputs by looking at ALL-CAPS symbols in the 2nd arg
17:32mjg123then I wouldn't need the first arg
17:32gfrlogwhenever I have a macro like that I'll decompose it into two pieces: a function called pr-truth-table* that takes the vector and the fn, and a macor called pr-truth-table that does nothing more than wrap the expression into a fn and call pr-truth-table*
17:33gfrlogthat way the macro does only the little bit that requires a macro
17:33mjg123sounds like that would make it simpler, yes
17:33gfrlogit makes these situations easier to sort through :)
17:33gfrlogalthough your problem of needing to know the args sounds hairy
17:35gfrlogmjg123: so how is it misbehaving?
17:36mjg123I want to remove the first arg,
17:36mjg123so I can just call (pr-truth-table (and A B)) and it will infer that A and B are the variables as they are in caps
17:37gfrlogoh okay. So it's currently working and you're just asking for help refactoring it?
17:37mjg123yes
17:37mjg123:)
17:38gfrlogcould you add (let [vs# (-> vs2# distinct sort)] ...)?
17:38mjg123yes that's needed too :)
17:38gfrlogI guess I don't see what else needs to be done
17:39gfrlogI guess you don't need a separate vs and vs2, right?
17:39gfrlogI'd write a helper function that takes the expression and returns the variables
17:39Mike|homeI'm not usually one for doing this, but this is pretty weird. I'm helping a first year CS student with a proble, and it's more mathematically challenging than anything else. Would anyone like to take a crack at it so I can help this person?
17:39Mike|homeProblem, rather*
17:40gfrlogMike|home: I'm certainly bored enough to try
17:40mjg123gfrlog, I'd like to remove vs, but I'm having trouble working out what to put in lines 19 & 20
17:40gfrlogor at least hear what it is :)
17:40mjg123instead of ~vs
17:43gfrlogmjg123: so you start off with (let [vs# (variables-in `~pred)] ...)
17:43gfrlogand just use vs# wherever you need the list of variables
17:45mjg123gfrlog, I get a lot of "Don't know how to create ISeq from: clojure.lang.Symbol" errors
17:45mjg123:(
17:46gfrlogmjg123: did you create the variables-in function?
17:51mjg123gfrlog yep: still working...
17:51gfrlogmjg123: maybe an updated gist would be helpful? :)
17:53jrabbitI'm trying to use https://github.com/stackoverflow/date-clj
17:55jrabbitI keep getting java.lang.Exception: Unable to resolve symbol: date in this context (NO_SOURCE_FILE:3)
17:55jrabbitwhen I use lein repl
17:55jrabbitor clooj
17:55jrabbitoooh I needc to switch into a ns that uses it >_>
17:55jrabbitodd
17:58mjg123gfrlog, yeah - here's where I am now: https://gist.github.com/1210177 - but it doesn't work any more :(
18:00mjg123I suppose pr-truth-table* can be a plan fn now rather than a macro ?
18:00mdeboardis the "else" clause of an if statement considered tail position wrt (recur)
18:00gfrlogmjg123: certainly, that was the idea
18:01mdeboardi feel like i read either position in the statement is considered tail as long as the if statement is in the tail position
18:01gfrlogmdeboard: yes, both clauses are tail positions
18:01mdeboardgfrlog: thanks
18:03gfrlogmjg123: also you could pull the call to variables-in outside of the quote
18:03bsteuberare there any standards yet on how to package cljs libraries?
18:04gfrlogso (let [vs (variables-in pred)] `(...
18:04gfrlog(inc bsteuber)
18:04lazybot⟹ 1
18:04gfrlogbsteuber: in particular I'd like to know if there's any good way to manage code that's intended to be used in both languages :)
18:04bsteubergood point
18:05gfrlogperhaps use a regex in your filenames, e.g. "shared_code.cljs?"
18:07bsteuberI was thinking of using something like resources/cljs for cljs-only code to be not confused with server code
18:07bsteuberbut that seems a bit hacky
18:07bsteuberthough it might be the only way to have it work out of the box with lein
18:07gfrlogbsteuber: I _think_ I've seen the clojurescript (and others?) project user src/clj/... and src/cljs/...
18:07bsteuberbesides munging everything in src
18:08gfrlogbsteuber: I definitely don't like the idea of cljs in resources, since you shouldn't need the cljs at runtime
18:08bsteuberagreed
18:08mdeboarder
18:09mdeboardhow does lein run work :\
18:09gfrlogmdeboard: I think you have to define a main class? maybe...
18:09gfrlogor something
18:09gfrlogactually I have no idea and shouldn't have said anything.
18:09bsteuberyes :main my.namespace in project.clj
18:09mdeboardwell, i've got that in my project.clj, e.g. `:main numguess.core` but I'm not clear on if that's right, ro if it shoul be the name of the .clj or what.
18:10mdeboardbsteuber: `:main my.namespace in project.clj`?
18:10bsteuberyes
18:10bsteuberand in my/namespace.clj you need a :gen-class in the ns declaration
18:10bsteuberas well as a (defn -main [] ...)
18:11mdeboardwhat
18:11mdeboardok
18:11mdeboardreally? ok
18:11mjg123there's a lot of examples in the sample.project.clj on the lein github
18:11gfrlogmdeboard: and all that should also get you an executable jar
18:11jrabbitwhats the difference between "(is? (today) :sunday)" and "(-> (today) (is? :sunday))"
18:11bsteubermain-classes are a java concept, so you need to generate a java class
18:12bsteuberjrabbit: should be no difference
18:12jrabbitwell I mean what is -> doing
18:13gfrlogjrabbit: transforming the second expression into the first :)
18:13jrabbitthe clojure documentation is a little opaque to understand
18:13seancorfieldtroussan: dnolen: __meta is not available in deftype as far as i can tell from tests
18:13jrabbitgfrlog: thats bizzare
18:13bsteuberso if you have lot's of nested forms like that, it improves readability
18:13gfrlogjrabbit: it's bizarre at first. It lets you avoid lots of nesting.
18:13jrabbitah ok
18:13jrabbitwhats a larger example of that?
18:13gfrlogjrabbit: once you get the aha moment, it becomes totally brilliant and you use it all the time
18:13seancorfielddefrecord supports metadata out of the box but it also implements a lot of other stuff - not sure data.priority-map could work on top of defrecord
18:14bsteuberthink of (a (b (c (d (e 42)))))
18:14gfrlog(a (b (c (d)))) becomes (-> (d) (c) (b) (a)
18:14bsteubercompared to (-> 42 d e c b a)
18:14jrabbitoh
18:14bsteubergfrlog: you can drop the parens
18:14seancorfieldbut clojure.data.priority-map now passes tests on 1.2 and 1.3: http://build.clojure.org/job/data.priority-map-test-matrix/
18:14jrabbitthats pretty slick the longer it gets
18:14gfrlogbsteuber: yeah I thought that would be confusing
18:14dnolenseancorfield: yes I know meta shouldn't be.
18:14jrabbitok I see why that'd be cool on longer things
18:15jrabbitalso is there a syntax hilighted repl?
18:15gfrlogjrabbit: also see ->> for comparison
18:16jrabbitgfrlog: is it the reverse?
18:16gfrlogjrabbit: it inserts things as the last argument instead of the first
18:16mjg123jrabbit: depends what you like - IntelliJ vi emacs all do syntax highlighting
18:16bsteuber-> puts stuff as the first argument, ->> as last argument
18:17jrabbitso whats that look like in that previous example?
18:17bsteuberso (-> 42 (foo a b)) becomes (foo 42 a b)
18:17bsteuberbut (->> 42 (foo a b)) becomes (foo a b 42)
18:17jrabbitahhh
18:18bsteuberso it doesn't matter for one-argument functions like I had before
18:18jrabbitand a dumb question whats the print macro/function?
18:18gfrlogjrabbit: print is like System.out.print()
18:18mjg123is there a good way to thread a series of functions which some need -> and some ->> ?
18:18jrabbitoh print is print :p
18:19bsteubermjg123: no standard way, so maybe just use let with explicit names for the intermediate results
18:20gfrlogmjg123: actually
18:20gfrlogyes
18:20jrabbitwhy does (if (is? (today) :sunday) (print "hi \n")) yeild "hi" then nil?
18:20jrabbitis print returning nil?
18:20mjg123yes
18:20gfrlogjrabbit: print returns nil, and if returns nil if the condition is false and there's no else
18:20jrabbitah ok
18:21bsteuberall stuff that is void in java returns nil in clojure
18:21bsteubermore or less
18:21jrabbitcool I think I can make something useful now :)
18:21gfrlogmjg123: ##(-> 30 (range) (distinct) (->> (map inc)))
18:21lazybot⇒ (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
18:21mjg123oh what?
18:21bsteuberyes ->> inside -> works
18:21bsteuberbut the other way doesn't
18:21gfrlogmjg123: obviously it's not necessary there, but that shows you how you can mix them syntactically
18:22bsteuberso be careful
18:22gfrlogbsteuber: right
18:22gfrlogoh also
18:22gfrlogyou can always insert function literals
18:23gfrlog&(-> 30 range ((fn [coll] (map inc coll))))
18:23lazybot⇒ (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30)
18:23gfrlogthat can give you arbitrary control
18:23bsteubergfrlog: good point
18:24bsteuberplease note the additional level of parens around fn
18:24gfrlogindeed
18:24mjg123,(-> 30 range (->> (filter even?)) #(* % %))
18:24clojurebot#<CompilerException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentVector, compiling:(NO_SOURCE_PATH:0)>
18:24mdeboardI feel like I'm missing something. The first line of my core.clj is "(ns numguess.core (:gen-class))". In my project.clj I've got ":main numguess.core in core.clj". But when I do `lein jar` or `lein uberjar` and chmod +x the resulting .jar I get an eror saying
18:25mdeboardException in thread "main" java.lang.NoClassDefFoundError: clojure/lang/IFn
18:25gfrlogmdeboard: you don't execute the jar directly, you "java -jar my.jar"
18:25mdeboardoh
18:25mdeboardI knew that
18:25mdeboardgood news gfrlog, you passed my test!
18:25gfrlogmdeboard: by "executable jar" I just meant a jar that provides a default main class so you don't have to specify it
18:25gfrlogmdeboard: now give me my dang diploma
18:26mdeboardstill get that exception: Could not find the main class: numguess.core. Program will exit.
18:26gfrlogmjg123: I have no idea what that expression was trying to do
18:26gfrlognumguess? Are you writing the program I wanted to write?
18:27mdeboardalmost certainly not
18:27gfrlogdarnit.
18:27gfrlogso you have a function called -main?
18:27mdeboardhttp://p.mattdeboard.net/numguess.html
18:27mdeboardyeah
18:28gfrlogmdeboard: oh I think it needs to take an arg
18:28gfrlogor varargs. I forget which.
18:28mjg123gfrlog, it was trying to be ##(-> 30 range (->> (filter even?) (map #(* % %))))
18:28lazybot⇒ (0 4 16 36 64 100 144 196 256 324 400 484 576 676 784)
18:29gfrlogmjg123: those are nice numbers
18:29mjg123thanks
18:30gfrlogit's hard to come up with natural examples that require both -> and ->>
18:30mjg123I've had exactly the problem of wanting to thread a (map) halfway through
18:32bsteubergfrlog: no -main doesn't need arguments
18:32bsteuberthough I'm not sure whether args are allowed
18:32bsteuberI'd rather guess not, but no idea
18:32gfrlogbsteuber: you mean varargs?
18:32bsteuberno arguments at all
18:33gfrlogbsteuber: certainly you need a way to get the command line args
18:33bsteuberI thought the way for reading command-line args is different
18:33gfrlogit's either a single arg that is a string seq, or it's varargs
18:33gfrlogI've definitely done it that way
18:33bsteuberthey're in *command-line-args* - that was it :)
18:34gfrlogit's supposed to be the same to the JVM as public static void main(String[] args){...}
18:34gfrlogoh I remember that var.
18:35mdeboardbsteuber: So, do you have any insight on what's going wrong with my deal
18:36mdeboardOr rather, what I'm doing wrong with my deal
18:36gfrlogmdeboard: I'd use "jar tf my.jar" on your jarfile to see if the class is there
18:36bsteuberdoes (-main) work from the repl?
18:37mdeboardOh, I have ":main numguess.core in core.clj" but in the class list it has "numguess/core"
18:37mdeboardmatter?
18:37clojurebothttp://www.math.chalmers.se/~rjmh/Papers/whyfp.pdf
18:37gfrlogmdeboard: no that should be the same
18:37bsteubermdeboard: do you use emacs?
18:38gfrlogclojurebot: forget matter
18:38clojurebothttp://www.math.chalmers.se/~rjmh/Papers/whyfp.pdf
18:38mdeboardbsteuber: Yep, It's tough to test the function because it relies heavily on read-line which sucks in slime-repl
18:38bsteuberah
18:38gfrlogmdeboard: where do you get the error? compiling or running the jar?
18:38mdeboardand by "sucks" I mean "is broken"
18:38bsteuberso you get an IFn not defined error right?
18:38mdeboardgfrlog: running
18:38bsteuberthat's perfectly normal
18:39mdeboardbsteuber: yeah
18:39bsteuberbecause your jar doesn't include the clojure.jar
18:39mdeboardCould not find the main class: numguess.core. Program will exit.
18:39bsteuberso you either have to include that to the classpath
18:40mjg123what is the name of your jar file?
18:40bsteuberso try "lein uberjar"
18:40mjg123I mean, are you definitely running the *-standalone.jar ?
18:40mdeboardbsteuber: running `lein uberjar` atm
18:41bsteuberand then java -jar foo-1.0.0-SNAPSHOT-standalone.jar
18:41mdeboard`java -jar numguess-1.0.0-standalone.jar` => "Could not find the main class: numguess.core. Program will exit."
18:41bsteuberhmm
18:41mdeboardbsteuber: Look right? http://p.mattdeboard.net/ngproj.html
18:42gfrlogmdeboard: have you tried sacrificing any moderate-sized animals?
18:42mdeboardbsteuber: output of `java tf numguess-1.0.0-standalon.jar`: http://p.mattdeboard.net/output.html
18:43mdeboardgfrlog: would that work
18:43bsteubermdeboard: you've got the "in core.clj" in your file???
18:43lazybotbsteuber: Oh, absolutely.
18:43mdeboardbsteuber: Yea, you explicitly said to :P
18:43gfrlogoh dear
18:43mdeboard13:09 <mdeboard> bsteuber: `:main my.namespace in project.clj`?
18:43mdeboard13:09 <bsteuber> yes
18:43gfrlogyes go sacrifice three sheepses and fix your project.clj
18:44bsteuberok what I meant was edit the project.clj file to include :main numguess.core
18:44gfrlogalso why aren't the deps included in the `jar tf`?
18:44bsteubersorry I overlooked the quotes ^^
18:45mdeboardrm'd the two .jar files, and re-ran `lein uberjar`. Do I need to run like `lein compile` or anything as well or does uberjar take care of that
18:46gfrlogI think it will clean for you
18:46bsteubersometimes you need to run "lein deps" on your own before
18:46bsteuberthe rest should be fine
18:46mdeboardsill the same issue :-\
18:48mdeboardthink I figured it out.
18:48mdeboardya
18:48gfrlogthe sheep?
18:48mdeboardIt was that "local-repo-classpath" line in project.clj
18:48bsteuberhuh I never used that
18:48mdeboardI forget why I included that
18:48mdeboardthink technomancy suggested it once, or something.
18:49bsteuberinteresting
18:49bsteuberbtw I like your clojure-html formatting
18:50bsteuberis that some standard one?
18:50mdeboardscpaste module for emacs
18:50mdeboardthe best
18:51bsteuberwow so it works for any color-scheme
18:51bsteuberthat's totally awesome
18:51mdeboardya
18:52bsteuberthough it won't help you with code you don'T have in emacs
18:52mdeboardno such thing
18:52bsteuberbecause it's someone else's code or whatever and you'Re too lazy to do it for each file
18:53mdeboardwrong, I wrote a spider that crawls the entire web, saves code in any language to a file on my computer, which I can then summon easily and copypaste
18:53mdeboardfeh, mortals.
18:54mdeboard*cough* But yeah seriously I use dpaste a lot too :)
18:54bsteuber:)
18:55mdeboardlol wow I can't believe this works :|
18:55bsteuberjust imagining an endless cluster of amazon machines running emacs to format all github code at once :)
18:55mdeboardI'm just going to upload the source and the jar without comment
18:56mdeboardalong with the C++ original
18:56mdeboardsee how/if he reacts, since brainless TAs grade all his shit
18:57bsteuberclojure/c++ code comparison is always funny
18:58mdeboardactually the clojure source is only 4 or 5 lines shorter than the C++ one
19:07jrabbitException in thread "main" java.io.FileNotFoundException: Could not locate src/is_saga_open/core__init.class or src/is_saga_open/core.clj on classpath: (NO_SOURCE_FILE:1)
19:07jrabbittrying to run compojure/ring with
19:07jrabbit:ring {:handler src.is_saga_open.core/app}) where I have thisr file in src
19:07jrabbit$ ls src/is_saga_open/
19:07jrabbitcore.clj
19:13jrabbithttps://github.com/jrabbit/Is-SAGA-open- >_>
19:14gfrlogjrabbit: change project.clj to {:handler is-saga-open.core/app}
19:14gfrlogthat might not fix it, but I think you need that either way
19:14jrabbitthe file is _ though
19:15jrabbitoh I see the namespace is -s
19:15gfrlogexactly
19:16gfrlogand you don't want src there, since that isn't part of the ns-name
19:16jrabbitah ok
19:16jrabbitthat makes more sense now
19:16jrabbitI was thinking it wanted the path to the file not a namespace
19:16jrabbityay it works :)
19:16gfrlogw00p
19:17jrabbitany idea if ring reloads? :P
19:17gfrlogI think if you start with "lein ring server" it will
19:17jrabbitneat
19:17jrabbitgfrlog: thanks
19:18gfrlogjrabbit: np
19:38mdeboardI've written exactly three working Clojure programs, and I'm shocked as hell every time
19:42mdeboardCan anyone tell me why the "Got it" line doesn't print when its condition is satisfied?
19:42mdeboardhttp://paste.pocoo.org/show/474365/
19:42mdeboardThe program just halts, which would otherwise be ok except I want some kind of alert that it got solved in there :P
19:43brehautmdeboard: not related to your bug, but if-not is a useful macro
19:45mdeboardbrehaut: thanks, what does that get me over just (if (not (foo)))
19:45brehautone less pair of parens
19:45mdeboardiuc
19:45mdeboardoic*
19:47mdeboardbrehaut: No insight on the line not printing though eh :\
19:47brehautmdeboard: i have no idea what the implementation of answer-case is
19:47mdeboardbrehaut: http://p.mattdeboard.net/numguess.html
19:47jrabbitany idea how to do classes/ids in hiccup?
19:48brehaut:div.class#id
19:48jrabbitbrehaut: ah
19:48brehautim not a hiccup expert
19:49brehautmdeboard: (defn correct [] false) is weird
19:49mdeboardbrehaut: Yeah :-\
19:50mdeboardguess I could just remove that function and make `"c" false`
19:50brehautindeed
19:51mdeboardYeah I'm totes confused on that not outputting the string.
19:51brehautgive me some time
19:53brehautits working for me
19:53mdeboardHuh.
19:53brehauthowever
19:53brehautif you are running this as a main
19:53brehautits not going to print the message
19:53brehautformat just returns a string
19:53mdeboardAh
19:53brehautyou need to print it
19:54brehautjust calling (-main)
19:54mdeboardHm I tried that, what then do I return
19:54brehautdoes what you expect though
19:54brehautdo you need to return something?
19:54mdeboardWell, I guess not.
19:55brehautalso, floor, ceiling, guess and counter probably shouldnt be distinct; make them a map and put one in the atom
19:55brehaut(if you must use an atom)
19:55mdeboardIsn't an atom the correct data structure there
19:55brehauttheres no reason it cant just be data passed recursively
19:56mdeboardLess confusing to read this way, I think.
19:56mdeboardEspecially since the grader will likely have no idea what Lisp is, let alone Clojure.
19:56brehautmdeboard: if you use an atom it should probably be (def game (atom {:floor 0 :ceiling 100 :guess 50 :counter 1}))
19:57mdeboardWhat's the syntax to get the value when dereferencing
19:57brehaut(:floor @game)
19:57mdeboard(@game :floor)?
19:57mdeboardoh
19:57brehautor that
19:57brehautbut you are using the map as an object, so keywords as fns is prefered
19:57mdeboardI see, I like that better.
19:58jrabbitjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
19:58jrabbitwhat the heck is that
19:58jrabbithttps://gist.github.com/1210319
19:59mdeboard(swap! (:counter game) + 1) ?
19:59brehautjrabbit: without context for what today, weekends, weekday are its hard to tell
19:59brehautmdeboard: no, you need to push all the updates into a function to pass to swap
20:00mdeboardI see.
20:00jrabbitbrehaut: oh that stuff works
20:00jrabbitits stuff from date-clj and some of my functions
20:00mdeboardbrehaut: I made a note in the comments; another time when I don't have discrete math homework :P
20:00brehautjrabbit: something at the head of a combination is a seq rather than a fun
20:01jrabbithttps://gist.github.com/1210319
20:01jrabbittheres the whoel file
20:02jrabbitso basically I get a true/false then want to switch the page generated
20:03mdeboardOh, that's handy, there's a printf :)
20:04jrabbitbrehaut: found a fix
20:04brehautmdeboard: (swap! game (fn [{:keys [counter ceiling guess] :as g}] (assoc g :counter (inc counter) :floor guess :guess (update-vals guess ceiling))))
20:04jrabbitits less sane but works
20:04mdeboardAhh
20:04mdeboardok
20:05mdeboardChanged (format "stuff %s" @thing) to (printf "stuff %s" @thing) but it still doesn't print the line.
20:05mdeboardAm I using the wrong metho dhere
20:05brehauti have no idea
20:05brehautsorry i have to get back to work
20:05mdeboardni yo tampoco
20:05mdeboardYeah get back to work
20:05mdeboardbring home the bacon
20:06mdeboardthanks for the help
20:06brehautjrabbit: your problem is that presumably the result of (include-css "/css/yes.css") is a sequence and you are tryung to call that as a function
20:07brehaut(at a guess)
20:07bhenryis there a built-in that prints the result of an expression to *out* and still returns the result of said expression to the reader?
20:07mdeboardthat is an excellent question
20:07jrabbitbrehaut: its a function :\
20:08brehautjrabbit: the result of include-css ?
20:08jrabbitbrehaut: a [:style ..] hiccup element
20:08gfrlogbhenry: I don't think so. It's a good thing to define in a util.clj
20:08brehauthttps://github.com/weavejester/hiccup/blob/master/src/hiccup/page_helpers.clj#L78-82
20:09brehautjrabbit: include CSS returns a lazy seq (thats the result ofa for)
20:09jrabbitbrehaut: I got it working by seperating it out into two fucntions
20:09brehautjrabbit: you have ((include-css …) …
20:09jrabbitthen calling the functs in if
20:09jrabbitI donno :(
20:09brehautjrabbit: if you dont understand why it didnt work you will hit this again
20:10mdeboardbrehaut: Changed (print) to (println) and it worked. :|
20:10brehautmdeboard: try (do (printf …) (flush))
20:11mdeboardbrehaut: Yar, that worked.
20:12brehautmdeboard: at a guess print without the ln isnt flushing stdout?
20:12mdeboardbrehaut: Yeah that sounds reasonable.
20:13bhenryjrabbit: unless if has some weird trick i've never seen, you've done something wrong around 23/24.
20:15seancorfieldif anyone has feedback on http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go pls email me sean@corfield.org
20:17brehautseancorfield: thats a great resource
20:20jrabbitI've worked around it :\
20:34gfrlogmdeboard: I'm about 98% sure that it is the case that println flushes and print doesn't
20:34mdeboardoic
20:35mdeboardI think the point is that I wrote a clojure program and it woks.
20:35mdeboardworks, too.
20:36gfrlogmdeboard: that's a good point
20:45amalloy&(+ 1 (doto 5 println)) ;; bhenry
20:45lazybot⇒ 5 6
20:47amalloyand also https://github.com/flatland/useful/blob/develop/src/useful/debug.clj if you want something a bit more drop-in
20:49bhenryamalloy: nice
20:49bhenrydoto is cool.
20:49amalloyit's pretty sweet, yeah
21:22xiaolongxiaI have a piece of clojurescript http://pastebin.com/errDKYEC that I'm trying to rewrite as more idiomatic clojure
21:23xiaolongxiathe commented out block results in something like object.method.call(null, arg, arg, arg)
21:23xiaolongxiawhile I want what the original function produces which is object.method(arg, arg, arg)
21:25amalloyxiaolongxia: you probably want to use ##(doc doto)?
21:25lazybot⇒ "Macro ([x & forms]); Evaluates x then calls all of the methods and functions with the value of x supplied at the front of the given arguments. The forms are evaluated in order. Returns x. (doto (new java.util.HashMap) (.put \"a\" 1) (.put \"b\" 2))"
21:26xiaolongxiaamalloy: thanks
21:26skelternetWhat is the selling-point of clojurescript? Better UI development?
21:27xiaolongxiaskelternet: depends
21:27amalloy,(macroexpand '(doto (X.) (. (setFoo 2)) (. (setBar 3))))
21:27clojurebot(let* [G__8917 (X.)] (. G__8917 (setFoo 2)) (. G__8917 (setBar 3)) G__8917)
21:30xiaolongxiaamalloy: i still haven't wrapped my head around macros, why is that better than doto by itself?
21:31skelternetI'm willing to be sold. I'm going to be spending much time in js and browser land in near future if I can't find a contrctor
21:32dnolenskelternet: after two days of using ClojureScript, I really wouldn't want to target browser code any other way. Everything else seems tedious. Lots of rough edges of course, but this is hands down better than anything else I've ever used.
21:32xiaolongxiaskelternet: one good use case is writing ALL of your logic in clojure. client or server side
21:33xiaolongxiadnolen: your blog about pattern matching really made me re-think the possibilities of clojurescript
21:33dnolenskelternet: it makes a lot JS frameworks / libraries seem, frankly, pointless.
21:34dnolenxiaolongxia: cool! yeah having access to macros is just fantastic.
21:34skelternet*nod* I can say with sincerity that had I seen clojure 4 years ago, I would have not written ETL loaders the same way.
21:34xiaolongxiaskelternet: also, goog closure + clojurescript is really pretty cool
21:34xiaolongxiaif you look at that pastebin, that's all you need to make a gauge
21:35xiaolongxiabased on this http://closure-library.googlecode.com/svn/trunk/closure/goog/demos/gauge.html
21:35skelternetI've only seen Hickey's presentation on clojurescript. Are the environments/frameworks shaping up?
21:36dnolenskelternet: ClojureScript hasn't yet seen anything like a release, and that looks a ways off. Still what's there is good enough to build apps with.
21:36dnolenskelternet: tools will need to be tweaked to support Browser REPL
21:36dnolenEmacs has inferior-lisp-mode so it's pretty trivial there.
21:38xiaolongxiaamalloy: that solved my problem, thanks alot
21:40amalloyxiaolongxia: i don't think we understood each other. i was just showing you what the doto would expand to
21:43xiaolongxiaamalloy: i follow you now.
22:16dnolendarn ClojureScript doesn't have reify yet
22:17hugodI must be doing something wrong. Every time I try a ns form at the clojurescript repl, I get a null pointer exception. And load-namespace exits the repl with the same exception…
22:18dnolenhugod: example?
22:19amalloyhugod: last i heard, cljs doesn't have real namespaces at runtime
22:19hugod(load-namespace 'goog.math.size)
22:20hugodor (ns test.myns (:require [goog.math.size :as s]))
22:20dnolenhugod: both of those work for me
22:20dnolenwhat's the exception?
22:21hugodjava.lang.NullPointerException: name in cljs.closure/add-dependencies
22:21hugodlet me doublecheck they are on the classpath…
22:22dnolenhugod: those work fine for me. have you set $CLOJURESCRIPT_HOME ?
22:24hugodthis is running from pre-compiled js files
22:25dnolenhugod: I don't follow.
22:27hugoddnolen: I have run the cljs compiler and have all the js files . I then run the repl, and try those commands…
22:31dnolenhugod: are other things working?
22:31dnolenfor example:
22:31dnolenrepljs
22:31dnolen(ns foo (:require [goog.date :as d]))
22:31dnolen(d/Date.)
22:31hugodgoog.date doesn't get included in my js
22:32hugodI picked goog.math.size since it was present
22:33dnolenhugod: but does that simple test at the repl work?
22:33dnolenjust trying to figure out how much isn't working for you.
22:33hugoddnolen: no
22:33hugod(+ 1 1) works, defn works
22:33clojurebot2
22:33dnolenhugod: and your repo is up-to-date?
22:34hugodpulled this afternoon
22:34dnolenI just pull the latest and I can run the above snippest from any directory.
22:37hugoddnolen: running repljs seems to work , thanks
22:37dnolenhugod: cool
22:37hugodI just need to work out what I'm doing differently now…
23:09sconoverhi, I'm a clojure noob. is this the appropriate place to ask questions?
23:10amalloywell, it's a better place than #scala
23:11sconoverI'm trying to use higher-level functions to accomplish a task
23:12sconoverI would like to take-while from a list, and stop the take while as soon as a certain number of a certain kind of item is taken from the list
23:12sconoverI'm trying to figure out the best way to "accumulate" or count as part of the predicate
23:13sriddoes anyone use pallet/jclouds to deploy to linode vms?
23:13sconover(take-while not(too-many-trues?) (take 8 booleans)))
23:14amalloyso you have a list like "+249*201-87", and you want to keep taking until you have (say) two punctuation marks?
23:14sconoveri'm wondering how i'd implement too-many-trues? such that it flips to true after 3 trues are taken...
23:14sconoveryeah that's a good example
23:15amalloysconover: that's a neat problem. do you mind if i add it to 4clojure.com?
23:15sconovernot at all
23:15amalloycool. anyway, i don't think take-while is a good tool because it can only look at the current element
23:16sconoveri'm sure i can accomplish this with recursion
23:16sconoverbut was wondering if there's some other way
23:16amalloyi think you can do something only a little bit ugly if you use reductions
23:16sconoveri'm still wrapping my head around how to properly handle/express mutable state...
23:17sconoverok. that's fine. mine sharing what you'd do?
23:17sconovermind
23:18amalloyyeah, gimme a few minutes
23:18sconover4clojure is nice, thanks for the pointer
23:19sconoverwould be even better if it were available via git ;-)
23:21amalloysconover: https://gist.github.com/1210514
23:22sconover<reading>
23:22amalloysconover: i don't understand. the source of 4clojure is available on github. i think i may have just deployed with a broken link, though
23:23sconoverah ok
23:24amalloythanks for the catch, in fact
23:24amalloywe're in the middle of moving repos and i forgot to fix that
23:24sconoverthere it is, right in front of me ;-)
23:25amalloyson of a...i can't fork this to the right place, because i already have a fork?
23:26sconoverso in your code, is the reductions
23:26sconoverreductions call handing back a nested sequence
23:26sconoverwith the count as the first element?
23:27amalloyit's returning a sequence, each item of which is a pair: [count items]
23:27sconoverok
23:29amalloyit does that lazily, of course
23:29amalloythen we take-while on count, and get the matching items
23:30sconoverok i think i get it
23:31sconoveri haven't used reductions before but i see what's generally happening here. i'm going to read up on reductions and then go put this in place.
23:31sconoverthanks a lot for your help
23:32amalloyyou're welcome! thanks for the problem
23:33sconovernp. interesting that it's novel.
23:35hugoddnolen: found half my problem - the goog/deps.js emitted by the compiler uses double quotes instead of single quotes, so cljs.closure/goog-dependencies* fails
23:35sriddamn, getting enlive to work with appengine is such a pain
23:36hugodthe other half will have to wait for tomorrow…
23:36amalloysconover: it's probably easier to solve with plain recursion, but reductions is a neat tool anyway
23:37dnolenhugod: ah now that I think about it, I was seeing this as well.
23:38sconoverwhich option would you say is more idiomatic / less "surprising" in clojure-land?
23:39amalloy*shrug*
23:39amalloyi have a tendency to combine things like reduce/filter/take-while/iterate too much, when simple recursion would be easier
23:39sconoverah ok
23:41amalloysconover: you might like http://amalloy.hubpages.com/hub/The-evolution-of-an-idea - a blog post in which i solve a pretty similar problem
23:50sconoverplaying around w/ reductions in the repl, neat. very much like ruby inject/reduce (the fact that you have access to intermediate values).
23:51amalloyyeah, and you don't need mutable state to get that