#clojure log - May 26 2011

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

0:00 tomoj: I just effectively wrote (->> (range) (map (juxt identity identity)) (map (partial apply *))) instead of (map #(* % %) (range))

0:18 amalloy: tomoj: c'mon, (map (comp (partial apply *) (juxt identity identity))

0:22 tomoj: :)

0:43 crowbar: I'm trying to run lein deps but the process is hanging on Downloading: org/clojure/clojure/1.2.1/clojure-1.2.1.pom from central and nothing is happening. any way for me to get around this?

2:29 raek: no_mindu: a node is a map with the keys :tag, :attrs and :content

2:31 no_mindu: "<p>foo <a href="http://example.com/&quot;>bar</a> baz</p>" corresponds to {:tag :p, :attrs {}, :content ("foo " {:tag :a, :attrs {:href "http://example.com/&quot;}, :content ("bar")} " baz")}

2:32 Jeffrey04: erm... I am following the tutorial provided by labrepl, and i don't understand this instruction (chapter: unified update model)

2:32 The request function takes a URL string and returns a map of response data. Try it a the REPL to see how it works.

2:32 raek: ...and when having these as code literals, you of course need [] instead of ()

2:33 Jeffrey04: (source request) yields => Source not found

2:34 raek: Jeffrey04: I haven't used labrepl, but have you required/used the namespace 'request' is in?

2:34 Jeffrey04: @raek no instruction on that

2:35 raek: source and doc will only work after the containing namespace has been loaded

2:35 Jeffrey04: @raek i thought it is using clojure-http.client, but doesn't seem like it is the case :/

2:35 raek: Jeffrey04: what happens if you just eval "request" (without the quotes) in the repl?

2:36 Jeffrey04: CompilerException java.lang.Exception: Unable to resolve symbol: request in this context, compiling:(NO_SOURCE_PATH:0)

2:36 do labrepl people host their own irc channel?

2:37 no_mindu: raek: thnxs, I figured that out

2:37 Jeffrey04: btw @raek, mind if i ask you what timezone are you in? you seem to be around 24/7

2:37 lol

2:37 raek: GMT+2

2:38 no_mindu: raek: my problem was that when I supplied a map, The element was not being rendered. So I wrapped the map in a cons and it worrked

2:38 raek: but since I am currenlty a student, I'm frequently on IRC...

2:38 or, I can be

2:38 Jeffrey04: @raek lol XD

2:42 @raek any good tutorial for beginner?

2:47 raek: Jeffrey04: well, there are the Clojure books, 4clojure.com (a site with a lot of small puzzles), and iirc there should be some kind of tutorial at try-clojure.org

2:47 I guess it depends on what you are looking for

2:48 Jeffrey04: @raek: finished try-clojure.org already, will have a look see at 4clojure.com

2:48 thanks

2:49 raek: regarding "installing" Clojure, it can be good to know that you most ofter don't install Clojure itself but one of the tools, like Leiningen or Cake

2:50 4clojure is not really a tutorial, but it is a very handy way of testing your knowledge

2:53 Jeffrey04: oh, how could I forget this: http://learn-clojure.com/

2:54 as the site says, this is a often-referenced one http://java.ociweb.com/mark/clojure/article.html

2:55 Jeffrey04: @raek is actually trying to pick up clojure in a week to see whether it is good enough for my postgrad project

2:57 raek: Jeffrey04: I also recommend Rich Hickey's presentations here http://blip.tv/clojure - especially the Clojure Concurrency one

2:58 he talks about why it matters that there is a language like Clojure

2:58 thorwil: in a week? won't the question rather be if your understanding of clojure will be good enough by then for a good decision? ;)

3:01 raek: some of the non-conference videos (Clojure Concurrency, Clojure Sequences, Clojure Data Structures, Clojure for Java Programmers, Clojure for Lisp Programmers) are quite long, so it will probably take about a week t osee them all... :-)

3:02 but they explain well what's included in Clojure, and why

3:03 Jeffrey04: @thorwil lol, yea, figured it may be an impossible task, but still gotta try. liking what i see so far (except the endless parentheses, but i have been writing short functions started a year ago so not that much of a problem)

3:03 raek: (those vids were what got me hooked on Clojure)

3:06 thorwil: after writing some JS for an anotherwise clj web project, i really don't see a problem with the syntax on the clj side ... ;)

3:07 Jeffrey04: @thorwil to me it is just placing the opening parenthesis in front of function name

3:07 lol

3:14 TobiasRaeder: Morning :)

3:15 What is the idiomatic way of comparing two strings (similar to <, > for numbers)

3:15 The strings are version strings in the format of "12.35.14335.15335" etc

3:16 chouser: hm, maybe split each string into a vector of integers and compare those?

3:16 ,(compare [12 35 45] [12 50])

3:16 clojurebot: 1

3:17 chouser: ,(compare [12 35 45] [12 25])

3:17 clojurebot: 1

3:17 chouser: heh, or maybe not

3:18 that might work if you pad with zeros to the same length

3:23 raek: ,(compare [12 35 45] [12 50 10])

3:23 clojurebot: -1

3:23 raek: ,(compare [12 35 45] [12 25 10])

3:23 clojurebot: 1

3:24 raek: ah, in lexicographical order, shorter sequences are sorted before those sequences that have it as a prefix

3:25 or?

3:26 clgv: raek: prefix?

3:27 TobiasRaeder: mh

3:27 raek: foo < foobar < foobaz

3:28 clgv: lol. I meant in your array case. for me it seems like a straight forward lexicographical sort

3:29 TobiasRaeder: what you think of splitting the string into int vectors and then walk all vectors,

3:29 compare them and if they are the same proceed to the next element otherwise return comparison result?

3:37 clgv: TobiasRaeder: sounds like lexicographical comparison as well ;)

3:38 TobiasRaeder: ;)

3:38 Thanks for the input

4:07 fmw: I'm having some trouble accessing metadata on my deftest objects: http://paste.pocoo.org/show/395393/ How do I get to access that metadata?

4:08 I'm trying to add a conditional to my fixture, so I can manually tell it not to create test databases for certain tests in my db module.

6:48 bpr: does the destructuring keyword :as not work when destructuring arguments to a function?

6:51 fliebel: bpr: I;d think it should work. You experience otherwise?

6:51 bpr: yeah

6:51 unless i was doing it wrong

6:52 fliebel: &((fn [[a b :as c]] [a b c]) 1 2 3)

6:52 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (3) passed to: sandbox11964$eval15285$fn

6:52 fliebel: &((fn [[a b :as c]] [a b c]) [1 2 3])

6:52 sexpbot: ⟹ [1 2 [1 2 3]]

6:52 bpr: hrm

6:52 fliebel: works for me...

6:53 bpr: so i see

6:53 fliebel: bpr: can you paste yours?

6:54 bpr: &(defn segment-matcher

6:54 [[[type var] & rest] :as pattern input bindings]

6:54 ((segment-match-table type) pattern input bindings))

6:54 sexpbot: java.lang.SecurityException: You tripped the alarm! def is bad!

6:54 bpr: does :as have to be at the very end?

6:55 i wound up coding it like: &(defn segment-matcher

6:55 "Call the right function for this kind of segment pattern."

6:55 [pattern input bindings]

6:55 (let [[[type var] & rest] pattern]

6:55 ((segment-match-table type) pattern input bindings)))

6:55 fliebel: bpr: try [[[type var] & rest :as pattern] input bindings]

6:56 bpr: oh nice

6:56 that compiles

6:56 i'm implementing the pattern matching described in PAIP

6:56 fliebel: PAIP?

6:57 bpr: Paradigms of Artificial Intelligence Programming

6:57 fliebel: bpr: Be sure to talk to dnolen in any case. :)

6:57 bpr: thanks for your help!

6:58 clgv: how can i easily replace the elements of a seq that match a given criterion by a constant?

6:58 fliebel: bpr: I wrote this mini thing, but dnolen is working on something much bigger and more efficient. http://pepijndevos.nl/clojure-micro-pattern-matcher

6:58 He's doing efficient predicate dispatch, with DAGs and maximum sharing and all.

6:59 bpr: (map #(if (predicate %) 'constant %) sequence)

6:59 fliebel: pattern matching is a specific case of predicte dispatch I;ve been told.

6:59 bpr: i think that'll do u clgv

6:59 clgv: bpr: I thought there might be something shorter built-in ;)

6:59 bpr: fliebel: wow, that sounds impressive

7:00 clgv: there may be

7:00 clgv: i'm pretty new to clojure

7:01 fliebel: &(map {:a :b} [:a :b :c]) ; not really a predicate

7:01 sexpbot: ⟹ (:b nil nil)

7:01 fliebel: ouch

7:01 clgv: I need the predicate. ;)

7:02 your use case can be done by "replace" ;)

7:02 fliebel: $doc replace

7:02 clgv: oh no. replace does it even better ;)

7:02 &(replace {:a :b} [:a :b :c])

7:02 sexpbot: ⟹ [:b :b :c]

7:03 fliebel: Tha's what I was aiming at yea...

7:03 bpr: wow, that's nice

7:03 clgv: but I need the predicate^^

7:03 fliebel: &(map {:a :b} [:a :b :c] [:a :b :c]) ;)

7:03 sexpbot: ⟹ (:b :b :c)

7:04 clgv: &({:a :b} :b :a)

7:04 sexpbot: ⟹ :a

7:05 clgv: &({:a :b} :c :a)

7:05 fliebel: hm, I can;t think of anything better for the predicate than the if bor came up with.

7:08 bpr: fliebel: thanks for that link

7:08 I think i'll prob learn a lot from that code

8:43 tufflax: what's the site with clojure beginner exercises online?

8:44 first war like (= _ true) or something

8:44 s/war/was/

8:44 sexpbot: <tufflax> first was like (= _ true) or something

8:45 bpr: i don't know about that example, but check out labrepl for a good set of beginner exercises

8:47 manutter: tufflax: I think you are looking for 4clojure.org

8:57 tufflax: aa yes manutter thanks

8:57 manutter: np

9:01 powr-toc: Is it possible to mock protocol functions with clojure.contrib.mock?

9:13 clizzin: if i need a clojure program to send me emails, what's the best lib/jar to use?

9:17 aav: clizzin: depends on what emails you expect o receive :)

9:18 clizzin: seriously - i'm using a simple wrapper (self made) around javamail api

9:18 manutter: There's one called Postal listed on clojure-toolbox.com, and I started a little one at https://github.com/manutter51/nonomail

9:19 mine is still work-in-progress, but the sending part works for me in testing, so feel free to check it out if you're interested

9:22 clizzin: manutter: thanks, i'll check it out

9:22 aav: what do you mean what emails i expect to receive?

9:22 manutter: I haven't looked at it in a couple months, but let me know if you have any questions or find anything really ugly

9:23 clizzin: it's just a monitoring program that will email me if it detects trouble

9:23 manutter: what's the concept of a session in the context of nonomail?

9:24 sthuebner: anybody using clojuresque (kotarak's Gradle plugin) with SLIME? I was expecting some similar feature like `mvn clojure:swank`. But couldn't find any pointers in the internets

9:24 manutter: clizzin: it's a JavaMail session, it holds the credentials (username/password/server/etc) and manages communications with the server

9:25 clizzin: ah i see

9:25 not very familiar with javamail, will take a look

9:25 manutter: It really makes more sense in the context of reading mail, like from an IMAP server, but I haven't got that part done yet

9:25 bartj: clizzin, you can find sample code somewhere here: http://github.com/kyleburton/sandbox/

9:26 clizzin: bartj: err examples of manutter's nonomail lib?

9:27 aav: clizzin: emails are different. i.e. spam, important news, etc :) sorry - it could be my broken sense of humor :)

9:27 clizzin: not sure what you're trying to say you have a sample of

9:27 manutter: I doubt if it's a sample of nonomail, I haven't really mentioned it publicly before today

9:28 come to think of it, I probably shouldn't have mentioned it today, since I don't recall writing any docs for it, hmmm...

9:29 bartj: clizzin, no, it uses javax.mail

9:29 clizzin: bartj: oh i see

9:29 bartj: mind telling me what the path is? there are a lot of different things in that repo.

9:30 joegallo: manutter: fancy seeing you here!

9:30 manutter: heya joe, how's things :)

9:31 joegallo: things are great! I just saw you mentioning postal, and than I looked at your name, and I thought, "I know that guy!"

9:31 bartj: clizzin, I can't find it there, I took the code sometime ago

9:32 clizzin, from his github repo. here's the relevant function you will need - http://pastebin.com/Pk0fGCvW

9:32 manutter: joegallo:Yeah, I've seen your name pop up here now and then but I was too busy at the time to shout out

9:32 joegallo: heh, no worries.

9:32 clizzin: manutter: it looks fairly clear from the code, though of course every project should have docs

9:32 bartj: clizzin, with relevant usage provided below in the paste

9:33 clizzin: bartj: cool, thanks

9:33 bartj: clizzin, just remember to add the appropriate imports and you will be good to go

9:33 manutter: clizzin: it's on my todo... ;)

9:33 joegallo: clizzin: but, ummm... docs aren't any fun to write... :)

9:33 manutter: actually, the most fun part of nonomail was writing the midje tests

9:33 clizzin: joegallo: i actually kind of like writing docs (to stuff i've written myself! i'm not volunteering for anything here). what's the point of writing something if no one can figure out how to use it?

9:34 bartj: clizzin, let me know if it works for you!

9:35 manutter: clizzin: the midje tests in nonomail are the best docs for how to use it right now

9:36 If I get some time tonight I think I can grab a code sample from somewhere

9:54 JG`: Quick Q. I'm trying to create a list of structs, and probably missing something very obvious. Here's my code: (defstruct nodex :p :rel :props)

9:54 (def tree-basics (list (

9:54 (struct nodex nil :identities {:type "identities"})

9:54 (struct nodex nil :decisions {:type "decisions"})

9:54 (struct nodex nil :trading {:type "trading"})

9:54 (struct nodex nil :testing {:type "testing"}))))

9:54

9:54 Wrong number of args (3) passed to: PersistentStructMap

9:54 [Thrown class java.lang.IllegalArgumentException]

9:55 the weird thing is, if i take the 'testing' line out (leaving it with 3 list members), it works fine.

9:59 bpr: &(do (defstruct nodex :p :rel

9:59 :props) [09:54]

9:59 (def tree-basics (list (

9:59 (struct nodex nil :identities {:type "identities"})

9:59 sexpbot: java.lang.SecurityException: You tripped the alarm! def is bad!

9:59 bpr: (struct nodex nil :decisions {:type "decisions"})

9:59 (struct nodex nil :trading {:type "trading"})

9:59 (struct nodex nil :testing {:type "testing"})))))

9:59 boo

10:00 Checkie: JG`... what's the purpose of the paren after list?

10:01 JG`: none, that was the problem. ty.

10:52 imade: I would expect that (reverse "madam") would give "madam" istead of char array

10:52 fliebel: imade: Look at clojure.string, it does that, I think.

10:53 imade: http://clojure.github.com/clojure/clojure.string-api.html#clojure.string/reverse

10:53 core/reverse works on the iseq interface, so you get back an iseq.

10:58 dsop: hmm how you guys start nailgun?

10:59 recent lein-nailgun doesn't seem to work with clojure 1.2.x

11:04 manutter: dsop: I never really played with nailgun per se, but I believe it's what's behind the jark stuff

11:05 and jark is working well for me

11:05 dsop: jar?

11:05 jark

11:05 clojurebot: jark is a clojure daemon for scripting: http://icylisper.in/jark/

11:05 dsop: kk thx

11:05 manutter: heh, tks clojurebot

11:06 what's that command now...

11:06 botsnack

11:06 #botsnack

11:06 hmm, something like that

11:06 o well, good job bot

11:06 fliebel: ,botsnack

11:06 clojurebot: java.lang.Exception: Unable to resolve symbol: botsnack in this context

11:06 manutter: lol, he choked on his snack

11:07 &botsnack

11:07 sexpbot: java.lang.Exception: Unable to resolve symbol: botsnack in this context

11:07 manutter: $botsnack

11:07 sexpbot: manutter: Thanks! Om nom nom!!

11:07 fliebel: wrong bot

11:07 manutter: ah, right command, wrong bot

11:07 fliebel: ~botsnack

11:07 clojurebot: thanks; that was delicious. (nom nom nom)

11:07 manutter: there we go

11:07 the bots are fed, my work here is done.

11:08 fliebel: clojurebot: botsnack is Thanks, can I have chocolate next time?

11:08 clojurebot: primetime is <lowlycoder> i'm not convined clojure is ready for primetime until i see facebook apps in clojure

11:12 danlarkin: wow

11:12 I was not aware that facebook apps were the arbiter of primetimeliness

11:13 fliebel: How do I tell clojurebot to forget stuff? :(

11:13 danlarkin: when did the committee decide?

11:13 clojurebot: forget primetime is <lowlycoder> i'm not convined clojure is ready for

11:13 primetime until i see facebook apps in clojure

11:13 clojurebot: c'est bon!

11:14 danlarkin: erf, like that except not with the linebreak

12:06 manutter: primetime

12:06 jark

12:07 hrm

12:07 ~jark

12:07 clojurebot: jark is a clojure daemon for scripting: http://icylisper.in/jark/

12:07 manutter: ah

12:07 ~primetime

12:07 clojurebot: primetime is <lowlycoder> i'm not convined clojure is ready for primetime until i see facebook apps in clojure

12:09 * hiredman wrote a facebook app in clojure so long ago that it has stopped working due to api drift

12:09 hiredman: to be fair that means I could have written it a month ago (it was actually over a year ago and was hosted on appengine)

12:09 manutter: Yes, but has lowlycoder SEEN it?

12:10 technomancy: k

12:10 oops

12:10 hiredman: manutter: excellent point

12:10 edw: ; Touch file: "machines/C/stackops.ext"

12:10 ; Touch file: "machines/C/traditional.bin"

12:10 ; Touch file: "machines/C/traditional.ext"

12:10 ;unable to open file #[pathname 6004 "/home/edw/dev/mit-scheme/src/compiler/machines/i386/dassm1.bin"]

12:10 ;To continue, call RESTART with an option number:

12:10 ; (RESTART 1) => Return to read-eval-print level 1.

12:10 2 error>

12:10 End of input stream reached.make: *** [all-native] Error 1

12:10 edw@li246-89:~/dev/mit-scheme/src$ more compiler/machines/

12:10 C/ bobcat/ mips/ spectrum/ vax/

12:10 alpha/ i386/ sparc/ svm/ x86-64/

12:10 edw@li246-89:~/dev/mit-scheme/src$ more compiler/machines/i386/

12:10 assmd.scm dassm2.scm instr2.scm make.scm rules4.scm

12:13 pjstadig: edw: good point

12:13 :)

12:23 faust45: how i can reload code in repl?

12:24 no_mindu: how do I iterate over all the keys of a map ?

12:26 Vinzent: ,(keys {:a 1 :b 2})

12:26 clojurebot: (:a :b)

12:26 tufflax: I have made a class with gen-class that has a -main, how do I run it in the repl? I don't wanna have to make a jar and execute java on it. :P

12:27 Vinzent: faust45, what do you mean? You can redefine any var from the repl

12:28 tufflax, i think -main is a plain function, so you can call it from the repl like any other

12:28 faust45: Vinzent: i have app running in repl how i can reload my app?

12:28 imade: no_mindu: (for [k (keys {1 1 2 2 3 3 4 4})] (inc k))

12:30 Vinzent: faust45, maybe try (require 'your.core.ns :reload-all)?

12:30 tufflax: Vinzent ok, thanks. There is something wrong with my code though :(

12:31 faust45: Vinzent: yes thanks ;)

12:42 clizzin: what's the best way to loop repeatedly with a pause at the end of each loop? basically, i want a function to run every minute, but i want to avoid the JVM startup time that would accompany the run if i were to make this a cron task that ran the function through a jar.

12:43 btw, to those who were giving mail advice earlier, i ended up going with postal because it looked like a very mature and actively maintained lib. sorry i didn't end up using any of your solutions, but i really appreciated the help

12:44 TimMc: clizzin: Is drift OK?

12:44 clizzin: TimMc: a little bit, but hopefully not beyond like 5s

12:45 Vinzent: clizzin, you can start fn in other thread, call Thread/sleep, then recur

12:45 clizzin: Vinzent: so, use 'loop' to control the loop and just pass no args to 'recur'?

12:46 TimMc: clizzin: What happens if you throw an exception in the loop?

12:46 daemons are tricky

12:47 clizzin: TimMc: ideally, it should email me the exception. if the emailing itself throws an exception, it should log on disk. but then the loop should continue.

12:47 raek: clizzin: cron4j is super-simple to use from clojure and uses the same syntax as cron. if you only want a task to be run every now and then this is probably overkill

12:47 (cron4j runs within one jvm instance)

12:48 Vinzent: clizzin, yep, simplest thing would be (.start (Thread. (fn [] (println "called") (Thread/sleep 1000) (recur))))

12:48 clizzin: raek: oohh nice. but re your overkill comment: do you mean to say that cron4j is overkill for running a task now and then?

12:50 raek: clizzin: if you don't care about that it is run exactly every 60 seconds (just that there is about one minute delay in betwen) a simple loop and a sleep solves the problem more simpler

12:50 clizzin: raek, Vinzent: gotcha, i'll just do the loop/sleep then for now

12:50 thanks!

12:50 great to know about cron4j though, that'll be perfect later on down the road

12:50 jvm startup time's a bitch

12:52 Vinzent: btw, i'd like to announce another web framework for clojure: https://github.com/dnaumov/jaco any feedback is strongly welcome!

12:52 raek: clizzin: this runs my-fn 12:30 on mondays to fridays :-) (doto (Scheduler.) (.schedule "30 12 * * 1-5" #'my-fn) (.start))

12:54 [org.clojars.ghoseb/cron4j "2.2.1"]

13:01 fliebel: Vinzent: I don't need webframeworks, I create my own ad hoc, informally -specified, bug-ridden, slow implementation of half of RoR

13:02 manutter: lol

13:03 fliebel: common guys, the logs are still not on google for this term. I'm trying to popularize Clojure here.

13:05 amalloy: fliebel: funny you should mention that. the php application i've been working on for a year falls into that category

13:06 Vinzent: fliebel, :)

13:06 * fliebel wonders why there is always a space in "informally -specified"

13:08 Vinzent: I have often heard that clojure doesn't need web frameworks, but that sounds strange, isn't it?

13:08 fliebel: amalloy: I thought PHP in itself was already an ad hoc... of RoR. You must be adding the other half?

13:08 amalloy: fliebel: php was first, so i doubt it

13:08 TimMc: Clojure is... porn? http://correlate.googlelabs.com/search?e=clojure&t=weekly

13:10 amalloy: fliebel: but we have a guy who likes rails and he's been adding feature after feature for months. we now have a bad, ugly version of rails that breaks a lot

13:10 ataggart: "ugly version of rails" didn't think that was possible

13:10 fliebel: amalloy: You should call it PHP on Rails New ;)

13:12 amalloy: nah. i'm calling it: so long, i'm off to work with ninjudd and lancepantz

13:14 fliebel: Vinzent: Real man use raw sockets. I guess Lisp attracts more real man then PHP and Ruby and all.

13:15 amalloy: fliebel: you don't mean high-level nonsense like socket.h, do you? i use raw ioctl

13:15 Vinzent: fliebel, well, russian lispers don't consider clojure as a lisp :)

13:18 real man use only parentheses

13:19 and never touches jvm :)

13:19 TimMc: Vinzent: ##(#(% %) #(% %)) alphanumerics are for wimps

13:19 sexpbot: java.lang.StackOverflowError

13:20 TimMc: gfrlog: Do you remember how far we got without alphanumerics?

13:25 * amalloy hopes not to hear anything like "nth base"

13:27 wastrel: i'm working on 4clojure problems

13:28 manutter: me too

13:28 well, in my free time

13:28 wastrel: right at this moment i mean :]

13:32 manutter: Compojure is a little more interesting than Clojure: http://correlate.googlelabs.com/search?e=compojure&t=weekly#

13:32 wastrel: what's brazil tube?

13:34 manutter: I'm at work, not sure I dare google that...

13:35 amalloy: hah

13:35 clizzin: well, that was a great penis joust that just happened there (re the 'real man' shit)

13:35 (as you can see, i'm taking clojure logs to searchability for something else)

13:36 Vinzent: looks like popularity going down fast

13:36 clizzin: i think clojure + mongrel2 has a lot of potential for a really amazing web framework

13:37 anyway, sleep time, night all

13:41 fliebel: wait, what? mongrel2? What's that good for? *googles*

14:01 dnolen: making a Scheme-ish pair abstraction for Clojure that's as fast as Cons / PersistentList is tricky ...

14:07 ataggart: to what end?

14:10 dnolen: ataggart: core.logic needs it, Prolog / miniKanren sequences allow logic variables as tails in addition to seqs and nil.

14:11 some core.logic programs run surprisingly slower than the comparable Prolog, I'm beginning to suspect it's the overhead around my LCons (Pair data structure) design.

14:11 ataggart: revealing my ignorance, what's the difference between a pair and a two-element vector?

14:12 dnolen: ataggart: (1 . 1) is legitimate Scheme, such a thing is impossible to do w/ vectors (or any sequence like thing in Clojure)

14:13 in Clojure only (1 . nil) or (1 . ()) is possible.

14:14 ataggart: so you want to use a cons-like fn that accepts not just seqs in the second slot?

14:15 no_mindu: Iam building a stack based on ring. I want that the request object recevied, should be available globally to all namespaces and functions. How do i do this ?

14:15 dnolen: ataggart: I already have it, I just want it to be faster.

14:15 ataggart: link to src?

14:18 dnolen: attagart: heh it's a doozy, https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/minikanren.clj#L340

14:18 ataggart: nvm, found it

14:18 dnolen: ataggart: another relevant line is 435, I think a lot of time being wasted there.

14:20 amalloy: no_mindu: that sounds tremendously non-functional

14:20 dnolen: ataggart: another issue is 440, (lcons a (lcons b ...)) way more expensive then '(a b ...), was considering using delays ...

14:22 amalloy: dnolen: isn't the consing in '(a b) done at read time? i don't think you can get as fast as "do nothing at runtime"

14:23 dnolen: amalloy: in some simple tests using delays will get you the same perf, like lazy sequences you don't pay for what you don't use.

14:27 no_mindu: amalloy: why ? if some data is to beused by every second function in the stack, it makes more sense to put it in some central store

14:29 no_mind: I mean put the data in some central store

14:29 amalloy: it will make your code hideously difficult to test at the repl, for example. nothing will work unless you create a valid ring request

14:30 if you want to make some *pieces* of the data global, just those pieces you use, that's going to be easier to work with. as long as you label them clearly and don't mutate them, it's not such a problem

14:31 no_mind: you can even see an example where i did just that, at https://github.com/dbyrne/4clojure/blob/develop/src/foreclojure/utils.clj#L15

14:35 fliebel: dnolen: You should try to win bpr for your predicate dispatch efforts ;)

14:35 ataggart: dnolen: please forgive the likely dumb question, but why isn't this the implementation of lcons? https://gist.github.com/993734

14:35 dnolen: "you don't have enough contextual knowledge" is an appropriate response.

14:35 itissid: Hey has some one used cascalog here?

14:36 maybe for Machine learning stuff

14:36 fliebel: itissid: nathanmarz has, I guess :)

14:36 itissid: nathanmarz, Hey can I know one thing I once wrote some machine learning algorithms in hadoop back when mahout was not there.. Now i had to write ridiculous amounts of code to do something like Newton raphson..

14:36 Now there is mahout

14:37 which still is too huge

14:37 cascalog seems to make the pain go away

14:37 fliebel: ataggart: You are just adding it as the last item, right? Not as 'the rest'

14:38 itissid: nathanmarz, are there examples on the web that do ML stuff with cascalog?

14:38 dnolen: ataggart: next will give you nil and you know you're done. that is not the case w/ lcons.

14:39 nathanmarz: itissid: i don't know of any examples on the web doing ML

14:39 dnolen: ataggart: next/rest always give seq or nil. lcons needs next/rest to give seq, nil, or lvar

14:39 amalloy: itissid: you could also look up sam ritchie who's done a lot of cascalog/hadoop stuff in clojure

14:39 nathanmarz: itissid: if you tell me about the algorithm you're trying to do, I can provide some guidance as to what that would look like with cascalog

14:40 dnolen: ataggart: we don't want to muck with Clojure next, so LConSeq defines lnext, which does the desired thing.

14:40 fliebel: bpr?

14:41 fliebel: dnolen: Yea, he was in here this morning, talking about writing a pattern matcher.

14:42 itissid: nathanmarz, well i am just scouting my old Hadoop project, I want to learn this new way of doing this, but first tell me; Do you think iterative map reduce is much easier than writing it with plain java and hadoop..

14:42 i mean iterative map reduce using datalog+clojure+cascade

14:46 no_mind: amalloy: well the requirement is to have a valid ring request for anything to work. I mean the whole stack is based on parsing the request url and request params... so in such case dependency on a ring request for things to work sounds fair enough.

14:46 dnolen: fliebel: ah yeah he was talking about the pattern matching bit in PAIP, which is simplistic.

14:47 nathanmarz: itissid: yes, dramatically easier

14:48 amalloy: *shrug* suit yourself. there's a reason nobody likes global variables: they add a lot of incidental complexity. but you have the power, and if your judgment is that it will make your program easier to maintain, feel free

14:48 itissid: nathanmarz, Thanks I will give it a try..

14:48 dnolen: nathanmarz: Storm sounds cool. looking forward to hearing more about that.

14:48 * fliebel agrees with dnolen

14:49 amalloy: dnolen: nathanmarz is probably going easy on Storm so he doesn't get a bad rep for all these tornados

14:53 fliebel: amalloy: tornados?

14:54 * fliebel wonders if there isn't a better way to binding syntax than ?symbol used by core.logic, cascalog, machure, etc.

14:57 choffstein: Hey all! Anyone here using moustache? I can't figure out a good way to get static files served (e.g. javascript, css, images, etc)

14:57 I keep having to create different paths

14:57 amalloy: fliebel: the US has had a couple really large tornado events in the past month or so

14:58 fliebel: amalloy: Ah, I was thinking http://www.tornadoweb.org/ so I did not get your joke.

15:01 dnolen: fliebel: open to suggestions, I won't adopt that syntax for predicate dispatch / pattern matching.

15:02 fliebel: in core.logic it's an important distinction because it means you're creating a logic variable.

15:02 fliebel: I toyed w/ capital letters a la Prolog, but that just seemed too un-Lispy. ? has a precedent w/ Norvig and others.

15:03 fliebel: dnolen: What about extending symbol/var with lvar?

15:03 dnolen: fliebel: a-lvar ?

15:04 fliebel: dnolen: dunno, but the equivalent of a lowercase symbol in Clojure would be a :keyword I think.

15:04 So basically any symbol is what would be an uppercase symbol in Prolog.

15:04 dnolen: fliebel: yeah can't do that because you can use any Clojure literal for unifying w/.

15:04 JG: Q on doseq. Code: (doseq [tree-node (filter #(= (:parent %) par-uid) tree-basics)]

15:05 How do I make sure this doesn't fail if the filter returns nill?

15:05 fliebel: dnolen: ?

15:05 dnolen: fliebel: no symbols are lowercase in Prolog too. Logic vars are uppercase.

15:07 fliebel: dnolen: OKay, other crazy idea. Make all symbols logic vars and unify them with what they might refer to.

15:08 dnolen: fliebel: sounds inefficient.

15:09 fliebel: dnolen: Then make them logic vars based on if they refer to something. Same thing.

15:09 dnolen: fliebel: refer to what?

15:10 fliebel: dnolen: something... I don't know. Okay, what about leaving symbols alone, and turning vars into lvars? So you'd write #'blah instead of ?blah.

15:11 ataggart: JG: if the seq is empty/nil, the body isn't called

15:11 dnolen: fliebel: changing the meaning of Clojure idioms seems ... ill-advised.

15:13 fliebel: dnolen: OKay. But I still don;t understand why you can;t make a var implement your logic var protocol.

15:13 dnolen: fliebel: LVar has data fields that Vars don't, can't bring Var into the protocol.

15:14 just like String can't have metadata

15:14 fliebel: dnolen: Okay, fair enough...

15:22 JG: ataggart - thanks. I get an error which suggests it is, probably some other hidden thing.

15:40 amalloy: JG: fwiw, i prefer to write that as (filter (comp #{par-uid} :parent) tree-basics)

15:57 jweiss: I"m noticing in my leiningen project that when i run lein install, it installs a jar file with some compiled classes from clojure.contrib. that's not supposed to happen, is it?

16:01 pjstadig: jweiss: do you have any AOT compiled classes?

16:02 jweiss: pjstadig: yeah

16:02 pjstadig: http://dev.clojure.org/jira/browse/CLJ-322

16:03 there's a bug where AOT compiles more than just the classes you ask it to

16:03 jweiss: pjstadig: ah ok that's exactly what i'm seeing, thanks

16:03 pjstadig: i think there are some lein mechanics to clean out the extra AOT classes

16:04 some options in the project.clj

16:04 technomancy would know better

16:04 jweiss: the bloat is insignificant, so it's no biggie, but just thought it looked 'wrong'

16:07 pjstadig: hm, i found a stackoverflow question where technomancy says lein 1.4 will have a workaround. i guess i need to activate it somehow since i have 1.5

16:08 pjstadig: yeah there's an option to have it clean extra class files

16:08 i don't recall it off the top of my head

16:09 jweiss: ah i found it :class-file-whitelist

16:09 from the lein tutorial

16:14 lucian: this reminds me, i've been wondering if clojure works with gcj

16:15 a use case might be android, since clojure's boostrap is gc-intensive and dalvik has a slow gc

16:15 pjstadig: lucian: in what way? clojure compiles down to jvm bytecode

16:15 isn't gcj a java compiler?

16:15 lucian: i was wondering if gcj AOT might be useful

16:16 it's a bytecode-to-native compiler

16:16 pjstadig: hmm

16:16 interesting

16:18 amalloy: lucian: stay away from gcj

16:19 fliebel: amalloy: why?

16:19 lucian: amalloy: have you tried it?

16:20 amalloy: not for years. it hasn't really kept up with javac

16:20 lucian: i see. last time i tried it (a couple of years ago) it was quite nice

16:21 amalloy: http://gcc.gnu.org/java/ hasn't been updated since 2009

16:21 and it didn't support 1.5 then

16:21 lucian: hmm, that is bad

16:21 any other ideas about android?

16:21 not even necessarily clojure, just not java

16:22 pjstadig: mirah

16:22 amalloy: yeah, mirah's an interesting idea

16:22 lucian: pjstadig: yeah, i looked at that

16:22 amalloy: http://gcc.gnu.org/java/status.html seems to be their "we know, everything is broken" page

16:22 lucian: couldn't get it to work, and it's appears immature. not sure what to think

16:23 pjstadig: technomancy seems to have gotten it to work for some simple android apps

16:23 fliebel: amalloy: That's like Java and rpython having a lovechild, right?

16:23 lucian: fliebel: jruby, but yeah

16:23 pjstadig: i've never used it myself, but i'm pretty convinced it would be great for an android app

16:25 lucian: i've also looked at kawa, since app inventor uses it. although it appears to be an interpreter

16:25 fliebel: lucian: I said rpython because it is a more static subset of Python, as far as I know.

16:26 lucian: fliebel: well, sort of. RPython is just an implementation detail of PyPy, you can't actually use it for anything other than building a VM

16:26 fliebel: mirah has extensions instead, so it's not even a subset of ruby

16:26 fliebel: i guess a more precise comparison would be with cython

16:26 pjstadig: mirah?...mirah is a statically typed ruby

16:28 Raynes: Am I the only one that finds it weird to compare Mirah to... Python? :o

16:29 pjstadig: essentially...or maybe ruby inspired...headius was specifically trying to bring static typing to a ruby-like syntax that compiles to JVM bytecode

16:29 fliebel: Raynes: I could compare it to Forth if that makes you feel more comfortable?

16:30 Raynes: fliebel: Sure.

16:30 lucian: Raynes: RPython and Cython are not quite python, hence the comparison

16:30 (just like mirah is not quite jruby)

16:31 fliebel: Raynes: Well, Mirah is kind of like Forht, in that it tries to embrace the host platform, instead of abstract it away. Unlike Python of course.

16:32 Both have very simple syntax also.

16:38 technomancy: mirah's syntax is not really simple

16:39 but it is a very thin layer over the host platform otherwise

16:41 fliebel: Hm, I should ask fogus what he's up to. Was babbling something about JVM Forth the other day on Twitter.

16:41 $seen fogus

16:41 sexpbot: I have never seen fogus.

16:41 hiredman: jvm bytecode is stack based

16:42 fliebel: hiredman: So in that case, Forth is just JVM assembly :)

16:42 hiredman: so the code is similar to forth in often being about stack manipulation

16:42 fliebel: ~seen fogus

16:42 clojurebot: I don't understand.

16:42 fliebel: $seen fogus'

16:42 sexpbot: I have never seen fogus'.

16:42 fliebel: grr

16:43 $seen fogus`

16:43 sexpbot: fogus` was last seen talking on #clojure 1 week and 6 days ago.

17:22 no_mind: Iwas going through clojure coding standards. can someone explain this to me "Unroll optional named arguments. Callers should not have to wrap optional named arguments in a map literal: "

17:25 pjstadig: no_mind: that sounds to me like the difference between (my-fun arg :optional-arg "foo") and (my-fun arg {:optional "foo"})

17:26 no_mind: pjstadig: my guess was same but wanted it to confirm this from experience developers

17:29 ataggart: no_mind: https://gist.github.com/994128

17:32 no_mind: thnxs ataggart

18:02 zakwilson: http://pastebin.com/Q2V8Kzbx <-- I'm getting a "No single method..." error when trying to compile this ClojureQL code. I imagine I simply don't quite understand how to use join/rename, and I can't find anything by googling the error message.

18:10 maacl: Does anyone know an elegant way of getting all moustache routes to also match routes with trailing /. It appears inelegant to have to write all routes twice.

18:12 Tcepsa: maacl: I know nothing of moustache, but can you somehow use a regular expression instead of a string to specify the route?

18:13 offby1: I am a total Clojure n00b, and have never used (or, for that matter, ever even heard of) mustache. But: I would hope that its config would let you pass in a function to match the URL.

18:13 If that's the case, you could (as Tcepsa suggests) trim any trailing / _before_ invoking the matcher

18:17 maacl: Tcepsa: offby1: Well the syntax is a bit different - I am already matching on a regex, but moustache expects an empty string to match just a trailing slash - it basically ignores the slashes and just looks at the parts in betweeb

18:22 amalloy: Tcepsa: you can just write a little middleware that strips the / before handing it to moustache

18:23 jweiss: is there some reason that AOT compiling is normally slow (like 15 seconds to compile 1 relatively simple class), or am i doing something wrong?

18:23 i am guessing it's compiling all the deps

18:23 amalloy: (defn strip-slash [handler] (fn [req] (handler (update-in req [:uri] remove-the-slash))))

18:23 jweiss: because the first class is slow but the next isn't

18:23 amalloy: then instead of passing your moustache routes straight to ring/jetty, pass jetty (strip-slash moustache-routes)

18:24 i use compojure, not moustache, so i don't know the route syntax, but the point is you can do it Ring-side before moustache ever sees it

18:28 for completeness: (update-in req [:uri] clojure.string/replace #"/$" "")

18:28 bpr: why would M-x clojure-jack-in bomb-out with: https://gist.github.com/994245

18:28 technomancy: jweiss: yes; there's a bug in the clojure compiler where you can't AOT compile a namespace without compiling all the namespaces it depends upon

18:28 Tcepsa: amalloy: Awesome ^_^

18:29 amalloy: Tcepsa: the ring concept makes it amazingly easy to extend and manipulate the pipeline

18:29 technomancy: bpr: probably competing versions of swank; try clearing everything but 1.3.1 out of ~/.lein/plugins and project.clj

18:29 bpr: ok thanks

18:32 now i get: error in process filter: Cyclic keymap inheritance

18:32 in *Messages* and the *swank* looks similar to the gist i posted, except there's no exception

18:33 maacl: amalloy: thanks that is a good idea

18:33 Tcepsa: amalloy: It's definitely on my list of things to learn! Just too many great tools, not enough time. ~grin~

18:40 bpr: technomancy: Thanks for your help. It looks like I had 2 problems, 1: multiple versions of swank-clojure and 2: I was setting up a slime keymap in my .emacs.d/*

18:40 it's working now though

18:40 technomancy: sweet

18:52 zakwilson: Am I understanding correctly that I can't use rename in ClojureQL without also using project?

18:59 wruthw4lk: hi there..some help with installing clojure-mode?

19:02 zakwilson: Hi there. Perhaps you could tell us exactly what your question is instead of just generally asking for help.

19:03 wruthw4lk: sorry....i have installed it as per the getting started page in dev.clojure...after installing the emacs starter kit..and used elpa to install it..it works for first time...but when i quit emacs reload it, i cant run it agai

19:03 again*

19:04 zakwilson: Pastebin your .emacs

19:07 wruthw4lk: http://pastebin.com/EG5BWzqJ

19:07 thats it

19:10 zakwilson: I think you need a (package-initialize) in there before you start using the package stuff.

19:10 wruthw4lk: thanks..let me try it out

19:12 ok...so that works..thanks!!! :)

19:14 zakwilson: No problem.

19:25 wruthw4lk: sorry..but there seems to be yet another problem...till i added (package-initialize) to my .emacs, i could connect to a swank server (lein, without syntax highlighting) but now, when i try slime-connect, i get "Symbol's function definition is void: slime-define-both-key-bindings"...any help here?

19:26 technomancy: wruthw4lk: maybe you have slime installed via apt-get as well or something?

19:28 wruthw4lk: technomancy: yeah i did...would that be a problem?

19:29 choffstein: Does anyone here use moustache?

19:29 technomancy: wruthw4lk: yeah, it will probably conflict

19:30 wruthw4lk: technomancy: thanks... ill try it out :)

19:40 technomancy: thanks...it works!! but shouldn't the slime repl too have syntax highlighting? i can get syntax highlighting in .clj files now..

19:44 nathanmarz: dnolen fliebel: we'll be putting up some cool demos of storm soon. our bottleneck on the demos actually isn't storm, but doing all the javascript to make a pretty realtime frontend

19:44 technomancy: repl syntax highlighting is separate

19:44 I think that's in durendal

19:44 ,google durendal clojure

19:44 clojurebot: java.lang.Exception: Unable to resolve symbol: google in this context

19:44 technomancy: ~google durendal clojure

19:44 clojurebot: First, out of 36 results is:

19:44 technomancy/durendal at master - GitHub

19:44 https://github.com/technomancy/durendal/blame/master/durendal.el

19:44 * technomancy can't believe he still gets that wrong

19:48 offby1: this channel needs a better bot! :-)

19:49 technomancy: offby1: you have no idea how often I have to keep myself from "Let's"ing in here

19:49 I did steal a few things though.

19:49 ~guards!

19:49 clojurebot: SEIZE HIM!

19:53 bpr: I'm very new to the java ecosystem and clojure especially. Is there any facility for tracing program execution? Like common lisp's trace?

19:53 I've been looking at clojure.tools.logging's trace macro, but i can't seem to get any output

19:54 technomancy: bpr: C-c C-t can toggle tracing a single defn inside slime

19:54 bpr: if you want step-by-step, cdt is probably your best bet

19:55 bpr: oh, i didn't know about cdt

19:55 thanks

19:56 tmciver: Need some help with swank-clojure: after M-x clojure-jack-in I try to use auto complete but emacs complains C-c TAB is undefined . . .

20:30 pickles1: quick q: is there a clojure bif equivalent to haskell's partition function? something that can like: (hpartition even? [1 2 3 4 5]) -> [[2 4] [1 3 5]]

20:37 amalloy: clojure.contrib.seq/separate

20:38 $google clojure contrib separate clojuredocs

20:38 sexpbot: First out of 93 results is: ClojureDocs - clojure.contrib.seq/separate

20:38 http://clojuredocs.org/v/57

20:38 amalloy: pickles1: ^

20:38 mangie_mutt: hi, trying to use jcurses with lein, but can't seem to get it to work: http://pastebin.com/xQRJcREz

20:39 pickles1: amalloy: thx a bunch! I was sure there had to be one, but didn't feel like going through the docs 1 fn at a time

20:40 (im open to suggestions on better ways to find functions)

20:40 amalloy: $findfn even? (range 10) [0 2 4 6 8]

20:40 sexpbot: [clojure.core/filter]

20:40 amalloy: pickles1: ^

20:41 fairly limited, but useful for finding basic functions

20:41 pickles1: neat, i shall have to put that somewhere that i'll remember so i can reference it

20:42 thx again!

20:42 2 internet points for you

20:42 zakwilson: $findfn (range 5) [1 2 3 4 5]

20:42 sexpbot: []

20:42 zakwilson: $findfn inc (range 5) [1 2 3 4 5]

20:42 sexpbot: [clojure.core/map clojure.core/pmap clojure.core/keep]

20:42 zakwilson: cool.

20:43 amalloy: $findarg (map % (range 5)) [1 2 3 4 5]

20:43 sexpbot: []

20:43 amalloy: hm. i thought that worked

21:07 pickles1: hm, clojure's not finding separate... is contrib a separate lib?

21:08 (i'm a clj noob)

21:09 ... apparently i need to rtfn

21:09 *rtfm

21:09 idk what rtfn would be...

21:16 amalloy: the news

21:17 but pickles1, you can define separate yourself. it's trivially easy

21:17 pickles1: tru

21:17 amalloy: (def separate (juxt filter remove))

21:17 pickles1: yeah, was just wonderin if there was already a function i had access to that would do it

21:17 amalloy: &(let [separate (juxt filter remove)] (separate even? (range 10)))

21:17 sexpbot: ⟹ [(0 2 4 6 8) (1 3 5 7 9)]

21:18 pickles1: since i don't know the library all that well yet

21:18 amalloy: *nod*

21:18 pickles1: hm, juxt looks interesting

21:19 amalloy: (inc juxt)

21:19 sexpbot: ⟹ 1

21:19 amalloy: heh

21:19 join the juxt fan club

21:21 danlarkin: president: hiredman

21:21 pickles1: what are the dues?

21:22 danlarkin: ...you have to use juxt

21:22 that's enough punishment

21:22 pickles1: lol

21:40 gfrlog: ,((juxt list vector hash-set str name identity) :what)

21:40 clojurebot: [(:what) [:what] #{:what} ":what" "what" :what]

22:02 amalloy: i like using juxt to demonstrate the difference between apply and reduce, because a lot of new users seem to think the two are interchangeable

22:02 &((juxt apply reduce) (partial list '+) (range 5))

22:02 sexpbot: ⟹ [(+ 0 1 2 3 4) (+ (+ (+ (+ 0 1) 2) 3) 4)]

22:05 pickles1: juxt seems like a dual of map to me

22:07 amalloy: pickles1: it is

22:08 pickles1: well then... that would be why

22:08 amalloy: it's a specialization of map to be more convenient for a common class of problems, i suppose

22:09 pickles1: mm

22:09 amalloy: eg, ##((juxt quot rem) 55 7)

22:09 sexpbot: ⟹ [7 6]

22:09 pickles1: wellp, tis mah bedtime

22:09 thx again for the help amalloy

22:10 amalloy: any time

22:10 pickles1: even pi o'clock?

22:10 amalloy: don't be irrational

22:12 pickles1: mm, i thot it was real, maybe i was imagining it

22:13 (i best leave before we go off on a tangent -- and use old math jokes too much)

22:13 nite, thx again

23:35 JulioBarros: Anybody here? New to clojure and want to play with https://github.com/getwoven/infer how do I add/import it to my project/repl?

23:44 offby1: wish I knew

23:44 probably using the "ns" form, but other than that ...

23:50 mefesto: JulioBarros: are you using leiningen or cake?

23:51 JulioBarros: Using is a strong word :) trying to use leiningen

23:51 mefesto: heh

23:51 a quick search of clojars came up with http://clojars.org/infer

23:51 dnolen: JulioBarros: it has a project.clj, install a lein, clone the repo, then from the repo dir you ran run 'lein install'. You can then include infer just like any other include your own project.clj dependency list

23:51 mefesto: pushed nov of last year

23:52 or you can clone the github repo and do a lein install

23:52 err, n/m dnolan beat me

23:54 JulioBarros: ok. Thanks. Let me try that. I'm brand new to this so could be messing up something obvious.

Logging service provided by n01se.net