#clojure log - Sep 11 2011

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

0:43 michaelr525: hello!

0:52 mtbeedee: what does it mean when a function has a - in front of it?

0:52 like (defn -main [] ...)

0:56 michaelr525: It'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

1:00 mtbeedee: ^^^

1:30 mtbeedee: thanks

1:50 jamiltron: I'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?

1:53 I 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")

1:54 Chousuke: is it the correct architecture? sounds like JNI stuff

1:55 jamiltron: I am not sure. In the java/lib directory there's also a amd64 folder.

1:55 It looks like it contains liblwjgl64.so stuff

1:58 Searching that error seems to have people talking about "natives" and making sure lwjgl.jar is added to the classpath, of which mine is.

2:01 jrabbit: whats the simplest way to get the current time/date?

2:05 jli: jrabbit: (.getTime (java.util.Date.)) perhaps

2:05 time in milliseconds since epoch, I believe

2:08 jrabbit: ah I guess i should check the java docs then

2:10 jli: jrabbit: actually, there's also the clj-time library

2:10 it let's you say (now)

2:10 lets*

2:10 https://github.com/hgiddens/clj-time

2:10 jrabbit: hm that mgiht be useful

2:10 * jrabbit sees if it can do dates

2:14 miwillhite: hi - I'm pretty new to clojure and graph data structures…anyone know of any good resources for working with graphs in clojure?

2:15 I have noticed that clojure.contrib has some graph functions, but its not clear to me exactly where to start

2:15 wiseen: is 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

2:16 hiredman: java.util.UUID

2:16 jrabbit: jli: date-clj seems to be a better fit but thanks!

2:16 way better than using the java stuff

2:17 wiseen: hiredman, 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

2:18 like in python I could do a = object() b = object() c = {a: 1, b: 2}

2:19 in clojure (let [a {} b {}] {a 1 b 2}) says duplicate key

2:19 is there a "object" primitive

2:19 hiredman: ,(Object.)

2:19 clojurebot: #<Object java.lang.Object@18a774d>

2:19 hiredman: ,(Object.)

2:19 clojurebot: #<Object java.lang.Object@58c90f>

2:20 wiseen: oh ok, and for javascript/clojurescript as well ?

2:20 hiredman: no idea

2:20 wiseen: k will figure out tnx

2:21 jli: miwillhite: there's clojure.contrib.graph. I also heard of loom today https://github.com/jkk/loom

2:22 miwillhite: cool, I'll check it out thanks

3:28 dark_src: just setup slime / swank in emacs... cool stuff.

3:31 anyone knows how to select a bunch of lines in emacs and run it?

3:32 i can exec one line cx ce but no luck with no luck with multiple lines

3:32 hiredman: C-c C-c

3:33 well run the toplevel form the cursor is in

3:33 Vinzent: Also C-c C-r for region

3:33 hiredman: although C-x C-e should also run multiple lines

3:33 dark_src: yeah i saw http://www.pchristensen.com/slimecommands.pdf

3:34 how can run something like (println "line 1") \n (println "line 2")

3:37 Vinzent: C-SPC C-M-f C-M-f C-c C-r

3:38 dark_src: Vinzent: got it. Marked the region and c-c c-r thanks

3:38 Vinzent: np

3:39 dark_src: one more thing. there is any way to clear the slime output before execution

3:40 ?

3:41 Vinzent: C-c C-o?

3:41 dark_src: C-c C-o is undefined

3:42 Vinzent: Try it in the repl buffer

3:46 dark_src: Vinzent: it doesn't work so well. it only clears the last few lines of output.

3:46 Vinzent: yep; C-c M-o for the whole buffer

3:48 dark_src: Vinzent: cool. thanks works! only that its little painful to toggle between the source and the repl everytime :(

3:49 in case you haven't guessed I am a emacs newbie and figuring things out myself.

3:49 Vinzent: is there a way to bind the toggle and buffer clear to some key

3:51 Vinzent: dark_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

3:53 dark_src: let me try it

3:58 Vinzent: how does swank work. I need to start lein swank on the project and then connect to it

3:58 ?

3:59 Vinzent: Vinzent, yes, $ lein swank, then M-x slime-connect. With durendal you can do it with the single command: durendal-jack-in

4:01 hm, btw C-c C-j is probably non-standard binding

4:01 dark_src: Vinznet: how do ppl do this right now. I am sure there is a easier way

4:04 Vinzent: Ypu 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? :)

4:52 khaliG: is there a normal lisp cond somewhere? I have more than one form and don't want to use (let [] ...)

4:54 hiredman: do

4:54 khaliG: heh

4:54 that's dumb :/

4:54 hiredman: do

4:54 http://clojure.org/special_forms#Special%20Forms--%28do%20exprs*%29

4:55 khaliG: no

4:57 hey lets cripple cond in a way that makes it like a if .. great idea :o

5:12 thorwil: khaliG: how do clojure an "normal lisp" cond differ?

5:12 khaliG: thorwil, one is useful the other one is broken

5:13 thorwil: that's a non answer. i'm honestly wondering what the difference is

5:14 khaliG: thorwil, http://www.lispworks.com/documentation/HyperSpec/Body/m_cond.htm - basically you have an implicit do in the non-test form

5:15 thorstadt, with the clojure one you have to put an explicit do or a let with an empty binding

5:16 thorwil: ah, 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

5:16 khaliG: thorwil, 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

5:18 thorwil: well, it reduces the behavior to the minimum, avoiding am implicit do. you call it broken, i think i will call it clean :)

5:18 khaliG: it isn't clean though because for any nontrivial use of code you have more clutter!

5:18 s/code/cond

5:18 lazybot: <khaliG> it isn't clean though because for any nontrivial use of cond you have more clutter!

5:19 khaliG: thorwil, why stop there? put explicit do's all over the place. for loop, when, etc

7:45 peteriserins: Shouldn'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.

7:46 sorry that's curl -X POST -d <query-string> <url>

8:11 tufflax: khaliG thorwil just create whatever you want with a macro!

8:14 thorwil: tufflax: i suppose he asked if there's a common lisp style cond available for not having to write it himself ;)

8:15 tufflax: i like clojurs cond better than cls :p

8:21 bsteuber: I don't care about implicit do, but what I dislike about cond is readability of indented code given larger expressions

8:22 tufflax: hm what do you mean? is it particularly bad with conds?

8:24 bsteuber: tufflax: I mean like that: https://gist.github.com/1209511

8:25 hard to see what's the conditionals

8:25 uh a paren missing - but you get the point

8:25 tufflax: yeah

8:25 bsteuber: so usually in longer expressions like these, I use comments for improving readability

8:26 but then a cond* with an additional level of parens seems more sane

8:26 which might come with implicit do for free

8:28 tufflax: hm, have not had that problem yet. but it does seem a bit icky

8:37 khaliG: bsteuber, exactly right

8:38 the clojure cond should really be a cond* and the cond should be whats cond on every single other lisp ..

8:40 Vinzent: but clojure is not every single other lisp... Clojure is special!

8:40 bsteuber: well not sure, sometimes the short one is just fine

8:41 and yes, being similar to other lisps was never one of clojure's design goals

8:41 but I'll use some cond* for my more complicated stuff from now on :)

8:42 khaliG: i think that's rich considering a lot of the clojure hype revolves around "look we're lisp and it's so cool" :)

9:01 TimMc: khaliG: Meh, it's a syntactic difference within the paren paradigm.

9:04 The fact that you can define your own cond is... telling.

9:06 khaliG: TimMc, it makes no sense though

9:06 the 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 :/

9:06 Chousuke: bsteuber: I tend to use commas if I have long cond expressions

9:07 just as a visual marker

9:08 khaliG: timb_, at the cost of clarity for the actual person writing code in the language

9:08 TimMc, even

9:10 bsteuber: Chousuke: yes I used ;;;; in between, but it still doesn't look that nice to me

9:10 TimMc: khaliG: I thought it would annoy me, but it hasn't.

9:11 I'm guessing it was just a personal decision by Rich -- he didn't like the extra grouping parens, so he nuked 'em.

9:11 khaliG: TimMc, sounds like a funny kind of design decision - sigh

9:14 TimMc: Eh, when you write a new language... it's good to be king. :-P

9:15 "commas are whitespace" doesn't bother you more?

9:15 Chousuke: bsteuber: it'd help if indentation didn't ignore the commas

9:15 commas being whitespace is a genius feature

9:15 it means you don't need extra syntax to allow for better readability.

9:16 you have a character that can be used as a visual cue wherever you find it appropriate

9:18 khaliG: 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.

9:18 even if it might help legibility in some cases

9:19 in most cases it's just extra noise

9:19 khaliG: it's not extra noise adding extra commas and explicit dos?

9:19 Chousuke: it is, but it's optional extra noise

9:19 khaliG: it's far more obscuring

9:20 Chousuke: added there whenever it's needed

9:20 khaliG: doesnt make sense

9:20 Chousuke: and using do explicitly is a good thing anyway

9:20 since it warns the reader that you have side-effects

9:20 it makes a lot of sense

9:20 khaliG: you use cond because when/if aren't enough - which means you need more functionality like that of the traditional cond

9:21 all clojure cond does is make for neat one liner cond test/exp pairs - which isn't that common anyway

9:21 Chousuke: but clojure is a functional language. You don't need do most of the time.

9:21 khaliG: ha

9:21 Chousuke: and when you do, it's good that it's explicit

9:21 khaliG: that whole java library thing makes the nonfunctional stuff pretty important

9:21 Chousuke: for the reason I stated

9:21 clojurebot: Something weird that I noticed: & (use '[clojure.contrib.json :as json]) & &| (json/pprint-json nil) |&

9:21 lazybot: java.lang.Exception: No such namespace: json

9:22 khaliG: but i guess if you're doing a lot of clojure4 problems then you dont need a proper cond :)

9:22 Chousuke: I don't see what's improper about Clojure's cond

9:22 khaliG: ok brb blog post

9:22 Chousuke: the lack of grouping is a difference, but it's not like it makes Clojure's cond any worse

9:35 TimMc: lazybot: Why did you respond to that?

9:37 does that mean I can: &(+ 1 2)

9:37 Guess not.

9:38 Bronsa: probably &| (+ 1 2) |&

9:38 lazybot: ⇒ 3

9:38 Bronsa: yes

9:40 TimMc: Huh. Why is that available when ##(+ 1 2) works just fine?

9:40 lazybot: ⇒ 3

9:41 TimMc: Perhaps an existing trigger.

11:47 * gfrlog digs around in cljs.core trying to figure out how to do instanceof

11:56 dnolen: gfrlog: instance?

11:59 pdk: ,(instance 1 Integer)

11:59 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: instance in this context, compiling:(NO_SOURCE_PATH:0)>

11:59 pdk: ,(= (type 1) Integer)

11:59 clojurebot: false

11:59 pdk: ,(= (class 1) Integer)

11:59 clojurebot: false

12:00 dnolen: ,*clojure-version*

12:00 clojurebot: {:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"}

12:00 pdk: ,(juxt (class type) 1)

12:00 clojurebot: #<core$juxt$fn__3805 clojure.core$juxt$fn__3805@408add>

12:00 pdk: ,((juxt (class type) 1))

12:00 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn>

12:00 pdk: ffs

12:00 ,[(type 1) (class 1)]

12:00 clojurebot: [java.lang.Long java.lang.Long]

12:00 pdk: well there ya go i guess

12:05 TimMc: ,((juxt [class type] 1))

12:05 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector>

12:06 TimMc: ,((juxt class type) 1)

12:06 clojurebot: [java.lang.Long java.lang.Long]

12:07 TimMc: ,(instance? Long 1)

12:07 clojurebot: true

12:08 TimMc: class is probably the more appropriate one here

12:20 ikr: Hi all. What's a proper shortening for (rest (rest (rest a-sequence)))?

12:20 dnolen: ,(drop 3 [1 2 3 4])

12:20 clojurebot: (4)

12:21 ikr: dnolen: super. Thanks!

12:25 Vinzent: (nth (iterate rest [1 2 3 4]) 3) is longer, but closer to the original ;)

12:31 ikr: Vinzent: OK, got it. Thanks.

12:44 dnolen: wow, ClojureScript actually makes JavaScript prototypes useful.

12:52 skelternet: dnolen, how so? tell me more

12:53 dnolen: skelternet: the compiler namespaces everything for you. so you even modify natives w/o fear.

12:54 prototypes are JavaScript most powerful feature but interoperability reasons nobody extends natives.

12:54 which is crippling for productivity.

12:54 skelternet: I 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:54 natives being the base-level prototypes?

12:55 dnolen: skelternet: compared to Clojure, JS looks like caveman stuff.

12:55 and I've been writing JS now for 6 years.

12:55 skelternet: yes

12:55 Object, Array, Element, CSSStyleDeclaration, XMLHttpRequest etc

12:56 jblomo: i'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:56 seems to be triggered by setting up a DiagnosticGroups in the closure compiler: options.setWarningLevel(DiagnosticGroups.NON_STANDARD_JSDOC

12:57 skelternet: my recollection from Hickey's presentation is that advanced mode is more aggressive about removing code it thinks will not be called

13:00 dnolen: being able call seq on CSSStyleDeclaration cause we extend-type'd to ISeqable is just too awesome

13:14 troussan: question 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:29 jamiltron: I'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:33 pandeiro_: how do i require a clojurescript file so I can use and test its functions at the cljs repl?

13:34 jblomo: pandeiro_: (require '[clojurescript.file :as file])

13:34 (file/functions stuff)

13:36 pandeiro_: 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:37 jblomo: the file name is determined by the namespace, so

13:38 how are you running a repl?

13:38 pandeiro_: in emacs as a shell, from the dir that my cljs file is in

13:41 I get a use of undeclared Var cljs.user/require ... something must be very wrong?

13:41 jblomo: oh.. yea :)

13:42 I recommend downloading leiningen and using `lein repl`

13:42 that will get you setup for making a full project as well

13:43 it also has emacs integration features, though I'm not familiar with them

13:43 pandeiro_: 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:45 jblomo: oh i see, so your clojurescript isn't compiled yet?

13:51 pandeiro_: 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:52 Bronsa: troussan: i am not a Compiler guru but that looks like a bug

13:52 jblomo: pandeiro_: yea, i haven't had much experience with the repl specifically

13:52 pandeiro_: dont know how i missed this:

13:52 https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments

13:53 but i am gonna take a look now and hopefully it will sort me out

13:53 thanks for the help

14:27 Nocab: so

14:27 to me (cond) seems very much like case

14:27 are there any particular distinctions I should be aware of? :)

14:28 gfrlog: I did not know there was such a thing as case.

14:28 Nocab: (case boo :case1 moo :case2 foo ) ; etc

14:28 to me that reads like cond

14:29 hugod: case expressions have to be compile time literals, I believe

14:29 gfrlog: I'm reading the case docs, and it seems like it is used just for literals

14:29 Nocab: ah ok

14:29 gfrlog: which is presumably purely for optimization

14:29 "Unlike cond and condp, case does a constant-time dispatch, the

14:29 clauses are not considered sequentially."

14:30 Nocab: right right

14:30 gfrlog: what command do you do to get those docs?

14:30 I know I have it written somewhere in this clojure book, but I can remember where :P

14:30 gfrlog: ,(doc case)

14:30 clojurebot: "([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:30 * Nocab tries

14:30 gfrlog: and when you're extra curious, ##(doc source) is also a good function

14:30 lazybot: java.lang.Exception: Unable to resolve var: source in this context

14:31 gfrlog: okay my point was that source is a good function too, so you could call (source case)

14:31 lazybot is uncooperative

14:31 Nocab: gfrlog: well that was easy. thanks :)

14:31 gfrlog: Nocab: np

14:37 thorwil: (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:37 gfrlog: thorwil: try (apply str my-coll)

14:38 or more efficiently...

14:38 use clojure.string/join instead of interpose

14:39 faust45: hi guy's

14:39 gfrlog: hi faust45

14:40 thorwil: gfrlog: works and good pointer, thanks!

14:40 gfrlog: thorwil: np

14:44 bsteuber: I'm trying to get a cljs browser repl up and running

14:44 faust45: can 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:45 bsteuber: but somehow a) the repl promt is shown before I open the browser window and b) it hangs after any input

14:45 gfrlog: bsteuber: 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:45 bsteuber: any ideas?

14:45 gfrlog: hmm

14:46 bsteuber: gfrlog: I thought it's like brepl, so a repl running in a shell whose outputs are in the browser

14:46 or at least side effects

14:46 gfrlog: bsteuber: right

14:46 based on your following comment I didn't need to say anything

14:46 you don't have a second browser-repl-tab open do you?

14:47 bsteuber: nope

14:47 so even if I have none I already get the promt

14:47 gfrlog: and you're not using Netscape 3?

14:47 hugod: bsteuber: a) is correct, b) probably your (repl/connect "http://localhost:9000/repl") line isn't being loaded by what require you are doing on the web page

14:47 bsteuber: tried stable chromium and firefox

14:47 gfrlog: okay well you've exhausted all my ideas then

14:51 Mohikaner: hmm 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:51 gfrlog: Mohikaner: http://twitter.com/#!/stuartsierra/status/110046298383712257

14:51 that's all I know :)

14:52 also that I use openjdk-6 for clojure all the time, if that's what you were asking

14:52 Mohikaner: ah good to know thanks

14:53 bsteuber: hugod: I'm fairly confident it is, because an iframe with some xhr connection was created

14:55 hugod: bsteuber: and no browser console errors, I take it

14:58 bsteuber: nope

14:59 weird, I did it in a fresh minimalistic setup and it works

14:59 so I must have done something wrong with hiccup or other stuff

15:35 mjg123: ,(let [A true B false] (and A B))

15:35 clojurebot: false

15:36 mjg123: good. How can I get the same effect if A and B are defined in a map, as in {'A true 'B false} ?

15:36 it looks like I could use with-bindings, but I can't figure it out

15:37 tufflax: ,(let [{:keys [a b]} {:a true :b false}] (and a b))

15:37 clojurebot: false

15:37 tufflax: is one way

15:37 :P

15:38 mjg123: that's interesting

15:39 tufflax: ,(let [{:symbols [a b]} {'a true 'b false}] (and a b))

15:39 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form: :symbols>

15:39 tufflax: ,(let [{:syms [a b]} {'a true 'b false}] (and a b))

15:39 clojurebot: false

15:40 mjg123: thanks

15:41 troussan: mjg123: form more than two : (every? (fn [[k v]] v) {'a true 'b false})

15:42 tufflax: isn't (fn [[k v]] v) simply val?

15:43 troussan: correct

15:43 tufflax: ,(map val {a true})

15:43 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>

15:43 tufflax: ,(map val {:a true})

15:43 clojurebot: (true)

15:45 mjg123: for 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:46 I 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:47 solussd: how can I make this not cause a stack overflow for large numbers? (defn ! [x] (if (zero? x) 1 (apply * ((juxt identity #(! (dec %))) x))))

15:47 tufflax: 'for' might be useful

15:47 ,(for [a [true false] b [true false]] [a b (and a b)])

15:47 clojurebot: ([true true true] [true false false] [false true false] [false false false])

15:49 mjg123: yep - exactly :)

15:50 problem 48 of the 99 lisp problems: http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html

15:51 tufflax: solussd try to save the value of (! (dec x)) in an accumulator

15:52 solussd read SICP ;)

15:53 bsteuber: hugod: it seems the problem is having the out directory being served by jetty

15:53 if I directly open the html from disk it works fine, but if I I use the served version it breaks

15:54 mdeboard: (some #{"l"} '("l" "h" "c"))

15:54 ,(some #{"l"} '("l" "h" "c"))

15:54 clojurebot: "l"

15:55 mdeboard: Is there an idiomatic way of checking for membership in a collection besides this?

15:55 hugod: bsteuber: out of interest, was the path to out specified relative to the html file?

15:55 bsteuber: yes

15:56 but it should be same both ways because the html file lies in public

15:56 tufflax: mdeboard i can't think of any. why? is there something wrong with that one?

15:57 mdeboard: That's the question I was trying to get the answer to myself :P Apparently the answer is "no"

15:59 tufflax: mjg123 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:59 i mean, normally

16:00 (i'm aware that these _are_ exercises)

16:01 mjg123: you mean the infixing? A or B instead of (or A B) ?

16:01 tufflax: yes

16:02 mjg123: Yeah - I don't mind about that so much. Am happy if I can call (table [A B C] (or A (and B C)))

16:02 tufflax: it might be a fun exercise but there isn't much point to it i think (but you shouldn't trust me completely)

16:03 mjg123: it's a good exercise (for me) because the truth-table itself seems to need a non-trivial macro

16:03 but I'm not getting anywhere particularly fast - although I *am* learning stuff :)

16:06 TimMc: ,(contains? #{nil 1 2} nil)

16:06 clojurebot: true

16:06 TimMc: ,(#{nil 1 2} nil)

16:06 clojurebot: nil

16:07 TimMc: mdeboard: If you have a set, contains? will work. (contains? checks for keys, not values)

16:07 And then there is always the Java Collections API.

16:08 ,(.indexOf [3 4 nil 5] nil)

16:08 clojurebot: 2

16:10 tufflax: mjg123 yeah the truth table seems to be a good one

16:11 mdeboard: TimMc: Thanks. I'm just looking for a way to validate user input

16:12 TimMc: OK. Just note that nil can be a special case for memebership.

16:12 bsteuber: hugod: lol, all I needed to do was restarting jetty :)

16:13 so I guess it didn't reflect all changes to the public dir

16:13 mdeboard: TimMc: What do you mean?

16:13 tufflax: ,(some #{1} ())

16:13 clojurebot: nil

16:14 TimMc: mdeboard: .indexOf and contains? can both tell you if nil was found in the collection. Using sets as functions cannot.

16:14 tufflax: ,(some #{nil} [nil])

16:14 clojurebot: nil

16:15 mdeboard: Tricky

16:15 TimMc: This is the price of "soft booleans" or whatever they're called.

16:16 They are hepful 99.999% of the time, though. :-)

16:16 mdeboard: I think for this extra credit problem for Computing II it ought to suffice :P

16:18 tufflax: it is a course in a school and u get to use clojure? i wish i was able to

16:19 TimMc: tufflax: I was able to do that in 2 classes in my senior year at Northeastern University.

16:19 The Computer Architecture prof was a little grumpy about it, being a solid C guy.

16:20 tufflax: problem 1) automatic judges that don't understand clojure. problem 2) manual judges that don't understand clojure

16:20 TimMc: Comp Graphics was wide-open, though.

16:22 tufflax: but 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:23 hugod: bsteuber: 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:25 TimMc: tufflax: Do it!

16:25 Any ideas for topics yet?

16:25 tufflax: nope, but i have read mostly theoretical sc and ai

16:26 s/sc/cs/

16:26 lazybot: <tufflax> nope, but i have read mostly theoretical cs and ai

16:27 tufflax: so i'm sure i can come up with something that fits

16:29 mdeboard: tufflax: The extra credit is, "Rewrite this in another language"

16:29 tufflax: mdeboard perfect :p

16:29 mdeboard: He didn't specify any other restrictions on language choice :P

16:29 seancorfield: Q about deftype - can you have an optional field?

16:30 mdeboard: unfortunately I'm unbelievably rusty with clojure :-\

16:35 Does the question mark have any special significance at the end of a function name, e.g. (is-valid?) ?

16:36 tufflax: no, just part of the name

16:36 gfrlog: mdeboard: it's idiomatic to mark the function as a predicate

16:36 mdeboard: ok

16:36 gotcha

16:36 gfrlog: seancorfield: I, who have little authority to speak on the matter, doubt it.

16:38 tufflax: as a resident of sc, I find your most recent typo rather thought-provoking.

16:38 tufflax: oh yeah? :p

16:39 gfrlog: I can't decide what it ought to mean though.

16:40 seancorfield: gfrlog: 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:40 mdeboard: Is there a fix for read-line not working as expected in the slime repl

16:43 * gfrlog tries to get the clojurescript tests to run

16:44 bsteuber: hugod: I'm using noir's default structure, so resources/public/js

16:44 and resources/public will automatically be served by noir

16:45 hugod: seancorfield: don't you just implement IObj?

16:46 bsteuber ok, does load-file work from the repl then?

16:48 * gfrlog gives up on being able to run the tests

16:52 gfrlog: the gclosure documentation is a little quirky... :/

16:54 bsteuber: hugod: in theory yes, but you need the stuff on the class-path I guess

16:57 TimMc: mdeboard: I woud go with valid?, since the is- is kind of redundant when there's a question mark.

16:58 But it's just a name.

17:00 mdeboard: TimMc: No, I agree, good point.

17:00 TimMc: isValid is how Java would do it -- lacking question marks for names. :-P

17:00 * gfrlog considers tense variants such as was-valid?, could-have-been-valid?, and will-wish-it-had-been-valid?

17:01 * hugod reads about __meta

17:02 gfrlog: hugod: is that where cljs puts metadata?

17:04 mdeboard: Isit legit to 'initialize' loop with no args, e.g. (loop [] ... )

17:04 gfrlog: mdeboard: totally

17:04 mdeboard: Oh, ok.

17:04 gfrlog: I think that's the normal way to do a while(true) sort of thing. Presumably it's for side effects.

17:04 mdeboard: Ok, that's exactly what I'm using it for, main loop of this thing

17:05 hugod: gfrlog: re seancorfield's question on metadata for deftype

17:05 gfrlog: mdeboard: I've done that dozens of times, and every single line of my code has been personally signed off on by Rich Hickey.

17:05 mdeboard: Ok, I'm going to copy-paste that into a comment in the code

17:06 :P

17:06 gfrlog: s/been personally signed off on/never been looked at/

17:06 lazybot: <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:06 mdeboard: hahaha

17:06 gfrlog: sorry, I make that typo all the time

17:06 mdeboard: Too late

17:07 gfrlog: is this site the best for gclosure docs? http://closure-library.googlecode.com/svn/docs/class_goog_graphics_AbstractGraphics.html

17:08 it seems to be missing the top-level functions in each package. Or at least I don't know where to find them.

17:15 troussan: seancorfield: looks like compiler inserts __meta field for deftype and defrecord. may be 1.2 was ignoring it when generating the constructor

17:19 dnolen: troussan: compiler should not insert __meta for deftype, only defrecord.

17:26 troussan: dnolen: thats true. I was looking at emit-defrecord

17:27 gfrlog: I found out last night that cljs only allows one :require in a (ns) declaration

17:28 dnolen: gfrlog: the list of things like that is long ;)

17:28 gfrlog: I bet

17:28 dnolen: but what is there is awesome

17:29 mjg123: someone mind helping my macro-fu?

17:29 https://gist.github.com/1210153

17:29 * gfrlog runs off to look at it

17:30 gfrlog: mjg123: what's this macro supposed to do?

17:31 mjg123: there's an example in the code (which I just updated with expected output)

17:31 gfrlog: so the point of it being a macro is so that the second arg doesn't need a (fn [x] ...) wrapper?

17:31 mjg123: yep

17:32 and, I ought to be able to infer the list of boolean inputs by looking at ALL-CAPS symbols in the 2nd arg

17:32 then I wouldn't need the first arg

17:32 gfrlog: whenever 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:33 that way the macro does only the little bit that requires a macro

17:33 mjg123: sounds like that would make it simpler, yes

17:33 gfrlog: it makes these situations easier to sort through :)

17:33 although your problem of needing to know the args sounds hairy

17:35 mjg123: so how is it misbehaving?

17:36 mjg123: I want to remove the first arg,

17:36 so 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:37 gfrlog: oh okay. So it's currently working and you're just asking for help refactoring it?

17:37 mjg123: yes

17:37 :)

17:38 gfrlog: could you add (let [vs# (-> vs2# distinct sort)] ...)?

17:38 mjg123: yes that's needed too :)

17:38 gfrlog: I guess I don't see what else needs to be done

17:39 I guess you don't need a separate vs and vs2, right?

17:39 I'd write a helper function that takes the expression and returns the variables

17:39 Mike|home: I'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:39 Problem, rather*

17:40 gfrlog: Mike|home: I'm certainly bored enough to try

17:40 mjg123: gfrlog, I'd like to remove vs, but I'm having trouble working out what to put in lines 19 & 20

17:40 gfrlog: or at least hear what it is :)

17:40 mjg123: instead of ~vs

17:43 gfrlog: mjg123: so you start off with (let [vs# (variables-in `~pred)] ...)

17:43 and just use vs# wherever you need the list of variables

17:45 mjg123: gfrlog, I get a lot of "Don't know how to create ISeq from: clojure.lang.Symbol" errors

17:45 :(

17:46 gfrlog: mjg123: did you create the variables-in function?

17:51 mjg123: gfrlog yep: still working...

17:51 gfrlog: mjg123: maybe an updated gist would be helpful? :)

17:53 jrabbit: I'm trying to use https://github.com/stackoverflow/date-clj

17:55 I keep getting java.lang.Exception: Unable to resolve symbol: date in this context (NO_SOURCE_FILE:3)

17:55 when I use lein repl

17:55 or clooj

17:55 oooh I needc to switch into a ns that uses it >_>

17:55 odd

17:58 mjg123: gfrlog, yeah - here's where I am now: https://gist.github.com/1210177 - but it doesn't work any more :(

18:00 I suppose pr-truth-table* can be a plan fn now rather than a macro ?

18:00 mdeboard: is the "else" clause of an if statement considered tail position wrt (recur)

18:00 gfrlog: mjg123: certainly, that was the idea

18:01 mdeboard: i feel like i read either position in the statement is considered tail as long as the if statement is in the tail position

18:01 gfrlog: mdeboard: yes, both clauses are tail positions

18:01 mdeboard: gfrlog: thanks

18:03 gfrlog: mjg123: also you could pull the call to variables-in outside of the quote

18:03 bsteuber: are there any standards yet on how to package cljs libraries?

18:04 gfrlog: so (let [vs (variables-in pred)] `(...

18:04 (inc bsteuber)

18:04 lazybot: ⟹ 1

18:04 gfrlog: bsteuber: 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:04 bsteuber: good point

18:05 gfrlog: perhaps use a regex in your filenames, e.g. "shared_code.cljs?"

18:07 bsteuber: I was thinking of using something like resources/cljs for cljs-only code to be not confused with server code

18:07 but that seems a bit hacky

18:07 though it might be the only way to have it work out of the box with lein

18:07 gfrlog: bsteuber: I _think_ I've seen the clojurescript (and others?) project user src/clj/... and src/cljs/...

18:07 bsteuber: besides munging everything in src

18:08 gfrlog: bsteuber: I definitely don't like the idea of cljs in resources, since you shouldn't need the cljs at runtime

18:08 bsteuber: agreed

18:08 mdeboard: er

18:09 how does lein run work :\

18:09 gfrlog: mdeboard: I think you have to define a main class? maybe...

18:09 or something

18:09 actually I have no idea and shouldn't have said anything.

18:09 bsteuber: yes :main my.namespace in project.clj

18:09 mdeboard: well, 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:10 bsteuber: `:main my.namespace in project.clj`?

18:10 bsteuber: yes

18:10 and in my/namespace.clj you need a :gen-class in the ns declaration

18:10 as well as a (defn -main [] ...)

18:11 mdeboard: what

18:11 ok

18:11 really? ok

18:11 mjg123: there's a lot of examples in the sample.project.clj on the lein github

18:11 gfrlog: mdeboard: and all that should also get you an executable jar

18:11 jrabbit: whats the difference between "(is? (today) :sunday)" and "(-> (today) (is? :sunday))"

18:11 bsteuber: main-classes are a java concept, so you need to generate a java class

18:12 jrabbit: should be no difference

18:12 jrabbit: well I mean what is -> doing

18:13 gfrlog: jrabbit: transforming the second expression into the first :)

18:13 jrabbit: the clojure documentation is a little opaque to understand

18:13 seancorfield: troussan: dnolen: __meta is not available in deftype as far as i can tell from tests

18:13 jrabbit: gfrlog: thats bizzare

18:13 bsteuber: so if you have lot's of nested forms like that, it improves readability

18:13 gfrlog: jrabbit: it's bizarre at first. It lets you avoid lots of nesting.

18:13 jrabbit: ah ok

18:13 whats a larger example of that?

18:13 gfrlog: jrabbit: once you get the aha moment, it becomes totally brilliant and you use it all the time

18:13 seancorfield: defrecord 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:14 bsteuber: think of (a (b (c (d (e 42)))))

18:14 gfrlog: (a (b (c (d)))) becomes (-> (d) (c) (b) (a)

18:14 bsteuber: compared to (-> 42 d e c b a)

18:14 jrabbit: oh

18:14 bsteuber: gfrlog: you can drop the parens

18:14 seancorfield: but clojure.data.priority-map now passes tests on 1.2 and 1.3: http://build.clojure.org/job/data.priority-map-test-matrix/

18:14 jrabbit: thats pretty slick the longer it gets

18:14 gfrlog: bsteuber: yeah I thought that would be confusing

18:14 dnolen: seancorfield: yes I know meta shouldn't be.

18:14 jrabbit: ok I see why that'd be cool on longer things

18:15 also is there a syntax hilighted repl?

18:15 gfrlog: jrabbit: also see ->> for comparison

18:16 jrabbit: gfrlog: is it the reverse?

18:16 gfrlog: jrabbit: it inserts things as the last argument instead of the first

18:16 mjg123: jrabbit: depends what you like - IntelliJ vi emacs all do syntax highlighting

18:16 bsteuber: -> puts stuff as the first argument, ->> as last argument

18:17 jrabbit: so whats that look like in that previous example?

18:17 bsteuber: so (-> 42 (foo a b)) becomes (foo 42 a b)

18:17 but (->> 42 (foo a b)) becomes (foo a b 42)

18:17 jrabbit: ahhh

18:18 bsteuber: so it doesn't matter for one-argument functions like I had before

18:18 jrabbit: and a dumb question whats the print macro/function?

18:18 gfrlog: jrabbit: print is like System.out.print()

18:18 mjg123: is there a good way to thread a series of functions which some need -> and some ->> ?

18:18 jrabbit: oh print is print :p

18:19 * jrabbit just had seen some weird names for it in other lispy things

18:19 bsteuber: mjg123: no standard way, so maybe just use let with explicit names for the intermediate results

18:20 gfrlog: mjg123: actually

18:20 yes

18:20 jrabbit: why does (if (is? (today) :sunday) (print "hi \n")) yeild "hi" then nil?

18:20 is print returning nil?

18:20 mjg123: yes

18:20 gfrlog: jrabbit: print returns nil, and if returns nil if the condition is false and there's no else

18:20 jrabbit: ah ok

18:21 bsteuber: all stuff that is void in java returns nil in clojure

18:21 more or less

18:21 jrabbit: cool I think I can make something useful now :)

18:21 gfrlog: mjg123: ##(-> 30 (range) (distinct) (->> (map inc)))

18:21 lazybot: ⇒ (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:21 mjg123: oh what?

18:21 bsteuber: yes ->> inside -> works

18:21 but the other way doesn't

18:21 gfrlog: mjg123: obviously it's not necessary there, but that shows you how you can mix them syntactically

18:22 bsteuber: so be careful

18:22 gfrlog: bsteuber: right

18:22 oh also

18:22 you can always insert function literals

18:23 &(-> 30 range ((fn [coll] (map inc coll))))

18:23 lazybot: ⇒ (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:23 gfrlog: that can give you arbitrary control

18:23 bsteuber: gfrlog: good point

18:24 please note the additional level of parens around fn

18:24 gfrlog: indeed

18:24 mjg123: ,(-> 30 range (->> (filter even?)) #(* % %))

18:24 clojurebot: #<CompilerException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentVector, compiling:(NO_SOURCE_PATH:0)>

18:24 mdeboard: I 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:25 Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/IFn

18:25 gfrlog: mdeboard: you don't execute the jar directly, you "java -jar my.jar"

18:25 mdeboard: oh

18:25 I knew that

18:25 good news gfrlog, you passed my test!

18:25 gfrlog: mdeboard: by "executable jar" I just meant a jar that provides a default main class so you don't have to specify it

18:25 mdeboard: now give me my dang diploma

18:26 mdeboard: still get that exception: Could not find the main class: numguess.core. Program will exit.

18:26 gfrlog: mjg123: I have no idea what that expression was trying to do

18:26 numguess? Are you writing the program I wanted to write?

18:27 mdeboard: almost certainly not

18:27 gfrlog: darnit.

18:27 so you have a function called -main?

18:27 mdeboard: http://p.mattdeboard.net/numguess.html

18:27 yeah

18:28 gfrlog: mdeboard: oh I think it needs to take an arg

18:28 or varargs. I forget which.

18:28 mjg123: gfrlog, it was trying to be ##(-> 30 range (->> (filter even?) (map #(* % %))))

18:28 lazybot: ⇒ (0 4 16 36 64 100 144 196 256 324 400 484 576 676 784)

18:29 gfrlog: mjg123: those are nice numbers

18:29 mjg123: thanks

18:30 gfrlog: it's hard to come up with natural examples that require both -> and ->>

18:30 mjg123: I've had exactly the problem of wanting to thread a (map) halfway through

18:32 bsteuber: gfrlog: no -main doesn't need arguments

18:32 though I'm not sure whether args are allowed

18:32 I'd rather guess not, but no idea

18:32 gfrlog: bsteuber: you mean varargs?

18:32 bsteuber: no arguments at all

18:33 gfrlog: bsteuber: certainly you need a way to get the command line args

18:33 bsteuber: I thought the way for reading command-line args is different

18:33 gfrlog: it's either a single arg that is a string seq, or it's varargs

18:33 I've definitely done it that way

18:33 bsteuber: they're in *command-line-args* - that was it :)

18:34 gfrlog: it's supposed to be the same to the JVM as public static void main(String[] args){...}

18:34 oh I remember that var.

18:35 mdeboard: bsteuber: So, do you have any insight on what's going wrong with my deal

18:36 Or rather, what I'm doing wrong with my deal

18:36 gfrlog: mdeboard: I'd use "jar tf my.jar" on your jarfile to see if the class is there

18:36 bsteuber: does (-main) work from the repl?

18:37 mdeboard: Oh, I have ":main numguess.core in core.clj" but in the class list it has "numguess/core"

18:37 matter?

18:37 clojurebot: http://www.math.chalmers.se/~rjmh/Papers/whyfp.pdf

18:37 gfrlog: mdeboard: no that should be the same

18:37 bsteuber: mdeboard: do you use emacs?

18:38 gfrlog: clojurebot: forget matter

18:38 clojurebot: http://www.math.chalmers.se/~rjmh/Papers/whyfp.pdf

18:38 mdeboard: bsteuber: Yep, It's tough to test the function because it relies heavily on read-line which sucks in slime-repl

18:38 bsteuber: ah

18:38 gfrlog: mdeboard: where do you get the error? compiling or running the jar?

18:38 mdeboard: and by "sucks" I mean "is broken"

18:38 bsteuber: so you get an IFn not defined error right?

18:38 mdeboard: gfrlog: running

18:38 bsteuber: that's perfectly normal

18:39 mdeboard: bsteuber: yeah

18:39 bsteuber: because your jar doesn't include the clojure.jar

18:39 mdeboard: Could not find the main class: numguess.core. Program will exit.

18:39 bsteuber: so you either have to include that to the classpath

18:40 mjg123: what is the name of your jar file?

18:40 bsteuber: so try "lein uberjar"

18:40 mjg123: I mean, are you definitely running the *-standalone.jar ?

18:40 mdeboard: bsteuber: running `lein uberjar` atm

18:41 bsteuber: and then java -jar foo-1.0.0-SNAPSHOT-standalone.jar

18:41 mdeboard: `java -jar numguess-1.0.0-standalone.jar` => "Could not find the main class: numguess.core. Program will exit."

18:41 bsteuber: hmm

18:41 mdeboard: bsteuber: Look right? http://p.mattdeboard.net/ngproj.html

18:42 gfrlog: mdeboard: have you tried sacrificing any moderate-sized animals?

18:42 mdeboard: bsteuber: output of `java tf numguess-1.0.0-standalon.jar`: http://p.mattdeboard.net/output.html

18:43 gfrlog: would that work

18:43 bsteuber: mdeboard: you've got the "in core.clj" in your file???

18:43 lazybot: bsteuber: Oh, absolutely.

18:43 mdeboard: bsteuber: Yea, you explicitly said to :P

18:43 gfrlog: oh dear

18:43 mdeboard: 13:09 <mdeboard> bsteuber: `:main my.namespace in project.clj`?

18:43 13:09 <bsteuber> yes

18:43 gfrlog: yes go sacrifice three sheepses and fix your project.clj

18:44 bsteuber: ok what I meant was edit the project.clj file to include :main numguess.core

18:44 gfrlog: also why aren't the deps included in the `jar tf`?

18:44 bsteuber: sorry I overlooked the quotes ^^

18:45 mdeboard: rm'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:46 gfrlog: I think it will clean for you

18:46 bsteuber: sometimes you need to run "lein deps" on your own before

18:46 the rest should be fine

18:46 mdeboard: sill the same issue :-\

18:48 think I figured it out.

18:48 ya

18:48 gfrlog: the sheep?

18:48 mdeboard: It was that "local-repo-classpath" line in project.clj

18:48 bsteuber: huh I never used that

18:48 mdeboard: I forget why I included that

18:48 think technomancy suggested it once, or something.

18:49 bsteuber: interesting

18:49 btw I like your clojure-html formatting

18:50 is that some standard one?

18:50 mdeboard: scpaste module for emacs

18:50 the best

18:50 * gfrlog shakes his fist stubbornly at emacs

18:51 bsteuber: wow so it works for any color-scheme

18:51 that's totally awesome

18:51 mdeboard: ya

18:52 bsteuber: though it won't help you with code you don'T have in emacs

18:52 mdeboard: no such thing

18:52 bsteuber: because it's someone else's code or whatever and you'Re too lazy to do it for each file

18:53 mdeboard: wrong, 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:53 feh, mortals.

18:53 * mdeboard strokes his beard

18:54 mdeboard: *cough* But yeah seriously I use dpaste a lot too :)

18:54 bsteuber: :)

18:55 mdeboard: lol wow I can't believe this works :|

18:55 bsteuber: just imagining an endless cluster of amazon machines running emacs to format all github code at once :)

18:55 mdeboard: I'm just going to upload the source and the jar without comment

18:56 along with the C++ original

18:56 see how/if he reacts, since brainless TAs grade all his shit

18:57 bsteuber: clojure/c++ code comparison is always funny

18:58 mdeboard: actually the clojure source is only 4 or 5 lines shorter than the C++ one

19:07 jrabbit: Exception 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:07 trying to run compojure/ring with

19:07 :ring {:handler src.is_saga_open.core/app}) where I have thisr file in src

19:07 $ ls src/is_saga_open/

19:07 core.clj

19:13 https://github.com/jrabbit/Is-SAGA-open- >_>

19:14 gfrlog: jrabbit: change project.clj to {:handler is-saga-open.core/app}

19:14 that might not fix it, but I think you need that either way

19:14 jrabbit: the file is _ though

19:15 oh I see the namespace is -s

19:15 gfrlog: exactly

19:16 and you don't want src there, since that isn't part of the ns-name

19:16 jrabbit: ah ok

19:16 that makes more sense now

19:16 I was thinking it wanted the path to the file not a namespace

19:16 yay it works :)

19:16 gfrlog: w00p

19:17 jrabbit: any idea if ring reloads? :P

19:17 gfrlog: I think if you start with "lein ring server" it will

19:17 jrabbit: neat

19:17 gfrlog: thanks

19:18 gfrlog: jrabbit: np

19:38 mdeboard: I've written exactly three working Clojure programs, and I'm shocked as hell every time

19:42 Can anyone tell me why the "Got it" line doesn't print when its condition is satisfied?

19:42 http://paste.pocoo.org/show/474365/

19:42 The program just halts, which would otherwise be ok except I want some kind of alert that it got solved in there :P

19:43 brehaut: mdeboard: not related to your bug, but if-not is a useful macro

19:45 mdeboard: brehaut: thanks, what does that get me over just (if (not (foo)))

19:45 brehaut: one less pair of parens

19:45 mdeboard: iuc

19:45 oic*

19:47 brehaut: No insight on the line not printing though eh :\

19:47 brehaut: mdeboard: i have no idea what the implementation of answer-case is

19:47 mdeboard: brehaut: http://p.mattdeboard.net/numguess.html

19:47 jrabbit: any idea how to do classes/ids in hiccup?

19:48 brehaut: :div.class#id

19:48 jrabbit: brehaut: ah

19:48 brehaut: im not a hiccup expert

19:49 mdeboard: (defn correct [] false) is weird

19:49 mdeboard: brehaut: Yeah :-\

19:50 guess I could just remove that function and make `"c" false`

19:50 brehaut: indeed

19:51 mdeboard: Yeah I'm totes confused on that not outputting the string.

19:51 brehaut: give me some time

19:53 its working for me

19:53 mdeboard: Huh.

19:53 brehaut: however

19:53 if you are running this as a main

19:53 its not going to print the message

19:53 format just returns a string

19:53 mdeboard: Ah

19:53 brehaut: you need to print it

19:54 just calling (-main)

19:54 mdeboard: Hm I tried that, what then do I return

19:54 brehaut: does what you expect though

19:54 do you need to return something?

19:54 mdeboard: Well, I guess not.

19:55 brehaut: also, floor, ceiling, guess and counter probably shouldnt be distinct; make them a map and put one in the atom

19:55 (if you must use an atom)

19:55 mdeboard: Isn't an atom the correct data structure there

19:55 brehaut: theres no reason it cant just be data passed recursively

19:56 mdeboard: Less confusing to read this way, I think.

19:56 Especially since the grader will likely have no idea what Lisp is, let alone Clojure.

19:56 brehaut: mdeboard: if you use an atom it should probably be (def game (atom {:floor 0 :ceiling 100 :guess 50 :counter 1}))

19:57 mdeboard: What's the syntax to get the value when dereferencing

19:57 brehaut: (:floor @game)

19:57 mdeboard: (@game :floor)?

19:57 oh

19:57 brehaut: or that

19:57 but you are using the map as an object, so keywords as fns is prefered

19:57 mdeboard: I see, I like that better.

19:58 jrabbit: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn

19:58 what the heck is that

19:58 https://gist.github.com/1210319

19:59 mdeboard: (swap! (:counter game) + 1) ?

19:59 brehaut: jrabbit: without context for what today, weekends, weekday are its hard to tell

19:59 mdeboard: no, you need to push all the updates into a function to pass to swap

20:00 mdeboard: I see.

20:00 jrabbit: brehaut: oh that stuff works

20:00 its stuff from date-clj and some of my functions

20:00 mdeboard: brehaut: I made a note in the comments; another time when I don't have discrete math homework :P

20:00 brehaut: jrabbit: something at the head of a combination is a seq rather than a fun

20:01 jrabbit: https://gist.github.com/1210319

20:01 theres the whoel file

20:02 so basically I get a true/false then want to switch the page generated

20:03 mdeboard: Oh, that's handy, there's a printf :)

20:04 jrabbit: brehaut: found a fix

20:04 brehaut: mdeboard: (swap! game (fn [{:keys [counter ceiling guess] :as g}] (assoc g :counter (inc counter) :floor guess :guess (update-vals guess ceiling))))

20:04 jrabbit: its less sane but works

20:04 mdeboard: Ahh

20:04 ok

20:05 Changed (format "stuff %s" @thing) to (printf "stuff %s" @thing) but it still doesn't print the line.

20:05 Am I using the wrong metho dhere

20:05 brehaut: i have no idea

20:05 sorry i have to get back to work

20:05 mdeboard: ni yo tampoco

20:05 Yeah get back to work

20:05 bring home the bacon

20:06 thanks for the help

20:06 brehaut: jrabbit: 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:07 (at a guess)

20:07 bhenry: is 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:07 mdeboard: that is an excellent question

20:07 jrabbit: brehaut: its a function :\

20:08 brehaut: jrabbit: the result of include-css ?

20:08 jrabbit: brehaut: a [:style ..] hiccup element

20:08 gfrlog: bhenry: I don't think so. It's a good thing to define in a util.clj

20:08 brehaut: https://github.com/weavejester/hiccup/blob/master/src/hiccup/page_helpers.clj#L78-82

20:09 jrabbit: include CSS returns a lazy seq (thats the result ofa for)

20:09 jrabbit: brehaut: I got it working by seperating it out into two fucntions

20:09 brehaut: jrabbit: you have ((include-css …) …

20:09 jrabbit: then calling the functs in if

20:09 I donno :(

20:09 brehaut: jrabbit: if you dont understand why it didnt work you will hit this again

20:10 mdeboard: brehaut: Changed (print) to (println) and it worked. :|

20:10 brehaut: mdeboard: try (do (printf …) (flush))

20:11 mdeboard: brehaut: Yar, that worked.

20:12 brehaut: mdeboard: at a guess print without the ln isnt flushing stdout?

20:12 mdeboard: brehaut: Yeah that sounds reasonable.

20:13 bhenry: jrabbit: unless if has some weird trick i've never seen, you've done something wrong around 23/24.

20:15 seancorfield: if anyone has feedback on http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go pls email me sean@corfield.org

20:17 brehaut: seancorfield: thats a great resource

20:20 jrabbit: I've worked around it :\

20:34 gfrlog: mdeboard: I'm about 98% sure that it is the case that println flushes and print doesn't

20:34 mdeboard: oic

20:35 I think the point is that I wrote a clojure program and it woks.

20:35 works, too.

20:36 gfrlog: mdeboard: that's a good point

20:45 amalloy: &(+ 1 (doto 5 println)) ;; bhenry

20:45 lazybot: ⇒ 5 6

20:47 amalloy: and also https://github.com/flatland/useful/blob/develop/src/useful/debug.clj if you want something a bit more drop-in

20:49 bhenry: amalloy: nice

20:49 doto is cool.

20:49 amalloy: it's pretty sweet, yeah

21:22 xiaolongxia: I have a piece of clojurescript http://pastebin.com/errDKYEC that I'm trying to rewrite as more idiomatic clojure

21:23 the commented out block results in something like object.method.call(null, arg, arg, arg)

21:23 while I want what the original function produces which is object.method(arg, arg, arg)

21:25 amalloy: xiaolongxia: you probably want to use ##(doc doto)?

21:25 lazybot: ⇒ "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:26 xiaolongxia: amalloy: thanks

21:26 skelternet: What is the selling-point of clojurescript? Better UI development?

21:27 xiaolongxia: skelternet: depends

21:27 amalloy: ,(macroexpand '(doto (X.) (. (setFoo 2)) (. (setBar 3))))

21:27 clojurebot: (let* [G__8917 (X.)] (. G__8917 (setFoo 2)) (. G__8917 (setBar 3)) G__8917)

21:30 xiaolongxia: amalloy: i still haven't wrapped my head around macros, why is that better than doto by itself?

21:31 skelternet: I'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:32 dnolen: skelternet: 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:32 xiaolongxia: skelternet: one good use case is writing ALL of your logic in clojure. client or server side

21:33 dnolen: your blog about pattern matching really made me re-think the possibilities of clojurescript

21:33 dnolen: skelternet: it makes a lot JS frameworks / libraries seem, frankly, pointless.

21:34 xiaolongxia: cool! yeah having access to macros is just fantastic.

21:34 skelternet: *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:34 xiaolongxia: skelternet: also, goog closure + clojurescript is really pretty cool

21:34 if you look at that pastebin, that's all you need to make a gauge

21:35 based on this http://closure-library.googlecode.com/svn/trunk/closure/goog/demos/gauge.html

21:35 skelternet: I've only seen Hickey's presentation on clojurescript. Are the environments/frameworks shaping up?

21:36 dnolen: skelternet: 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:36 skelternet: tools will need to be tweaked to support Browser REPL

21:36 Emacs has inferior-lisp-mode so it's pretty trivial there.

21:38 xiaolongxia: amalloy: that solved my problem, thanks alot

21:40 amalloy: xiaolongxia: i don't think we understood each other. i was just showing you what the doto would expand to

21:43 xiaolongxia: amalloy: i follow you now.

22:16 dnolen: darn ClojureScript doesn't have reify yet

22:17 hugod: I 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:18 dnolen: hugod: example?

22:19 amalloy: hugod: last i heard, cljs doesn't have real namespaces at runtime

22:19 hugod: (load-namespace 'goog.math.size)

22:20 or (ns test.myns (:require [goog.math.size :as s]))

22:20 dnolen: hugod: both of those work for me

22:20 what's the exception?

22:21 hugod: java.lang.NullPointerException: name in cljs.closure/add-dependencies

22:21 let me doublecheck they are on the classpath…

22:22 dnolen: hugod: those work fine for me. have you set $CLOJURESCRIPT_HOME ?

22:24 hugod: this is running from pre-compiled js files

22:25 dnolen: hugod: I don't follow.

22:27 hugod: dnolen: I have run the cljs compiler and have all the js files . I then run the repl, and try those commands…

22:31 dnolen: hugod: are other things working?

22:31 for example:

22:31 repljs

22:31 (ns foo (:require [goog.date :as d]))

22:31 (d/Date.)

22:31 hugod: goog.date doesn't get included in my js

22:32 I picked goog.math.size since it was present

22:33 dnolen: hugod: but does that simple test at the repl work?

22:33 just trying to figure out how much isn't working for you.

22:33 hugod: dnolen: no

22:33 (+ 1 1) works, defn works

22:33 clojurebot: 2

22:33 dnolen: hugod: and your repo is up-to-date?

22:34 hugod: pulled this afternoon

22:34 dnolen: I just pull the latest and I can run the above snippest from any directory.

22:35 * hugod discovers repljs

22:37 hugod: dnolen: running repljs seems to work , thanks

22:37 dnolen: hugod: cool

22:37 hugod: I just need to work out what I'm doing differently now…

23:09 sconover: hi, I'm a clojure noob. is this the appropriate place to ask questions?

23:10 amalloy: well, it's a better place than #scala

23:11 sconover: I'm trying to use higher-level functions to accomplish a task

23:12 I 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:12 I'm trying to figure out the best way to "accumulate" or count as part of the predicate

23:13 srid: does anyone use pallet/jclouds to deploy to linode vms?

23:13 sconover: (take-while not(too-many-trues?) (take 8 booleans)))

23:14 amalloy: so you have a list like "+249*201-87", and you want to keep taking until you have (say) two punctuation marks?

23:14 sconover: i'm wondering how i'd implement too-many-trues? such that it flips to true after 3 trues are taken...

23:14 yeah that's a good example

23:15 amalloy: sconover: that's a neat problem. do you mind if i add it to 4clojure.com?

23:15 sconover: not at all

23:15 amalloy: cool. anyway, i don't think take-while is a good tool because it can only look at the current element

23:16 sconover: i'm sure i can accomplish this with recursion

23:16 but was wondering if there's some other way

23:16 amalloy: i think you can do something only a little bit ugly if you use reductions

23:16 sconover: i'm still wrapping my head around how to properly handle/express mutable state...

23:17 ok. that's fine. mine sharing what you'd do?

23:17 mind

23:18 amalloy: yeah, gimme a few minutes

23:18 sconover: 4clojure is nice, thanks for the pointer

23:19 would be even better if it were available via git ;-)

23:21 amalloy: sconover: https://gist.github.com/1210514

23:22 sconover: <reading>

23:22 amalloy: sconover: 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:23 sconover: ah ok

23:24 amalloy: thanks for the catch, in fact

23:24 we're in the middle of moving repos and i forgot to fix that

23:24 sconover: there it is, right in front of me ;-)

23:25 amalloy: son of a...i can't fork this to the right place, because i already have a fork?

23:26 sconover: so in your code, is the reductions

23:26 reductions call handing back a nested sequence

23:26 with the count as the first element?

23:27 amalloy: it's returning a sequence, each item of which is a pair: [count items]

23:27 sconover: ok

23:29 amalloy: it does that lazily, of course

23:29 then we take-while on count, and get the matching items

23:30 sconover: ok i think i get it

23:31 i 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:31 thanks a lot for your help

23:32 amalloy: you're welcome! thanks for the problem

23:33 sconover: np. interesting that it's novel.

23:35 hugod: dnolen: 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:35 srid: damn, getting enlive to work with appengine is such a pain

23:36 hugod: the other half will have to wait for tomorrow…

23:36 amalloy: sconover: it's probably easier to solve with plain recursion, but reductions is a neat tool anyway

23:37 dnolen: hugod: ah now that I think about it, I was seeing this as well.

23:38 sconover: which option would you say is more idiomatic / less "surprising" in clojure-land?

23:39 amalloy: *shrug*

23:39 i have a tendency to combine things like reduce/filter/take-while/iterate too much, when simple recursion would be easier

23:39 sconover: ah ok

23:41 amalloy: sconover: 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:50 sconover: playing around w/ reductions in the repl, neat. very much like ruby inject/reduce (the fact that you have access to intermediate values).

23:51 amalloy: yeah, and you don't need mutable state to get that

Logging service provided by n01se.net