#clojure log - May 27 2012

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

0:10 emezeske: lynaghk`: All you should have to do is clone it and then run bin/test-install.sh

0:10 lynaghk`: It might complain at the end if you don't have phantomjs installed, but that's no biggie

0:11 lynaghk`: I've gotta reboot into windows for some diablo; I'll probably be back tomorrow sometime

0:16 lynaghk`: emezeske: okay, rad

0:28 amalloy: $mail emezeske have you tried vmware? it's a lot more convenient than dual-booting

0:28 lazybot: Message saved.

0:28 Raynes: amalloy: Yeah, but doesn't that have a significant impact on performance?

0:29 amalloy: you don't need a ton of CPU and RAM to run emacs, dude

0:29 Raynes: Oh, you run Ubuntu from Windows?

0:30 That's evil and sick.

0:30 amalloy: yes

0:30 muhoo: almost, but the :tr's are lists not vectors: https://www.refheap.com/paste/2884

0:30 Raynes: You're not worthy of your computer nor your monitor.

0:31 muhoo: running ubuntu from windows is fairly common. if you need windoze for games, but ubuntu for work, bob's yer uncle

0:31 gfredericks: I run ubuntu vm from a macbook pro at work; it's plenty fast

0:31 amalloy: what in...muhoo, what the hell is that

0:32 muhoo: amalloy: brain fart, after reading that little table thing above

0:32 give it a vector of vectors, and get an html table. maybe.

0:32 scottj: can you guys move windows on linux guest w/o redraw lag?

0:32 Raynes: muhoo: I don't think you're calling vector enough.

0:32 amalloy: scottj: yeah

0:32 muhoo: amalloy: is there a less ugly way to force everything to be dam vector, not a list?

0:33 amalloy: i run it in seamless mode with no problem

0:33 (defn tablify [head vv] [:table [:th head] (for [r vv] [:tr [:td r]])])?

0:33 Raynes: amalloy: I guess if you run it full screen, you can't really tell you're in Windows?

0:33 gfredericks: scottj: I use xmonad so the question doesn't really apply

0:33 Raynes: amalloy: Don't you mean (vec (for ..))?

0:34 amalloy: no, i don't because that would be incorrect

0:34 Raynes: But why do you need a vector all over the place?

0:34 muhoo: into maybe

0:34 amalloy: you want that to absolutely NOT be a vector, which is why muhoo's snippet is so bizarre

0:34 muhoo: amalloy: that's it

0:35 amalloy: no, actually that's wrong

0:35 almost. i need each item to be it's own td, is how i ended up with that bizarre mess

0:36 gfredericks: so just one tr?

0:36 scottj: amalloy: do you have a regular integrated video card?

0:36 amalloy: scottj: no, i have a recent gaming card

0:36 though until recently i had a three-year-old gaming card and that was fine too

0:37 scottj: amalloy: ahh, cause I tried it on a brand new pretty good laptop with integrated card recently and wasn't able to get it to be smooth

0:37 amalloy: muhoo: the point is to only use vectors to denote new tags

0:37 use lists to group content inside of existing tags

0:37 Raynes: amalloy: It doesn't need to be a vector, but puppies will continue to live it is one. You confused me when you implied that it wouldn't work at all if it was a vector.

0:38 It *would*, indeed, continue to work if it was a vector, right?

0:38 amalloy: no

0:38 Raynes: What are we working with here? Hiccup?

0:38 muhoo: &&(let [vv [[1 2] [3 4] [5 6]]] [:table [:th "head"] (for [r vv] [:tr (for [i r] [:td i])])])

0:38 lazybot: java.lang.RuntimeException: Unable to resolve symbol: & in this context

0:38 muhoo: &(let [vv [[1 2] [3 4] [5 6]]] [:table [:th "head"] (for [r vv] [:tr (for [i r] [:td i])])])

0:38 lazybot: ⇒ [:table [:th "head"] ([:tr ([:td 1] [:td 2])] [:tr ([:td 3] [:td 4])] [:tr ([:td 5] [:td 6])])]

0:38 muhoo: hiccup

0:38 Raynes: I guess I don't know how hiccup works then.

0:38 amalloy: [:table [[:tr ...] [:tr ...]]] is incorrect hiccup markup

0:39 muhoo: right, it should be [:table [:tr [:td 1] [:td 2]] ..

0:39 amalloy: muhoo: looks fine

0:39 muhoo: not [:table ([:tr ([:td 1....

0:39 amalloy: muhoo: doesn't matter

0:40 try it

0:40 muhoo: haha, great, you're right! thanks!

0:41 amalloy: if you like, you can imagine that hiccup throws away all the ()s in the forms before rendering thme

0:41 muhoo: that's very helpful, thanks, did not know that

0:41 omasanori: scottj: I'm using Core i3 (probably SandyBridge) laptop with Ubuntu guest on VirtualBox w/o (almost) lag

0:44 hiredman: something about 20,000

1:25 muhoo: is this clever or insane: https://www.refheap.com/paste/2885

1:42 serpent223: hi

1:43 can't get this example to run: http://pastebin.com/ae1dHJTS

1:43 error is ClassCastException clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.IRef for the defmulti

1:43 any idea?

1:44 tried clojure 1.[2-4].0

1:44 muhoo: it wants an atom

1:45 or something that can be dereferenced, a var maybe?

1:46 serpent223: would probably make sense to store the hierarchy in an atom...

1:48 yes, does work with an atom -- thx!

1:48 a hint in the docs would be nice though... :)

1:55 * muhoo is getting reasonably adept at interpreting clojure java stacktraces, at last

3:14 amalloy: muhoo: it's a clever approach, but surely just using an atom would be easier than repeatedly def-ing stuff

3:16 (defn reloader [f] (let [srv (atom nil)] (fn [] (when @srv (.stop @srv)) (reset! srv (f)))))...(def reload (reloader -main)) (reload) (reload)...

3:18 not actually a threadsafe use of an atom, but since you're just doing it at the repl it should be fine

4:45 PKHG: hallo, new to clojure and esp. lein on Vista, some help needed to be able to start ;-)

4:47 ... going to coffee .. ==> afk for a while

5:01 `rand`: pkhg_afk: you'll enjoy playing with Clojure--and Leiningen is a great build tool. Are you using Emacs?

5:04 PKHG: rand: back and thanks for giving a sign of life... yes Emacs user I am ..

5:05 `rand`: Great! Do you have swank-clojure installed?

5:06 PKHG: yes it worked ... if I use Mx slime

5:07 clojure ? no not swank-clojure

5:07 slime use SBCL (steel commen lisp or so)

5:08 so how to use clojure in Emacs?

5:08 scottj: PKHG: M-x clojure-jack-in or lein swank and then M-x slime-connect

5:09 PKHG: hmm can try clojure-jack-in but do not know if emacs does know ...

5:09 `rand`: pkhg: Install swank-clojure by typing lein plugin install swank-clojure 1.3.4, then what scottj said. :)

5:10 Dvyjones: clojure-jack-in made learning emacs worth it by itself.

5:10 PKHG: but LEIN does not yet work nice on Vista (I am not Linux) ..

5:10 `rand`: er, 1.4.2

5:11 Ugh--install Virtualbox.

5:12 Raynes: And why would you use Vista?

5:12 PKHG: too slow ... (have Ubuntu, but that behaves not good either ... sometimes it does something without seeing what and why and how long)

5:12 Raynes: That's like the antiOS, isn't it?

5:12 raek: PKHG: do you get an error when you try to install it?

5:12 PKHG: Raynes: don't let us talk about that ;-)

5:13 `rand`: try Arch or Mint.

5:15 PKHG: TC:\Astro_PKHG>lein.bat install swank-clojure

5:15 Wrong number of arguments to install task.

5:15 Expected ([project] [project-name version])

5:15 raek: (whether you are using Emacs or not you need Leiningen)

5:15 `rand`: lein plugin install swank-clojure 1.4.2

5:15 Dvyjones: PKHG: lein.bat plugin install swank=clojure 1.4.2

5:15 PKHG: Remember the "plugin".

5:15 Also, s/=/-/ :P

5:16 PKHG: trying ...

5:16 raek: if you use lein2, you install plugins in another way

5:16 PKHG: are you using 1.x or 2 preview?

5:16 PKHG: seems I need maven Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository

5:17 ??? no idea waht 1.x or 2 meand (newbie: clojure since this morning )

5:17 `rand`: ah--have you run self-install yet?

5:17 PKHG: I think I have to install maven first ...

5:18 Dvyjones: PKHG: Try lein.bat self-install

5:18 PKHG: C:\Astro_PKHG>lein.bat self-install

5:18 "C:\Users\Peter\.lein\self-installs\leiningen-1.7.1-standalone.jar" already exists. Delete and retry.

5:18 C:\Astro_PKHG>

5:18 really delete?

5:18 oh will rename ..

5:18 raek: it looks like you have already done that step

5:19 `rand`: lein deps, maybe?

5:19 raek: PKHG: can you run "lein repl" and get a repl?

5:19 PKHG: moment

5:19 yes ;-)

5:19 and (exit) works too ;-)

5:20 raek: also, the "Unable to download the artifact from any repository" message could be cause by a typo. are you sure you typed "lein plugin install swank-clojure 1.4.2" exactly like that?

5:20 PKHG: I think exact ...

5:20 raek: PKHG: ok, then lein 1.7.1 shold be installed ok

5:20 PKHG: but I do not have maven yet

5:20 raek: I think those part is included in lein's jar file

5:20 but I'm not 100% sure on that

5:21 `rand`: part: you do, thus the error.

5:21 er, pkhg

5:21 PKHG: confused ...

5:22 hm you mean in the jar maven is included?

5:22 raek: yes

5:22 PKHG: ok good to know ...

5:22 raek: the exception comes from "org.apache.maven.wagon.ResourceDoesNotExistException". thus it must be somewhere on your computer

5:22 PKHG: so I have some lein working (the one with cloned with git does not work) ..

5:23 raek: don't use the bleeding edge development version if you are just going to use it

5:23 you also need lein ro build it... :-)

5:23 *to

5:24 PKHG: oh maybe I had a typing error swanj-cloure-1.4.2.jar is created ... (tried again lein plugin install swank-clojure 1.4.2)

5:24 so now I do what in emacs?

5:24 and have to find it first where that jar lives ... moment

5:25 raek: PKHG: you only need to install one emacs package: clojure-mode

5:25 `rand`: M-x clojure-jack-in

5:25 PKHG: clojure-mode needs el files ... searching or do you have a link raek?

5:26 raek: PKHG: do you have emacs-starter-kit, ELPA or some other package.el?

5:26 `rand`: M-x package-list-packages

5:26 PKHG: never used start kit (so I do no know)

5:26 raek: if you have, all you need to do is M-x package-install RET clojure-mode RET

5:26 PKHG: will look for list-packages ... moment

5:27 raek: if not, install package.el using these instructions: http://marmalade-repo.org/

5:27 PKHG: no Mx pac gives nothing ...

5:27 ok ... looking (trying) ... takes some time

5:28 madsy: PKHG: Novice-tip for SLIME: C-c C-c interrupts swank if the REPL hangs up. C-c M-o clears the REPL history.

5:28 And set *print-length* to something sensible so you don't get spammed :-)

5:29 PKHG: packag-list-packages works! ... so now (reading advice ... moment)

5:30 `rand`: I on clojure-mode, then x

5:31 raek: a buffer with compilation errors may pop up when you install clojure-mode. this is normal

5:31 PKHG: raek: install package does not know about clojure ;-( so more help needed ;-)

5:32 `rand`: C-c C-o clears just the last output, which can be useful.

5:32 raek: brb 5 mins

5:32 PKHG: brb = ... (going to coffee?)

5:32 `rand`: pkhg: clojure-mode isn't listed?

5:33 PKHG: no

5:33 `rand`: argh!

5:33 PKHG: yes but will be solved ... ;-)

5:33 sooner or later ...

5:33 `rand`: try M-x package-install, as raek suggested

5:34 PKHG: https://github.com/jochu/clojure-mode a good link/

5:34 ?

5:35 `rand`: M-x package-install RET clojure-mode

5:35 RET

5:36 PKHG: rand: will try your suggestion ... with RET

5:36 no match ...

5:37 `rand`: You could clone that repo and add it to your load path--not sure where that is on Windows.

5:37 What's in your .emacs?

5:38 PKHG: cd c:/Users/Peter/AppData/Roaming/test && lein jack-in 1187: exited abnormally with code 1. so it is directory problem

5:38 cd c:/Users/Peter/AppData/Roaming/test && lein jack-in 1187: exited abnormally with code 1. directory problems

5:39 sorry for twice ..

5:39 `rand`: np

5:40 PKHG: rand: What's in your emacs? do not understand what you mean with this question ...

5:40 coming closer ;-)

5:40 `rand`: Were you in a clojure buffer when you ran clojure-jack-in?

5:41 PKHG: probably not ...

5:41 `rand`: .emacs is the emacs config file

5:41 PKHG: How to do ..

5:41 `rand`: Is Roaming a lein project?

5:42 e.g., lein new Roaming

5:42 PKHG: hmm ?? I have a running lime.bat using /users/peter/.lime but emacs uses */Appdata/Roaming .. I think that is the problem .. how to tell emacs to use as home /users/Peter ???

5:42 lazybot: PKHG: Yes, 100% for sure.

5:43 `rand`: Vista uses AppData/

5:44 PKHG: yes and no ...

5:45 depends on software ...

5:46 `rand`: Modify your Emacs shortcut, change the Start in folder.

5:48 raek: PKHG: I think you need to set your emacs exec-path so it can find lein

5:48 PKHG: yes sound good ...

5:49 trying to save this chat file ... for your advices ;-) (not yet succeeded)

5:49 succes ;-)

5:50 thanks guys ... I am close and will report later ;-)

5:51 (by the way am 70+ retired mathatician ;-)

5:51 PKHG_afk: ...

5:51 `rand`: Cool--I'm using Clojure right now for math. ^_^

5:52 aperiodic: PKHG_afk: what did you focus in?

5:52 PKHG: rand: and I am on a course 'machine-learning' of Stanford U ;-)

5:52 Blender

5:53 `rand`: Very cool--love OCW.

5:53 PKHG: not stirring eating things but the 3D Blender ...

5:54 rand: translate for me OCW = ???

5:54 lazybot: PKHG: Oh, absolutely.

5:56 `rand`: Open Courseware

5:57 the Stanford course is OCW, I think

5:57 progo: always loved the pun :)

5:58 PKHG: ahh yes, by the way, if one has no know how about matrics and vectors it is rather difficult (it was not for me ;-) as you can guess)

5:58 it is ocw but started already ... and is near the finish

5:59 programming tasks ==> 100% up to now ... questions between 50 5 and 95 % ;-)

5:59 5 = %

5:59 `rand`: MIT has a ton of good OCW courses

6:00 PKHG: will have a look too ;-) (good for old brain ...)

6:00 `rand`: ...and check Yale

6:00 PKHG: http://ocw.mit.edu/index.htm

6:01 `rand`: That's it.

6:01 PKHG: Yale too? oooo soooo muccch to learn ...

6:01 `rand`: Harvard may have some as well.

6:03 PKHG: ... ok ... will first see how to persuade emacs to use clojure ... ;-) bye and see you later (I think ...)

6:03 raek: PKHG: when the path is set up correctly, you should be able to do "M-! lein version RET" and get the version info in the echo area

6:04 http://emacswiki.org/emacs/ExecPath

6:04 `rand`: good luck!

6:04 PKHG: ... fine (looking at ExecPaht .._ thanks raek!!!_

6:04 raek: PKHG: after that you need to create a clojure project using "lein new tinkering" (where "tinkering") is your project name

6:05 you always do everything in a project

6:05 PKHG: ... clear ...

6:05 raek: then you visit a file in the tinkering/ directory (for example tinkering/src/tinkering/core.clj)

6:05 and do M-x clojure-jack-in

6:06 you should then get a repl that can use any source files in the project and any libraries you have declared in the project.clj file

6:07 (also, "RET" stands for the return key)

6:08 PKHG: bye guys leaving ...

7:36 alexyakushev: Could someone please help? I have macro called `with-activity` that binds the dynamic var *activity*. Then I have another macro called `do-ui` that executes it's body on the UI thread.

7:36 So when I call (do-ui (with-activity foo ....)) all is well.

7:37 But when I call (with-activity foo (do-ui .....)) the *activity* is unbound

7:38 Any way to solve this?

7:39 Oh, I understand now. Because dynamic scope is thread-local, so the *activity* is not authomatically transfered to the other thread. Am I right?

7:49 ivan: alexyakushev: that or the bindings were not captured

8:01 alexyakushev: I've solved this by grabbing *activity* to the lexical scope (by let'ting it in the beginning of `do-ui` macro) and then binding it again to the dynamic scope at the beginning of the new thread

8:26 mittchel: Is it possible to use clojure color codes in a word document?;o

8:38 Is there an easy way to obtain the last item in a list?

8:38 progo: last

8:38 scottj: &(last '(1 2))

8:38 lazybot: ⇒ 2

8:38 mittchel: isn't that for sequences only?

8:39 progo: what is a list then :)

8:39 mittchel: Where is that ' for?

8:39 scottj: mittchel: so it doesn't think 1 is a function

8:39 mittchel: When I'm not using that it gives me an error. Cause I've tried last without '

8:39 ahh

8:40 he doesn't evaluate right?

8:40 scottj: he?

8:41 &(quote (1 2 3))

8:41 lazybot: ⇒ (1 2 3)

8:41 scottj: &(1 2 3)

8:41 lazybot: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

8:41 mittchel: ah

8:41 I'm still confused.. () is list and [] is sequences right?

8:41 scottj: [] is a vector

8:42 you can make sequences out of many things, including lists and vectors

8:42 mittchel: ah

8:42 scottj: you can quote many things too

8:42 &foo

8:42 lazybot: java.lang.RuntimeException: Unable to resolve symbol: foo in this context

8:42 scottj: &'foo

8:42 lazybot: ⇒ foo

8:42 mittchel: hmm thanks scottj

8:43 scottj: mittchel: I take it you haven't gotten to macros yet?

8:43 mittchel: By the way, is destructuring only possible on vectors?

8:43 scottj: no, lists and maps are supported too

8:43 mittchel: scottj: Very basic.. going to do that in a sec.. studying my course got an exam about clojure soon ;D

8:43 scottj: &(let [{:a a} {:a 1}] a)

8:43 lazybot: java.lang.Exception: Unsupported binding form: :a

8:43 scottj: &(let [{a :a} {:a 1}] a)

8:43 lazybot: ⇒ 1

8:44 mittchel: (defn myfun [[x y]] (print x) (print y))

8:44 this is restructuring too right?

8:44 scottj: &(let [[a b] '(1 2 3)] a)

8:44 lazybot: ⇒ 1

8:44 mittchel: de*

8:44 but on a vector

8:44 scottj: its destructuring on a sequence. in destructing [] means sequence not vector

8:45 mittchel: alright

8:45 LEts say I want the same function to work with a list.. how should it be then?

8:46 scottj: you just going down your list of homework problems?

8:46 (myfun '(1 2))

8:46 or (myfun (list 1 2))

8:47 you should figure out the difference between those two

8:47 mittchel: No it just describes sequences and I wanted to find out on lists too but had to be sure since I'm writing myself a summary

8:47 Yea but when I use this: (defn myfun [[x y]] (print x) (print y)) can i call it by: (my fun '(1 2))? since you use [] inside the defn

8:48 That's the only issue I've problems with to be honest.. I thought when you use [] you can only use vectors/sequences since thats the format for a vector (with destructuring a sequence)

8:50 Hm got it now :P found it out thanks

8:51 Vinzent: mittchel, it doesn't matter whether the argument is a list or a vector or something else; clojure has the sequence abstraction which hide differences between them. Thus, you can use your [[x y]] destructing for any seqable thing

8:52 mittchel: Vinzent: Thanks :D that really helped me lol I think I'm used to Java since they are strict in this

8:52 A string is a string and nothing else

8:52 scottj: Vinzent: almost, I think. anything that's sequential, not that you can call seq on.

8:53 &(map seq [[1] '(1) {:a 1} "foo"])

8:53 lazybot: ⇒ ((1) (1) ([:a 1]) (\f \o \o))

8:53 scottj: &(map sequential? [[1] '(1) {:a 1} "foo"])

8:53 lazybot: ⇒ (true true false false)

8:53 scottj: [] destructuring will only work on sequential? things I think

8:54 Vinzent: it works on strings

8:54 scottj: ahh, apologies

8:55 Vinzent: ,(let [[[k v] entry] {:a 1 :b 2}] [k v entry])

8:55 clojurebot: #<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap>

8:55 Vinzent: hah, but not on maps

9:53 serpent213: hi

9:53 where did clojure.contrib.ns-utils/immigrate go?

9:53 i try to write a simple wrapper...

9:55 kmicu: serpent213: http://clojure.github.com/clojure-contrib/ns-utils-api.html

9:57 serpent213: is this still valid for clojure >= 1.3?

10:00 kmicu: serpent213: from clojure-contrib readme file

10:00 = Clojure-contrib Versions = Versions of clojure-contrib are matched to versions of Clojure. If you are using Clojure 1.0, use clojure-contrib 1.0.* If you are using Clojure 1.1, use clojure-contrib 1.1.* If you are using Clojure from the "master" branch on Github, use clojure-contrib from the "master" branch on Github. If you are using Clojure from the "new" branch on Github, use clojure-contrib from the "new" branch on Github.

10:01 scottj: serpent213: I don't think that contrib was migrated to new contrib. that function may happen to work though. I suspect it won't be.

10:01 won't be migrated, since I think some people disapproved of immigrate

10:02 kmicu: serpent213: it exists in 1.3.0-alpha

10:03 scottj: it was written for compojure which I don't think uses it since migration to ring

10:06 serpent213: hmmm... i'm trying something like: http://pastie.org/3976825

10:06 maybe immigrate is not the right way...?

10:07 i would like to use my http-client instead of clj-http.client, as a drop in

10:14 scottj: clj-http has middleware for this kind of thing, I'm not sure exactly how to use it though

10:20 serpent213: something like http://jaderholm.com/paste/wrap-user-agent.clj.html

10:22 borkdude: ,(type (list* 1 2 3))

10:22 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

10:22 borkdude: ,(doc list*)

10:22 clojurebot: "([args] [a args] [a b args] [a b c args] [a b c d & ...]); Creates a new list containing the items prepended to the rest, the last of which will be treated as a sequence."

10:22 scottj: serpent213: scratch that, that doesn't help with the other request methods. clj-oauth2/client.clj has a macro and redefines get/post/etc

10:24 borkdude: ,(type (list* 1 2 3 nil))

10:24 clojurebot: clojure.lang.Cons

10:24 borkdude: ,(type (cons 1 nil))

10:24 clojurebot: clojure.lang.PersistentList

10:24 borkdude: ,(type (cons 1 (range 10)))

10:24 clojurebot: clojure.lang.Cons

10:24 borkdude: ??

10:24 lazybot: borkdude: What are you, crazy? Of course not!

10:25 serpent213: scottj: thanks, i'll have a look! :)

10:25 borkdude: cemerick I'm rading your book about cons and list* now

10:25 cemerick I don't totally get what you mean with "creating a seq" directly

10:26 cemerick (or one of the other authors, I don't know who wrote what of course)

10:28 ,(type (rest (cons 1 (range 10))))

10:28 clojurebot: clojure.lang.LazySeq

10:29 borkdude: ,(type (cons 1 (range 10)))

10:29 clojurebot: clojure.lang.Cons

10:29 borkdude: ok

10:30 so why does (cons 1 nil) return a persistentlist?

10:33 AimHere: ,(rest '())

10:33 clojurebot: ()

10:35 AimHere: ,(concat nil nil)

10:35 clojurebot: ()

10:35 AimHere: nil seems to standin for the empty list sometimes

10:35 pandeiro: the other day i asked if there was a way to emulate a 'for x in obj...' loop in cljs - anyone know?

10:35 borkdude: ,(type (cons 1 '()))

10:35 clojurebot: clojure.lang.Cons

10:35 borkdude: ,(type (cons 1 nil))

10:35 clojurebot: clojure.lang.PersistentList

10:36 borkdude: pandeiro I wrote a macro for it

10:36 pandeiro you can easily define your own, using for and range

10:36 pandeiro o wait, for is already that

10:36 pandeiro: borkdude: cool, but working with js objects right, not maps?

10:37 borkdude: pandeiro ah.. wait.. cljs...

10:37 pandeiro I don't know about cljs, but if the obj is seqable it should work I think

10:37 pandeiro: borkdude: not seqable

10:37 at least not by default

10:37 borkdude: pandeiro then extend-type it?

10:38 pandeiro: borkdude: it's time i learned how to do that, you're right :)

10:38 i'm still not sure how one would implement it

10:38 beyond just the clojure extend-type semantics, i don't know what if anything implements the 'in' special form of js

10:38 cemerick: Borkdude: I don't have a PDF in front of me right now.

10:39 But, cons creates a seq, list* creates a list.

10:39 The fact that lists are themselves seqs, and that cons sometimes returns lists is an implementation detail fundamentally.

10:41 borkdude: cemerick I'm slightly confused by the sentence "there are two ways to <it>create</it> a seq: <tt>cons</tt> and <tt>list*</tt>

10:41 "

10:41 cemerick create as in, from scratch?

10:42 cemerick nm, I'll read on ;)

10:44 cemerick: "from scratch" is a bit ambiguous :-)

10:45 borkdude: cemerick create as in "the most fundamental seq using only scalar values and not other collections" ?

10:46 cemerick: There is no "most fundamental seq"

10:46 that is, there is no ground or base case

10:47 gfredericks: ,(time (first (cons a (range 100000))))

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

10:47 gfredericks: ,(time (first (cons :a (range 100000))))

10:47 clojurebot: "Elapsed time: 0.099 msecs"

10:47 :a

10:47 gfredericks: ,(time (first (list* :a (range 100000))))

10:47 clojurebot: "Elapsed time: 0.105 msecs"

10:47 :a

10:48 gfredericks: cemerick: doesn't "creating a list" imply that the rest has to be realized?

10:48 ,(type (list* :a (range 1000000)))

10:48 clojurebot: clojure.lang.Cons

10:48 gfredericks: ,(type (cons :a (range 1000000)))

10:48 clojurebot: clojure.lang.Cons

10:48 borkdude: a footnote on page 93 says list* does *not* return a list

10:49 gfredericks: I've always thought of list* as just a generalization of cons

10:49 borkdude: cemerick the text seems to make a distinction between "producing" and "creating" seqs and for the latter there are only two ways: cons and list*

10:51 "you can think of cons always 'prepending' to the tail collection's sequence' ..

10:51 tail collection?

10:52 the tail meaning, the future tail right?

10:53 nm… I think I understand most of it

10:53 gfredericks: ,(type (apply list (range 100000)))

10:53 clojurebot: clojure.lang.PersistentList

10:55 borkdude: The book says cons has little to do with other Lisps cons cells

10:55 but is Cons.java not what a cons cell really is all about: a value and a tail?

10:56 the only difference is that the tail always has to be a seq

11:01 cemerick: Borkdude: I think it's fair to distinguish between creation and production, where the latter more accurately characterizes lazy seqs.

11:01 gfredericks: yes

11:02 Borkdude: AFAIK, if you can't create a dotted pair, it's not a cons cell.

11:02 but, I'm by no means a CL expert.

11:02 borkdude: cemerick "it has little to nothing to do with it", of course it has to do with it ;)

11:04 cemerick: In terms of heritage, sure.

11:04 borkdude: cemerick "you can create a lazy sequence" p93

11:06 hyPiRion: Well, a main difference is that you can represent leaves in a CL cons, but cannot in Clojure.

11:06 borkdude: hyPiRion that's basically the main difference yes

11:06 hyPiRion: And, of course, you cannot change the values, but in CL, you can.

11:08 borkdude: cemerick I'm just dealing with details here, don't worry

11:09 cemerick I like the book very much so far

11:10 cemerick: Borkdude: Sure; of course, details are important. Don't get too hung up on the creates/produces thing though. :-)

11:10 borkdude: cemerick I can keep a list for little improvements for the next edition if you'd appreciate it

11:43 logaan: is it possible to use protocols without using deftype or defrecord?

11:44 perhaps by setting the :type metadata of a clojure datastructure?

11:44 AimHere: Well you can extend protocols to data structures that are already created

11:44 ,(doc extend)

11:44 clojurebot: "([atype & proto+mmaps]); Implementations of protocol methods can be provided using the extend construct: (extend AType AProtocol {:foo an-existing-fn :bar (fn [a b] ...) :baz (fn ([a]...) ([a b] ...)...)} BProtocol {...} ...) extend takes a type/class (or interface, see below), and one or more protocol + method map pairs. It will extend the polymorphism of the protocol's methods to call the suppl...

11:45 logaan: i would like some instances of clojure's map to behave in one way and other instances to behave in another way

11:45 as i understand it, extending types would cause all instances to behave in the same way

11:47 i've implemented using multimethods for now. but it feels like protocols would be a perfect fit.

11:47 AimHere: You mean you want different things to happen when you call objects of the same type?

11:47 logaan: yes

11:48 AimHere: That sounds more like a multimethod thing

11:48 gfredericks: protocols dispatch on type

11:49 logaan: @gfredericks type as returned by the type function? or do you mean class?

11:49 gfredericks: class

11:49 AimHere: The choice is between multimethods dispatching on whatever-the-hell-you-like and being relatively inefficient, and protocols dispatching on type and being efficient

11:50 logaan: https://github.com/logaan/orm-untangled/blob/master/src/orm_untangled/validation_types.clj this is the file where i'm using multimethods if you're curious

11:50 ok i guess that makes sense

11:51 gfredericks: are extend-type'd protocol dispatches more efficient than multimethods?

11:52 logaan: at the very least they'd be dropping a call to the dispatch function you define with defmulti

11:52 and i imagine they could be more efficient in addition to that as they line up with the underlying architecture

11:55 gfredericks: I mean extend-type'd as opposed to types that were created with the protocol implementation in place

11:57 AimHere: I'd guess they'd be pretty close to any normal function dispatch

11:57 You can use defn to overload any bog-standard function type multiple argument types

11:59 I can't see how extend is going to be much more inefficient than whatever defn is doing already

12:26 wink: anyone knows if the change of syntax highlighting in CCW 0.8 was intentional? Can I get the old colors back without manually doing it?

12:52 kilon_alios: aloha guys

12:53 anyone can recommend me a link to show how to install and setup slime for clojure in emacs ?

13:13 kmicu: kilon_alios: https://github.com/technomancy/swank-clojure

13:15 kilon_alios: kmicu: thanks follow the instruction there when i issue jack-in it reports error "erro in process filter: Symbol's definition is void :define-slime-contrib", any idea how to fix this ?

13:16 kmicu: kilon_alios: what version of os, emacs, lein, swank-clojure do you have?

13:16 kilon_alios: what i did with lein was this 1) create a folder, and do a lien new

13:16 and then take the project.clj and add this line in the end

13:16 :plugins [[lein-swank "1.4.4"]]

13:17 kmicu: i got emacs 24 , macos lion , latest clojure and lein

13:17 I have also installed JDK

13:17 the latest one from apple

13:17 kmicu: kilon_alios: lein 2 or lein 1.7?

13:18 kilon_alios: kmicu: https://github.com/technomancy/leiningen

13:18 is that 2 or 1.7 ?

13:19 konr: Is there a function/macro that expands like (foobar 5 inc 10) -> (-> 10 inc inc inc inc inc)?

13:19 kmicu: 1.7.1 currently

13:19 kilon_alios: sorry my emacs and lisp kung fu is very weak, can you guid me through

13:19 ?

13:21 semperos: can anyone interpret this stracktrace and provide any info? https://gist.github.com/2815145

13:22 happens when I compile ClojureScript

13:22 been making edits on my codebase for a while now, so not exactly sure what's caused it yet

13:24 konr: In case anybody got curious, (defmacro run-n-times [initial fun times] `(-> ~initial ~@(repeat times fun)))

13:25 gfredericks: konr: if you're just using functions, you could use comp

13:25 ,((apply comp (repeat 20 inc)) 1)

13:25 clojurebot: 21

13:26 konr: gfredericks: even better! Thanks!

13:29 coventry: In the code at http://pastebin.com/inpNCR8x if I replace "takeends" in the definition of endstarts with what I think is the corresponding anonymous function, #(vec (last (last %)) (last (first %))), I get "Wrong number of args (2) passed to: core$vec". Why is that?

13:32 alexyakushev: ,(doc vec)

13:32 clojurebot: "([coll]); Creates a new vector containing the contents of coll."

13:32 alexyakushev: You want to use a vector: ,(doc vector)

13:32 ,(doc vector)

13:32 clojurebot: "([] [a] [a b] [a b c] [a b c d] ...); Creates a new vector containing the args."

13:33 alexyakushev: Could someone please explain this behavior? http://pastie.org/3977918

13:34 bordatoue: Is it possible to make an executable jar from clojure project similar to java project within eclipse

13:35 gfredericks: bordatoue: are you using lein? or are you asking how to do it in eclipse?

13:35 alexyakushev: what're you trying to do?

13:36 bordatoue: no I am not using lein, is there a plugin for eclipse

13:36 gfredericks: I could explain why it does that if you're really after understanding, but it's a little subtle

13:37 bordatoue: I just want to make an executable jar for clojure project in eclipse , what would be the best way to do it

13:37 coventry: alexyakushev: Thanks, I was getting its signature confused with that of list.

13:37 alexyakushev: gfredericks: This is a condensed example. My real macro extracts an anonymous function from a map in the compile time (using the arguments user provides) and then calls this function

13:38 gfredericks: alexyakushev: so the short answer is that macros have to return s-expressions. You're trying to return a list containing a function; a function is not an s-expression

13:38 alexyakushev: you want to "call this function" at compile-time or runtime?

13:38 loliveira: hi, i'm trying to create a macro to wrap include-js hiccup helper but something is wrong: (defmacro include-backbone []

13:39 (defmacro include-backbone []

13:39 coventry: Followup question: Why does (#([1 2])) fail with an arity exception? (I'll know to use an extra vec in there in future, though.)

13:40 gfredericks: coventry: you're calling the vector as a function; vectors take 1 arg

13:40 ,([1 2] 1)

13:40 clojurebot: 2

13:40 coventry: Oh, beautiful. Thanks.

13:41 alexyakushev: gfreederick: Why, no, I return a list with that function inside, basically I want to call this function in runtime

13:41 gfredericks: loliveira: try using refheap.com

13:41 alexyakushev: note if you add a backtick to your function form on line 2 it should work

13:41 bordatoue: how is any documentation on creating a clojure binary distribution

13:42 gfredericks: alexyakushev: whether or not that helps you is a separate issue I'm not sure about

13:42 alexyakushev: gfreedericks: Do you mean before the "let"?

13:42 gfredericks: (let [macro-clojure `(fn [] ~macro-argument)]

13:42 forgot the ~ as well

13:42 loliveira: ty gfredericks

13:42 alexyakushev: gfreedericks: But I want to create the closure at the runtime, not just its definition

13:43 *compile-time, sorry

13:43 gfredericks: so you want that function to return the quoted code that is the argument to the macro?

13:43 loliveira: https://www.refheap.com/paste/2888

13:43 include-jquery works fine

13:44 but include-backbone does not.

13:44 gfredericks: loliveira: extra parens?

13:44 well I guess it's more complex than that

13:44 does include-js let you give multiple args?

13:44 loliveira: don't work even without them

13:45 alexyakushev: gfreedericks: basically yes, I want a closure that returns just the argument to the macro

13:45 gfredericks: (let [macro-clojure `(fn [] ~(list 'quote macro-argument))]

13:45 loliveira: gfredericks, yes

13:45 nice idea.

13:46 alexyakushev: gfredericks: But once again, this one would be just a list, it won't be evaluated in the compile-time this way

13:47 loliveira: it worked, ty. but what could i do if include-js didn't support multiple args?

13:47 alexyakushev: gfredericks: But thanks so far, I don't dare to waste your time anymore

13:48 gfredericks: loliveira: this is hiccup?

13:48 loliveira: yes

13:48 gfredericks: alexyakushev: no I like these kinds of questions

13:49 loliveira: you could replace the outer parens with square-brackets for a vector, and then splice them into your calling hiccup forms with concat or something like that

13:49 loliveira: you want to call the function at compile-time?

13:49 bordatoue: can anyone please tell me the preferred way to compile clojure to an executable

13:49 loliveira: gfredericks: yes

13:50 gfredericks: bordatoue: does your project have a project.clj? I'm not familiar with how eclipse handles clojure

13:50 loliveira: then what do you want to do with the return value from the function?

13:50 loliveira: i am looking for a C macro expansion behavior.

13:50 bordatoue: so what is the preferred way, I don't mind changing it

13:51 gfredericks: loliveira: oh like you have a map somewhere defining all possible expansions?

13:51 loliveira: this is the client code: https://www.refheap.com/paste/2889

13:52 i'd like (include-backbone) were being replaced by that 2 functions calls (underscore and backbone)

13:52 gfredericks: bordatoue: if you use leiningen, you'll need to specify your main namespace as the :main key in the project.clj, then add (:gen-class) to the ns-decl in that file, and make sure there is a function called -main

13:53 alexyakushev: you want to call the function at compile-time?

13:53 loliveira: sorry I just mixed you up with alexyakushev. did you still have a question?

13:53 loliveira: i think i don't have this map.

13:53 alexyakushev: gfredericks: No, generate at the compile-time, but call at the runtime.

13:54 gfredericks: alexyakushev: then why did you say previously that my solution wouldn't call the function at compile time?

13:54 bordatoue: does clojure have an entry point method, similar to public static void main in java

13:54 gfredericks: (i.e., why is that a problem if you don't want to do it?)

13:54 bordatoue: yes I just described for you how to set that up

13:54 using (:gen-class) to make sure a class gets generated and a -main function for the public static void main

13:54 loliveira: yes, i still have.

13:55 =)

13:55 gfredericks: loliveira: okay -- was the using-a-vector-and-splicing-in comment not clear?

13:55 or have you not asked the question yet?

13:56 alexyakushev: gfredericks: because macroexpand of your solution looks like ((clojure.core/fn [] (quote "sample-argument")))

13:56 loliveira: can you pls point me some comment not clear?

13:56 <gfredericks> or have you not asked the q

13:56 gfredericks: alexyakushev: and why doesn't that do what you want? You said you wanted the function to return the argument to the macro

13:56 loliveira: can you pls point me some using-a-vector-and-splicing-in exemple?

13:56 example*

13:56 gfredericks: loliveira: I said:

13:56 <gfredericks> loliveira: you could replace the outer parens with

13:56 square-brackets for a vector, and then splice them into your

13:56 calling hiccup forms with concat or something like that [13:45]


13:57 loliveira: i will try, but i don't know how to do that yet.

13:58 alexyakushev: gfredericks: Because in my actual example I do a lot more than just wrap the macro-argument in a fn, so I want to save time by running this in compile-time

13:58 gfredericks: loliveira: another thing you could try is wrapping them both in a :div -- I don't know if that's legal in a <head> though

13:59 alexyakushev: maybe I'd have an easier time if you gave me an example of the macro being called and what it should expand to

14:00 loliveira: i dont think is legal using div inside head.

14:00 thank you soo much

14:01 gfredericks: loliveira: so [:html (vec (cons :head (include-backbone)))] would work I think

14:01 or wait no

14:01 you can just return a list from include-backbone and it should work naturally now that I think about it

14:02 so (defmacro include-backbone [] `(list (include-js ...) (include-js ...))) would do it

14:02 loliveira: i will try, 1 sec

14:04 ir worked! =D

14:04 ir = it

14:04 ty gfredericks

14:04 gfredericks: np

14:06 alexyakushev: also you might find something helpful in clojure.tools.macro

14:09 antares_: Quartzite documentation site is up: http://clojurequartz.info/ (very much WIP but I feel it may be already useful)

14:09 jblomo: anyone familiar with the new reducers code?

14:20 alexyakushev: gfredericks: Thanks again. My actual problem was that I tried to transfer an Object from compile-time to the runtime

14:23 pandeiro: where is let implemented in cljs?

14:33 kilon_alios: who wants to listen to my new ambient track ? raise hands now !

14:34 konr: I do

14:34 composed with clojure tools? :)

14:34 kilon_alios: no sorry i use mainly hardware synthesizers

14:34 konr: here -> http://www.mediafire.com/?cgi2g3dojlgof97 , sorry for the unkowning ads

14:35 but i plan to start using Overtone , i hope soon enough

14:35 oh the track is still WIP

14:37 kmicu: pandeiro: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/core.clj

14:38 kilon_alios: konr: dont be afraid not to like it, i love all critics ;)

14:41 konr: kilon_alios: it's interesting. Not very familiar with ambient music, although I used to listen to Aghast, Maison close et al

14:42 kilon_alios: konr: thanks, glad you like it

14:42 bartiosze: Hi! is this a proper place to ask ClojureScript/ClojureScriptOne related questions?

14:43 kmicu: bartiosze: clojure google group or here :)

14:44 bartiosze: ok, then maybe my answer is already on the group. ;-)

14:44 kmicu: bartiosze: I make project based on ClojureScript One, maybe I can help

14:45 pandeiro: kmicu: what line?

14:46 kmicu: pandeiro: from 28 to 45 I guess

14:46 pandeiro: its imported from clojure.core

14:47 pandeiro: ok so it's not defined in clojurescript at all?

14:47 kmicu: pandeiro: I can't confirm that :)

14:50 pandeiro: but from code it looks like 'let' macro is imported from clojure.core

14:56 pandeiro: kmicu: ok thanks

15:01 are non-blocking fns possible in clojure? ie (do (prn 1) (slow-async-prn 2) (prn 3)) ;=> 1 3 2

15:04 gfredericks: pandeiro: try future

15:15 upwardindex: Raynes: I just translated the js in tryclojure to cljs, I sent you a pull request, let me know if you'd like me to improve anything

15:17 Dvyjones: How do I round of a rational number to the nearest integer? (Or just always round down, either works)

15:17 upwardindex: ,(Math/round 3.4)

15:17 clojurebot: 3

15:17 Dvyjones: Duh.

15:18 I keep forgetting I have Java :P

15:18 ,(Math/round 22/7)

15:18 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: round>

15:18 Dvyjones: :(

15:19 upwardindex: Dvyjones: java doesn't know rationals, I'm afraid

15:19 Dvyjones: upwardindex: Figured. How do I round those?

15:20 upwardindex: ,(Math/round (float 22/7))

15:20 clojurebot: 3

15:20 gfredericks: there's an exact way too, that'll work for arbitrarily large rationals

15:21 tmciver: ,(int 22/7) ;; rounds down

15:21 clojurebot: 3

15:21 borkdude: I tend to do just (int 3.1516)

15:31 Raynes: upwardindex: Cool stuff. Not sure I actually want to use ClojureScript there though. I'll take a look shortly.

15:32 upwardindex: Raynes: why not?

15:33 Raynes: Because we don't really gain anything besides a compile step from it and I haven't used cljs enough to know how any of that stuff works which could end up making it difficult to make simple changes in the future. *shrug*

15:34 But that doesn't mean I wont take the pull request. Just going to think about it.

15:35 upwardindex: I'll let you have a look, I'm sure you'll be pleasantly surprised at how much it looks like your original code :)

15:35 Raynes: Most of that code was actually someone else's.

15:36 Nibble: Raynes, what happened to 9b?

15:36 Raynes: A lovely fellow who added the dynamic tutorial thingy.

15:36 Nibble: The IRC network? It's 10b now.

15:37 Nibble: Raynes, zc00gii still around?

15:37 Raynes: Nibble: No.

15:37 Nibble: d'awww

15:37 Raynes, nixeagle?

15:38 Raynes: upwardindex: That's kind of my point though, really. The code is pretty much the same either way. But I'm probably just being an asshole. I've always been apprehensive about cljs.

15:38 Nibble: Once every few months.

15:38 Nibble: kk

15:38 upwardindex: Raynes: last week you asked me for cljs code to work with jquery console, but I was at work

15:39 Raynes: Indeed!

15:39 upwardindex: What does (clj->js ..) do?

15:39 upwardindex: Raynes: transforms clojure data in javascript data

15:40 Raynes: So Clojure to JSON?

15:40 gfredericks: probably javascript objects rather than a serialized string

15:40 so "to JSON" would be misleading

15:40 upwardindex: what gfredericks said

15:41 Raynes: Seems odd that ClojureScript wouldn't do that itself.

15:42 gfredericks: when would clojurescript do that?

15:43 Raynes: Uh, I don't know.

15:43 gfredericks: or you mean provide the function instead of jayq

15:44 Raynes: No, I would have expected ClojureScript to make the conversion under the covers, since the map would be being passed to a javascript function. I'm sure there are technical reasons that that is stupid, but I'm ignorant enough about javascript and friends to mention it anyways.

15:45 gfredericks: I think that would be kind of unexpected

15:45 like asking why clojure doesn't auto-convert seqs to arrays if you call an array-expecting function

15:46 and I doubt there's a foolproof way to know for sure if you're calling a js function vs a cljs function

15:46 ibdknox: a cljs function *is* a js function

15:46 gfredericks: that last point is probably the real issue

15:46 ibdknox: yes; thus they're hard to tell apart :)

15:47 Raynes: I was thinking more along the lines of how you can pass maps to Java that expects a HashMap, but no conversion actually happens there IIRC.

15:47 y3di: ibdknox: did you start devving lighttable in lighttable yet?

15:48 ibdknox: y3di: been working on the playground first :)

15:48 anonymoose_: hello, new clj user here, is there a definitive tidy utility for clojure? I love using tidy for all my blocks.

15:49 kilon_alios: wow did not know light table uses clojure o_O

15:50 ibdknox: kilon_alios: it's written entirely in Clojure

15:50 and CLJS

15:50 kilon_alios: ibdknox: wow, I am actually making a similar project and I wanted to unite with project doing similar things

15:51 mine is more a GUI and a visual programming language

15:51 anonymoose_: Hi Chris! Great work on light table!

15:51 ibdknox: thanks :)

15:51 kilon_alios: but i wanted IDE capabilities like the ones you implement

15:51 ibdknox: are you aware of field ? its JVM but jython

15:51 ibdknox: I am

15:52 kilon_alios: do you intend for visual coding too ?

15:52 anonymoose_: anybody know of a tidy utility for clj? i.e. reformatter? also, is there and official style guide somewhere?

15:52 ibdknox: it's intended to be a general surface, so absolutely

15:53 kilon_alios: very interesting

15:53 borkdude: ibdknox support for touch interfaces? (don't know how, but sounds cool ;))

15:53 ibdknox: borkdude: should get it for "free"

15:54 borkdude: since it uses a webview

15:54 kilon_alios: this is my project --> https://github.com/kilon/Ephestos

15:54 ibdknox: borkdude: but yeah, that's something I really want to explore later on

15:54 kilon_alios: its basically just a blender addon for now (new GUI for blender) but i am also doing the rest with clojure

15:55 *considering doing the rest

15:55 borkdude: ibdknox touching and moving s-expressions around is easier than remembering paredit key bindings

15:55 * kilon_alios notes to try light box

15:55 ibdknox: kilon_alios: cool

15:55 kilon_alios: i mean lighttable sorry :D

15:56 ibdknox: borkdude: yeah, I think there's some really neat stuff that could be done there. Unfortunately the hardware issues haven't really been addressed yet

15:56 cljn00b: anybody? tidy for clj?

15:56 ibdknox: borkdude: if Light Table really takes off, I'd love to help push in that direction

15:56 upwardindex: cljn00b: what does that do?

15:56 gfredericks: Raynes: methods expecting a HashMap specifically? or just a Map?

15:57 ibdknox: borkdude: finding a way to mix a keyboard centric interface with touch elements would be awesome

15:57 most people just use the indent rules from emacs as gospel I think

15:57 cljn00b: tidy is a reformatter for code, normalizes indents and newlines from unformatted code.

15:57 ibdknox: vim has similar indenting though it's slightly different

15:57 Raynes: Emacs and Vim can both do that.

15:58 Well, unless you write the whole thing on a single line.

15:58 It can fix indentation.

15:58 cljn00b: yah, I'm looking for something I can pipe a block of clj to and have consistent style enforced by the util.

15:58 like perltidy or other variants.

15:59 pandeiro: could anyone point me a naive impl of a let macro?

15:59 kilon_alios: ibdknox: is there a download i can try, sorry i am very new with clojure

16:00 ibdknox: kilon_alios: it's not out yet

16:00 kilon_alios: ok so it wont be free and open source ?

16:00 eduard: how to write short: (map (fn [a b] [a b]) coll) ?

16:01 gfredericks: (map vector coll)

16:01 borkdude: Raynes cljn00b do I feel a new leiningen plugin coming up? (lein tidy)

16:02 eduard: gfredericks, Thanks

16:03 kilon_alios: ah ok the info is in the kickstarter

16:03 ibdknox: kilon_alios: it will be once it's built

16:03 kilon_alios: sorry :D

16:03 ibdknox: no worries :)

16:04 borkdude: ibdknox any thoughts on scripting abilities? clojure?

16:04 ibdknox: borkdude: GUI scripting will be CLJS

16:04 reisio: looking for a copy of the image that was here: http://clojure.googlegroups.com/web/Clojure-logo.png

16:05 ibdknox: the language backends can be written in anything that can do TCP and JSON :)

16:05 which enables a lot of *really* cool stuff

16:05 the sql and benchmarking modes that I showed were only about 100 lines of CLJS each

16:07 Raynes: borkdude: Nope.

16:07 cljn00b: made a gist for what I'm looking for. Please let me know if anybody knows about a tidy util for clojure. https://gist.github.com/2815682

16:08 Raynes: Yeah, I don't think there is anything that can do that.

16:08 Those rules are entirely arbitrary.

16:08 kilon_alios: oh python support is close too :)

16:08 nice

16:08 reisio: cljn00b: not a lint?

16:09 cljn00b: if linting implies reformatting, yes. I thought linting was just syntax checking.

16:09 reisio: I've seen some that reformat, too

16:09 ibdknox: that kind of reformatting is incorrect

16:09 reisio: there's at least one clojure lint tool, might check it

16:09 cljn00b: I'm hoping for a perltidy analogue.

16:09 ibdknox: or rather "not correct"

16:09 lol

16:10 I don't think it'd be meaningful to have such a thing

16:10 for clojure, that is

16:11 cljn00b: for consistency across developers in a shared project, I'd think style enforcement would be a good thing.

16:11 reisio: don't really need a tool for that

16:11 cljn00b: my incorrect newlines not withstanding.

16:11 reisio: though obviously one would be useful

16:12 kilon_alios: oh a lot of requests for python, did not know python is so popular

16:12 ibdknox: the problem is that what should and should not be on the next line is highly context dependent

16:12 reisio: kilon_alios: half are probably to do with pornography :p

16:12 ibdknox: kilon_alios: it's consistently the highest rated language on most general tech sites

16:13 cljn00b: which is why I was hoping for a clojure style guide to help me figure the newlines out.

16:13 ibdknox: cljn00b: I mean that to the point where it depends on what the function/macro does

16:13 reisio: I assume if it parses there are no rules

16:13 kilon_alios: really ? i thought people hated because of whitespaces and slow execution. I am a big fan of python myself

16:14 i know of course its fairly popular and people love it for the small learning curve

16:14 zakwilson: There are Lisp style guides to be found. They don't vary much.

16:14 cljn00b: ibdknox, what would be the idiomatic indentation for my sample?

16:15 reisio: I used to hate it just because of the white space, but for even more reasons now :p

16:15 ibdknox: haha probably the way you have it to begin with :)

16:16 cljn00b: oh.

16:16 borkdude: global variables in for loops are really a weird property of Python

16:16 ibdknox: that's all a single context describing a single output

16:17 those things usually end up on one line

16:17 though that would probably be wrapped in a function and hopefully you wouldn't embed the vectors there

16:17 it'd be much smaller if you didn't

16:18 cljn00b: thank you ibdknox.

16:18 zakwilson: ibdknox: I hear you had dinner with someone I sort of know last night. You kept him from an online meeting about a game in development.

16:18 cljn00b: (this is just tutorial code here)

16:18 ibdknox: zakwilson: haha I see

16:18 borkdude: but I like Python and a fantasic IDE for it would be great

16:19 ibdknox: zakwilson: yeah a friend of a friend sort of thing

16:19 zakwilson: Yeah, that's what he said. He thought Lighttable sounds interesting.

16:19 reisio: looking for a copy of the image that was here if someone's got it: http://clojure.googlegroups.com/web/Clojure-logo.png

16:20 borkdude: real time debugging in light table will maybe convert more "statically typed" fans to dynamic languages?

16:20 ibdknox: with clang

16:20 you could do the same thing with C :)

16:20 kilon_alios: realtime debugging style common lisp ?

16:20 and smalltalk ?

16:21 inject live objects, compile and decompile, inspect, modify source and resume etc

16:22 zakwilson: Lisp and Smalltalk environments have had features along those lines for ages. If Lighttable only gets people to start using them in Python, it will be huge.

16:22 kilon_alios: and Clojure ;)

16:22 ibdknox: LT has definitely helped spread Clojure around some :)

16:22 zakwilson: I really don't understand why people still develop such languages in an essentially batch-mode style instead of talking to a running program with their editor.

16:23 borkdude: ibdknox I mean the real time debugging thing will maybe give them the same (or better) sense of safety a type checker does now for them

16:23 kilon_alios: its sad when some of those best technologies are left behind, I am working on Morphic GUI, the very first to implement visual coding on low level with self programming language and then smalltalk

16:23 Raynes: ibdknox: Maybe light table is that 'killer app' crap people talk about.

16:23 ibdknox: maybe

16:23 who knows

16:24 It'd be nice to push Clojure out to more folks though

16:24 kilon_alios: 40 years after, GUIs are inferior in design :D

16:24 make you scratch your head a bit

16:24 zakwilson: I already thought of something I want to bulid on top of it - a web-based SASS editor for client projects and such where somebody might want to change the CSS but not instal SASS tooling.

16:28 kilon_alios: well its nice at least that all programming languages and software return back to the roots of software revolution

16:30 pandeiro: how can i make a macro take let bindings and then execute its body form with those same let symbols bound to recomputed values?

16:33 borkdude: pandeiro a bit like this? https://www.refheap.com/paste/2700

16:33 amalloy: pandeiro: i suspect if you start by writing down one specific example input and the output you want it to expand to it'll be much clearer

16:33 Raynes: borkdude: You got paste 2700. Congratulations, you win nothing.

16:34 borkdude: Raynes great, maybe an air guitar?

16:34 michaelr`: hello

16:35 eduard: how to swap two values at defined indexes in vector?

16:36 pandeiro: amalloy: like this? (let*2 [a 1 b 2] (+ a b)) ;=> 6

16:37 borkdude: eduard I guess taking the subvectors and then concatting them back with the swapped values in between, but there might be a better way…

16:37 amalloy: well, it surely won't just straight-up expand to six

16:37 pandeiro: amalloy: right, that logic would be in the macro

16:37 amalloy: it'll expand to (let [a (* 2 1) b (* 2 2)] (+ a b))

16:38 pandeiro: amalloy: k let me think about that; borkdude: thanks i am also looking at your example

16:39 eduard: borkdude, assoc found http://stackoverflow.com/questions/5979538/what-is-the-idiomatic-way-to-swap-two-elements-in-a-vector

16:40 borkdude: eduard of course, assoc.. I was confused by an example I did earlier: removing an element from a vector

16:44 ag90: Is there a macro/function similar to -> for functions? That is, instead of inserting the value of a form as the first value in the next, it assumes that the next form is a function and calls it?

16:45 I think I recall a function that did that, but cannot seem to remember the name.

16:45 amalloy: &(doc comp)

16:45 lazybot: ⇒ "([] [f] [f g] [f g h] [f1 f2 f3 & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."

16:45 Raynes: comp

16:45 ag90: Ah!

16:45 Raynes: amalloy: I hate you.

16:45 ag90: Thanks!

16:46 amalloy: man, imagine if comp actually did take a set of functions

16:49 Raynes: amalloy: Well, it actually can.

16:49 amalloy: okay, fair enoguh

16:49 borkdude: set as function or of functions?

16:51 ag90: borkdude: I think he was suggesting in jest that if comp accepted a set of functions (which it does), it would really ruin everything because sets are unordered.

16:51 (and you need the functions to be ordered for a functional composition)

16:51 borkdude: ag90 I know about the order, but does it really take a set of functions?

16:52 ag90: highly doubt it

16:52 ag90: Well, a set of functions is still a seq. So, the order it evaluates them in is probably one that you won't like.

16:52 borkdude: ag90: without apply I mean

16:52 ag90: Oh, yes, with apply.

16:53 borkdude: apply doesn't count

16:53 ag90: Though, if you think about it, a set of functions is a set which is a function too.

16:53 borkdude: ag90: finally, I (we?) got it

16:53 ag90: heh

16:54 borkdude: ,((comp #{+ - *}) +)

16:54 clojurebot: #<core$_PLUS_ clojure.core$_PLUS_@2f47a2>

17:01 borkdude: composing sets can actually be useful: https://www.refheap.com/paste/2890

17:10 pandeiro: there's no way to do something like (let-async-resource [foo "http://foo.com"] (.log js/console foo)) ;=> "<html><head>..." with cljs, is there? to abstract away async via a macro?

17:11 p_l: write in CPS?

17:14 pandeiro: p_l: like javascript?

17:16 p_l: well, it doesn't come from javascript, but it also makes it possible

17:16 no idea how hard CPS would be in Clojure

17:34 kab3wm: pandeiro: http://brianmckenna.org/blog/cps_transform_js

17:38 pandeiro: kab3wm: thanks

18:04 brainproxy: so vec (as opposed to vector) will consider a string argument to be a collection of chars?

18:05 playing in the REPL w/ examples from the Cloj Prog book ... just making sure I understand correctly

18:08 tmciver: brainproxy: it would appear so. ##(source vec)

18:08 lazybot: java.lang.RuntimeException: Unable to resolve symbol: source in this context

18:08 coventry: brainproxy: Yes. Let me see if I can use this clojurebot. ,(set (map type (vec "test")))

18:08 Oh, that didn't work.

18:08 tmciver: &(clojure.repl/source vec)

18:08 lazybot: ⇒ Source not found nil

18:09 tmciver: bah

18:10 Well, vec calls to-array on its arg if (instance? java.util.Collection arg) is false

18:10 &(instance? java.util.Collection "test)

18:10 lazybot: java.lang.RuntimeException: EOF while reading string

18:10 hyPiRion: heh

18:10 tmciver: &(instance? java.util.Collection "test")

18:10 lazybot: ⇒ false

18:11 coventry: I'm using swank, and when it drops me into the sldb buffer, I'll type "e", then an expression, and I always get back "nil". Even for constant exrpressions like "1". I checked the *Messages* buffer, and there's nothing extra in there. Anything else I should try?

18:11 brainproxy: tmciver: thanks, was just looking at the source via clojureatlas and learning how it works

18:12 sometimes I forget I can look at the source for most of the builtins

18:12 but you reminded me with your invocation of the bot

18:42 amalloy: coventry: a lot of swank features aren't implemented in the clojure swank server. that's probably one of them

18:42 coventry: Ah, thanks.

18:48 amalloy: my understanding is that nobody knows how swank-clojure works, and it's a miracle that it still does

18:49 danlarkin: that's pretty accurate

19:07 velvia: Newbie here trying to set up emacs / clojure-mode / slime etc. I followed a bunch of different blogs, but how can I tell that my setup works? I just see a bunch of different warnings when I try to do "clojure-jack-in".

19:10 amalloy: ~swank

19:10 clojurebot: swank is trust the readme and the readme only. all others will lead you astray.

19:14 velvia: @clojurebot: so follow the README at github swank-clojure?

19:14 Has anybody had experience with clooj, or La Clojure (IntelliJ plugin)? Are those any good?

19:40 wink: La Clojure sadly only works on IDEA and not on PHPStorm, so couldn't test it for lack of licence :(

19:40 (at least back when I tried) but seems sensible, given lack of Java stuff

19:43 scottj: wink: works on free intellij

19:44 velvia: eclipse is most actively developed of non-emacs plugins.

19:45 velvia: following readme at swank-clojure is best, yes

19:45 velvia: @scottj, thanks

19:47 scottj: coventry: same behavior here. I think that works in ritz though

19:49 * gfredericks is not now known as weavejester

20:18 * emezeske isn't not now knowing *gfredericks*

20:19 emezeske: amalloy: That mail about vmware I just got, was that in regards to me rebooting to play diablo 3?

20:21 amalloy: yes

20:22 emezeske: I dunno about running games in a VM

20:22 And there's no way I'm making windows my base OS :)

20:23 lynaghk: emezeske: The only reason I'm on linux is for Xmonad.

20:23 emezeske: lynaghk: I didn't know you were a fellow xmonader!

20:23 lynaghk: emezeske: I ran windows for years; you just learn to love PuTTY and do lots and lots with VMs. Which is actually a pretty good habit, ops-wise.

20:24 emezeske: lynaghk: Yeah I do lots in VMs, but I like running my editor/etc on raw hardware

20:24 lynaghk: emezeske: yep. My primary machine is something like 5 years old now. Running linux with three montiors.

20:25 seancorfield: Windows belongs in a VM, safely locked up where it can't do any harm!

20:25 lynaghk: emezeske: thanks for getting that lein cljsbuild out so quickly, by the way.

20:25 emezeske: lynaghk: Yeah, no problem, I'd wanted that for a long time but never saw a simple solution

20:25 seancorfield: :)

20:26 seancorfield: emezeske: new version of lein-cljsbuild? what's new/cool in it?

20:26 emezeske: Oh, nothing major, probably my favorite new feature is that it reloads *.clj files in the clojurescript source dir (for macros)

20:26 seancorfield: i'm not doing anything with clojurescript yet except playing but cljsbuild is my drug of choice for that :)

20:26 nice

20:27 emezeske: Also, it is faster most of the time, in auto mode

20:27 lynaghk: seancorfield: Also upstream authors can now package JavaScript + Externs that'll get sucked in automatically without end users needing to pass in custom ClojureScript compiler options

20:28 so basically, I'm going to get everyone to eat highly mutable raw JavaScript and never know it = )

20:28 emezeske: Bwahaha!

20:30 lynaghk: emezeske: what are you working on in cljs, anyway? You are doing all of this rad work with the toolchain, but don't seem to have any public projects

20:30 weren't you making a game or some such?

20:31 emezeske: I'm building a website to help school teachers build seating charts

20:31 It is all closed-source, which is a bummer, because I want to show it off!

20:31 xeqi: they don't just use alphabetical order?

20:32 emezeske: The uninspired ones do

20:32 lynaghk: xeqi: problems with children whose names can be coerced to numbers.

20:32 emezeske: The tool I'm making lets teachers assign students to groups, and it will build randomized charts that keep loudmouths away from one another, for instance

20:33 Good teachers engineer their charts like that, and mix them up on a regular basis so kids have to work with new people

20:33 But that is a huge pain in the ass.

20:38 pipeline: do you expect teachers to mark children as "loudmouths"

20:38 in a written record ?

20:39 gfredericks: perhaps as "Group A"

20:39 pipeline: how will you advertise the feature

20:39 haha

20:39 gfredericks: where A has a "dispersed" characteristic

20:39 emezeske: You'll just have to see how it works once it's out :)

20:40 I'm sure I'll talk it up on the ML as a finished commercial project using clj/cljs :)

21:55 brainproxy: is there an emacs command (within some mode, i mean) that will "prettify" a region, e.g. a large hash-map literal I've copied over from the REPL

22:02 nvm, found clojure.pprint/pprint

22:06 _KY_: #{(1 2 3) (4 5)} is a set with 2 elements, right?

22:06 ,(conj #{(1 2 3) (4 5)} '(6 7))

22:06 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

22:06 _KY_: How come that doesn't work?

22:07 Iceland_jack: _KY_: You ness to do '(1 2 3) or (list 1 2 3)

22:07 ,(count #{(list 1 2 3) (list 4 5)}

22:07 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

22:07 Iceland_jack: bah

22:07 ,(count #{(list 1 2 3) (list 4 5)})

22:07 clojurebot: 2

22:08 _KY_: I see...

22:08 So what was that?

22:08 Without "list"

22:08 Iceland_jack: a function call

22:08 _KY_: Ahhh I see =)

22:08 Iceland_jack: Lisps assume that the first element of a list is the function

22:09 or something that will eval to a function

22:10 Lists aren't nearly as idiomatic in Clojure as they were in older Lisps though

22:11 ,(conj #{[1 2] [10 20]} [100 200]})

22:11 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: }>

22:11 Iceland_jack: hah, every time

22:11 ,(conj #{[1 2] [10 20]} [100 200])

22:11 clojurebot: #{[1 2] [100 200] [10 20]}

23:10 gfredericks: what do CLers and schemers do when they want to do [(+ x y) (* a b)]? Do they have to (list (+ x y) (* a b))? (i.e., no data literal for it)

23:19 amalloy: gfredericks: there may be other options, but that's common

23:21 or `(~(+ x y) ~(* a b)), i suppose

23:22 gfredericks: ah

23:23 well thank you rich hickey for vectors.

23:31 amalloy: of course, in any other lisp you can write a reader macro for it

23:31 CL probably has some kind of reader syntax for vectors

23:32 but they're not as interchangeable with lists as clojure's are, i suspect

Logging service provided by n01se.net