#clojure logs

2011-06-07

00:39mrnex2010is there any lib or fn for graphing dependencies of functions inside a ns?
00:58ihodesmrnex2010: 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
01:05mrnex2010ihodes thx for the tip, ill check the api
02:48opqdonuti have a macro (foobar ...) where calls to foo inside the body are treated specially
02:49opqdonutis it okay to do: (defn foo (assert false)) (defmacro foobar [& bodies] `(let [~'foo #(something)] ~@bodies))
02:50opqdonutI'm not sure I want to use binding, since I want the transformation to be fairly syntactic
04:00hoeckopqdonut: why not, I guess it depends
04:02hoeckopqdonut: for example in anaphoric macros, aliasing locals is totally fine
04:05opqdonuthoeck: yeah I thought the solution was pretty clean. I just like to check since macro idioms are sometimes weird
04:07hoeckopqdonut: you will find lots of people disliking this :), and the general advice to newbies is don't do it
04:23Dranikhi all!
04:24DranikI 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?
04:26morphlingDranik: (declare a) (defn b ...
04:26Dranikmorphling: thanks, that was helpful!
05:32Dranikwhich is the best function to read from console?
05:33Draniks/best/easiest
05:33sexpbot<Dranik> which is the easiest function to read from console?
05:34fliebel&(read-line)
05:34sexpbotExecution Timed Out!
05:34Dranikfliebel: thanks!
05:44fliebelxkb: Just ran my code with increased heap space, and now I can get all words, super fast.
05:46fliebelNow, 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.
06:20Dranikhow to transform a line of text to a clojure list?
06:21fliebelDranik: What kind of list? like you expect eval to do?
06:21Dranikyep
06:22fliebel$findfn "[1 2 3]" [1 2 3]
06:22sexpbot[clojure.core/read-string]
06:23Dranikah, yeah!
06:23Dranikthanks!
06:43GeoffSKweb framework recommendations?
06:49fliebelGeoffSK: PHP. What for?
06:50GeoffSKi was think maybe clojure.
06:50GeoffSKi was thinking maybe clojure.
06:51fliebelGeoffSK: Have a look at the Ring ecosystem.
06:52GeoffSKI was afraid you would say that. painful.
06:52fliebelGeoffSK: So, say what you're looking for then, rather than just random recommondations.
06:53mrBlissGeoffSK: https://github.com/macourtney/Conjure or https://github.com/ibdknox/noir/
06:53mrBlissmust read: http://brehaut.net/blog/2011/ring_introduction
06:54GeoffSKNoir i hadn't seen.
06:54fliebelmrBliss: Ah! Thanks, I was looking for the brehaut post already.
06:55fliebelhttps://github.com/brentonashworth/sandbar
06:56GeoffSKsandbar itself says we are about to have a major API change.
06:56DranikGeoffSK: I've tried to apply clojure for web development. Although I have succesfully implemented a simple blog with comments an authorization, it was painfull
06:58GeoffSKDrainik: 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
07:00Dranikno, that's not the reason :-)
07:00Dranikthere is sufficient amount of documentation on the existing clojure libs
07:00GeoffSKoh?
07:00Dranikbut clojure really lacks the environment: e.g. the web stack
07:01Dranikeverything you need -- you have to implement by yourself :-(
07:01Dranikexcept Ring/Compojure of courese
07:01Dranikit's a great router -- the only part which I've used with pleasure
07:02GeoffSKquick question then can you wrap all your routes in a single authentication route ?
07:02Dranikit depends :-)
07:02Dranikbut probably yes -- with macros
07:03Dranikor code walkers
07:03GeoffSKhope you don't write copy for sales brochures :)
07:04Dranik:-D
07:04DranikI'm also frustrated with that...
07:04Draniksuch a great language -- and no real webframework
07:05Draniknot even the support for any existing frameworks
07:05GeoffSKi guess thats just the early part of the development cycle
07:05DranikI've tried to use clojure with J2EE6 -- and it was also unacceptable
07:06GeoffSKthat's some dedication, masochism
07:07Dranikthat's what I'm talking about! :-)
07:07Dranikwe need anyone like DDH for ruby! :-)
07:07Dranikwho would do all the job and we will just use hist web-stack!))
07:08GeoffSKDDH?
07:09Draniksorry, DHH
07:09GeoffSKyep rails guy.
07:09DranikDavid Heinemeir Hanson
07:10GeoffSKsee ya, i am off to hack some more.
08:06@rhickeyPoll - how often are your leveraging the concrete mixin capability of extend, i.e. passing evaluated expressions rather than map literals?
08:06@rhickeyare you
08:39fliebel$mail rhickey re poll: Never. I did use it to extend to an existing function fe we times.
08:39sexpbotMessage saved.
08:59pjstadighttp://clojure.org/downloads is missing a 1.2.1 download
09:00pjstadigand there's no tag for 1.2.1 in the github repo
09:00@rhickeyPoll: How often, if ever, do you leverage the fact that extend evaluates the fn maps, e.g. for concrete mixins, reuse of impls etc?
09:03pjstadigdon't know if i ever knew that it did
09:03@rhickeyah
09:04jedihey rhickey, i'm just new so can't help with the poll, but love your work ;)
09:04@rhickeyjedi: thanks, have fun
09:04pjstadigwell i mean i've known about using a fn map to do "mix-ins" directly with extend, if that's what you mean
09:04pjstadigto reuse implementation code
09:05@rhickeypjstadig: yes, that's it
09:05pjstadigI haven't really used that directly, though i have considered it before
09:05chouserrhickey: 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. :-/
09:06@rhickeychouser: heh
09:06jedichouser: oh, i'm reading your book atm
09:07jedithis channel is trippy
09:07ejacksonrhickey: poll: never.
09:07@rhickeyit 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
09:08@rhickeyif defprotocol and extend were primitives like deftype, things would be a lot simpler
09:08pjstadighmm
09:08chouserjedi: great, hope you're enjoying it!
09:08jedisure am!
09:10raekrhickey: so how would, for example, the implementations of IOFactory in clojure.java.io be written if one can not use assoc in that place?
09:11@rhickeyraek: more verbosely
09:12@rhickeyshared code in named fns, inline literal fns forward to named helpers
09:12@rhickeygranularity of reuse is fn, not map of fns
09:12@rhickeyand more named things
09:12fliebel~logs
09:12clojurebotlogs is http://clojure-log.n01se.net/
09:14chouserfliebel: reload that
09:16@rhickeyraek: that's a good example of what it was intended for
09:18fliebelOh, 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?
09:18Guest72123given 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?
09:19@rhickeyfliebel: who said that?
09:19pjstadigGuest72123: apply
09:19pjstadig~(doc apply)
09:19clojurebotdefmulti doc is (defmulti #^{:doc "docs for foo"} foo class)
09:20pjstadig,(doc apply)
09:20clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
09:20raekrhickey: 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?
09:20@rhickeyfliebel: this is about getting them to exist early, so e.g. protocols can be used for the basic abstractions underlying everything else
09:20Guest72123pjstadig: thanks
09:22fliebelrhickey: Oh, okay. So basically extend has to move to pre-runtime, which requires the map to be literal, like a macro.
09:22@rhickeyraek: I haven't defined an alternative, just surveying use right now.
09:23@rhickeyraek: but basically extend would look more like extend-type/protocol
09:24raekI haven't needed the mixin capability myself yet :-)
09:25raekright now I can't imagine a scenario where I would need to compose the implementation at runtime
09:26raekso I think I would be fine with factoring out the verbosity with a macro
09:42@rhickeythanks all
09:52midshow would I convert a ServletInputStream to a String?
09:57raekmids: you can use slurp (works with any stream): (slurp the-stream :encoding "UTF-8")
09:57raekjust replace "UTF-8" with the actual encoding of the text (if you leave it out, it will default to UTF-8)
10:00gfrlogevery 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:00gfrlogthat was not a very well-defined question :-/
10:01z_zwhat's a good way to depend with cyclic function dependencies when a function requires another function to be defined and vice versa?
10:01gfrlogz_z: ##(doc declare)
10:01sexpbot⟹ "Macro ([& names]); defs the supplied var names with no bindings, useful for making forward declarations."
10:01z_zgfrlog: thanks
10:01gfrlogz_z: yep
10:02coconutelaosohola
10:02coconutelaosohello
10:02gfrloghalo
10:02clgvz_z: letfn is an option for mutual usage/recursion as well
10:05coconutelaosomuseum coconut
10:06klanggfrlog: 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:06coconutelaoso am new to this so do not do many things I'm learning.
10:07klanggfrlog: if you make the same helpers again and again, it can be crystalized out to make a better web testing framework, right?
10:07gfrlogklang: exactly -- but it's not worth the effort if the better web-testing framework already exists somewhere :)
10:07gfrlogthus I ask
10:08gfrlogthis ring.mock.request namespace is not something I have seen before
10:08gfrlogso your examples have taught me something already :)
10:08klanggfrlog: and therefore I am interested .. because I look for this ever once in a while ..
10:10klanggfrlog: 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:11gfrlogklang: 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:13klanggfrlog: yep, makes sense. I guess.
10:13gfrlogklang: I thought it made the tests a lot more readable
10:13klanggfrlog: sort of like "expect" for web apps ..
10:14djpowellso is 1.2.1 actually released then?
10:14gfrlogyeah; it seemed especially helpful when you want several successive requests to be part of the same test
10:14gfrlograther than having a lot of nested (let)s
10:17klanggfrlog: I was trying make add successive tests for the above examples ..
10:46CozeyHow to type an Integer constant in clojure, and not Long?
10:46Cozey,(class (int 123))
10:46clojurebotjava.lang.Integer
10:46Cozeyuh - on clojure 1.3 this gives a Long
10:46stuartsierraStarting in 1.3 alphas, all integer literals are Long.
10:47Cozeyso i will have to use Integer/valueOf ?
10:47raekCozey: why do you need an integer? interop?
10:48raeksince 1.3, all integer-like numbers are boxed as Longs.
10:50stuartsierraIf you want a big-I Integer, yes you can use Integer/valueOf.
10:53Cozeythanks
10:54bprwhere 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:56bprnm, i found it lol
10:57stuartsierraclojure.contrib.json is no more; see github.com/data.json
10:57bprthanks
10:59bpryup, it's fixed
10:59stuartsierraGood.
11:00solussdCould 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:02bprOther 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:03fliebelbpr: But that does not effect the VM quality directly.
11:03bprI can't speak to optimizations and performance concerns though. So I guess that was a non-answer.
11:03bprfliebel: true
11:03solussd:)
11:03fliebelI know Clojure creates a lot of debris, so it might the GC that's different.
11:04solussdLLVM supports automatic reference counting, which is essentially 'compile time garbage collection'
11:04solussdi.e. it inserts 'releases' at the appropriate places in your code
11:04raekdoes LLVM support loading of new code at runtime?
11:04fliebelsolussd: Would that work for a dynamic language?
11:05cemericksolussd: Which isn't sufficient given Clojure's runtime/dynamic characteristics.
11:05solussdgood question. Clojure compiles everything, so I'm assuming it would?
11:05cemerickThere's also the lack of JIT.
11:06solussdwhat runtime/dynamic characteristics? LLVM can compile bytecode to native at runtime
11:06clgvhmm I wonder how to get this debug-repl macro running in clojure.tools.nrepl
11:06cemerickhttp://vmkit.llvm.org/ would be a solution for these issue, but I don't know how usable it is.
11:07solussdcemerick: thanks
11:07fliebelcemerick: Is that what Unladen Swallow is... was using?
11:08cemerickfliebel: I don't know anything about unladen swallow.
11:09clgvcemerick: can you give me a hint how I can launch another local repl (similar to George Jahad's (debug-repl))in an nrepl?
11:09fliebelcemerick: 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:10cemerickfliebel: 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:10cemerickclgv: "another"? Presumably the same way you launched the first one…?
11:10cemerickWhat are you really trying to do?
11:11clgvcemerick: you know the (debug-repl) macro? it doesnt work with nrepl. probably due to not reading from the right input
11:12clgvcemerick: that one https://github.com/GeorgeJahad/debug-repl/blob/e1e74b8328bae79d59ac07ddab051b618b8398d5/src/alex_and_georges/debug_repl.clj
11:14cemerickclgv: yeah, so debug-repl is assuming that it's running in a console
11:14cemerickor, actually, that code is being provided on stdin
11:14cemerickclgv: I'm guessing you're seeing the dr=> prompt being printed?
11:15clgvyeah it looks like that. is there an easy fix? I would really like to be able to use it with nrepl (CCW)
11:15clgvcemerick: I see a prompt like that - I tweaked it for myself with additional info ;)
11:16cemericknREPL 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:16cemerickIf your REPL process is remote, then you're SOL at the moment.
11:17clgvcan't I get access to the input stream that is passed to the repl within nrepl?
11:18clgvas far as I saw nrepl is just using clojure.main/repl in its interior but that call does pretty much stuff
11:18cemerickperhaps…and that would be easier for you than typing in the console?
11:19clgvthe problem is that the execution doesnt suspend at all at the point where the debug-repl is supposed to interrupt
11:20cemerickwhat does it do instead?
11:20cemericki.e. is there a return value?
11:21clgvopps. well in that case I just tested it works.
11:21clgvthe case is: I launched CCW repl with a file and while loading it will run into debug-repl
11:22cemerickI'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:22clgvI had another case when I invoked a command from CCW repl and it just wrote the prompt of debug-repl and continued
11:23clgvI'll try to recover that case
11:23cemerickok
11:23clgvI have another question to nrepl
11:23cemerickFWIW, adding stdin/out support to nREPL isn't hard, but having a suitable UI for it isn't straightforward.
11:25clgvAssume 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:32cemerickclgv: sorry, flake-tastic wifi.
11:32cemerickclgv: yes, that is the point of nREPL :-) Deploy it with your app, open it up on startup, and REPL in from anywhere.
11:33clgvcemerick: humm the point is I want to deploy a tiny nrepl jar and use it as "satellite" for CCW
11:33cemerickReally the only restrictions that apply are the same that apply in any REPL, e.g. can't AOT, etc
11:34cemerickclgv: as in, deploy a minimal shell, and then ramp up whatever you want through the REPL?
11:35clgvcemerick: 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:36Vinzentis there a way to shorten code like {:foo foo :bar bar ...}?
11:36cemerickclgv: so you want to have CCW figure out the full set of files that need to be loaded given a top-level?
11:37clgvyes. I don't know if it does that by default.
11:37clgvif it works normally, does it only work since the repl server instance has access to my local working directory?
11:37cemerickExactly right.
11:37clgvdamn^^
11:38cemerickOr, more to the point, the remote side does not have your local src dir on its classpath.
11:39cemerickThere's nothing stopping CCW from providing a "load all" feature or somesuch, but that's out of scope for nREPL.
11:40cemerick_putting_ your local src dir on the classpath for the scope of a particular evaluation would be pretty neat, tho
11:41cemerickclgv: FWIW, enabling what you're talking about is a planned/potential feature.
11:42clgvcemerick: that's nice to hear.
11:42clgvIt would enable me to do some larger test instances on the remote machine without having to build an entire standalone jar
11:44cemerickclgv: 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:44cemerickMy intention would be to allow for save-your-ass sorts of scenarios.
11:46clgvcemerick: 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:48Krato``hm why does this return out of memory error
11:48Krato``(take 1E6 (comb/lex-permutations [0 1 2 3 4 5 6 7 8 9]))
11:48Krato``where comb is clojure.contrib.combinatorics
11:49Krato``that's only 1 million vectors of 10 elements
11:49pjstadigdepends on what your max heap is
11:49Krato``should be default
11:49fliebel"48kb should be enough for everyone"
11:49Krato``which is 125 mb
11:50cemerickclgv: 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:52clgvcemerick: I don't know pallet yet. let's have a look at it ;)
11:52fliebels/"48kb should be enough for everyone"/"640K ought to be enough for anybody"/
11:52sexpbot<fliebel> "640K ought to be enough for anybody"
11:53Krato``where did you hear 48k anyway
11:53fliebelMade it up...
11:53clgvfliebel: ah that urban legend ;)
11:56pjstadigKrato``: 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:58Krato``ah
11:58Krato``well :P
11:58Krato``1 million really doesn't seem much to me :P
11:59pjstadigKrato``: i think basically the point is, if you get a Java heap OOME, then bump up the max heap
12:01Fossii think basically the point is you should rethink whether your problem really needs that much heap :>
12:06pjstadigFossi: or that :)
12:41solussd,(str "hi " "matt")
12:41clojurebot"hi matt"
12:41droidboihi
12:54droidboiwhat does it mean when a fun starts with . eg .split?
12:54hiredmanit's not a fn
12:55hiredman,(macroexpand '(.split "foo" "o"))
12:55clojurebot(. "foo" split "o")
12:57droidboithx hiredman
12:57droidboiday 2 of clojure 4 me
13:47bartjer, which is the best message queueing system you have used and would recommend ?
13:51hiredmanrabbitmq seems to be pretty standard
13:51hiredmanI am very interested in hornetq but have not used it as part of a production system
13:52hiredmanhornetq is all java and you can configure and launch hornetq servers using clojure code
13:52hiredmanhttps://github.com/hiredman/vespa-crabro
13:54xkb0MQ might be nice?
13:54xkbhavent really used it myself though
13:57technomancy0MQ isn't really a queueing system.
13:58xkbtrue
14:06bartjthanks all, I'll jump into rabbitmq for now
14:06xkbyou could use 0MQ as a queing mechanism though
14:08gfrloghaha jump
14:32offby1technomancy: it isn't?
14:39technomancyoffby1: 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:41hiredman0mq: because there are 0 message queues here
14:42bartjwow, the tutorials at rabbitmq really rock!
16:04Kratosshere a question
16:05Kratossif I do (range (Math/sqrt n)) does the sqare function get evaluated each time a new number taken from the seq
16:05Kratossfor the bounds check
16:06chouserrange takes a number, the *result* of evaluating (Math/sqrt n)
16:06chouserso, the sqrt happens just once
16:06Kratossalso, should I typehint the sqrt call
16:06chouserProbably not
16:06Kratosshm
16:07Kratosswell I made 2 fns prime?
16:07chouserdefinitely not. Math/sqrt only takes a double, so no reason to type hint
16:07Kratoss(defn prime? [n] (if (even? n) false (not-any? #(zero? (mod n %)) (range 3 (Math/sqrt n) 2))))
16:08Kratossand another that uses loop recur instead of not-any?
16:08Kratossthe loop recur is twice as fast as not-any? :((((
16:10chouserit's possible that the loop/recur may be using primitive numbers, which the seq-processing functions like not-any? can't do yet.
16:10Kratosshm not intentionally
16:10Kratossand it's clojure 1.2
16:11chouserhm. with 1.2, you're not likely to be using primitives without knowing it. :-)
16:11Kratosslooks like not-any? is actually comp (not some)
16:11Kratossand some uses recursion with tail optimization
16:11Kratossprobably slower than local loop recur
16:12Kratossspeed difference factor 2 is still a bit high
16:12chouseroh, your loop/recur doesn't use range at all?
16:12Kratossno, it's straight up
16:12Kratossloop though an index
16:12Kratosscall the function
16:12Kratossexit when false
16:12chouserok, it's probably the creation of all the seq steps that's hurting you then.
16:13Kratossoh ok
16:13chousereven though with 1.2 that should be a chunked seq, it's still doing memory allocation
16:13chouserwhile your loop/recur probably isn't allocating any memory at all inside the loop
16:13Kratossyes I've noticed clojure can be really expensive because of loads of allocations
16:14KratossIt's like in java
16:14chouserwell, seq processing in particular, though Rich is continuing to work on that.
16:14chouserseqs 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:15Kratosseven 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:15Kratosspurely because it doesn't do an allocation for each element added
16:15chouserThere's some possibility that the long-rumored "pods" feature may allow some seq-processing loops to collapse to an non-allocating loop
16:16KratossI know it has to do with the whole immutable data structures things
16:16hiredmanwell, if a seq is lazy, realization requires allocation
16:16Kratossbut often I know I don't need immutability inside a certain loop as the data isn't leaving the function
16:17KratossI hope you understand what I mean
16:17hiredmanKratoss: you can just use an arraylist in that case
16:18hiredmanor use a transient
16:18hiredmanhttp://clojure.org/transients may be out of date (even though no major on going work is going on there)
16:19Kratosstransients require at least 100 elements to break even
16:19KratossI'll use arraylist
16:19Kratosstoo bad it doesn't have a reader shorthand
16:20hiredman,(ArrayList. [1 2 3])
16:20clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: ArrayList
16:20hiredman,(java.util.ArrayList. [1 2 3])
16:20clojurebot#<ArrayList [1, 2, 3]>
16:22Kratosswell but you have just spent that advantage
16:22Kratossfor short list
16:22Kratossalso add function on it returns null
16:22KratossI think
16:22Kratosshard to chain
16:22Kratossin any case
16:23hiredman,(doto (java.util.ArrayList. [1 2 3]) (.add 4))
16:23clojurebot#<ArrayList [1, 2, 3, 4]>
16:23Kratosswhat happens when I use multiple functions that return lazy seqences on each other
16:23Kratoss(filter (map (range
16:23Kratosshow many sequence allocations do I get
16:24amalloy&(doto (java.util.ArrayList. [1 2 3]) (.add 4))
16:24sexpbot⟹ #<ArrayList [1, 2, 3, 4]>
16:24amalloyoh, hiredman beat me to it. still getting used to my irc client, sorry
16:26Kratossi mean does filter cause an allocation for each element and map for each element etc?
16:29hiredmaneach step will cause some allocation of aditional lazy-seq "cells" but the number depends on the implementation of each function
16:30Kratossthat's pretty bad
16:31hiredmandefine bad
16:31Kratossespecially considering how these allocations are all over the place
16:31Kratossit will rape any cache
16:31Kratossno locality
16:32Kratossworst 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:38z_zis there something in the standard libraries or contrib that takes a predicate function and returns a "reverse" predicate function?
16:38joly,(doc complement)
16:38clojurebot"([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:39z_zthanks
16:57z_zis there anything similar to "(fn [f x] (fn [y] (= (f y) x))" in the standard libraries of contrib?
16:58gfrlogz_z: what would you call that?
16:58z_zstandard libraries or contrib*
16:59z_zi'm not sure how i would name it
16:59z_zmaybe transform=
16:59z_zreturn a predicate that checks for equality with x after transforming y with f
16:59clojurebotexecutable jar is a sample executable jar build using ant : http://github.com/cark/clj-exe-jar/tree/master
16:59TimMcI stink at threads and locks. :-(
16:59fliebelTimMc: It's the other way around.
17:00Somelauwz_z do you mean currying?
17:00TimMcThey stink at me?
17:00gfrlogz_z: I'd be surprised if it was in contrib, and I'd be surprised if it wasn't in amalloy_utils
17:00fliebelyea
17:00z_zSomelauw yes
17:00z_zi guess
17:01Somelauw,(partial +)
17:01clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$partial
17:01gfrlog(comp (partial = x) f)
17:01Somelauw,((partial + 3) 4)
17:01clojurebot7
17:01Somelauw,((partial + 3) 4 5)
17:01clojurebot12
17:01Somelauwpartial seems to work when there is at least one argument
17:01gfrlogwe were just discussing that the other day...
17:01fliebelIn clojure 1.3 it works without, I think.
17:02amalloy(fn [x f] (comp #{x} f))?
17:02amalloydoesn't work for nil and false x's
17:03gfrlogamalloy: I just conjectured that you had it in amalloy_utils
17:03amalloyone of these days i hope someone changes sets so that my great ideas aren't broken
17:03amalloygfrlog: no, i haven't had a need for it
17:03gfrlogamalloy: changes them to true/false predicates?
17:03amalloyyes
17:03gfrlogI would like that too.
17:04gfrlogif Integers implemented IFn, what would they do?
17:04amalloynot work very well
17:04gfrlogthat damn five never does what I want it to
17:04gfrlogI'll try calling six
17:05joly(= (2 "one") "oneone")
17:05gfrlogyeah I did think of something like (repeat)
17:05gfrlogthat doesn't cover negative integers though
17:06joly(= (-2 "one") "enoeno") ;)
17:06gfrlogI'm sold
17:06gfrlogwhen can we start?
17:06droidboihi. noob here. whats the # prefix for/called eg (map #(assoc ... ))
17:06gfrlogdroidboi: is fn syntax: #(assoc ...) == (fn [%] ...)
17:06gfrlogmore or less
17:07amalloydroidboi: it does lots of things depending on context. #, in general, is a flag to send the reader into a different mode
17:07gfrlogby "context" he means "depending on the rest of the syntax"
17:07joly#() is anonymous function, #{} is a set, #"regexp"
17:08gfrlog## is a call to sexpbot
17:08z_zis there a way to return an expression that isn't a function call using
17:08z_z#()
17:08droidboicool. so i look at reader doc?
17:08gfrlogz_z: maybe you want to use ##(doc constantly)?
17:08sexpbot⟹ "([x]); Returns a function that takes any number of arguments and returns x."
17:09z_zgod you guys are helpful
17:09z_z:)
17:09gfrlogz_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:10gfrloge.g., rather than (fn [x] [x x]) you could do #(vector x x)
17:10gfrlogor #(vector % %) sorry
17:10gfrlogalso see the functions list, hash-set, hash-map, list*, set, vec, ...
17:32z_zis there a macro similar to doto for a use case like this? http://pastebin.com/JHwcgHda
17:33z_zwhere you don't have to type in prop-zip-str over and over
17:33amalloyjuxt
17:33gfrlogholy crap he's right
17:33amalloy&(let [[bigger smaller] ((juxt inc dec) 10)] [bigger smaller])
17:33sexpbot⟹ [11 9]
17:33gfrlogamalloy: do you just sit around waiting for people to ask questions with that answer?
17:33amalloygfrlog: it's easy. juxt is the right answer to any question
17:34bprwhy?
17:34clojurebotwhy not?
17:34amalloy~o/
17:34clojurebot\o ... High five!
17:34bprhaha
17:35gfrlogwhat's the tilde doing there?
17:35amalloy~help
17:35clojurebothttp://www.khanacademy.org/
17:35amalloyhm
17:35gfrlog~tilde
17:35clojurebotHuh?
17:35amalloyanyway it's clojurebot's command prefix
17:35gfrlogI was imagining maybe it was hair waving
17:35gfrlogor...a bandana?
17:35amalloyaction lines
17:36z_zcan the vector from the juxt be directly used?
17:36amalloyuh
17:36z_z(let (juxt ...)
17:37gfrlogno?
17:37gfrlognot sure what that would mean
17:37z_zo wait nvm
17:37gfrlogbut it wouldn't compile at least
17:37amalloyit's a vector. you can do things with it that can be done with vectors; exactly that set of things
17:37z_zit's not even in the right form
17:38gfrlog,(class ((juxt identity) 4))
17:38clojurebotclojure.lang.PersistentVector
17:38gfrlogamalloy: why should it be a vector?
17:38amalloymaking it a unicorn instead would have been harder? that's not really a meaningful question
17:38gfrloglazy seq?
17:39amalloy*shrug* it could be, but there's little benefit
17:39gfrlogI guess a vector seems strangely specific
17:39gfrloglike making it a finger tree
17:39amalloyjuxt is just a special case of map; if you want a lazy version, use map instead
17:40gfrlog...it is?
17:40amalloy&(map #(%1 10) [inc dec])
17:40gfrlogI guess maybe
17:40sexpbot⟹ (11 9)
17:41gfrlogI'm always surprised that #(%1 10) is not a function in core
17:41amalloy#(apply % %&) would be useful, yes
17:43z_zlol
17:43gfrlog(defn fix-args [& args] (fn [f] (apply f args)))
18:09mtrelinsomethinghow 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:10Chousukedoall will eval the thing
18:10mtrelinsomethingi've done a (count (doall lseq)) and it seems to only operate on the first item in the list
18:10Chousukeunless you have nested lazy sequences, in which case you will end up with a fully real seq of lazy seqs :)
18:10mtrelinsomethingyeah
18:10mtrelinsomethingi have nested lazy sequences
18:10chouserhow deep? just one level?
18:11Chousukethen you need extra care.
18:11Raynes(slapthelazyoutofalloftheselazysequences lseq) ; I require this function.
18:11mtrelinsomethinghttp://pastie.org/2034768
18:12lancepantzcould you not post-walk do-all?
18:12mtrelinsomethingso i need a post-walk-doall ?
18:13lancepantzmtrelinsomething: check out https://github.com/richhickey/clojure/blob/c1c39162608551d50cfb18998d015974b11cfecc/src/clj/clojure/walk.clj#L95
19:31z_zwhat's the correct way to memoize a recursive function?
19:31hiredman(def foo (memoize (fn [..] ...)))
19:32z_zty
19:32hiredmananything else is broken since some point pre-1.2
19:32hiredmanhttp://groups.google.com/group/clojure-dev/browse_thread/thread/33b52b24616967f?hl=en
19:35amalloyto force nested lazy-seqs i use (postwalk identity coll)
19:35hiredmanugh, but clojure.walk is so slow
19:35amalloyhiredman: yeah, it won't be winning any races
19:36ieureArgh. 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:36ieureThey’re here: http://download.osgeo.org/webdav/geotools/
19:36ieure:repositories {"geonames" {:url "http://download.osgeo.org/webdav/geotools/&quot;}}
19:36ieureAdded that to project.clj.
19:36ieureNo dics.
19:36ieureUh. Dice.
19:36amalloyieure: {"geonames" "http:…"} iirc
19:37ieureamalloy, Same issue.
19:38amalloyieure: all i can offer is my experience with https://github.com/amalloy/clojopts/blob/master/project.clj
19:38amalloywhich works
19:40amalloyso i'd guess you need to get the group/artifact ids right
19:40ieureThey’re correct.
19:40ieurehttp://download.osgeo.org/webdav/geotools/org/geotools/geotools/2.7.1/
19:40ieureThere are no JARs there.
19:40amalloyyeah, i just checked that
19:40ieureWhat the fuck.
19:41amalloyieure: geotools has deps, though. so if you depend on that it should pull those in transitively
19:44ieureHm.
19:44ieureI guess, but there’s no .jar file to fetch.
19:45ieureHm.
19:45amalloyso?
19:46ieureSo lein deps pukes because it doesn’t exist.
19:46ieureAnd it doesn’t download any other deps.
19:46ieureI can depend on gt-shapefile and get most/all of what I need.
19:46ieureFor whatever reason, this stuff is broken down into sixty-three separate jars.
19:46amalloyhaha awesome
19:57gfrlogI guess they only had six bits in their jar counter
20:25ieureHm, what’s the thing that I can use to generate a symbol inside a macro so I don’t collide with other bindings?
20:25offby1in other lisps, it's traditionally called "gensym" ... dunno what it is in clojure though
20:26ieureYeah, Clojure has gensym, but I think there’s a reader macro or something.
20:26gfrlogieure: stick a # at the end of the symbol
20:26ieureThat’s it.
20:26gfrlogso `(let [x# 12] ...)
20:28amalloy&`x#
20:28sexpbot⟹ x__9952__auto__
20:28gfrlog,(take 5 (repeatedly gensym))
20:28clojurebot(G__395 G__396 G__397 G__398 G__399)
20:29gfrlogstrangely when I do it one by one at the repl it hops by 3's
20:29gfrlog,(gensym)
20:29clojurebotG__402
20:29gfrlog,(gensym)
20:29clojurebotG__405
20:29gfrloglike that
20:44amalloygfrlog: because there are other things creating gensyms
20:44amalloywhen you do a quoted form they all get generated in sequence
20:48gfrloginteresante
21:03hiredmanclojurebot: 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:03clojurebotc'est bon!
21:49cemerick~seen ejackson
21:49clojurebotejackson was last seen joining #clojure, 433 minutes ago