#clojure log - Oct 04 2012

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

0:12 ori-l: i'm new to clojure and am totally boggled by namespaces -- there seem to be 12 ways of managing them. since i'm still learning the language, i'd like to have an ease way to load the repl and have all the bindings from my clj file in the immediate repl scope.. how do i do that?

0:12 gert: ori-l: use leiningen

0:12 Sgeo: If I add-watch on a mutable reference, and then sometime after that nothing is holding on to the mutable reference, will it stick around due to the watcher holding the reference to the mutable reference in memory, or will it be GCed, along with the watches?

0:12 gert: ori-l: http://leiningen.org/

0:13 ori-l: gert: i did. lein new foo, editing things in foo/src/core, not available in repl unless i require

0:13 gert: ah.

0:13 yes

0:13 uvtc: ori-l: there's a link to this tutorial http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html in the cheatsheet.

0:13 ori-l: (as far as i remember -- i last butted my head with this a few hours ago)

0:13 uvtc: this looks useful..

0:14 * ori-l reads.

0:14 uvtc: ori-l: if you create your project as an app, like so: `lein new app my-proj`, and then `cd my-proj` and start a repl, it will be in your project's namespace by default.

0:14 ori-l: uvtc: why isn't that the default? is the default template geared toward libraries?

0:15 uvtc: ori-l: yes, the default template is geared for creating libs.

0:15 rmarianski: ori-l: (ns my-namespace)

0:16 uvtc: ori-l: what rmarianski said. :)

0:17 ori-l: this is a little nuts. just think of the number of discrete concepts you need to grok to fully parse this line: (use '[clojure.string :only [split]])

0:19 uvtc: ori-l: I suggest not using `use`. Prefer `require` (in the repl) and :require in your own `ns` macro.

0:21 ori-l: yes, that's what the tutorial recommends too

0:21 uvtc: ori-l: just curious; which tutorial are you following?

0:22 ori-l: i'm a bit too erratic to follow one thing through, so i'm solving problems on 4clojure and going to the books when i get stuck

0:22 uvtc: Ah.

0:24 ori-l: the riddles are mostly about transforming sequences, though, and i feel like what i'm missing is how to glue these transformation together into a program. can you recommend some short, idiomatic open-source clojure apps?

0:28 uvtc: ori-l: what sort of app do you want to write?

0:28 ori-l: uvtc: reads udp datagrams, parses them, slots them into redis

0:29 uvtc: but i'm not particular.. if that's not a particularly good problem to explore clojure with i could fish around for something else to do

0:31 uvtc: ori-l: the only suggestion I think I can make is that you might try what I've done: start a new lein app project. Into -main put a call into some high-level function that seems like it ought to do what you want, then work your way down. :) Top-down like that works nicely for me.

0:32 ori-l: sounds like you're going to need a few extra pieces working too though, such as db connectivity and network support. You might ask about those separately at a time when this place has more active folks. Maybe in 10 hours or so.

0:33 ori-l: thanks, both good tips

1:39 spoon16: I'm looking for advice about running noir in production

1:40 it uses embedded Jetty right? but I can also build a war and deploy that to standalone Jetty....

1:40 what is the best practice?

1:40 there does not seem to be clear documentation

1:42 Raynes: spoon16: lein-ring

1:42 spoon16: Look at gen-handler in noir.

1:42 You can generate a handler that can be passed to run-jetty (and specified in your lein ring config).

1:44 spoon16: looking

2:00 lein-ring talks about being run as a development web server

2:00 I may not understand linux system administration well enough

2:00 but how do you set things up so that if the process crashes it is restarted?

2:15 upstart for Ubuntu looks like a good way to keep things running

3:31 beberlei: in clojure sql examples you often see the (into [] results) inside with-query. is there anything similar to get all values into a vector of records?

3:43 amalloy: it sounds like you just described exactly what you're asking for

4:00 Long: Good afternoon everybody!

4:00 I am trying to :gen-class a Servlet

4:01 this is my code

4:02 (ns test.test

4:02 (:import (java.io PrintWriter) (javax.servlet.http HttpServlet))

4:02 (:gen-class :name test.TestServlet :extends javax.servlet.http.HttpServlet))

4:02 (defn -doGet[request response]

4:02 (let [wrtr (.getWriter response)]

4:02 (.println wrtr "hello from clojure")))

4:02 it can't be compiled by Lein

4:02 it said "Exception in thread "main" java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet (Test.clj:1)"

4:03 I already modified the :library-path in Lein as ":library-path "/home/long/workspaces/spring/LongHDi/war/WEB-INF/lib"

4:04 but it didn't work

4:04 do you have any idea why it did not find the class?

4:56 lpetit: Hello everybody, everybody hello

4:57 ejackson: Hello lpetit !

4:57 clgv: bonjour monsieur

4:57 lpetit: ejackson: congratulations for your talk at the conj !!!

4:57 clgv: bonjour jeune homme

4:57 :)

4:57 ejackson: thank you :)

4:58 I'm running around a bit to develop something worth presenting

4:58 I was thinking that 45 mins of lolcats might not make me popular :)

4:58 although....

4:58 lpetit: YMMV :)

4:59 ejackson: indeed

4:59 I'm just back from Strata in London where I was pushing all things Clojure

4:59 lpetit: I guess people will definitely expect more from you ;)

4:59 What's this Strata thing ?

4:59 ejackson: its a conference put on by O'Reilly about data

5:00 its fully buzzword compliant, but did manage to attract some nice hackers

5:00 they hold the conference every few months in a different city so it always seems to be on :)

5:00 lpetit: he

5:03 ejackson: lpetit: you standing today ?

5:03 lpetit: ejackson: no, but I should, I'm almost asleep :)

5:04 cark: how should i go about providing clojure style equality to a type i created with deftype ?

5:04 ejackson: hehe, I also succumb in those times to sitting

5:05 lpetit: ejackson: but it's a clear indicator that maybe we should rest.

5:05 Ok, let's take a snap :)

5:06 I haven't done standing much these days. I need to by a separate keyboard.

5:06 clgv: cark: assuming the fiels of you deftype are pure clojure data you can just compare them

5:07 cark: but isn't there an interface i should "derive" from ?

5:08 ejackson: lpetit: yeah the keyboard is critical

5:09 clgv: cark: you just need to overwrite `equals` and `hashCode` from java.lang.Object

5:09 cark: allright thanks

5:17 clgv: thanks, worked like a charm

5:17 tho i'm not quite sure how good my hashCode is =D

5:17 I should just minimise potential collisions, right ?

5:18 like add a random (per class) number to the sum of hashcodes of my enclosed data ?

5:21 clgv: cark: clojure exposes it's own hash function clojure.core/hash

5:22 cark: you should not do a per class modification when you want clojure's comparison by value semantic

5:22 cark: you could return (hash [field1 field2 ...])

5:23 cark: well if i have class A and class B which both contain a char, but I don't want these to be equal even when containing the same char, so they should have a different hashCode ?

5:24 clgv: yes, but then you do not have comparison by value anymore

5:24 cark: right, I'm not really building a clojure style container or collection

5:24 it's actually the Either type

5:25 (Left 1) and (Right 1) should not be equal

5:25 anyways thanks !

5:26 tomoj: &(clojure.set/union {1 2 3 4} {3 4 5 6})

5:26 lazybot: ⇒ {5 6, 1 2, 3 4}

5:26 tomoj: &(clojure.set/union [1 2 3] [3 4 5])

5:26 lazybot: ⇒ [1 2 3 3 4 5]

5:27 tomoj: &(clojure.set/intersection #{1 2 3} [4 5 6])

5:27 lazybot: ⇒ #{1 2}

5:27 tomoj: (clojure.set/intersection #{1 2 3} {3 4})

5:27 &(clojure.set/intersection #{1 2 3} {3 4})

5:27 lazybot: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.IPersistentSet

5:27 cark: woah the intersection with vector and set is pretty bad =P

5:28 tomoj: I wonder if those are bugs

5:28 cark: i'd say undefined behaviour

5:28 tomoj: I know I saw code that depended on the union of a vector

5:28 I think it was in the cljs compiler

5:28 clgv: ,(doc clojure.set/intersection)

5:28 clojurebot: Excuse me?

5:28 clgv: &(doc clojure.set/intersection)

5:28 lazybot: ⇒ "([s1] [s1 s2] [s1 s2 & sets]); Return a set that is the intersection of the input sets"

5:28 clgv: tomoj: "input sets" so it is a user error^^

5:29 tomoj: &(clojure.set/union {1 2 3 4} #{3 4 5})

5:29 lazybot: ⇒ #{[3 4] [1 2] 3 4 5}

5:29 tomoj: sure

5:30 but what should clojure do?

5:31 clgv: well, that' the discussion "checking every possibility VS assume some knowledge of the user"

5:31 cark: that's clojrue for you, providing the fast path, let you shoot your foot

5:31 i like it this way

5:32 means *I* can be so much more inefficient =)

5:32 ejackson: after a few days conferencing I'm so glad to get back to coding

5:32 (with a cold, compliments of the huddled masses of fellow conferenceees)

5:34 tomoj: &(clojure.set/union #{} "foo")

5:34 lazybot: ⇒ "foo"

5:34 tomoj: &(clojure.set/union #{1} "foo")

5:34 lazybot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentCollection

5:34 tomoj: clgv: makes sense

5:35 kral: namaste

5:35 tomoj: but it is hard to see where to draw the line

5:35 ejackson: and good luck !

5:35 clgv: tomoj: you could wrap a contract function with :pre :post around those for your development phase

5:35 tomoj: with alter-var-root?

5:36 clgv: not necessarily. fogus wrote about it,

5:36 just write a second function with pre post that calls that one

5:37 tomoj: looks like trammel uses alter-var-root

5:37 but, yeah

6:07 clgv: tomoj: you could use trammel right

6:18 wingy: why is :/sdasd invalid as keyword but :/sd/asd valid?

6:47 clgv: wingy: namespaced keyword probably only looks for the last /

7:13 marianoguerra: hi, how can I store a "reference" to a module in a dynamic variable?

7:13 I want to be able to change that dynamic variable when testing

7:13 or is there any other way of achieving this?

7:14 clgv: what is a "module"?

7:14 marianoguerra: (new to clojure) a set of functionallity in a namespace

7:15 clgv: marianoguerra: do you mean a namespace?

7:15 marianoguerra: clgv: maybe :)

7:15 clgv: marianoguerra: what exact yrtifact do you want to exchange?

7:15 marianoguerra: I have a namespace that stores objects in a database

7:15 clgv: *artifact

7:15 marianoguerra: I want to change it for tests

7:16 other one is a messaging namespace, I would like to be able to "mock" those for testing

7:16 clgv: marianoguerra: you know that functions are first class in clojure? so you could just pass a function along

7:16 marianoguerra: do you use midje for testing?

7:16 marianoguerra: clgv: but if I'm testing a ring handler I don't want to pass the storage functions to it so it knows how to test

7:17 clgv: will look at midje, I'm coding in clojure since a week :)

7:17 clgv: marianoguerra: well you can assign a function to a dynamic variable if you like to

7:18 cark: mock functions =)

7:18 marianoguerra: clgv: ok, that would work too :)

7:18 namespaces in clojure are like in java? (non first class?

7:19 in python/js/erlang I can store the module in a variable and use the variable, that's why I was asking

7:19 clgv: marianoguerra: there are namespace objects.

7:19 lotia: marianoguerra: you can use the :as keyword to alias a namespace

7:20 clgv: but I dont think that mocking the whole namespace via a variable is idiomatic

7:20 marianoguerra: clgv: ok, will check midje and do the function in a variable thing, thanks!

7:20 clgv: marianoguerra: usually you would mock the functions individually

7:43 wingy: clgv: yeah forgot it was a namespace

8:32 ds300: Anyone know how I can extend a custom java class which implements an immutable map to use assoc and dissoc? Can I just make it implement IPersistentMap or is there something easy I can whip up with protocols?

8:33 wingy: is datomic open source?

8:33 altious: hi

8:33 does anyone got an idea why 4clojure dislikes def s?

8:33 "You tripped the alarm! def is bad!"

8:34 beberlei: it wants you do work without defs

8:34 xeqi: altious: it uses clojail, which blocks it for security and isolation from other users

8:34 beberlei: let always works instead

8:35 altious: may someone give me advise how to rewrite this without using def? http://pastie.org/4908536

8:35 let is not an option

8:36 xeqi: ds300: I think you have to implement that interface, the clojure on the jvm doesn't use protocols for that

8:36 beberlei: with (fn fib for example

8:36 xeqi: there might be clojure in clojure for the jvm that does, but not yet

8:36 * one day there might be

8:37 wingy: no, it is closed source

8:37 Sgeo: Can someone please explain TryClj's behavior here? https://www.refheap.com/paste/5496

8:37 wingy: xeqi: :(

8:37 ds300: altious: (map (memoize fib) (range 1 (inc x))) ?

8:37 altious: ds300, no

8:37 fib uses fibm inside

8:37 wingy: closed source is never good for business!

8:37 altious: fib use memoized results as well

8:38 Sgeo: Who's the genius that thought that letrec would be unnecessary in Clojure?

8:38 :(

8:38 altious: maybe i can rewrite (def fibm (memoize fib)) with defn?

8:41 doh :(

8:41 writing without defs is effectively impossible

8:41 don't remember such limitations earlier

8:42 Sgeo: letfn?

8:42 cark: ,(doc letfn)

8:42 clojurebot: "([fnspecs & body]); fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+) Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body."

8:42 cark: beat me to it =P

8:42 Sgeo: letfn is recursive, but it kind of sucks that it's limited to functions

8:42 algernon: altious: loop + recur?

8:42 Sgeo: Erm, using function syntax

8:42 altious: algernon, code may be not left recursive

8:43 like in this case

8:43 Sgeo: Because you want to use fibm and have it visible from before it, but writing fibm as a function with an argument is tedious and idiotic

8:43 algernon: altious: aha, I see

8:43 Sgeo: (Well, ok, not very tedious, but it's still stupid.)

8:43 clgv: altious: you can write single recursions without def like: (fn [x] ... (recur (inc x)))

8:45 cark: also don't have to have tail recursion with this :

8:45 ,((fn blah [val] (when (> val 0) (blah (dec val)))) 10)

8:45 clojurebot: nil

8:45 cark: tho it's tail here

8:45 clgv: altious: in the case of fibonacci numbers you should use dynamic programming since you need all previous numbers anyway

8:46 altious: clgv, you mean to storea a map of earlier values manually?

8:47 clgv: altious: no you calculate the whole vector up to the number.

8:47 there should be a lot of examples on the net ;)

8:47 altious: clgv, memoization in this sample give us more

8:47 clgv: more runtime ;)

8:48 altious: it removes necessity to always do "+1"

8:48 err. no sure i can explain this

8:48 *not

8:50 Sgeo: Seems like defns at tryclj expire

8:50 Not sure if it's after a number of lines or after an amount of time

8:50 clgv: Sgeo: I think your whole session expires overthere

8:50 altious: one more question

8:50 Sgeo: I think it's number of lines

8:50 altious: is there a builtin fucntion which executes f(x), receives result of function and pass the result back to f(x) as param?

8:51 creating infinite loop

8:51 clgv: altious: `iterate`

8:51 altious: with shared state

8:51 Sgeo: Well, (comp last iterate)

8:51 oh

8:51 clgv: ,(iterate + (range 5))

8:51 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: Cannot cast clojure.lang.LazySeq to java.lang.Number>

8:52 Sgeo: ,(iterate + 5)

8:52 clojurebot: (5 5 5 5 5 ...)

8:52 clgv: ,(take 10 (iterate inc 0))

8:52 clojurebot: (0 1 2 3 4 ...)

8:52 altious: err

8:52 something like fsm

8:52 Sgeo: ,(type (last (range 3))

8:52 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

8:52 Sgeo: ,(type (last (range 3)))

8:52 clojurebot: java.lang.Long

8:52 altious: do i really have to have a lazy seq :\

8:53 Sgeo: altious, last tries to get the last element of a lazy seq

8:53 clgv: altious: otherwise you have to write that function yourself, but then you need a stop criterion as well

8:53 altious: clgv, probably System.exit ? :)

8:53 oh, criterion

8:53 of course

8:54 lpetit: clgv: say you have this expression in an editor : "^foo :bar" and your cursor is at the start. Say you hit "forward delete" key. Currently it throws an exception. So I have to fix it.

8:54 clgv: lpetit: it's the mean reader, I guess ;)

8:55 lpetit: the issue is in the :paredit-forward-delete of paredit's multi method.

8:56 clgv: my question is: what should be the correct behavior, so that it is consistent with the rest of paredit mode?

8:56 should the expected result be "^foo :bar" with cursor after the ^, or should it erase the ^and bring "foo :bar" as a result

8:56 clgv: I guess the former would be more consistent

8:58 clgv: lpetit: the first suggestion is the behavior with parentheses, right?

8:59 lpetit: clgv: right

8:59 clgv: lpetit: well, then it's probably the consistent one

8:59 lpetit: agreed

8:59 deal :)

9:01 clgv: lpetit: I got my hands on repl backward search on monday after setting up the dev environment.

9:01 lpetit: oh great

9:01 clgv: lpetit: not completed yet - but maybe next weekend

9:01 lpetit: make sure to synchronize somehow with cemerick because I know he's quite busy correcting issues atm

9:02 grrrr8 ! :)

9:02 I should mark you as a developer, so you can mark the issue as started

9:03 clgv: lpetit: do you still have a CA to sign? I read something on the google code page somewhere

9:06 lpetit: clgv: it's still not ready (shame on me). But when it's ready (in one month ? one year ?) you can sign it and it will also concern past contributions to the project. So since I trust you, if you say to me now that you'll sign it eventually, that's fine with me.

9:08 clgv: lpetit: ah ok. that was not obvious from that page ;)

9:08 lpetit: sure, I don't remember why I suddenly stopped the initiative. One more thing on my plate .. :)

9:08 clgv: you're now have the "commuter" profile, I hope it allows you to update issues

9:10 clgv: lpetit: I marked it "started"

9:11 lpetit: clgv: thanks, it will help a lot tracking what's happening

9:15 jweiss: is there a way to have a var's root binding be an alias to another var (when the target changes, so does the alias). and still be able to make thread-local bindings?

9:15 clgv: jweiss: afaik, there is no real defalias even the one in contrib copied the root binding

9:16 jweiss: clgv: so i would have to set the var's value to another var, and explicitly deref everywhere i want to get the value?

9:17 clgv: jweiss: sounds like that would get the job done. you should make sure that you really need such behavior, though

9:19 jweiss: clgv: i have 2 ns's, api and conf. conf reads in some credentials at runtime, but doesn't know anything about the api ns. the api ns needs to have a default value for the credentials as soon as conf knows them.

9:21 clgv: jweiss: so why do you need the alias? you could just use the var defined in conf in the api namesapce

9:22 jweiss: clgv: hm, that is a good point. i don't want api to mess with the value in conf, but thread-local bindings would be ok because no other ns would end up seeing any change.

9:23 clgv: jweiss: you mean no other thread, I guess ;)

9:24 jweiss: clgv: well, even the same thread. i know clojure isn't stopping other namespaces from seeing the thread-local change, but the api namespace doesn't call anthing that would care.

9:32 clgv: jweiss: if the thread local bindings must not be visible for other ns - then thread local bindings are probably wrong for that task

9:42 lpetit: should the completion work with namespace-alias already?

9:42 jweiss: clgv: that's why i wasn't using the same var between conf and api. but the model you suggest should work, it's just a different assumption than i had before. might have to comb through the code to make sure it's all going to accept the change and fix where necessary. thanks for the help.

9:43 lpetit: clgv: yes

9:43 and it does, afaik

9:43 clgv: lpetit: but nor for protocol functions?

9:43 *not

9:44 wingy: why are they using "c" in [:find ?c :where [?c :community/name]] in datomic

9:44 what does c stand for?

9:44 ejackson: anything

9:44 Bronsa: a variable

9:44 wingy: why not ?e for entity

9:44 or ?i for id

9:44 just want to know why they picked c

9:44 clgv: community starts with c ;)

9:44 wingy: ah

9:45 riddle solved

9:45 clgv: just guessing ^^

9:45 lpetit: clgv: ??

9:45 lazybot: lpetit: What are you, crazy? Of course not!

9:45 wingy: clgv: has to be right

9:46 lol

9:46 if i just read 1 more sentence

9:46 The :find section specifies we want to retrieve all values of the variable ?c (for community).

9:46 clgv: lpetit: normal functions are suggested in the completion dialog but protocol functions are not, it seems

9:46 lpetit: clgv: well, if they are present in ns-publics, they should show up

9:47 clgv: lpetit: they are only suggested if I used them once before in the file.

9:47 on 0.10.1 stable

9:48 lpetit: clgv: I'll check that. Maybe it's a bug in clojure-complete which has been inherited by ccw ..

9:51 clgv: wingy: fail ;)

9:52 (dec wingy)

9:52 lazybot: ⇒ -1

9:52 clgv: :P

9:52 lpetit: clgv: you're right, it's a bug. Can you please file an issue ,

9:52 ?

9:54 clgv: lpetit: "code completion" is the right term here?

9:54 lpetit: clgv: Eclipse 's jargon is "content assistant", but using "auto completion" or "code completion" is fin

9:54 e

9:54 "content assist"

9:59 clgv: lpetit: done. #451

10:01 lpetit: ok, tthx

10:04 iosica: question about java interfaces and clojure:

10:04 I have 2 interfaces A and B extends A

10:04 A defines a method foo

10:04 B defines a method bar

10:04 in clojure I reify A and assign implementation to var a

10:04 how do I reify B and reuse implementation from a for foo method defined in A

10:08 chouser: iosica: factor out the common code into a function and call it from each refiy?

10:08 clgv: iosica: you cant directly

10:08 iosica: what chouser said ^^

10:09 iosica: ok, I'll have to dup then, as my A actualy has 10 methods and B adds 2

10:09 thx

10:11 pandeiro: anyone know the difference between a java.io.InputStream and a java.io.FilterInputStream?

10:13 antares_: Langohr doc guides are up: http://blog.clojurewerkz.org/blog/2012/10/04/announcing-langohr-documentation-guides/, http://clojurerabbitmq.info

10:14 clgv: pandeiro: InputStream is abstract, FilterInputStream not

10:21 TimMc: &(cycle [])

10:21 lazybot: ⇒ ()

10:22 iosica: trying from a different angle:

10:22 say I have interface B with 2 methods foo and bar

10:22 I reify B to var b

10:22 is it possible to dynamically change the impl of foo method on b?

10:24 clgv: iosica: if you use `proxy` instead, yes

10:24 iosica: moce, so how do I use proxy for this?

10:26 clgv: update-proxy?

10:27 clgv: iosica: yes. there is an example in JoC

10:31 iosica: clgv: thx I got it

10:52 clgv: I have a solution to my original question, works fine with proxies

10:52 (def a

10:52 (proxy [rvm.stat.A] []

10:52 (foo [] "foo called")))

10:52 (def b

10:52 (-> (proxy [rvm.stat.B] [] (bar [] "bar called"))

10:52 (update-proxy (proxy-mappings a))))

10:52 user=> (.foo b)

10:52 "foo called"

10:52 user=> (.bar b)

10:52 "bar called"

10:53 clgv: iosica: good. :) next time use a gist on e.g. refheap ;)

10:54 cark: omg i've been developing quite a bit based on the state monad, state-t, and now i find that because there's no tail call optimization in clojure it breaks with a stack overflow on larger datasets

10:54 that one won't be easy to fix =/

10:54 clgv: cark: you probably have to use trampoline therefore

10:55 cark: yeah, won't be easy at all

10:55 mpenet: sweet, we are finally getting column metadata

10:56 cark: m-bind (with-monad m (fn m-bind-state-t [stm f] (fn [s] (m-bind (stm s) (fn [[v ss]] ((f v) ss))))))

10:56 now trampoline this

10:56 =P

10:56 it truly returns a value in the end

10:57 but hell

10:57 m-bind is like the very base of everything monadic

10:58 then what if the state is itself a function

11:22 mmitchel_: what's the most succinct way to apply a function to every value in a map, and get a new map back? I'm using reduce, thought about doing map wrapped in an "into"... but thinking there must be a simpler, core function to do this?

11:23 _ulises: mmitchel_: how about merge-with?

11:23 &(doc merge-with)

11:23 lazybot: ⇒ "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."

11:23 _ulises: &(merge-with inc {:a 1} {:a 1})

11:23 lazybot: clojure.lang.ArityException: Wrong number of args (2) passed to: core$inc

11:24 _ulises: &(merge-with #(inc %1) {:a 1} {:a 1})

11:24 lazybot: clojure.lang.ArityException: Wrong number of args (2) passed to: sandbox7657$eval57656$fn

11:24 _ulises: &(merge-with (fn [a _] (inc a)) {:a 1} {:a 1})

11:24 lazybot: ⇒ {:a 2}

11:24 mmitchel_: _ulises: ahh ok, thanks. that's what I'm after!

11:24 _ulises: I know it's ugly, but that might work for you

11:25 I'd certainly document what you want, because when you come back and see (merge-with your-fn the-map the-map) it's likely that you'll go wtf?

11:25 mmitchel_: yeah maybe so :)

11:27 clgv: the merge-with approach is strange.

11:27 clojure 1.4 has reduce-kv

11:28 mmitchel_: ^^

11:28 mmitchel_: clgv: cool, i'll check that out

11:28 ,(doc reduce-kv)

11:28 clojurebot: Excuse me?

11:28 mmitchel_: &(doc reduce-kv)

11:28 lazybot: ⇒ "([f init coll]); Reduces an associative collection. f should be a function of 3 arguments. Returns the result of applying f to init, the first key and the first value in coll, then applying f to that result and the 2nd key and value, etc. If coll contains no en... https://www.refheap.com/paste/5510

11:31 clgv: &(reduce-kv (fn [m k v] (assoc m k (inc v))) {} {:a 1 :b 10})

11:31 lazybot: ⇒ {:b 11, :a 2}

11:42 clgv: lpetit: does the auto completion need a literal "defn" statement to work?

11:42 lpetit: clgv: ?

11:42 clgv: lpetit: I have a defn+opts that expands to a defn

11:43 and the auto completion doesnt show me that one. gotta restart the repl to double check

11:43 lpetit: auto completion is dynamic, it calls (ns-publics), etc., so yes that should just work

11:44 clgv: lpetit: oh well, than namespace aliases are broken in general.

11:45 lpetit: oh. there is a difference whether I use it in the repl or in the editor

11:46 lpetit: in the repl it works - in the editor not

11:46 lpetit: clgv: must leave for 30', feel free to fill in an issue please

11:46 clgv: lpetit: I'll add a comment to the previous one

11:46 lpetit: ok

11:46 bbl

12:20 abalone: cljsbuild question: i had it generate a debug version and an optimized version. the optimized version throws an exception that the debug version does not. has anyone seen something like this? please see the issue at https://github.com/achengs/subpar/issues/1 which has a link to a page that demos the exception

12:22 if you want to see the debug version handle your requests without throwing the exception, go to demo.html instead

12:22 hiredman: abalone: how familiar are you with the google closure model?

12:22 ds300: Anyone know how to convert a java Iterable to an ISeq from within java without writing a wrapper class? There must be something in clojure.lang...

12:22 abalone: hiredman: not. also not very familiar with js

12:23 hiredman: are you using any external libraries and expecting that to work?

12:23 abalone: no

12:23 codemirror is separate.

12:23 didn't :use or :require

12:24 only dependency is clojure 1.4.0

12:26 gfredericks: "codemirror is separate" is a correction to "no"?

12:26 for any raw JS libs you're using you'll need to provide an externs file to the cljs compiler

12:26 abalone: i didn't ask google closure to minify any codemirror stuff with mine. i kept the codemirror js file separate

12:27 gfredericks: abalone: so without the externs, any reference in your code to codemirror things will get munged and thus not work

12:27 abalone: what i mean is i have a plain js file that calls codemirror stuff. it also calls my cljs stuff. but my cljs stuff doesn't call any codemirror stuff

12:28 gfredericks: okay. then all you should need is for the functions in your code that you call from elsewhere to be exported

12:28 abalone: so my cljs stuff is meant to compile and it does export functions for my plain js file to call

12:28 gfredericks: okay I'm out of ideas then

12:29 abalone: i think the fact that the debug version that the google closure tool outputs ... the fact that this version works is a good indication that i got it mostly right

12:29 Bronsa: wow, :column metadata patch was pushed to clojure

12:30 holo: hi

12:30 redline6561: hell yeah source maps!

12:31 clgv: Bronsa: that means there is column information for a def additional to the line information?

12:31 Bronsa: yeah

12:32 gfredericks: Bronsa: what does column information consist of? How far indented the (defn ...) line is?

12:32 * gfredericks assumes not since that doesn't sound very useful

12:33 technomancy: gfredericks: now you can write a lein plugin that yells at anyone who puts def in a nonzero column; what's not to like?

12:34 gfredericks: amalloy would not like that

12:34 and neither would I! we must fight for our right to top-level-let!

12:34 Bronsa: gfredericks: column info is now also used in error messages

12:34 clgv: I like the sound of that commit: "reduce lock contention in MultiFn"

12:34 hiredman: itym fight for our right to leak memory

12:35 gfredericks: Bronsa: I wonder about it because I would think it's usually 0

12:35 technomancy: gfredericks: why do you hate private def?

12:35 gfredericks: I guess maybe helpful for tools trying to find an in a filesexp?

12:36 "sexp in a file"*

12:36 * gfredericks is typing with lag

12:36 gfredericks: technomancy: that only gives me only one kind of visibility

12:37 technomancy: closing over stuff means you can't access it from the repl

12:38 gfredericks: technomancy: stop making me reconsider in public!

12:38 hiredman: vars are the best

12:38 why do you hate them?

12:38 gfredericks: I don't hate them I just like hiding stuff

12:39 hiredman: why do you hate me then?

12:39 hiding stuff is just going to make it harder for me to make your code do what I want

12:39 gfredericks: okay I renounce all previous opinions

12:40 holo: is there any pattern for "any vector"? i want to use it in a multimethod

12:40 clgv: holo: vector?

12:40 gfredericks: holo: what are you dispatching on? the value of the vector?

12:41 holo: gfredericks, yes, i'm dispatching a vector value

12:41 clgv, yes

12:41 clgv: I mean: `vector?`

12:42 gfredericks: holo: then you could either use :default, or if not that, then you can't do it

12:42 clgv: or if your decision is not binary dispatch on `type`

12:42 gfredericks: multimethods are a bit limited that way

12:42 clgv: it's not predicate dispatch so he couldn't just (defmethod foo vector? ...)

12:43 holo: clgv, gfredericks, no, i think you are spot on.. thanks. will try it. hope the order in which they are declared matter

12:43 clgv: gfredericks: I didnt suggest that. you can build something via `cond` and `vector?`

12:43 gfredericks: clgv: still using multimethods?

12:44 holo: clgv, oh, so you mean "vector?" as some available function for binary test. hehehe. no, the dispatch function doesn't evaluate that

12:44 clgv: gfredericks: yes. (defmulti foo (fn [x] (cond (vector? x) :vector (map? x) :map ...))

12:45 gfredericks: so depends if he can change the dispatch function or not

12:45 I was assuming not

12:46 clgv: he didnt write that he can't change the defmulti

12:46 * gfredericks imagines lazybot being programmed to shout "or she!" whenever somebody says "he"

12:47 gfredericks: I think a dispatch function that only returns a fixed set of values somewhat defeats the purpose of a multimethod

12:48 clgv: gfredericks: dont forget the default case of the `cond` you can add (type x) there

12:49 gfredericks: do vectors have more than one type?

12:49 I guess transients count

12:50 clgv: dunno, maps do. I didnt check since he said "all vectors" ... ;)

12:50 holo: gfredericks, i think i can't change the dispatch function, because adding a new test would still oblige me to match the previous ones

12:50 clgv: otherwise `type` is sufficient. that way you can even use :type metadata^^

12:51 jkkramer: ,(map (juxt vector? class) [[1 2 3] (subvec [1 2 3] 0 3) (vector-of :int 1 2 3)])

12:51 clojurebot: ([true clojure.lang.PersistentVector] [true clojure.lang.APersistentVector$SubVector] [true clojure.core.Vec])

12:53 lpetit: jkkramer: hello

12:53 jkkramer: lpetit: howdy

12:54 lpetit: jkkramer: just wanted to know if you had switched back to emacs :)

12:54 jkkramer: lpetit: still using ccw :) though I occasionally find myself using emacs keychords

12:55 lpetit: jkkramer: wow, you're almost converted then :)

12:57 jkkramer: lpetit: I still wrangle with ccw's paredit now and then, but it's not too bad

12:58 lpetit: is syntax highlighting repl return values on the to-do list?

12:59 lpetit: jkkramer: ?

13:00 no, indeed, but that could be a great addition. Feel free to file an issue !

13:00 (working on REPL Log Area colors right now, for people using Eclipse Color Themes)

13:00 jkkramer: I used a hack in emacs for that and it was very helpful

13:01 clgv: does it make any sense to have `ref`s inside a `ref`?

13:05 jkkramer: lpetit: issue created

13:05 gfredericks: clgv: I hope not

13:05 lpetit: jkkramer: thanks. Must go now, see you.

13:05 clgv: gfredericks: well atoms in an atom makes sense

13:06 gfredericks: refs in a ref could - if the transaction fail semantic considers that

13:06 jkkramer: clgv: see http://clj-me.cgrand.net/2011/10/06/a-world-in-a-ref/ and https://github.com/cgrand/megaref

13:07 gfredericks: clgv: what do you use atom atoms for?

13:07 clgv: jkkramer: thanks =)

13:08 Frozenlo`: technomancy: Thanks for the mostly lazy podcast!

13:08 djanatyn: I don't have access to clojars right now, but I managed to download the joda-time jar

13:08 how can I use the classes inside in clojure, just with the jar? I use leiningen and nrepl inside emacs

13:09 wingy: datomic question: i get a vector with all ids with (def results (q '[:find ?c :where [?c :item/name]] (db conn)))

13:09 djanatyn: I tried starting lein repl inside the directory with the jar, but I'm not entirely sure what classes to iport anyway

13:09 wingy: nvm

13:12 back to my question

13:12 that will give me : [[17592186045424], [17592186045423], [17592186045425], [17592186045427], [17592186045428], [17592186045429], [17592186045431]]

13:12 what is the best way to loop through each of the ids?

13:13 antares_: wingy: map over them to get the first value of each vector, then doseq or map or whatever you need?

13:16 wingy: yeah map is good

13:17 djanatyn: can I launch "lein repl" with the classpath including the current directory?

13:18 lynaghk: ping: ohpauleez

13:18 ohpauleez: lynaghk: pong

13:18 internet already?

13:18 lynaghk: I'm at a coffee shop.

13:18 ohpauleez: staying strong - I admire your dedication - what's up?

13:19 lynaghk: But yeah, realized I should get an Internet hookup at my apt. otherwise my sq. meter of monitor space is basically wasted.

13:20 ohpauleez: I need someone to bounce ideas off of re: the grammar of graphics and, more generally, architectural tradeoffs between specificity and generality.

13:20 basically, a technical beer or two. You have time later today?

13:21 ohpauleez: I do. I'll be busy around 3:15-3:45 and 7:45-8:15 - other than that, just call/text and I'll bike to wherever

13:21 muhoo: is something dead at heroku and/or maven? it's complaining that the checksums on clojure don't match.

13:22 Retrieving org/clojure/clojure/maven-metadata.xml, Checksum validation failed, expected 9c684b580e1a70ab5eea761b854e1899152d4a40 but is a7d750077d5f2d54ae2d660a48539f7b068bda8f

13:22 ohpauleez: muhoo: I know heroku keeps their own mirror of things and last week maven central was all over the place (down and up without reason, missing packages)

13:23 muhoo: :-/

13:23 * muhoo hightails it over to #heroku

13:23 technomancy: muhoo: no don't do that; #heroku is useless

13:23 lemme take a look

13:24 muhoo: technomancy: thank you!

13:24 wingy: i ended up with this: (map #(d/entity (db conn) (first %)) (q '[:find ?item :where [?item :item/name]] (db conn)))

13:24 gave me a vector with all entities

13:26 technomancy: anyone else seeing checksum mismatches for clojure?

13:27 muhoo: also, did it say which repo it was coming from?

13:27 wingy: fail again

13:27 borkdude: What's with this (Object.) in get-in? https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L5517,L5534

13:27 wingy: (dec wingy)

13:27 lazybot: You can't adjust your own karma.

13:27 wingy: one more line and i could see they using map

13:27 im such a failure!

13:28 scriptor: borkdude: the key is in line 5530

13:29 sentinel is the not-found value for that get call, and I guess they need to use identical to make sure that they actually got sentinel

13:30 borkdude: scriptor ah right…

13:30 pandeiro: why is intern called intern?

13:30 dnolen: nice :column metadata made it into 1.5.0

13:30 alpha

13:31 shaungilchrist: pandeiro: "To confine, especially in wartime." /war/run

13:31 emezeske: dnolen: Last I heard, you were pessimistic about that happening. That's great news!

13:32 technomancy: pandeiro: I think it's a CLism

13:33 dnolen: emezeske: yes it is.

13:34 pandeiro: thanks shaungilchrist technomancy

13:36 scottj: dnolen: when I saw that commit I wondered if today was your birthday :)

13:42 dnolen: scottj: haha, let's get excited when we can actually step through sexprs in Chrome.

13:42 _firesofmay: Anyone tried this Clojure to Obj C Library? https://github.com/joshaber/clojurem

13:42 dnolen: _firesofmay: no, and it looks stalled

13:43 _firesofmay: dnolen, oh :-/

13:43 firesofmay: dnolen, Why do you think its stalled? Last update was 22 days back.

13:44 dnolen: firesofmay: if you want to interop with iOS I think it would be more useful to hear issues around leveraging ClojureScript for that via PhoneGap or JavaScriptCore directly etc.

13:45 dgrnbrg_: Hey clojurians--I have an interesting problem that i'm trying to find a more elegant solution to in clojure

13:45 dnolen: firesofmay: I follow him on Twitter. Just a hunch.

13:45 firesofmay: dnolen, Hmm.

13:47 dgrnbrg_: I have an atom that periodically gets assigned a new value, and often that value corresponds to a resource on an unreliable blocking network resource. I need to fetch that resource's data and update a textbox with its contents, and when the resource changes, display "loading..." until the resource becomes available. I'm currently using a swing timer and futures to do the blocking reads, but this causes problems if the resource beco

13:48 since too many threads spawn. I have experimented with using an atom for rate-limiting, but the imperativeness of the code makes me sad

13:48 firesofmay: dnolen, people are using Clojurescript to write iOS Apps? Any idea?

13:49 dnolen: firesofmay: not that I'm aware of. But people write iOS apps w/ JS so seems like a promising direction to me.

13:49 firesofmay: certainly interested in anything that makes that easier for people

13:50 _ulises: dnolen, firesofmay: it may be an idea to try clojurescript + phonegap

13:51 firesofmay: dnolen, I was learning Obective C today. Makes me feel so yuck :-/ specially after learning basics of clojure.

13:51 _ulises: dgrnbrg_: without any more context or knowledge, it almost sounds like you could be using agents there

13:51 firesofmay: _ulises, yeah dnolen was suggesting the same thing.

13:51 _ulises: firesofmay: oh, I'm late to the party then ... as always.

13:52 firesofmay: _ulises, it's cool :)

13:52 dnolen: firesofmay: I like fine Obj-C for what it is, but I'd much prefer to program in Clojure if I could.

13:53 dgrnbrg_: _ulises: it does feel like something that could be done with agents, but it's more of a single agent sending the function to itself, repeatedly

13:53 firesofmay: dnolen, Yeah. And moreover I've heard that phonegap (or similar) apps are damn slow. So clojurescript might not work for everyone.

13:54 _ulises: dgrnbrg_: and how is that bad? :)

13:54 dgrnbrg_: I mean, other than it potentially being insane and all

13:54 dgrnbrg_: _ulises: i made the mistake of using swing for a gui :/

13:54 lol

13:54 so i've been losing my sanity slowly as threads overwhelm me

13:56 uvtc: Hi #clojure. I've been working on a Clojure tutorial. It's currently at http://www.unexpected-vortices.com/clojure/cds/tutorials/introduction.html . Feedback appreciated.

13:56 _ulises: dgrnbrg_: can you have the update fns update the swing component and then call itself again?

13:56 dgrnbrg_: _ulises: that's what i'm thinking about. But there's the additional issue of rate-limiting

13:56 i mean, I can solve it all, but i was hoping there's a lib I haven't heard of that I could use :)

13:57 dnolen: firesofmay: I started on something like a XCode project template for doing CLJS last year but I'm too busy with other stuff. Basically it would be sweet to have a XCode template project that could run the ClojureScript compiler and give you a REPL for live coding.

13:58 _ulises: dgrnbrg_: if you want to go down the library route, you could enqueue requests using aleph channels and have the agent pull these and rate limit the frequency of the pulls

13:58 dnolen: firesofmay: yes there are some kinds of apps (mostly games) where I think this might not be fast enough.

13:58 _ulises: dgrnbrg_: but I'd keep it simple initially, try with an agent without rate limiting. Then you can wrap the update fn of the agent with something that retries, rate-limits, etc.

13:59 dgrnbrg_: i.e. make those two orthogonal

13:59 firesofmay: dnolen, yeah live coding is what would set it apart besides beautiful code. And to think of it, it'll open up a huge door for clojure developers to make iOS apps.

14:01 casion: uvtc: do you mention keywords as functions in here?

14:02 uvtc: casion: Oh, y'know, I accidentally omitted that. Thanks. The source is on github, btw.

14:02 dnolen: firesofmay: somebody w/ a lot of time (& probably money) could try something like RubyMotion ...

14:03 pandeiro: you can't destructure nested keys in defn arguments?

14:04 casion: uvtc: IMO, it maybe worth mentioning that when you say "we can get a modified copy of the data structure", that you're not actually getting a new object like one would expect in another language

14:05 TimMc: pandeiro: Huh, I guess not. Interesting design tradeoff.

14:05 casion: when I started clojure that confused me that it was "returning copies"… and in fact I'm pretty sure you're the person who clarified that for me :)

14:05 pandeiro: TimMc: did you not know that?

14:06 dnolen: firesofmay: i did a basic cljs wrapper for the casperjs (phantomjs) api and i like the idea of doing the same for phonegap when i have time... would love to write clojure for android; my brain is just not big enough for java syntax

14:06 TimMc: pandeiro: I had never tried it before.

14:06 pandeiro: TimMc: so you are calling me weird?

14:06 :)

14:06 it works with let, right?

14:06 muhoo: technomancy: maven, iirc

14:07 TimMc: pandeiro: I think it uses the desctructure macro.

14:07 uvtc: casion: updated, thanks.

14:07 muhoo: technomancy: no, it was s3pository

14:08 technomancy: muhoo: still getting it? I can't reproduce here

14:10 firesofmay: pandeiro, Clojure for android/iOS would be killer. I don't know so much of android/iOS but this might be a game changer.

14:11 TimMc: dgrnbrg_: I just wrote my first actually-multithreaded Swing GUI. It wasn't that bad, except I suspect I'm still missing something re: Swing threads...

14:11 antares_: casion: for all intents and purposes, you are getting a new copy

14:12 TimMc: Specifically, according to one stack trace, SwingUtilities/invokeLater at one point called a Runnable right away isntead of putting it into an event queue.

14:13 casion: antares_: I just noticed he explains it under values, immutability and persistence… I just found the idea of persistent shared data structures confusing when I started, and most tutorials didn't really make the concept very clear

14:14 antares_: I don't think a tutorial should go deep into how persistent data structures are implemented

14:14 uvtc: casion: Ah, I got that out of order. Will put a note in there. Thanks.

14:14 antares_: only that they can be considered immutable copies

14:14 casion: antares_: I agree, but in the order I read the tutorial it didn't look like it was mentioned at all :)

14:15 uvtc: casion: It's meant to be read in order. I took care to have it make sense that way. But you found a minor bit that I overlooked. Will fix.

14:16 dgrnbrg_: TimMc: it's not bad at all, until you start dealing with other weird blocking IO

14:16 which is where my problems come from

14:16 casion: uvtc: looks like a great intro tutorial, it's nice that people are still putting effort into things like this

14:17 uvtc: casion: thanks. Please let me know if you spot any more inconsistencies.

14:20 doomlord: what are the barriers to clojure/android

14:20 hiredman: the android gc is apparently not great

14:21 doomlord: ah, and pure-functional generates more garbage..

14:22 perhaps other GC's make better use of immutability assumptions too

14:22 hiredman: android doesn't use a real jvm, which causes issues when you generate jvm bytecode

14:22 chouser: anyone know if python has something like clojure's 'take' fn?

14:22 hiredman: all this is solvable of course, and oracle is pumping out arm jvms

14:23 scriptor: chouser: slicing, maybe?

14:23 TimMc: hiredman: Does Scala have issues on Android as well?

14:23 chouser: scriptor: ah, of course! thanks.

14:23 hiredman: no idea

14:23 TimMc: I'm thinking of other non-Java things that produce JVM bytecode...

14:23 chouser: scriptor: silly me looking for functions when I should have been looking for syntax...

14:23 technomancy: scala makes it easier to strip out the parts you're not using

14:24 plus it makes imperative code more idiomatic

14:24 TimMc: technomancy: That's more a size/startup time thing, right?

14:24 technomancy: TimMc: yeah, startup time is the #1 blocker for Clojure

14:24 hiredman: https://github.com/sattvik/neko

14:25 technomancy: hiredman: ouch, the last commit message just reads ":("

14:25 TimMc: dgrnbrg_: My program just has the Swing thread and an application thread that blocks ona queue until the human does something.

14:26 casion: the commit messages are pretty pessimistic sounding on neko

14:26 dgrnbrg_: TimMc: did you check out seesaw? It's really awesome for that part

14:26 casion: :(, try again, still doesn't look good, try fixing…, try fixing…,

14:26 TimMc: casion: Fighting with Github, looks like.

14:27 dgrnbrg_: I haven't! I really should, though.

14:27 hiredman: the oracle arm jvm runs clojure great :)

14:27 scriptor: casion: to be fair, it looks like he was just trying to change something with the docs

14:27 dgrnbrg_: TimMc: it's glorious for making a swing gui!

14:27 TimMc: casion: This is where editing on Github directly makes sense.

14:27 dgrnbrg_: My GUI consists entirely of one JComponent I use for drawing. :-P

14:28 pandeiro: interesting read on using v8 in android: http://stackoverflow.com/questions/6880778/android-utilize-v8-without-webview

14:28 casion: Ah, so these are all commits on the readme

14:28 doomlord: what are the pros and cons of clojure v scala

14:28 casion: that makes more sense then :)

14:28 dgrnbrg_: TimMc: seesaw also has a nice api for graphics

14:28 hiredman: clojurebot: tell us about scala?

14:28 clojurebot: http://www2.palomar.edu/users/mhudelson/studyguides/rmnsqvsgothic_wa.html

14:29 hiredman: clojurebot: tell us about scala

14:29 clojurebot: scala is val foo = bar ~-> 45 <~< "Fred" %% x

14:29 hiredman: clojurebot: tell us about scala

14:29 clojurebot: scala is val foo = bar ~-> 45 <~< "Fred" %% x

14:29 hiredman: clojurebot: what about clojure?

14:29 clojurebot: clojurebot is amazing

14:29 hiredman: clojurebot: what about clojure?

14:29 clojurebot: clojureql is http://github.com/LauJensen/clojureql

14:29 hiredman: clojurebot: clojure

14:29 clojurebot: clojure is like life: you make trade-offs

14:29 hiredman: clojurebot: clojure

14:29 clojurebot: clojure is a language to use if you want to up your game

14:29 hiredman: clojurebot: clojure

14:29 clojurebot: clojure is not groovy

14:29 casion: clojurebot is having a stroke

14:29 Lutin`: lol

14:30 \o/

14:30 metellus: clojurebot: clojurebot

14:30 doomlord: ok.. i'm none the wiser :)

14:30 thorbjornDX: what is going on @_@

14:30 clojurebot: clojurebot is a cold unfeeling genderless mechanism

14:30 wingy: i love clojure

14:30 Lutin`: thorbjornDX: You're in here too!

14:30 TimMc: thorbjornDX: hiredman is playing clojurebot factoid roulette.

14:31 thorbjornDX: Lutin`: :)

14:31 doomlord: i like FP ideas, i'm kind of hovering around lisp for being multiparadigm and little dedicated syntax (eg wont reprogram symbol recognition i have for c++)

14:31 uvtc: I ♡ clojurebot.

14:31 TimMc: teehehe... "factoid roulette"

14:32 hiredman: ~clojure

14:32 doomlord: those who say they love clojure- were they lispers *before* clojure. has anyone moved from an algolsyntax language too clojure and liked it

14:32 clojurebot: clojure is not groovy

14:32 hiredman: ~blip.tv

14:32 clojurebot: blip.tv is http://clojure.blip.tv/

14:32 technomancy: doomlord: check out the "state of clojure" survey; very few people come to Clojure from other lisps comparatively

14:32 thorbjornDX: I have a problem with a function: I want it to use functions from different namespaces based on the input arguments, is this something I want a multimethod for?

14:33 hiredman: thorbjornDX: (if ...)

14:33 doomlord: (perhaps ; over on #lisp .. they seem to look down on clojure as some strange mutant ..)

14:33 technomancy: doomlord: they're just jealous

14:33 Lutin`: Now I'm coming from Haskell and am interested in clojure

14:34 thorbjornDX: hiredman: okay. I had a seemingly terrible idea of passing a namespace into the function, and I quickly dismissed it :p

14:34 doomlord: i like the threading macro , funcallable objects, and literal vectors/maps

14:35 technomancy: yeah it's amusing that "just use reader macros" is an acceptable excuse for not having map literals in CL

14:35 Lutin`: Where should I start

14:36 nDuff: Lutin`: The O'Reilly book is a pretty good place.

14:36 http://www.clojurebook.com/ <- that one.

14:36 thorbjornDX: Lutin`: Joy of Clojure is good once you get the basics down

14:37 * nDuff also wholeheartedly seconds thorbjornDX's suggestion.

14:37 scriptor: Lutin`: the best free and online resource is http://java.ociweb.com/mark/clojure/article.html

14:37 thorbjornDX: nDuff: I'm pretty sure you suggested it to me in the first place :)

14:37 scriptor: hmm, if only they used syntax highlighting in there

14:38 thorbjornDX: Lutin`: http://www.4clojure.com/problems can be fun too

14:38 uvtc: scriptor: I actually sent him a pull-request for that, but I think the maintainer is a bit busy with other things.

14:39 scriptor: uvtc: ah, hopefully he'll get back to working on it soon

14:40 pandeiro: Lutin`: i would start with https://github.com/technomancy/leiningen/blob/master/README.md

14:40 muhoo: uvtc: there's also lein-droid

14:41 uvtc: muhoo: wrong person perhaps?

14:42 scriptor: Lutin`: and for a light but very quick introduction there's the online repl: http://tryclj.com/

14:42 muhoo: sorry

14:42 Sgeo: Is it still accurate to say there are no REPL applets?

14:43 * Sgeo should attempt to make one but knows nothing about applets

14:43 muhoo: technomancy: still failing. https://www.refheap.com/paste/5515

14:44 technomancy: i can't seem to figure out which jar exactly it's failing on, based on that error message

14:45 technomancy: muhoo: ugh yeah, unfortunately we don't get enough data back from the underlying API to construct a useful error message =(

14:45 muhoo: technomancy: well, this is a production app, now dead in the water

14:45 any ideas?

14:46 technomancy: I'll pm

14:47 muhoo: k, thanks

14:48 kaoD: hi

15:06 bonega: doomlord: I had never used Lisp before Clojure. Mostly c/python

15:07 And I love Clojure :)

15:07 Iceland_jack: I've used tons of Lisps before Clojure and I love Clojure :)

15:08 bonega: I still think that the java knowledge "needed" for Clojure were harder than the Lisp/functional leap

15:08 Iceland_jack: bonega: depends on your functional background though?

15:08 bonega: none

15:09 But I might just be weird

15:13 pandeiro: workflow to add some println to a third-party lib while in emacs/nrepl: change .m2/.../file, overwrite, C-c C-k, work at repl, back to .m2/.../file in emacs, C-/ C-/ etc, resave ... is there a better way?

15:20 gfredericks: pandeiro: a clojure lib? you can't just re-def some vars?

15:30 jkkramer: pandeiro: clone the lib's repo and symlink in 'checkouts' dir

15:30 pandeiro: jkkramer: projectroot/checkouts ?

15:30 antares_: pandeiro: what jkkramer said, the checkouts feature leiningen has

15:31 jkkramer: pandeiro: yup

15:31 pandeiro: awesome

15:31 antares_: pandeiro: if the 3rd party lib name is someorg/libxyz, then it should be under root/checkouts/libxyz and leiningen will use it from there instead of ~/.m2

15:31 jkkramer: you could also use with-redefs or robert hooke to wrap target fns, if you don't need to alter the fn interiors

15:33 pandeiro: jkkramer: and i could still inspect state inside the function when it is being invoked?

15:33 jkkramer: pandeiro: you could inspect the arguments or outputs, but not the inner workings on the fn

15:33 s/on/of

15:37 pandeiro: lein says it is ignoring the checkouts dir b/c the lib has no project.clj, but in the jar it is there, just in META-INF/leiningen/lib/project.clj

15:38 TimMc: pandeiro: ls -l ./checkouts

15:39 pandeiro: TimMc: I need to manually copy it to the lib root?

15:40 neotyk: pandeiro: try adding sources to source-paths

15:40 TimMc: No, I was asking for a listing of your checkouts dir.

15:41 technomancy: pandeiro: have you tried the tracing lib?

15:41 TimMc: pandeiro: Are you symlinking an unpacked jar? The target needs to be a Leiningen project, with a project.clj at the root.

15:42 pandeiro: And remember that checkouts won't work unless the project is still listed as a :dependency

15:46 neotyk: can anyone help with lein templates?

16:05 pandeiro: TimMc: neotyk: thanks, i thought i could use a jar

16:06 technomancy: which tracing lib?

16:06 technomancy: pandeiro: I think there's a contrib or something?

16:07 pandeiro: tools.trace, got it, thanks

17:11 bisenbek: k

17:19 SegFaultAX|work: I have a massive lazy seq (like, causes an OOM if I realize the whole thing massive). How can I scan the list in constant space?

17:20 (some my-pred big-ass-seq) doesn't work as I thought it would.

17:20 technomancy: SegFaultAX|work: it should work if you're not holding the head of the seq

17:21 SegFaultAX|work: In other words, once I've realized a value I can safely discard it.

17:21 Hmm, that's what I thought.

17:22 Is mapcat not lazy, or break lazy semantics?

17:22 emezeske: mapcat is lazy.

17:23 SegFaultAX|work: Then wtf.

17:23 Lemme paste some code

17:23 https://gist.github.com/3836525

17:24 That's to find the longest palindrome inalongsentencewithnospaces

17:24 technomancy, emezeske: Code paste ^

17:25 amalloy: SegFaultAX|work: (count s)

17:25 casion: I'd imagine...

17:25 amalloy beat me

17:25 SegFaultAX|work: Why would counting the size of the string matter?

17:25 amalloy: that's the most obvious problem; the algorithm would have similar issues if you addressed that

17:25 SegFaultAX|work: How is that relevant?

17:26 casion: emezeske: re: question I asked before you logged off last night, conj was correct as I'm sure you guessed :)

17:26 amalloy: SegFaultAX|work: you walk to the end of the seq to count it, and you need to keep the head of the seq around to mapcat it

17:26 SegFaultAX|work: ,((fn [s] (count s) "hello world")

17:26 casion: I was misunderstanding what I was trying to do

17:26 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

17:26 SegFaultAX|work: ,((fn [s] (count s)) "hello world")

17:26 clojurebot: 11

17:26 SegFaultAX|work: amalloy: Wait, huh?

17:27 amalloy: I'm counting the size of the input string once to build the range which is used to subdivide the string. I don't understand.

17:27 emezeske: casion: Oh, wasn't apply (as amalloy suggested) even better?

17:27 amalloy: SegFaultAX|work: what object is it that you think is getting too large?

17:28 SegFaultAX|work: amalloy: The result of slice-all, I think.

17:28 casion: emezeske: no, afaik apply wouldn't apply (pun intended) because I needed to 'unroll' the arguments in the middle of a nested vector

17:28 SegFaultAX|work: amalloy: But I don't see how what you suggested is hurting it.

17:28 ,((fn [s] (mapcat #(partition % 1 s) (range (count s) 1 -1))) "hello")

17:28 clojurebot: ((\h \e \l \l \o) (\h \e \l \l) (\e \l \l \o) (\h \e \l) (\e \l \l) ...)

17:28 emezeske: casion: Well, glad you got a solution working.

17:28 casion: so I just needed to put a conj in the right place, which I had tried before I asked but had it at the wrong nesting level because the enlive docs (imo) were confusing

17:28 amalloy: no, the size of slice-all will not cause memory issues. but if the size of any particular element of it is too large, it will

17:29 casion: emezeske: I don't think I'd have ever figured it out if you didn't say conj would work so plainly

17:29 SegFaultAX|work: amalloy: It just gets a large-ish string.

17:29 amalloy: About 1170 bytes.

17:29 amalloy: That's the issue?

17:30 emezeske: casion: :)

17:30 amalloy: if you're running on a machine with 1KB of ram, that's probably the issue

17:30 SegFaultAX|work: amalloy: I mean the biggest element would have 1170 bytes.

17:30 amalloy: It's a MBP with like 8gigs. :)

17:30 casion: the whole 'code as data' thing still needs to sink into my head haha

17:32 SegFaultAX|work: Can anyone see any obvious reason why my code is dying?

17:32 (Or non-obvious, as the case may be)

17:36 amalloy: i don't think this should cause you to run out of memory. how long does it take, and can you provide a string for which that happens?

17:37 SegFaultAX|work: amalloy: http://challenge.greplin.com/static/gettysburg.txt

17:37 amalloy: Just grab like 100 characters of that and you'll see what I mean.

17:38 amalloy: Doing the whole thing will OOM.

17:38 amalloy: huh. i did this problem about a year ago in clojure

17:38 SegFaultAX|work: amalloy: Do you see anything horrificly wrong with my code?

17:39 amalloy: well, you're using seqs, reverse, and partition instead of vectors, rseq, and subseq; those will reduce performance problems

17:40 but i ran your code to completion and it works fine

17:40 on the whole string

17:40 SegFaultAX|work: amalloy: Wtf.

17:40 amalloy: How long did it take?

17:40 amalloy: a minute? two?

17:40 technomancy: PSA: central has screwed up jackson again =\

17:40 amalloy: process has 1.5GB of virtual memory

17:40 casion: I get out of memory

17:40 SegFaultAX|work: amalloy: Lame. Maybe I'll just rewrite it with a list comprehension.

17:41 I don't care if it runs slow, but why is it consuming memory like that?

17:41 I mean a list with just 1k elements is not an issue.

17:42 casion: SegFault1X: slice-all making a huge collection

17:42 SegFaultAX|work: casion: But I'm not holding the head, am I?

17:44 casion: hmm

17:54 SegFaultAX|work: why do you want mapcat instead of map?

17:55 SegFaultAX|work: casion: Try it and see.

17:55 casion: I did, and either I don't understand what you're trying to do, or map works correctly

17:55 the former is quite likely

17:58 amalloy: i think chunking is to blame

17:58 clojurebot: You don't have to tell me twice.

18:00 amalloy: i don't quite see what you're winding up with too many of, but if i un-chunkify the result of range, the whole thing runs in 60MB

18:00 SegFaultAX|work: casion: Slice-all is just trying to get a list of all possible subsequences of its imnput

18:00 casion: So if the input is 5 characters, get all 5 4 3 and 2 character long subseqs

18:01 casion: Then check each one to see if it's a palindrome, and yield the largest one.

18:01 casion: Using a map there would result in a list of lists of subseqs. Mapcat makes it just a list of subseqs.

18:01 casion: SegFault1X: ah, I misunderstood what the function was trying to accomplish

18:01 SegFaultAX|work: casion: http://challenge.greplin.com/

18:02 amalloy: SegFaultAX|work: https://gist.github.com/3836677 is a change that should work

18:02 SegFaultAX|work: amalloy: Is it something I did wrong?

18:02 amalloy: well, you caused an OOM, so yes

18:02 but i don't see why

18:03 SegFaultAX|work: Well, at least my initial assumption that it should have worked wasn't totally off.

18:03 amalloy: like i said, something about chunking. i think you're keeping dozens of the 1k-element strings in memory at a time. that should still be fine, though, i would think

18:03 SegFaultAX|work: amalloy: Either way, this is probably better done with a list comprehension and subseq.

18:04 I

18:04 I'm sad my first pass didn't work, though.

18:04 amalloy: right, subseq is the more important change

18:04 since you never need make a second copy of the string in memory

18:05 SegFaultAX|work: amalloy: Ah! It can share memory with the original string, can't it!?

18:05 amalloy: not just share; entirely reuse

18:05 SegFaultAX|work: amalloy: So each subseq will be a view of the original?

18:05 amalloy: yes. subvec though, not subseq

18:06 SegFaultAX|work: Should I vectorize the string, then?

18:06 amalloy: i would. i guess you can leave it as a string and use subseq instead, if that works

18:06 &(subseq "abc" 0 1)

18:06 lazybot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Sorted

18:06 SegFaultAX|work: ,(doc subseq)

18:06 clojurebot: "([sc test key] [sc start-test start-key end-test end-key]); sc must be a sorted collection, test(s) one of <, <=, > or >=. Returns a seq of those entries with keys ek for which (test (.. sc comparator (compare ek key)) 0) is true"

18:24 TimMc: SegFaultAX|work: Have you checked whether there are any leaks related to .substring?

18:25 amalloy: TimMc: he doesn't call substring, so it seems unlikely :P

18:25 TimMc: Oh, this is all done as seqs of chars?

18:25 Sorry, I haven't looked at the code. :-P

18:26 SegFaultAX|work: TimMc: I'm still befuddled as to why it doesn't work. But I'd love to hear your input if you have time to look at the code.

18:26 TimMc: Either way, I solved the problem using a different technique.

18:27 TimMc: Well, I'll most likely take a look when I get home. Glad to hear you solved it!

18:38 thorbjornDX: how should I make a lookup table for a function? def a map? or defn a function that takes a key and looks in a map?

18:38 SegFaultAX|work: thorbjornDX: What are you trying to do?

18:39 thorbjornDX: SegFaultAX|work: I pass a map into a function, and I want to pass that map on to a different function based on the content of the map

18:39 SegFaultAX|work: thorbjornDX: Is this not a case for multimethods?

18:40 thorbjornDX: SegFaultAX|work: I was thinking that way earlier, someone suggested that I just used 'if. I compromised by making these fn-lookup-maps

18:41 SegFaultAX|work: thorbjornDX: It sounds like the pattern you're looking to recreate is multiple dispatch. Maybe you should look at multimethods again :)

18:42 thorbjornDX: SegFaultAX|work: I'll take a look. Thanks for the advice.

18:42 amalloy: i don't see anything "multiple" about that dispatch, but multimethods are still reasonable

18:44 BrainBacon1: Can someone tell me what I'm doing wrong in a cheshire binding? I'm trying to decode json with single quotes in a middleman in noir https://gist.github.com/3836907

18:45 amalloy: BrainBacon1: that's a bunch of code and no question

18:49 BrainBacon1: amalloy: specifically the function json-update gist.github.com/3836907#L24 I have a middleman that uses that function with a binding for cheshire options. In the repl it will parse the json properly (single quotes in json, no quotes on field names), but when I run the noir server it doesn't seem to bind the options I put in.

18:50 amalloy: https://github.com/dakrone/cheshire#advanced-customization-for-factories is what I was basing my binding on

18:51 amalloy: https://github.com/dakrone/cheshire/blob/master/src/cheshire/factory.clj#L11 is where I found the options

18:55 casion: SegFaultAX|work: does this work for you? https://gist.github.com/3836958

18:56 I assume that unchunks the range and makes the mapcat 'actually lazy'

19:04 updated with something that actually returns the palindrome

19:04 which is accepted as the answer on greplin

19:05 TimMc: SegFaultAX|work: What is slice-all?

19:06 casion: TimMc: it returns all subseqs of s

19:08 well, all that are count > 1

19:11 TimMc: I'd like to see the definition on that.

19:11 clojurebot: excusez-moi

19:11 TimMc: clojurebot: ~chunking

19:11 clojurebot: No entiendo

19:11 TimMc: clojurebot: chunking?

19:11 clojurebot: Pardon?

19:11 casion: that was fun to figure out though, and amalloy was as usually correct

19:11 usual*

19:12 TimMc: Oh, DERP. slice-all is a local!

19:12 casion: TimMc: for whatever reason, slice-all was being realized in chunks of 32 due to the range

19:13 holo: hi >.<

19:18 thorbjornDX: SegFaultAX|work: I'm a little lost on how to use multimethods. Is the second argument to defmulti a 'lookup' function to determine which method should be dispatched?

19:18 nDuff: thorbjornDX: Yes.

19:19 thorbjornDX: nDuff: so when I 'defmethod, I need to provide the expected results of calling that 'lookup' on whatever I'm passing in?

19:21 nDuff: thorbjornDX: Right.

19:23 thorbjornDX: nDuff: would you mind looking at this?: http://pastebin.com/UmH4LrLB I must be doing something wrong

19:24 nDuff: it doesn't like that I'm passing in PersistentArrayMaps for some reason.

19:29 casion: thorbjornDX: that code works for me

19:29 SegFaultAX|work: Yup.

19:29 thorbjornDX: casion: clojure 1.4.0?

19:29 casion: thorbjornDX: yes

19:30 thorbjornDX: I wonder if it's vimclojure or something

19:30 SegFaultAX|work: thorbjornDX: Try reevaluating the whole file.

19:31 thorbjornDX: oh, weird

19:31 SegFaultAX|work: thorbjornDX: Got it working?

19:31 thorbjornDX: yeah, that's strange

19:31 I dropped it into a separate file/namespace

19:31 and reevaluated

19:32 SegFaultAX|work: thorbjornDX: Sweet :) So is that kinda what you're looking for?

19:32 casion: SegFaultAX|work: did my comments above clarify the issue with your palindrome func anymore?

19:32 thorbjornDX: SegFaultAX|work: yes, it seems like a more-concise version of what I was doing before

19:32 amalloy: thorbjornDX: multimethods have a misfeature whereby if you redefine one its dispatch function doesn't change

19:32 you can avoid it by (ns-unmap *ns* 'foo)

19:32 technomancy: or just (def foo nil) before defmulti

19:33 thorbjornDX: amalloy: can I just re-evaluate the entire block again? Including the defmulti

19:33 SegFaultAX|work: casion: I don't really understand why realizing the range makes a difference.

19:34 amalloy: SegFaultAX|work: nothing to do with realizing. de-chunking

19:34 casion: SegFault1X: it was making mapcat produce chunks of data… which seems to be too much for either of our jvm processes

19:34 SegFaultAX|work: Ohhh. Neat.

19:34 casion: so when you dechunk the range it's 'one at a time' again

19:34 SegFaultAX|work: Still, isn't the chunk size 32 by default?

19:35 casion: perhaps not again, but now

19:35 amalloy: it's 32, yes

19:35 casion: I thought it was 32, that's what it looked like it was doing

19:35 SegFaultAX|work: So with a large string like the proposed input, that would only be 1170 * 32 which still is only 32k per chunk /at worst/

19:35 amalloy: there's still the problem of each chunk being much larger than we think it should be, but de-chunking makes the total small enough to fit in memory

19:35 SegFaultAX|work: Why did it consume gigs?

19:36 casion: it wasn't consuming gigs here

19:36 SegFaultAX|work: casion: amalloy said his ran up to like 1.7g

19:36 amalloy: SegFaultAX|work: 32k per chunk is pretty optimistic. strings waste a big glob of space, and lazy sequences have to allocate a bunch of objects

19:36 casion: that's odd!?

19:36 thorbjornDX: amalloy: I dropped a (def foo nil) above my defmulti, and that takes care of it

19:37 amalloy: meh. i'm sure 1.5g was the max heap size set for the process, so it didn't bother to gc before then

19:37 SegFaultAX|work: amalloy: Even if the overhead was a meg each, that's still only 32 megs.

19:37 Is it something worth filing a bug over?

19:38 It does seem like one of those pathological worst-case scenarios.

19:39 casion: SegFaultAX|work: fwiw I found lots of similar cases while googling

19:40 where people were having issues withe chunked sequences consuming seemingly way more memory than they should

19:40 all the way back to when chunked seqs were introduced

19:40 unfortunately every resolution was along the lines of 'don't do that then!'

19:44 amalloy: SegFaultAX|work: i don't recommend filing a bug if you can't figure out what's actually happening. "my program uses a lot of memory and nobody can tell why, so it must be a bug in chunking" is not a convincing issue

19:46 dnolen: argh

19:46 defrecord's are IPersistentCollection

19:46 but they don't implement empty

20:20 thorbjornDX: multimethods seem dangerously powerful, should I use :default to raise an exception to make sure I don't break anything?

20:21 nDuff: thorbjornDX: they'll raise an exception if there's no handler regardless.

20:22 dnolen: thorbjornDX: haha dangerously powerful :)

20:23 hiredman: they throw an exception by default if there is no :default

20:23 doomlord: Does closure have CLOS style multiple dispatch

20:23 nDuff: doomlord: Not CLOS style, no.

20:23 doomlord: ...but it has flexible dispatch mechanisms.

20:23 doomlord: .. or is the OO more defined by java

20:23 thorbjornDX: nDuff: okay, cool

20:24 nDuff: doomlord: ...there are both mechanisms that are meant to be fast on the JVM, and mechanisms that are meant to be flexible; you take your pick.

20:24 technomancy: when stuart H spoke on clojure at rubyconf one of the Q&A audience questions was "multimethods sound like they can be really hard to follow if they allow completely arbitrary dispatch"

20:24 doomlord: java etc use double-dispatch as a workaround for multi-dispatch?

20:24 thorbjornDX: dnolen: danger is good, unless my code is capable of causing physical harm to someone

20:24 technomancy: which was kind of ironic considering ruby has method_missing

20:24 doomlord: heh usual tradeoff

20:24 nDuff: doomlord: (which is to say -- Clojure supports some of each kind)

20:25 * nDuff has also seen some folks working on pattern-matching-based dispatch.

20:25 nDuff: ...so that's also an available option, if you're willing to use 3rd-party code.

20:25 thorbjornDX: I'm using multimethods to close some fns around variables based on a :type that I pass in. I odn't think that's too far off the track

20:29 azkesz: hey, does anyone want to do something(that we both agree on) in clojure, _together_ ? I'm not really a programmer(certainly not in clojure) but maybe it will work eventually - I have the time

20:29 amalloy: "close some fns around variables based on :type"? i don't understand what that means

20:29 dnolen: technomancy: it's also only seems too powerful in theory - most uses I've seen are fairly straightforward.

20:29 amalloy: azkesz: just find an open-source project that you use and try to contribute something that would make your use of it better

20:30 you'll wind up working with someone that way

20:30 azkesz: okay thanks amalloy

20:30 any sugestions tho?

20:30 of such projects :)

20:31 (in clojure preferably)

20:31 technomancy: dnolen: it's easy to imagine code using it that is hard to follow, but yeah, it's also easy to use your judgment and just don't do anything crazy =)

20:33 amalloy: easy?! but the crazy things i want to do are usually really cool!

20:34 technomancy: amalloy: just stick to juxt

20:35 amalloy: ~:(

20:35 clojurebot: Huh?

20:35 amalloy: i dunno what that emoticon is supposed to look like. i was just hoping clojurebot had a factoid for :(

20:36 it kinda looks like a sad squirrel

20:36 azkesz: did anyone try storing clojure code in datomic? instead of in files let's say?

20:37 holo: azkesz, are you polish?

20:37 azkesz: I'm mainly wondering if the reloading of code would be better that way

20:37 no holo

20:37 dnolen: azkesz: not Clojure code but the Clojure AST yet.

20:37 azkesz: reloading of the REPL session maybe, kovasb is working on that.

20:42 gfredericks: clojurebot: :( is <reply> #<RuntimeException java.lang.RuntimeException: Invalid token: :>

20:42 clojurebot: Ik begrijp

20:42 azkesz: dnolen, this abstract syntax tree is it something like Extended Backus–Naur Form (EBNF) of the clojure language, or more likely the tree after the macro parsing and can thus store any clojure code written by anyone?

20:44 holo: it can even store macros written by me

20:46 azkesz: ok so the repl reads the textual code and transforms it into the AST ? that kind of AST then...

20:48 wingy: there is a function returning its argument. what is it called now?

20:48 emezeske: wingy: identity?

20:48 wingy: yeah thx

20:50 gfredericks: $findfn 42 42

20:50 holo: azkesz, an AST is so i think because it doesn't have any "concrete" syntax (so it's abstract). coding in clojure is almost the same, because it doesn't use concrete syntax.. hey guys, did i say something wrong?

20:50 lazybot: [clojure.set/union clojure.set/intersection clojure.set/difference clojure.core/time clojure.core/dosync clojure.core/long clojure.core/short clojure.core/+ clojure.core/* clojure.core/doto clojure.core/unchecked-long clojure.core/+' clojure.core/unchecked-short... https://www.refheap.com/paste/5524

20:54 wingy: i need to loop through a sequence and return a value for matching if test

20:54 https://www.refheap.com/paste/5525

20:54 azkesz: I'm kind of hoping that by using datomic to store and load functions (even though I only saw it with java code) would be better with code reloading than by reloading an entire namespace file like normally; and in effect if would be a better way for me at least, to store my code like so

20:54 dnolen: azkesz: holo: I was referring to the AST produced by the CLJS analyzer

20:54 wingy: the issue is that a for loop takes only one body form

20:55 how can i make the logic of the code snippet working

20:55 dnolen: azkesz: by AST I mean a form of Clojure code such that it's something useful for further analysis or for a compiler backend.

20:56 azkesz: dnolen, i think I get it, but isn't clojure already doing something like that after the read part of repl? or something

20:56 ...i thought that's what you meant at first

20:57 dnolen: azkesz: sexprs are friendly then ASTs for user level code transformation - but they lack too much context for other kinds of things you might want to do.

20:57 azkesz: of course that's debatable - Racket seems to pushing the macro things very far.

20:57 macro thing

21:00 adiabatic: Clojure newbie here. I tried Eclipse with counterclockwise and, oddly enough, found myself missing C-a and C-e and C-k something fierce — especially since End took me to the end of the file. I'm actually ready to try Clojure in — dun dun dun — an emacs on OS X. What's everyone's favorite SLIME-compatible emacs that runs on OS X?

21:01 holo: what is a dun dun dun?

21:01 amalloy: most mac users i know installed cocoa emacs via homebrew

21:02 wingy: i should have used (case)

21:02 azkesz: like a sound effect :))

21:02 adiabatic: It's a musical something-or-other to introduce something in a dramatic fashion

21:02 holo: oh! i know what it is!

21:02 azkesz: well said :D

21:02 holo: it's actually 4 duns i think

21:03 gfredericks: probably depends on the melody

21:03 adiabatic: ^

21:03 dnolen: adiabatic: I just use Cocoa Emacs from here http://emacsformacosx.com

21:04 adiabatic: I think all you need to do now is install clojure-mode via (M-x package-list-packages)

21:05 adiabatic: some of the cool kids are on nREPL but I haven't ventured there - others might have pointers about using that.

21:05 adiabatic: not from an identified developer…grumble grumble…

21:06 eggsby: mmm techmesh looks like a good conference... wonder if I can get work to float it :3

21:06 adiabatic: also an emacs newbie — what do I do to find clojure-mode on that page?

21:07 azkesz: is there something that would allow applying updates to clojure code in a stack-like fashion? where each update is say a transaction changing/adding clojure code

21:07 eggsby: adiabatic: I highly recommend technomancys emacs-starter-kit

21:07 icey: Is there anything like a "Built with Clojurescript" site out there?

21:07 eggsby: adiabatic: https://github.com/technomancy/emacs-starter-kit helped me enormously getting started with emacs

21:08 azkesz: i don't dare think of modular transactions :))

21:08 icey: or barring that, does anyone have any clojurescript sites they think are particularly great?

21:09 akhudek: icey: I imagine that most sites using clojurescript use clojure on the server

21:09 eggsby: I've always thought himera was a good cljs example icey http://himera.heroku.com/

21:09 dnolen: icey: emezeske has one

21:09 zmaril: Any ideas about how to get better performance from a noir server?

21:09 dnolen: icey: Light Table is mostly CLJS

21:09 icey: akhudek: I'd imagine the same thing, I'm interested in seeing what people are doing with CLJS on the client side

21:09 eggsby: d2 is pretty great as well

21:10 err, c2 :p

21:10 icey: dnolen: Ah, I didn't think about Light Table

21:10 * gfredericks used cljs with org-html-slideshow to make a fun interactive set of slides for a talk

21:10 dnolen: icey: ohpauleez's startup uses a bunch of CLJS on their frontend as well I believe.

21:11 icey: dnolen: Is that Tutorspree?

21:12 dnolen: icey: yes

21:12 icey: dnolen: awesome, thank you sir

21:12 emezeske: icey: You are looking for an example of a site built in CLJS?

21:13 azkesz: what do you guys think about datomic? i wanna get into it

21:13 icey: dnolen: btw, core.match is half the reason I'm looking at CLJS for some stuff; awesome library

21:13 emezeske: Yeah, mostly I'm just curious as to what people are doing with it. Are they using it for everything, or just for application bits, etc

21:14 dnolen: icey: thanks, sadly only 2/3rds awesome ... but it'll get there one day.

21:14 emezeske: icey: http://blog.mezeske.com/?p=552

21:14 icey: Unfortunately I haven't written the blog posts that go into great detail yet

21:14 icey: But I used it for all the UI stuff

21:14 akhudek: azkesz: think it's pretty interesting, but haven't yet had any experience working with it

21:15 icey: emezeske: bad ass, this is exactly the sort of thing I was looking for

21:15 azkesz: akhudek, same here, I only watched the youtube videos and I'm pretty excited about it

21:15 emezeske: icey: The first post isn't super detailed :/

21:15 Sgeo: What's the discussion about?

21:16 Also, why isn't the URL to the logs in the topic?

21:16 I believe it's Freenode policy to have them in the topic?

21:16 Or at least mention that it's being logged

21:17 azkesz: yeah the last part

21:17 Sgeo: Also, the logger seems broken

21:18 holo: :o my crap is being logged

21:18 azkesz: lol crap

21:18 Frozenlock: holo: yeah, it's really creepy the first time a google search gives you back one your conversations...

21:19 adiabatic: eggsby: do you also recommend starter-kit-lisp?

21:19 icey: Is there anything like socket.io out there for ring?

21:19 holo: makes you feel kind of a public figure right?

21:19 gfredericks: holo: and all I do is make stupid jokes

21:20 Frozenlock: Well I'm used to #emacs no-logging. I was mostly surprised... and happy I haven't said anything dangerous :P

21:20 holo: gfredericks, you're being humble. i saw you more than once, giving god like tips in this #

21:21 icey: emezeske: Your blog post is useful just for the libraries listed at the bottom.

21:21 xeqi: icey: https://github.com/ztellman/aleph

21:24 Sgeo: xeqi, I'm... I don't quite get it. I see how you could buold a socket.io like thing on top of Aleph, but that's not the same as being a substitute for socket.io

21:25 icey: I saw someone was working on a browserchannel implementation in Clojure, but that's the closest thing I've found

21:25 azkesz: what does this mean to unify in this context: https://github.com/clojure/core.logic/wiki/Extending-core.logic-%28Datomic-example%29

21:26 Sgeo: icey, well, there are socket.io servers for Java, maybe ... doing something with that might be possible

21:26 icey: Sgeo: ah, right - I think there's something for Jetty. Thanks

21:26 Sgeo: Ooh, there is?

21:27 Link? Because I also happen to need this, and browserchannel may be bad for my use case because I plan on sending both ways lots of small information

21:27 icey: Sgeo: NO idea if it's any good: https://github.com/thegeez/clj-browserchannel-demo

21:28 holo: anyone knows why "clojure.java.shell" 's "sh" form sits there alot of time after returning the map with :in , :out, etc?

21:28 icey: Sgeo: err - https://github.com/thegeez/clj-browserchannel

21:28 Sgeo: icey, that's browserchannel, not socket.io

21:28 icey: Sgeo: sorry, I didn't realize which thing you were asking about

21:28 zerokarmaleft: ,(assoc-in [[nil nil] [nil nil]] [0 0] 0)

21:28 clojurebot: [[0 nil] [nil nil]]

21:29 zerokarmaleft: is it possible to update an inner pair in one call?

21:29 i'm thinking no, but need a sanity check

21:29 icey: Sgeo: there are a few socket.io java libraries around on github

21:29 I'm coming from .net so I couldn't tell you which ones are better than others though

21:29 Sgeo: zerokarmaleft, isn't that what you just did?

21:30 amalloy: &(update-in [[nil nil] [nil nil]] 0 assoc 0 0 1 0) is what you want?

21:30 lazybot: java.lang.UnsupportedOperationException: nth not supported on this type: Long

21:30 amalloy: &(update-in [[nil nil] [nil nil]] [0] assoc 0 0 1 0)

21:30 lazybot: ⇒ [[0 0] [nil nil]]

21:30 zerokarmaleft: amalloy: yea, that's it

21:31 that solution also makes me feel like i'm off in the weeds

21:32 Sgeo: ,(doc assoc)

21:32 clojurebot: "([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)."

21:32 Sgeo: oh

21:40 zerokarmaleft: i'm basically wanting to reduce into a 2d matrix by checking the collection i'm reducing against a corresponding row# in a diff 2d matrix: https://gist.github.com/3837554

21:42 i guess it's going to be hairy no matter what since i don't think i can escape dealing with indices

21:57 TimMc: zerokarmaleft: Why not this? ##(assoc-in [[nil nil] [nil nil]] [0] [1 2])

21:57 lazybot: ⇒ [[1 2] [nil nil]]

21:58 azkesz: looks nice

21:58 ,(assoc-in [[nil nil] [nil nil]] [1] [1 2])

21:58 clojurebot: [[nil nil] [1 2]]

21:58 azkesz: awesome

21:58 TimMc: which of course is just ##(assoc [[nil nil] [nil nil]] 0 [1 2])

21:58 lazybot: ⇒ [[1 2] [nil nil]]

21:59 azkesz: so many ways to do it...

21:59 zerokarmaleft: TimMc: that would work great as well, but it presumes i build a nested data structure of nils beforehand, right?

21:59 else it inserts a MapEntry?

21:59 azkesz: ,(assoc-in [[nil nil]] [1] [1 2])

21:59 clojurebot: [[nil nil] [1 2]]

21:59 azkesz: ,(assoc-in [] [1] [1 2])

21:59 clojurebot: #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>

22:00 azkesz: ,(assoc-in [] [0] [1 2])

22:00 clojurebot: [[1 2]]

22:00 zerokarmaleft: ah, swank

22:00 TimMc: azkesz: vectors support assoc'ing to the index right after the end, for convenience.

22:00 azkesz: timmc makes sense thanks

22:02 TimMc: zerokarmaleft: I don't quite understand what you're trying to do. Sample input and output?

22:02 Are the elements of sigs pairs of row #s?

22:02 zerokarmaleft: TimMc: https://gist.github.com/3837554

22:03 TimMc: Oh wait, you're going column-first?!

22:03 Yeah, I was reading that and failing to comprehend.

22:03 azkesz: what's a sig?

22:04 signature?

22:04 zerokarmaleft: yea, they're collections of hash function values

22:08 TimMc: zerokarmaleft: If you want advice, you're going to need to explain more clearly what you're trying to do.

22:12 zerokarmaleft: TimMc: i'm updating the gist to explain it in a couple steps

22:12 TimMc: ok, cool

22:15 Ah, this is starting to make sense.

22:16 zerokarmaleft: i omitted some less interesting steps

22:17 bah, i'll go ahead and add it

22:17 Sgeo: Hmm, I'm wondering if it would be a bad idea to just put a large hash into an agent rather than have the hash hold mutable values which hold hashes with mutable values etc.

22:19 Raynes: Sgeo: You're going to want to restrict yourself to as few mutable things as possible. Go for a mutable thing holding a not mutable thing and not a not mutable thing holding a bunch of mutable things.

22:20 Sgeo: Hmm. Although I do wonder about efficiency with that, in particular, different threads trying to update different parts of it at the same time, there's no reason for one to wait for the other

22:21 There's also the fact that I would want watchers watching just portions...

22:21 TimMc: zerokarmaleft: So the inputs are an r-by-c matrix and a pair-vector of length r, and the output is a pair-vector of length c.

22:22 and you're merging pairs element-wise by min.

22:22 zerokarmaleft: TimMc: yes

22:23 much more succinctly put, heh

22:25 TimMc: I think you'll want a map followed by a reduce.

22:26 (map (fn [row sig] ...) matrix sigs) gives you a seq of ([[1 1] nil nil [1 1]] ...)

22:27 and then (reduce merge-sigs (vec (cycle c nil)) sig-partials)

22:28 This supposes that the matrix is a sequence of rows, not columns.

22:30 zerokarmaleft: ah, that makes sense

22:31 it should be possible column-wise too, it just needs to be consistent throughout

22:31 TimMc: thanks, i'll try that track

22:36 TimMc: row-then-column is the convention, so if you have a choice, it may be more maintainable that way.

22:36 May I ask what this is all in pursuit of?

22:41 Oh, and I'll note that the reduce step is associative, so if you're dealing with big wads of data, the reducers lib might be useful.

22:45 wingy: im trying to learn cljs

22:45 could someone help me converting this to cljs: $(document).on('mobileinit', function() {...});

22:58 (.on (js/$ js/document) "mobileinit" #(...))

23:01 if i :use js in the beginning of the file: (.on ($ document) "mobileinit" #(…))

23:06 didnt seem to work to :use js

23:14 adiabatic: Half off-topic, but: I have a line that looks like " ))". How can I tell emacs to take the entire file, or at least a region, and reformat everything so the parens go at the end of the previous line? C-M-\ only handles indentation

23:48 zerokarmaleft: TimMc: sorry, wandered off to grill some dinner

23:49 i'm implementing an algorithm for finding similar items with locality-sensitive hashing

23:52 it probably makes more sense to do it in hadoop, but i just wanted to hack it up in clojure as a non-trivial exercise

23:55 TimMc: Ah, LSH.

23:55 bjorkintosh: lispshell?

23:56 TimMc: bjorkintosh: It's a way of clustering things based on feature vectors.

23:59 zerokarmaleft: TimMc: hence, that naive matrix representation and so on

Logging service provided by n01se.net