#clojure log - Jun 07 2011

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

0:39 mrnex2010: is there any lib or fn for graphing dependencies of functions inside a ns?

0:58 ihodes: mrnex2010: i can't think of one off the top of my head, but it would be fairly straightforward to write one i think. there's some snaffu with ns and listing fns in them i remmber from trying to do a similar thing myself a while back, but it's doable with namespace fns that exist

1:05 mrnex2010: ihodes thx for the tip, ill check the api

2:48 opqdonut: i have a macro (foobar ...) where calls to foo inside the body are treated specially

2:49 is it okay to do: (defn foo (assert false)) (defmacro foobar [& bodies] `(let [~'foo #(something)] ~@bodies))

2:50 I'm not sure I want to use binding, since I want the transformation to be fairly syntactic

4:00 hoeck: opqdonut: why not, I guess it depends

4:02 opqdonut: for example in anaphoric macros, aliasing locals is totally fine

4:05 opqdonut: hoeck: yeah I thought the solution was pretty clean. I just like to check since macro idioms are sometimes weird

4:07 hoeck: opqdonut: you will find lots of people disliking this :), and the general advice to newbies is don't do it

4:23 Dranik: hi all!

4:24 I have two functions written in this order: (defn b [] (a)) (defn a [] "") . How can I resolve the function a in the function b if it a is written after b?

4:26 morphling: Dranik: (declare a) (defn b ...

4:26 Dranik: morphling: thanks, that was helpful!

5:32 which is the best function to read from console?

5:33 s/best/easiest

5:33 sexpbot: <Dranik> which is the easiest function to read from console?

5:34 fliebel: &(read-line)

5:34 sexpbot: Execution Timed Out!

5:34 Dranik: fliebel: thanks!

5:44 fliebel: xkb: Just ran my code with increased heap space, and now I can get all words, super fast.

5:46 Now, do you have a plan for multiple words? Because my phone number will turn up nothings. Also, all numbers with 1 and 0 fail, because these contain no characters on my phone.

6:20 Dranik: how to transform a line of text to a clojure list?

6:21 fliebel: Dranik: What kind of list? like you expect eval to do?

6:21 Dranik: yep

6:22 fliebel: $findfn "[1 2 3]" [1 2 3]

6:22 sexpbot: [clojure.core/read-string]

6:23 Dranik: ah, yeah!

6:23 thanks!

6:43 GeoffSK: web framework recommendations?

6:49 fliebel: GeoffSK: PHP. What for?

6:50 GeoffSK: i was think maybe clojure.

6:50 i was thinking maybe clojure.

6:51 fliebel: GeoffSK: Have a look at the Ring ecosystem.

6:52 GeoffSK: I was afraid you would say that. painful.

6:52 fliebel: GeoffSK: So, say what you're looking for then, rather than just random recommondations.

6:53 mrBliss: GeoffSK: https://github.com/macourtney/Conjure or https://github.com/ibdknox/noir/

6:53 must read: http://brehaut.net/blog/2011/ring_introduction

6:54 GeoffSK: Noir i hadn't seen.

6:54 fliebel: mrBliss: Ah! Thanks, I was looking for the brehaut post already.

6:55 https://github.com/brentonashworth/sandbar

6:56 GeoffSK: sandbar itself says we are about to have a major API change.

6:56 Dranik: GeoffSK: I've tried to apply clojure for web development. Although I have succesfully implemented a simple blog with comments an authorization, it was painfull

6:58 GeoffSK: Drainik: yep, thats about the level of complexity i am targeting. I am (almost) tempted to use java. I think lack of relevant and complete documentation might be the source of my frustration

7:00 Dranik: no, that's not the reason :-)

7:00 there is sufficient amount of documentation on the existing clojure libs

7:00 GeoffSK: oh?

7:00 Dranik: but clojure really lacks the environment: e.g. the web stack

7:01 everything you need -- you have to implement by yourself :-(

7:01 except Ring/Compojure of courese

7:01 it's a great router -- the only part which I've used with pleasure

7:02 GeoffSK: quick question then can you wrap all your routes in a single authentication route ?

7:02 Dranik: it depends :-)

7:02 but probably yes -- with macros

7:03 or code walkers

7:03 GeoffSK: hope you don't write copy for sales brochures :)

7:04 Dranik: :-D

7:04 I'm also frustrated with that...

7:04 such a great language -- and no real webframework

7:05 not even the support for any existing frameworks

7:05 GeoffSK: i guess thats just the early part of the development cycle

7:05 Dranik: I've tried to use clojure with J2EE6 -- and it was also unacceptable

7:06 GeoffSK: that's some dedication, masochism

7:07 Dranik: that's what I'm talking about! :-)

7:07 we need anyone like DDH for ruby! :-)

7:07 who would do all the job and we will just use hist web-stack!))

7:08 GeoffSK: DDH?

7:09 Dranik: sorry, DHH

7:09 GeoffSK: yep rails guy.

7:09 Dranik: David Heinemeir Hanson

7:10 GeoffSK: see ya, i am off to hack some more.

8:06 rhickey: Poll - how often are your leveraging the concrete mixin capability of extend, i.e. passing evaluated expressions rather than map literals?

8:06 are you

8:39 fliebel: $mail rhickey re poll: Never. I did use it to extend to an existing function fe we times.

8:39 sexpbot: Message saved.

8:59 pjstadig: http://clojure.org/downloads is missing a 1.2.1 download

9:00 and there's no tag for 1.2.1 in the github repo

9:00 rhickey: Poll: How often, if ever, do you leverage the fact that extend evaluates the fn maps, e.g. for concrete mixins, reuse of impls etc?

9:03 pjstadig: don't know if i ever knew that it did

9:03 rhickey: ah

9:04 jedi: hey rhickey, i'm just new so can't help with the poll, but love your work ;)

9:04 rhickey: jedi: thanks, have fun

9:04 pjstadig: well i mean i've known about using a fn map to do "mix-ins" directly with extend, if that's what you mean

9:04 to reuse implementation code

9:05 rhickey: pjstadig: yes, that's it

9:05 pjstadig: I haven't really used that directly, though i have considered it before

9:05 chouser: rhickey: not much. the places where I could, I most often have ended up with tortured macros to get all the code in-line in a deftype or defrecord. :-/

9:06 rhickey: chouser: heh

9:06 jedi: chouser: oh, i'm reading your book atm

9:07 this channel is trippy

9:07 ejackson: rhickey: poll: never.

9:07 rhickey: it ends up that feature slides a substantial portion of protocols et al into the runtime profile, rather than compile-time, making it harder to primitivize and move down in the bootstrap

9:08 if defprotocol and extend were primitives like deftype, things would be a lot simpler

9:08 pjstadig: hmm

9:08 chouser: jedi: great, hope you're enjoying it!

9:08 jedi: sure am!

9:10 raek: rhickey: so how would, for example, the implementations of IOFactory in clojure.java.io be written if one can not use assoc in that place?

9:11 rhickey: raek: more verbosely

9:12 shared code in named fns, inline literal fns forward to named helpers

9:12 granularity of reuse is fn, not map of fns

9:12 and more named things

9:12 fliebel: ~logs

9:12 clojurebot: logs is http://clojure-log.n01se.net/

9:14 chouser: fliebel: reload that

9:16 rhickey: raek: that's a good example of what it was intended for

9:18 fliebel: Oh, okay, so basically the whole protocols-as-maps thing has to go for decent performance, and that means extend has to go as well. Is that correct?

9:18 Guest72123: given a list of arguments and wanting to call a function that takes variable arguments is there an alternative to calling eval on a quasiquoted expression with unquote-splicing on the list of arguments?

9:19 rhickey: fliebel: who said that?

9:19 pjstadig: Guest72123: apply

9:19 ~(doc apply)

9:19 clojurebot: defmulti doc is (defmulti #^{:doc "docs for foo"} foo class)

9:20 pjstadig: ,(doc apply)

9:20 clojurebot: "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."

9:20 raek: rhickey: so the method map must be a map literal. what is allowed as a value of the of a method map entry? only a (fn ...) form? a symbol for a var? a symbol for a local?

9:20 rhickey: fliebel: this is about getting them to exist early, so e.g. protocols can be used for the basic abstractions underlying everything else

9:20 Guest72123: pjstadig: thanks

9:22 fliebel: rhickey: Oh, okay. So basically extend has to move to pre-runtime, which requires the map to be literal, like a macro.

9:22 rhickey: raek: I haven't defined an alternative, just surveying use right now.

9:23 raek: but basically extend would look more like extend-type/protocol

9:24 raek: I haven't needed the mixin capability myself yet :-)

9:25 right now I can't imagine a scenario where I would need to compose the implementation at runtime

9:26 so I think I would be fine with factoring out the verbosity with a macro

9:42 rhickey: thanks all

9:52 mids: how would I convert a ServletInputStream to a String?

9:57 raek: mids: you can use slurp (works with any stream): (slurp the-stream :encoding "UTF-8")

9:57 just replace "UTF-8" with the actual encoding of the text (if you leave it out, it will default to UTF-8)

10:00 gfrlog: every time I want to test a web app I find myself writing the same helper functions for making ring requests. Are there some testing helpers for this somewhere?

10:00 that was not a very well-defined question :-/

10:01 z_z: what's a good way to depend with cyclic function dependencies when a function requires another function to be defined and vice versa?

10:01 gfrlog: z_z: ##(doc declare)

10:01 sexpbot: ⟹ "Macro ([& names]); defs the supplied var names with no bindings, useful for making forward declarations."

10:01 z_z: gfrlog: thanks

10:01 gfrlog: z_z: yep

10:02 coconutelaoso: hola

10:02 hello

10:02 gfrlog: halo

10:02 clgv: z_z: letfn is an option for mutual usage/recursion as well

10:05 coconutelaoso: museum coconut

10:06 klang: gfrlog: I tried to add some examples here https://github.com/klang/clojure-web at some point because I couldn't find anything about testing web-applications anywhere .. It's supposed to be easy, but I suppose I am missing something..

10:06 coconutelaoso: am new to this so do not do many things I'm learning.

10:07 klang: gfrlog: if you make the same helpers again and again, it can be crystalized out to make a better web testing framework, right?

10:07 gfrlog: klang: exactly -- but it's not worth the effort if the better web-testing framework already exists somewhere :)

10:07 thus I ask

10:08 this ring.mock.request namespace is not something I have seen before

10:08 so your examples have taught me something already :)

10:08 klang: gfrlog: and therefore I am interested .. because I look for this ever once in a while ..

10:10 gfrlog: there is a bit of help to be found in ring.mock.request and the general test scripts for ring and the other parts used in clojure web applications .. but it isn't much, unfortunately.

10:11 gfrlog: klang: on one of my projects I had an interesting threading thing going on where I would do this sort of thing: https://gist.github.com/1012326

10:13 klang: gfrlog: yep, makes sense. I guess.

10:13 gfrlog: klang: I thought it made the tests a lot more readable

10:13 klang: gfrlog: sort of like "expect" for web apps ..

10:14 djpowell: so is 1.2.1 actually released then?

10:14 gfrlog: yeah; it seemed especially helpful when you want several successive requests to be part of the same test

10:14 rather than having a lot of nested (let)s

10:17 klang: gfrlog: I was trying make add successive tests for the above examples ..

10:46 Cozey: How to type an Integer constant in clojure, and not Long?

10:46 ,(class (int 123))

10:46 clojurebot: java.lang.Integer

10:46 Cozey: uh - on clojure 1.3 this gives a Long

10:46 stuartsierra: Starting in 1.3 alphas, all integer literals are Long.

10:47 Cozey: so i will have to use Integer/valueOf ?

10:47 raek: Cozey: why do you need an integer? interop?

10:48 since 1.3, all integer-like numbers are boxed as Longs.

10:50 stuartsierra: If you want a big-I Integer, yes you can use Integer/valueOf.

10:53 Cozey: thanks

10:54 bpr: where would i find the "canonical" git repo for clojure.contrib.json? I found a bug in 1.2.0 and I'd like to submit a patch if it's not already fixed.

10:56 nm, i found it lol

10:57 stuartsierra: clojure.contrib.json is no more; see github.com/data.json

10:57 bpr: thanks

10:59 yup, it's fixed

10:59 stuartsierra: Good.

11:00 solussd: Could someone here explain (in keywords / concepts I can google) why LLVM w/ automatic reference counting would not make a good host platofrm for clojure? I remember reading awhile back that clojure relies on some dynamic optimizations that the JVM performs at runtime that LLVM was poorly suited for (I have no idea what these might be)

11:02 bpr: Other people here are far more suited to answer that than I am, but as I recall that a big draw of the JVM is the large quantity of libraries available to it.

11:03 fliebel: bpr: But that does not effect the VM quality directly.

11:03 bpr: I can't speak to optimizations and performance concerns though. So I guess that was a non-answer.

11:03 fliebel: true

11:03 solussd: :)

11:03 fliebel: I know Clojure creates a lot of debris, so it might the GC that's different.

11:04 solussd: LLVM supports automatic reference counting, which is essentially 'compile time garbage collection'

11:04 i.e. it inserts 'releases' at the appropriate places in your code

11:04 raek: does LLVM support loading of new code at runtime?

11:04 fliebel: solussd: Would that work for a dynamic language?

11:05 cemerick: solussd: Which isn't sufficient given Clojure's runtime/dynamic characteristics.

11:05 solussd: good question. Clojure compiles everything, so I'm assuming it would?

11:05 cemerick: There's also the lack of JIT.

11:06 solussd: what runtime/dynamic characteristics? LLVM can compile bytecode to native at runtime

11:06 clgv: hmm I wonder how to get this debug-repl macro running in clojure.tools.nrepl

11:06 cemerick: http://vmkit.llvm.org/ would be a solution for these issue, but I don't know how usable it is.

11:07 solussd: cemerick: thanks

11:07 fliebel: cemerick: Is that what Unladen Swallow is... was using?

11:08 cemerick: fliebel: I don't know anything about unladen swallow.

11:09 clgv: cemerick: can you give me a hint how I can launch another local repl (similar to George Jahad's (debug-repl))in an nrepl?

11:09 fliebel: cemerick: Okay, I would think they have solved much the same problems. And I do remember reading some complaints about the maturity of dynamic stuff of llvm they where using.

11:10 cemerick: fliebel: based on a 30-skim of http://code.google.com/p/unladen-swallow/wiki/ProjectPlan it looks like they implemented their own JIT on top of LLVM

11:10 clgv: "another"? Presumably the same way you launched the first one…?

11:10 What are you really trying to do?

11:11 clgv: cemerick: you know the (debug-repl) macro? it doesnt work with nrepl. probably due to not reading from the right input

11:12 cemerick: that one https://github.com/GeorgeJahad/debug-repl/blob/e1e74b8328bae79d59ac07ddab051b618b8398d5/src/alex_and_georges/debug_repl.clj

11:14 cemerick: clgv: yeah, so debug-repl is assuming that it's running in a console

11:14 or, actually, that code is being provided on stdin

11:14 clgv: I'm guessing you're seeing the dr=> prompt being printed?

11:15 clgv: yeah it looks like that. is there an easy fix? I would really like to be able to use it with nrepl (CCW)

11:15 cemerick: I see a prompt like that - I tweaked it for myself with additional info ;)

11:16 cemerick: nREPL does not yet support providing stdin input. The workaround in CCW would be to type your code into the corresponding Console (which does accept input that pipes into stdin).

11:16 If your REPL process is remote, then you're SOL at the moment.

11:17 clgv: can't I get access to the input stream that is passed to the repl within nrepl?

11:18 as far as I saw nrepl is just using clojure.main/repl in its interior but that call does pretty much stuff

11:18 cemerick: perhaps…and that would be easier for you than typing in the console?

11:19 clgv: the problem is that the execution doesnt suspend at all at the point where the debug-repl is supposed to interrupt

11:20 cemerick: what does it do instead?

11:20 i.e. is there a return value?

11:21 clgv: opps. well in that case I just tested it works.

11:21 the case is: I launched CCW repl with a file and while loading it will run into debug-repl

11:22 cemerick: I've never used debug-repl, but I'd expect it to suspend the thread executing the code containing the (debug-repl) call, print the dr prompt, and sit waiting.

11:22 clgv: I had another case when I invoked a command from CCW repl and it just wrote the prompt of debug-repl and continued

11:23 I'll try to recover that case

11:23 cemerick: ok

11:23 clgv: I have another question to nrepl

11:23 cemerick: FWIW, adding stdin/out support to nREPL isn't hard, but having a suitable UI for it isn't straightforward.

11:25 clgv: Assume I build a jar starting an nrepl server, distribute it to another computer and launch it there. When I conenct with CCW to that nrepl, will CCW be able to send my files to that nrepl instance?

11:32 cemerick: clgv: sorry, flake-tastic wifi.

11:32 clgv: yes, that is the point of nREPL :-) Deploy it with your app, open it up on startup, and REPL in from anywhere.

11:33 clgv: cemerick: humm the point is I want to deploy a tiny nrepl jar and use it as "satellite" for CCW

11:33 cemerick: Really the only restrictions that apply are the same that apply in any REPL, e.g. can't AOT, etc

11:34 clgv: as in, deploy a minimal shell, and then ramp up whatever you want through the REPL?

11:35 clgv: cemerick: almost. deploying a minimal shell/repl and let CCW send the files needed for running a selected file via "Run" in that remote shell/repl

11:36 Vinzent: is there a way to shorten code like {:foo foo :bar bar ...}?

11:36 cemerick: clgv: so you want to have CCW figure out the full set of files that need to be loaded given a top-level?

11:37 clgv: yes. I don't know if it does that by default.

11:37 if it works normally, does it only work since the repl server instance has access to my local working directory?

11:37 cemerick: Exactly right.

11:37 clgv: damn^^

11:38 cemerick: Or, more to the point, the remote side does not have your local src dir on its classpath.

11:39 There's nothing stopping CCW from providing a "load all" feature or somesuch, but that's out of scope for nREPL.

11:40 _putting_ your local src dir on the classpath for the scope of a particular evaluation would be pretty neat, tho

11:41 clgv: FWIW, enabling what you're talking about is a planned/potential feature.

11:42 clgv: cemerick: that's nice to hear.

11:42 It would enable me to do some larger test instances on the remote machine without having to build an entire standalone jar

11:44 cemerick: clgv: building the standalone jar/war will always be more efficient. Functionally adding local bits to the remote classpath will entail repeatedly potentially large data transfers (e.g. for loading additional dependencies, etc).

11:44 My intention would be to allow for save-your-ass sorts of scenarios.

11:46 clgv: cemerick: the problem is that it takes quite a while to build that jar and often I only want to switch from a tiny test instance to a medium sized one for a short test or comparison of a new implemented feature

11:48 Krato``: hm why does this return out of memory error

11:48 (take 1E6 (comb/lex-permutations [0 1 2 3 4 5 6 7 8 9]))

11:48 where comb is clojure.contrib.combinatorics

11:49 that's only 1 million vectors of 10 elements

11:49 pjstadig: depends on what your max heap is

11:49 Krato``: should be default

11:49 fliebel: "48kb should be enough for everyone"

11:49 Krato``: which is 125 mb

11:50 cemerick: clgv: Sure, I can see that…though I would point you at pallet as a way to simplify/automate your deployment process. You'll nevertheless have to be cognizant of what a given file load would imply (e.g. N other .clj loads, M classes from .jar files, etc)

11:52 clgv: cemerick: I don't know pallet yet. let's have a look at it ;)

11:52 fliebel: s/"48kb should be enough for everyone"/"640K ought to be enough for anybody"/

11:52 sexpbot: <fliebel> "640K ought to be enough for anybody"

11:53 Krato``: where did you hear 48k anyway

11:53 fliebel: Made it up...

11:53 clgv: fliebel: ah that urban legend ;)

11:56 pjstadig: Krato``: I calculate that 10M longs would take 80MiB, without including persistent vector overheads. that means the rest of the java objects have to fit into 45MiB. also not all OOMEs are equal

11:58 Krato``: ah

11:58 well :P

11:58 1 million really doesn't seem much to me :P

11:59 pjstadig: Krato``: i think basically the point is, if you get a Java heap OOME, then bump up the max heap

12:01 Fossi: i think basically the point is you should rethink whether your problem really needs that much heap :>

12:06 pjstadig: Fossi: or that :)

12:41 solussd: ,(str "hi " "matt")

12:41 clojurebot: "hi matt"

12:41 droidboi: hi

12:54 what does it mean when a fun starts with . eg .split?

12:54 hiredman: it's not a fn

12:55 ,(macroexpand '(.split "foo" "o"))

12:55 clojurebot: (. "foo" split "o")

12:57 droidboi: thx hiredman

12:57 day 2 of clojure 4 me

13:47 bartj: er, which is the best message queueing system you have used and would recommend ?

13:51 hiredman: rabbitmq seems to be pretty standard

13:51 I am very interested in hornetq but have not used it as part of a production system

13:52 hornetq is all java and you can configure and launch hornetq servers using clojure code

13:52 https://github.com/hiredman/vespa-crabro

13:54 xkb: 0MQ might be nice?

13:54 havent really used it myself though

13:57 technomancy: 0MQ isn't really a queueing system.

13:58 xkb: true

14:06 bartj: thanks all, I'll jump into rabbitmq for now

14:06 xkb: you could use 0MQ as a queing mechanism though

14:08 gfrlog: haha jump

14:32 offby1: technomancy: it isn't?

14:39 technomancy: offby1: it's a tool for constructing queueing systems and other things; it's very low-level. it's closer to sockets than protocols like amqp.

14:41 hiredman: 0mq: because there are 0 message queues here

14:42 bartj: wow, the tutorials at rabbitmq really rock!

16:04 Kratoss: here a question

16:05 if I do (range (Math/sqrt n)) does the sqare function get evaluated each time a new number taken from the seq

16:05 for the bounds check

16:06 chouser: range takes a number, the *result* of evaluating (Math/sqrt n)

16:06 so, the sqrt happens just once

16:06 Kratoss: also, should I typehint the sqrt call

16:06 chouser: Probably not

16:06 Kratoss: hm

16:07 well I made 2 fns prime?

16:07 chouser: definitely not. Math/sqrt only takes a double, so no reason to type hint

16:07 Kratoss: (defn prime? [n] (if (even? n) false (not-any? #(zero? (mod n %)) (range 3 (Math/sqrt n) 2))))

16:08 and another that uses loop recur instead of not-any?

16:08 the loop recur is twice as fast as not-any? :((((

16:10 chouser: it's possible that the loop/recur may be using primitive numbers, which the seq-processing functions like not-any? can't do yet.

16:10 Kratoss: hm not intentionally

16:10 and it's clojure 1.2

16:11 chouser: hm. with 1.2, you're not likely to be using primitives without knowing it. :-)

16:11 Kratoss: looks like not-any? is actually comp (not some)

16:11 and some uses recursion with tail optimization

16:11 probably slower than local loop recur

16:12 speed difference factor 2 is still a bit high

16:12 chouser: oh, your loop/recur doesn't use range at all?

16:12 Kratoss: no, it's straight up

16:12 loop though an index

16:12 call the function

16:12 exit when false

16:12 chouser: ok, it's probably the creation of all the seq steps that's hurting you then.

16:13 Kratoss: oh ok

16:13 chouser: even though with 1.2 that should be a chunked seq, it's still doing memory allocation

16:13 while your loop/recur probably isn't allocating any memory at all inside the loop

16:13 Kratoss: yes I've noticed clojure can be really expensive because of loads of allocations

16:14 It's like in java

16:14 chouser: well, seq processing in particular, though Rich is continuing to work on that.

16:14 seqs are beautiful for higher-level work, but if you need the most speed in a tight loop, it's best to avoid them still.

16:15 Kratoss: even though LinkedList is O(1) for adding elements at the front and ArrayList is O(n), the arraylist keeps being faster for lists of few thousand elements

16:15 purely because it doesn't do an allocation for each element added

16:15 chouser: There's some possibility that the long-rumored "pods" feature may allow some seq-processing loops to collapse to an non-allocating loop

16:16 Kratoss: I know it has to do with the whole immutable data structures things

16:16 hiredman: well, if a seq is lazy, realization requires allocation

16:16 Kratoss: but often I know I don't need immutability inside a certain loop as the data isn't leaving the function

16:17 I hope you understand what I mean

16:17 * fliebel weeps at #python, how do you explain you need a thrush?

16:17 hiredman: Kratoss: you can just use an arraylist in that case

16:18 or use a transient

16:18 http://clojure.org/transients may be out of date (even though no major on going work is going on there)

16:19 Kratoss: transients require at least 100 elements to break even

16:19 I'll use arraylist

16:19 too bad it doesn't have a reader shorthand

16:20 hiredman: ,(ArrayList. [1 2 3])

16:20 clojurebot: java.lang.IllegalArgumentException: Unable to resolve classname: ArrayList

16:20 hiredman: ,(java.util.ArrayList. [1 2 3])

16:20 clojurebot: #<ArrayList [1, 2, 3]>

16:22 Kratoss: well but you have just spent that advantage

16:22 for short list

16:22 also add function on it returns null

16:22 I think

16:22 hard to chain

16:22 in any case

16:23 hiredman: ,(doto (java.util.ArrayList. [1 2 3]) (.add 4))

16:23 clojurebot: #<ArrayList [1, 2, 3, 4]>

16:23 Kratoss: what happens when I use multiple functions that return lazy seqences on each other

16:23 (filter (map (range

16:23 how many sequence allocations do I get

16:24 amalloy: &(doto (java.util.ArrayList. [1 2 3]) (.add 4))

16:24 sexpbot: ⟹ #<ArrayList [1, 2, 3, 4]>

16:24 amalloy: oh, hiredman beat me to it. still getting used to my irc client, sorry

16:26 Kratoss: i mean does filter cause an allocation for each element and map for each element etc?

16:29 hiredman: each step will cause some allocation of aditional lazy-seq "cells" but the number depends on the implementation of each function

16:30 Kratoss: that's pretty bad

16:31 hiredman: define bad

16:31 Kratoss: especially considering how these allocations are all over the place

16:31 it will rape any cache

16:31 no locality

16:32 worst thing about modern CPUs is that since access speeds of RAM haven't changed much in last 10 years, they are insanely reliant on cache for performance

16:38 z_z: is there something in the standard libraries or contrib that takes a predicate function and returns a "reverse" predicate function?

16:38 joly: ,(doc complement)

16:38 clojurebot: "([f]); Takes a fn f and returns a fn that takes the same arguments as f, has the same effects, if any, and returns the opposite truth value."

16:39 z_z: thanks

16:57 is there anything similar to "(fn [f x] (fn [y] (= (f y) x))" in the standard libraries of contrib?

16:58 gfrlog: z_z: what would you call that?

16:58 z_z: standard libraries or contrib*

16:59 i'm not sure how i would name it

16:59 maybe transform=

16:59 return a predicate that checks for equality with x after transforming y with f

16:59 clojurebot: executable jar is a sample executable jar build using ant : http://github.com/cark/clj-exe-jar/tree/master

16:59 TimMc: I stink at threads and locks. :-(

16:59 fliebel: TimMc: It's the other way around.

17:00 Somelauw: z_z do you mean currying?

17:00 TimMc: They stink at me?

17:00 gfrlog: z_z: I'd be surprised if it was in contrib, and I'd be surprised if it wasn't in amalloy_utils

17:00 fliebel: yea

17:00 z_z: Somelauw yes

17:00 i guess

17:01 Somelauw: ,(partial +)

17:01 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$partial

17:01 gfrlog: (comp (partial = x) f)

17:01 Somelauw: ,((partial + 3) 4)

17:01 clojurebot: 7

17:01 Somelauw: ,((partial + 3) 4 5)

17:01 clojurebot: 12

17:01 Somelauw: partial seems to work when there is at least one argument

17:01 gfrlog: we were just discussing that the other day...

17:01 fliebel: In clojure 1.3 it works without, I think.

17:02 amalloy: (fn [x f] (comp #{x} f))?

17:02 doesn't work for nil and false x's

17:03 gfrlog: amalloy: I just conjectured that you had it in amalloy_utils

17:03 amalloy: one of these days i hope someone changes sets so that my great ideas aren't broken

17:03 gfrlog: no, i haven't had a need for it

17:03 gfrlog: amalloy: changes them to true/false predicates?

17:03 amalloy: yes

17:03 gfrlog: I would like that too.

17:04 if Integers implemented IFn, what would they do?

17:04 amalloy: not work very well

17:04 gfrlog: that damn five never does what I want it to

17:04 I'll try calling six

17:05 joly: (= (2 "one") "oneone")

17:05 gfrlog: yeah I did think of something like (repeat)

17:05 that doesn't cover negative integers though

17:06 joly: (= (-2 "one") "enoeno") ;)

17:06 gfrlog: I'm sold

17:06 when can we start?

17:06 droidboi: hi. noob here. whats the # prefix for/called eg (map #(assoc ... ))

17:06 gfrlog: droidboi: is fn syntax: #(assoc ...) == (fn [%] ...)

17:06 more or less

17:07 amalloy: droidboi: it does lots of things depending on context. #, in general, is a flag to send the reader into a different mode

17:07 gfrlog: by "context" he means "depending on the rest of the syntax"

17:07 joly: #() is anonymous function, #{} is a set, #"regexp"

17:08 gfrlog: ## is a call to sexpbot

17:08 z_z: is there a way to return an expression that isn't a function call using

17:08 #()

17:08 droidboi: cool. so i look at reader doc?

17:08 gfrlog: z_z: maybe you want to use ##(doc constantly)?

17:08 sexpbot: ⟹ "([x]); Returns a function that takes any number of arguments and returns x."

17:09 z_z: god you guys are helpful

17:09 :)

17:09 gfrlog: z_z: or if it depends on the arguments, like say you want to return a data structure, then there is usually a fn for the particular data structure

17:10 e.g., rather than (fn [x] [x x]) you could do #(vector x x)

17:10 or #(vector % %) sorry

17:10 also see the functions list, hash-set, hash-map, list*, set, vec, ...

17:32 z_z: is there a macro similar to doto for a use case like this? http://pastebin.com/JHwcgHda

17:33 where you don't have to type in prop-zip-str over and over

17:33 amalloy: juxt

17:33 gfrlog: holy crap he's right

17:33 amalloy: &(let [[bigger smaller] ((juxt inc dec) 10)] [bigger smaller])

17:33 sexpbot: ⟹ [11 9]

17:33 gfrlog: amalloy: do you just sit around waiting for people to ask questions with that answer?

17:33 amalloy: gfrlog: it's easy. juxt is the right answer to any question

17:34 bpr: why?

17:34 clojurebot: why not?

17:34 amalloy: ~o/

17:34 clojurebot: \o ... High five!

17:34 bpr: haha

17:35 gfrlog: what's the tilde doing there?

17:35 amalloy: ~help

17:35 clojurebot: http://www.khanacademy.org/

17:35 amalloy: hm

17:35 gfrlog: ~tilde

17:35 clojurebot: Huh?

17:35 amalloy: anyway it's clojurebot's command prefix

17:35 gfrlog: I was imagining maybe it was hair waving

17:35 or...a bandana?

17:35 amalloy: action lines

17:36 z_z: can the vector from the juxt be directly used?

17:36 amalloy: uh

17:36 z_z: (let (juxt ...)

17:37 gfrlog: no?

17:37 not sure what that would mean

17:37 z_z: o wait nvm

17:37 gfrlog: but it wouldn't compile at least

17:37 amalloy: it's a vector. you can do things with it that can be done with vectors; exactly that set of things

17:37 z_z: it's not even in the right form

17:38 gfrlog: ,(class ((juxt identity) 4))

17:38 clojurebot: clojure.lang.PersistentVector

17:38 gfrlog: amalloy: why should it be a vector?

17:38 amalloy: making it a unicorn instead would have been harder? that's not really a meaningful question

17:38 gfrlog: lazy seq?

17:39 amalloy: *shrug* it could be, but there's little benefit

17:39 gfrlog: I guess a vector seems strangely specific

17:39 like making it a finger tree

17:39 amalloy: juxt is just a special case of map; if you want a lazy version, use map instead

17:40 gfrlog: ...it is?

17:40 amalloy: &(map #(%1 10) [inc dec])

17:40 gfrlog: I guess maybe

17:40 sexpbot: ⟹ (11 9)

17:41 gfrlog: I'm always surprised that #(%1 10) is not a function in core

17:41 amalloy: #(apply % %&) would be useful, yes

17:43 z_z: lol

17:43 gfrlog: (defn fix-args [& args] (fn [f] (apply f args)))

18:09 mtrelinsomething: how do i force evaluation of a lazy-seq? i've tried (doall lseq) but it doesn't eval the whole thing, when i just do repl> lseq then it evals the whole thing

18:10 Chousuke: doall will eval the thing

18:10 mtrelinsomething: i've done a (count (doall lseq)) and it seems to only operate on the first item in the list

18:10 Chousuke: unless you have nested lazy sequences, in which case you will end up with a fully real seq of lazy seqs :)

18:10 mtrelinsomething: yeah

18:10 i have nested lazy sequences

18:10 chouser: how deep? just one level?

18:11 Chousuke: then you need extra care.

18:11 Raynes: (slapthelazyoutofalloftheselazysequences lseq) ; I require this function.

18:11 mtrelinsomething: http://pastie.org/2034768

18:12 lancepantz: could you not post-walk do-all?

18:12 mtrelinsomething: so i need a post-walk-doall ?

18:13 lancepantz: mtrelinsomething: check out https://github.com/richhickey/clojure/blob/c1c39162608551d50cfb18998d015974b11cfecc/src/clj/clojure/walk.clj#L95

19:31 z_z: what's the correct way to memoize a recursive function?

19:31 hiredman: (def foo (memoize (fn [..] ...)))

19:32 z_z: ty

19:32 hiredman: anything else is broken since some point pre-1.2

19:32 http://groups.google.com/group/clojure-dev/browse_thread/thread/33b52b24616967f?hl=en

19:35 amalloy: to force nested lazy-seqs i use (postwalk identity coll)

19:35 hiredman: ugh, but clojure.walk is so slow

19:35 amalloy: hiredman: yeah, it won't be winning any races

19:36 ieure: Argh. I need to get org.geotools/geotools into my Leiningen project, but it’s not in the usual repos and I’m not sure how to add the one they’re in to my project.

19:36 They’re here: http://download.osgeo.org/webdav/geotools/

19:36 :repositories {"geonames" {:url "http://download.osgeo.org/webdav/geotools/&quot;}}

19:36 Added that to project.clj.

19:36 No dics.

19:36 Uh. Dice.

19:36 amalloy: ieure: {"geonames" "http:…"} iirc

19:37 ieure: amalloy, Same issue.

19:38 amalloy: ieure: all i can offer is my experience with https://github.com/amalloy/clojopts/blob/master/project.clj

19:38 which works

19:40 so i'd guess you need to get the group/artifact ids right

19:40 ieure: They’re correct.

19:40 http://download.osgeo.org/webdav/geotools/org/geotools/geotools/2.7.1/

19:40 There are no JARs there.

19:40 amalloy: yeah, i just checked that

19:40 ieure: What the fuck.

19:41 amalloy: ieure: geotools has deps, though. so if you depend on that it should pull those in transitively

19:44 ieure: Hm.

19:44 I guess, but there’s no .jar file to fetch.

19:45 Hm.

19:45 amalloy: so?

19:46 ieure: So lein deps pukes because it doesn’t exist.

19:46 And it doesn’t download any other deps.

19:46 I can depend on gt-shapefile and get most/all of what I need.

19:46 For whatever reason, this stuff is broken down into sixty-three separate jars.

19:46 amalloy: haha awesome

19:57 gfrlog: I guess they only had six bits in their jar counter

20:25 ieure: Hm, what’s the thing that I can use to generate a symbol inside a macro so I don’t collide with other bindings?

20:25 offby1: in other lisps, it's traditionally called "gensym" ... dunno what it is in clojure though

20:26 ieure: Yeah, Clojure has gensym, but I think there’s a reader macro or something.

20:26 gfrlog: ieure: stick a # at the end of the symbol

20:26 ieure: That’s it.

20:26 gfrlog: so `(let [x# 12] ...)

20:28 amalloy: &`x#

20:28 sexpbot: ⟹ x__9952__auto__

20:28 gfrlog: ,(take 5 (repeatedly gensym))

20:28 clojurebot: (G__395 G__396 G__397 G__398 G__399)

20:29 gfrlog: strangely when I do it one by one at the repl it hops by 3's

20:29 ,(gensym)

20:29 clojurebot: G__402

20:29 gfrlog: ,(gensym)

20:29 clojurebot: G__405

20:29 gfrlog: like that

20:44 amalloy: gfrlog: because there are other things creating gensyms

20:44 when you do a quoted form they all get generated in sequence

20:48 gfrlog: interesante

21:03 hiredman: clojurebot: code review is <reply> I get into the meanest, nastiest frame of mind I can manage, and I write the nastiest (testing) code I can think of. Then I turn around and embed that in even nastier constructions that are nearly obscene. - Donald E. Knuth

21:03 clojurebot: c'est bon!

21:49 cemerick: ~seen ejackson

21:49 clojurebot: ejackson was last seen joining #clojure, 433 minutes ago

Logging service provided by n01se.net