#clojure logs

2013-03-27

00:01ivanhttp://bugs.sun.com/view_bug.do?bug_id=4262078 says to JCP it
00:10jonasendnolen: why is core.logic/llist a macro? (I made it a function and all tests pass)
00:15SgeoPeople sometimes write a macro when a function would work. Don't know if that's the case here though
00:15SgeoIt is the case with whatchamacallit monad library
00:15Sgeolift was made a macro instead of a function
00:26n_bIs there a clojure equivalent to rake?
00:43rbxbxn_b: I feel like most people use leiningen to those ends.
00:43n_bI think I must be missing something/glossed over some documentation. Basically I want to have it try and grab some static files and toss them into lib/ if they don't already exist/haven't changed
00:44antares_n_b: a custom Leiningen task can do that
00:45n_bAh, alright. Just wanted to make sure I wasn't missing anything obvious/preferred. Will throw that on the todo list and try and throw it on GitHub once finished. Thanks for the help rbxbx and antares_
00:45rbxbxcheers.
00:45antares_n_b: tasks and plugins are covered by https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md
00:53firesofmayIs it possible to do bulk require in clojure? like test.* :as t
00:53firesofmayand I refer all the ns inside test like t.app, t.core etc?
00:59firesofmayanyone?
00:59clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
01:00rbxbxfiresofmay what's your question? :require foo :as bar should work, no?
01:00rbxbxyou can also use :use if you don't want to namespace it
01:01rbxbx(though that's typically frowned upon in production code)
01:01firesofmayrbxbx yes but I would like to do something like import foo.bar.* :as baz
01:01rbxbxfor java imports?
01:01firesofmayrbxbx and then do bas.app1/fn , bas.app2/fn
01:01firesofmayrbxbx no for clojure ns
01:02firesofmayrbxbx I have many ns inside a directory and instead of doing require for all can i do :as on the directory itself?
01:02amalloyfiresofmay: no
01:02rbxbxah okay
01:02firesofmayamalloy okay
01:02rbxbx^^^ what that guy said
01:03rbxbxwell, amalloy. not yourself.
01:03firesofmayrbxbx amalloy so no way to do this except require each of them?
01:03rbxbxfiresofmay I dare say you should ask yourself why that's necessitated.
01:04firesofmayrbxbx I am basically writing my tests for iPhone in clojure using calabash.
01:04amalloywell, i actually don't think it would be such a bad idea (whereas being able to :use or :import multiple namespaces would be)
01:04firesofmayrbxbx and I wanted to separate each view as its own ns
01:05firesofmayamalloy I don't want to do :use. wanted the require but was wondering if there is a way around bulk require.
01:06rbxbxfiresofmay I'm not sure how to help. Sorry.
01:06firesofmayrbxbx no problem :)
01:40hyPiRiongfredericks, TimMc: Ping.
02:07tylerim trying to implement irc nick auto complete in clojure
02:08tyleranyone have any algorithm ideas?
02:09arrdemtyler: a trie is probably your best bet.. maybe a probability weighted trie at that.
02:10arrdemthat is, a trie such that the order of its children when iterating is decided not by the character ordinal values, but in order of decreasing probability of following the parent.
02:19tieTYT2would it be advantageous to have a repl that auto reloads files?
02:19tieTYT2i never want to use an out of date one
02:19tieTYT2or is there a shorthand way of reloading all the current namespaces I've required?
02:20arrdemtieTYT2: if you're in emacs there's got to be a way to re-eval files on buffer flush
02:20arrdemif you find one share the snippet 'cause I want it.
02:21arrdemin the more general case not sure. Noir did some magic to reload files at runtime but I don't think your average repl will.
02:21tieTYT2i see
02:22tieTYT2well i use intellij's plugin (atm) not emacs
02:22tieTYT2but it sounds like you want this feature too
02:22arrdemI mean.. if I spent 15 with the manual and google I could build it.. for emacs and nrepl.
02:22arrdemas it is I relaod files when I save them anyway
02:23tieTYT2how?
02:23clojurebotwith style and grace
02:23tieTYT2emacs script?
02:24ivanC-c C-k runs the command nrepl-load-current-buffer
02:25arrdemand C-c C-l is the general lisp-mode eval buffer
02:25ivantools.namespace can reload everything you've required
02:26arrdemyou can also enter (use 'my-ns :reload-all) to force clojure to read from source again
02:27arrdemI don't know anything specifically about the intelliJ LaClojure environment, but I'm sure there's a "load file" command somewhere that should also do for you.
02:28tieTYT2arrdem: well i use lein side by side with it
02:28tieTYT2which is probably a bad idea
02:28tieTYT2i think there's a bug in it
02:28arrdemit's an approach...
02:28tieTYT2in la clojure I mean
02:28arrdemmine was tmux with vim and lein for months
02:28tieTYT2it's hard to figure out how to start up a repl
02:29arrdemwhat OS are you on? windows, mac or a real Nix?
02:30tieTYT2ivan: cool. I'll look into that later
02:30tieTYT2windows
02:31arrdemhum can't help you much then. If you were mac or linux I'd strongly suggest looking into emacs.. I know that official emacs builds exist for windows but I've never used one and thus won't attempt to commend it to you.
02:31tieTYT2IME learning a new editor can reduce your productivity for weeks
02:32tieTYT2and since I'm also learning clojure at the same time, I'm not sure i could handle that
02:32arrdemhah I learned Vim, Tmux and Clojure at the same time this past summer. My productivity was in the tank for two week straight.
02:32arrdemI absolutely understand not wanting to change environments.
02:33tieTYT2there's an eclipse and netbeans plugin i haven't tried yet
02:33tieTYT2if they're better i may swithc
02:34ivanEmacs works fine on Windows
02:34arrdemwith nrepl?
02:34ivanyep
02:34arrdemcan't say I'm shocked...
02:34ivanthough if git is in your PATH it may take 4 seconds per call to git, perhaps 47 seconds to start if you have Emacs loading all your files on startup
02:35ivangit.cmd is the trainwreck, git.exe is reasonably fast
02:35arrdemyuck
02:35arrdemand I thought that Eight Megabytes And Constant Swapping was bad on Linux...
03:02DaReaper5i need some help working with an input stream
03:03DaReaper5i need to: create a zip input stream from an array of input streams
03:04amalloyDaReaper5: https://github.com/flatland/io/blob/develop/src/flatland/io/core.clj
03:05amalloyie, if you (:require flatland.io.core, [clojure.java.io :as io]), you should be able to just call (io/input-stream (seq the-array-of-streams))
03:06DaReaper5really1?
03:06DaReaper5that seems to easy
03:06DaReaper5i need to return the zip to a client (this is a component on a clojure server)
03:06amalloywell, you still have to wrap it in a zipinputstream however
03:07amalloyi'm just handling the array part
03:07DaReaper5oh i see
03:07amalloybut java.util.zip contains a wrapper that turns an inputstream into a zipstream
03:07amalloyso that's like no work
03:07DaReaper5i hope
03:07DaReaper5something like this:
03:08DaReaper5zipInStream (java.util.zip.ZipInputStream. (io/input-stream allReports))
03:08DaReaper5?
03:08DaReaper5allReports is my array
03:09DaReaper5shouldnt i need to add each individually
03:09DaReaper5and specify a name?
03:14DaReaper5amalloy?
03:14clojurebotamalloy is <amalloy> just use juxt, it'll be great
03:14amalloyzip input streams are for reading zip files. you want to write a zip file, so you have to do something else entirely
03:15DaReaper5ya
03:15DaReaper5i think i have to read the input stream like a buffer
03:15DaReaper5for each one
03:15DaReaper5ew
03:19DaReaper5can i use io/copy to convert the inputstream to an outputstream
03:19DaReaper5which i can just call toByteArray on?
03:20arrdemyou should be able to..
03:21arrdemif you have another object to act as an output buffer
03:27tomojDaReaper5: example https://www.refheap.com/paste/80bad6da903cc2e6542b33d3d
04:23piranhais there a threading function in clojure core akin to ->, but which will call fns? Something like (... x #(func1 % arg1) #(func2 arg2 %))
04:23arrdemso -> is wacky when it comes to inline fns.
04:24arrdemif you define an inline fn, then you need to parenthesize it in order for -> to invoke it correctly.
04:24arrdemeg. #(println "foo") -> (#(println "foo"))
04:25arrdemhowever if you have a bound function, say clojure.core/inc, you can just stick that in line and -> will deal with it.
04:25arrdemthere is the function comp, which is similar to -> in effects...
04:25arrdem,(doc comp)
04:25clojurebot"([] [f] [f g] [f g h] [f1 f2 f3 & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
04:26arrdem,((comp #(* 3 %) inc dec dec) 3)
04:26clojurebot6
04:34piranhaarrdem: hm, sure, comp looks like a good choice for that
04:35arrdemnote what they are intended for tho.. comp returns a function which must be called while -> is intended for un-nesting expressions.
04:36arrdem,(-> {} (assoc :foo 1) (assoc :bar 2) (assoc :baz 3))
04:36clojurebot{:baz 3, :bar 2, :foo 1}
04:37arrdemis equivalent to (and macroexpands to) &(assoc (assoc (assoc {} :foo 1) :bar 2) :baz 3)
04:37arrdem,(assoc (assoc (assoc {} :foo 1) :bar 2) :baz 3)
04:37clojurebot{:baz 3, :bar 2, :foo 1}
04:44piranhaarrdem: yes, well, I understand that
04:44piranhaarrdem: in the end it seems for quick repl sessions ->> and wrapping all others in parens works best for me :)
04:44piranhai.e. (->> a (#(s/split % #"&")) (map #(s/split % #"=")) (into {}) (#(get % "url")) java.net.URLDecoder/decode)
04:44tomojanyone thinking about reducer fusion?
04:45piranha->> is better than -> because map in other case will require wrapping in fn, which means even more text
04:45arrdemtomoj: please elaborate
04:49piranhais it possible to somehow install package with lein without creating a project.clj with this package in dependencies?
04:49piranhalike in python I would do 'pip install lxml' and the lxml will be available for use in repl
04:50arrdemyeah so in Lein 1.X that was doable
04:50arrdemin Lein 2.X not so much....
04:50piranhaeh :(
04:50arrdemyou can add packages to your Lein profile for autoloading..
04:50arrdemwhich gets you almost the same place
04:51arrdembut in general no Lein isn't designed to just kick off a repl and hack any old where it's designed to be a project tool.
04:52arrdemanyone else still alive please correct me, but that's my understanding and I'm not going to ping technomancy in here for this at 2AM PST
04:53winkstill alive? at work for nearly an hour already... silly americans 8)
04:53kalasjohnny2000when lein trampoline cljsbuild repl-listen I get Exception in thread "main" java.lang.IllegalArgumentException: contains? not supported on type: clojure.lang.LazySeq at cljs.closure: at cljs.closure$js_dependencies$fn__1448.invoke(closure.clj:540)
04:54kalasjohnny2000I run clojure 1.5.1, cljsbuild 0.3.0, lein 2.1.1
04:54kalasjohnny2000it seems to me that it\s a lazy dependency list that has to be realized
04:55winkpiranha: I've wished for that in the past too, but maybe there's even a way I don't know of. I'd suggest #leiningen later on :)
04:56kalasjohnny2000wov, I check #leiningen.
04:56piranhawink: yeah, in the mean time I've just added package to one of projects, downloaded it and removed; maybe writing a plugin would be nice for that...
04:57winkpiranha: yes, but if it's possible it needs to be documented. if not, it might be worth building.
05:02tomojarrdem: ..you did ping him :)
05:04tomojarrdem: to elaborate, an example: (r/map inc coll) -> (reify CollReduce (coll-reduce [_ f val] (r/reduce (fn [ret v] (f ret (inc v))) coll)))
05:05tomojbasically the idea is just to do some reducer transformations at compile time instead of runtime
05:05Glenjaminarrdem, wink if its for having in an arbitrary repl to play with, ~/.lein/profiles.clj seems like the right place
05:05arrdemtomoj: damnit who the shit uses non-prefix ping notifications
05:05tomoj(well, I bet he's using erc, dunno his config — mine (the default) highlights on all mentions)
05:07arrdem,(doc ret)
05:07clojurebotHuh?
05:08tomojI'm thinking like collections containing primitives and supporting fast loops (matrices?)
05:09arrdemhum.. you're into deeper magic than I'm familliar with or can reason about at 4am local
05:09tomojdo the reducer transform at compile time and your math is all inlined, no boxing (except across fork/join tasks), and maybe fusion of loops over zipped collections, for the 'multireducer' case
05:09tomojah, OK
05:10arrdemso that'll work just fine for fixed dimensionality vector aditions and scalar multiplication
05:10arrdemnot sure if it's applicable to multiplication tho
05:12arrdemwell if you can inline your transpose? somehow..
05:12tomojtranspose is pretty close to free I think
05:12arrdemit should be
05:13tomojhmm
05:13arrdembecause A * B is the matrix M being the dot products of A[i] by col and B[i] by row
05:13arrdemyay I learned something in linalg and remembered it!
05:13arrdemisn't that what core.matrix is doing already tho?
05:15tomojcore.matrix is already trying to be a matrix library
05:15tomojs/trying to be //
05:15arrdemoh and this is just a more general reducer structure?
05:15tomojwell, yeah, and I'm not sure I like core.matrix :)
05:16arrdemseemed.. heavily engineered when I looked at it
05:16arrdembut maybe I'm just too used to my own "lone hacker" style where I don't have to support anyone but myself XP
05:17tomojI'm not too interested in protocols wrapping a bunch of java libraries
05:18tomojI want one very fast pure-clojure reducer-based impl, and a compatible CUDA impl, and that's it
05:18tomojwith as few new protocols as possible
05:18arrdemif this thing runs on CUDA, my hat is off to you
05:20tomojmy bottleneck is matrix multiplication so I think it should be pretty easy to satisfy myself initially
05:20tomojwhether you can really do a full reducer-based matrix library with compatible Clojure/CUDA impls.. no clue
05:24arrdemI
05:24ejacksontomoj that would be impressive
05:24arrdem'll be interested to see if you can pull it off.. is that something you think could be extended to generic arithmetic operaitons, or only primitive type arithmetic?
05:24tomojimpressive as in "oh, that's cool" or as in "no way, that's impossible!"
05:25tomojhmm
05:25tomojgeneric arithmetic == a multimethod?
05:25tomojnot going to put a multimethod in the inner matrix loop :)
05:26arrdemlol I wouldn't ask you to
05:26tomojbut if you had really flexible reducers and your arithmetic can be defined on a product of primitives (like complex arithmetic) then that seems like a really interesting idea
05:27arrdemthis last weekend I was playing with doing a Protocol based CAS by defing protocols for + & -, another for * and a third for /
05:27tomojinstead of reduce-kv (fn [ret k v]) it'd be like reduce-complex (fn [ret real imag]) ?
05:27arrdemnot sure.
05:28tomojcan only go up to the quaternions with primitives :)
05:29ejacksontomoj: i don't see why it shouldn't be possible!
05:29arrdem0430 arrdem can't track quaternions
05:29arrdemwill add to reading stack
05:30ciphergoth_I want to write a unit test for my cookie code: I got to url X, and that sets a cookie, and so when I go to Y, I'm allowed because I have a cookie. Is there something that will help me do that?
05:30tomojoh, no, actually, you only get max 3 primitive args after the monoid
05:31tomojwell if you're doing crazy inlining it doesn't matter anyway I suppose
07:38ToBeReplacedanyone use OData from clojure?
07:41clgvs/ToBeReplaced/NowReplaced/
07:42clgvoh that's a Microsoft format^^
07:43clgvToBeReplaced: do you use ClojureCLR? then you could just use one of micrsofts libs (they have one, right?)
07:45ToBeReplacedi don't; it looks like i could use odata4j though
07:47clgvToBeReplaced: is this for work or a hobby project?
07:48ToBeReplacedwork
07:48ToBeReplacedonly consuming OData, not producing
07:50clgvok, from the google code page it is not easy to tell how active this project is maintained
07:50ToBeReplacedseems like the best java option... odata.org lists is as the java implementation with no alternatives
07:51clgvah ok. so you have no choice but to try it^^
07:52ToBeReplacedyep :)
08:30ciphergothHmm, is there something already existing that takes a request and a local URL, and returns an absolute URL suitable for handing to ring.util.response/redirect?
08:32weavejesterciphergoth: The java.net.URL constructor does a little like what you want.
08:33ciphergothbah. Think that HTTP should have allowed relative URLs in Location headers
08:34ciphergoth all popular browsers will accept a relative URL[citation needed], and it is correct according to the upcoming revision of HTTP/1.1[citation needed].
08:34ciphergothhmmmmmm
08:35skoodgeambrosebs: is there a type for sets in core.typed?
08:35ambrosebsskoodge: IPersistentSet
08:35ambrosebseg. (IPersistentSet Number)
08:35skoodgeah, ok, thanks
08:36ambrosebsskoodge: np. To be clearer, I mean clojure.lang.IPersistentSet.
08:38skoodgeambrosebs: yep, seems obvious in retrospect, as strings are java.lang.String. Didn't make the connection that I could user other "java" types, too. oh well...
08:40ambrosebsskoodge: I don't think I've documented it anywhere, so don't beat yourself up. My fault.
08:43skoodgeambrosebs: when I'm using a map in a homogeneous way, I guess (IPersistentMap a b) is the correct type, right?
08:43ambrosebsskoodge: correct
08:43skoodgegreat, thanks
08:47TimMchyPiRion: PONG
08:50hyPiRionTimMc: https://github.com/hyPiRion/hello-swearjure
08:51hyPiRionThat a program printing "Hello, World!" in Swearjure with only meta and ns-map (the project.clj) is also swearjurized
08:52TimMcThat is truly a work of great beauty.
08:52hyPiRionindeed
08:52TimMcThe project.clj is a wonderful touch.
08:54TimMcI look forward to the writeup... and the compiler.
08:55hyPiRionyeah, it's not all that complex really
08:55hyPiRionI just have to remember what I did, I think.
08:55TimMcYou got ahold of eval through ns-map?
08:55Bronsaww-woah
08:56hyPiRionTimMc: yeah
08:58TimMcThis all depends on arbitrary map ordering, then?
08:58hyPiRionhahah, yeah. That's why it's only working on Leiningen 2.1.x
08:58lsoawhat does ^ mean in clojure?
08:58TimMcI'm not surprised it doesn't work as a jar.
08:59TimMclsoa: It's a way to attach metadata to a compile-time form.
08:59lsoa(let [^Server s (create-server (dissoc options...
08:59TimMclsoa: It's used to attach doc strings, add type hints, make vars private...
08:59lsoaso this says s is of type Server
08:59TimMcSort of.
08:59hyPiRionSo the bootstrap part is essentially (defn -- [-] (meta -)), (defn *+ [*] (ns-map *)), then right after I define ++, which is essentially (defn ++ [+] (get-in (*+ (:ns (-- #'+))) [+ 1]))
09:00skoodgeis it possible to rename java libraries loaded using import?
09:00lsoaan instance of class Server?
09:00TimMclsoa: I mean yes, that's what it says, but the only impact is on interop forms.
09:00lsoaI see, thanks :)
09:01TimMcSo if you call (.foo s), Clojure knows that's Server.foo
09:01TimMcand doesn't have to emit code to do reflection
09:01lsoaahh interesting
09:01TimMclsoa: There's no actual type-checking.
09:02TimMc&(let [^String x (apply + (range 5))] (* 2 x))
09:02lazybot⇒ 20
09:02TimMc&(let [^String x (apply + (range 5))] (.toString x))
09:02lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
09:02TimMc&(let [x (apply + (range 5))] (.toString x))
09:02lazybot⇒ "10"
09:03TimMcskoodge: Not using the ns form, but you can do it by hand right after it.
09:03skoodgehow? By defining my own bindings using (def new-name old-name)?
09:04TimMcskoodge: https://github.com/baznex/imports/blob/v1.4.0/src/org/baznex/imports.clj#L59
09:06TimMc,(.importClass *ns* 'M java.lang.Math)
09:06clojurebotjava.lang.Math
09:06TimMc,(M/abs -5)
09:06clojurebot5
09:06TimMcskoodge: ^
09:07skoodgeTimMc: wow, nice snippet. Thanks a lot
09:07TimMcMind you, this is slightly skeevy.
09:08TimMcTheoretically, clojure.lang.Namespace/importClass could be renamed at any time.
09:15hyPiRion,(importClass *ns* 'm java.lang.Math)
09:15clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: importClass in this context, compiling:(NO_SOURCE_PATH:0:0)>
09:15hyPiRion,(.importClass *ns* 'm java.lang.Math)
09:15clojurebotjava.lang.Math
09:15hyPiRionohhhhh
09:17TimMc,(.importClass *ns* '& java.lang.Math)
09:17clojurebotjava.lang.Math
09:17TimMc,(&/abs -5)
09:17clojurebot5
09:18hyPiRionwoop
09:18hyPiRion,(.importClass *ns* 'nil java.lang.Math)
09:18clojurebot#<NullPointerException java.lang.NullPointerException>
09:18hyPiRionoh well, worth a shot
09:18hyPiRion,(.importClass *ns* 'true java.lang.Math)
09:18clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol>
09:19hyPiRion,(.importClass *ns* 'let java.lang.Math)
09:19clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class>
09:19TimMc,(.importClass *ns* (symbol "true") java.lang.Math)
09:19clojurebotjava.lang.Math
09:19hyPiRionI think I'll stop there for today
09:19hyPiRionoh
09:19supersym:)
09:19TimMc,(true/abs -5)
09:19clojurebot5
09:19hyPiRion,(true? true)
09:19clojurebottrue
09:20hyPiRion,(.importClass *ns* (symbol "let") java.lang.Math)
09:20clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class>
09:20hyPiRionboo
09:21TimMc...interesting.
09:22rkneufeldhyPiRion: not sure if this is relevant to you at all, but here, have some math: https://github.com/alandipert/mathemagician
09:22TimMchyPiRion: That doesn't look right.
09:23TimMcrkneufeld: That looks like a subset of what org.baznex/imports does (or is planned to do).
09:24hyPiRion,(symbol "let")
09:24clojurebotlet
09:24hyPiRion,(-> "let" symbol symbol?)
09:24clojurebottrue
09:25hyPiRionWe live in a strange world.
09:26ambrosebsskoodge: This should be useful https://github.com/clojuredocs/cds/blob/master/articles/ecosystem/core_typed/types.md
09:29skoodgeambrosebs: ah, great. Do you already have common type aliases defined somewhere? Not only things like Option, but also for example an alias Set to avoid always writing IPersistentSet
09:30ambrosebsNo, that would probably be a good idea for portability.
09:34dnolenambrosebs: did you see this new feature in typescript, not sure if it's relevant for typed racket or typed clojure but it's interesting - http://blogs.msdn.com/b/typescript/archive/2013/03/25/working-on-typescript-0-9-generics-overload-on-constants-and-compiler-performance.aspx
09:34dnolenambrosebs: constants can refine the return type
09:37ambrosebsdnolen: that's cool. We can do it in TR and TC with function intersections. (Fn [(Value :a) -> String] [(Value "a") -> Number])
09:37dnolenambrosebs: ah cool!
09:37ambrosebsdnolen: I had no idea Typescript didn't have generics :/
09:40ambrosebsdnolen: so do some JS libraries have interesting/complicated types? continuations and such?
09:41dnolenambrosebs: hmm, maybe
09:54bosiei tried to get lein midje running but it fails on me
09:54bosiehttps://www.refheap.com/paste/13002
09:54bosieeven without any facts i get this error
10:04TimMcamalloy: Welp. It turns out that defrecords have a static "create" method taking a map. So that works.
10:05TimMcA little reflection and there it is.
10:05yunfan_homehi i met 403 forbidden error when i try to using lein
10:05yunfan_homeits the latest version of lein 2.2
10:06TimMcyunfan_home: I'm not sure that's been released yet.
10:06TimMcYou probably downloaded the wrong script.
10:06yunfan_homesince it download from amazon aws, i doubt if their bandwith limits exceed
10:06yunfan_homeTimMc: i use the scrip fromo the github repo
10:08TimMcyunfan_home: You downloaded it from the master branch?
10:08TimMcUse this instead: https://raw.github.com/technomancy/leiningen/stable/bin/lein
10:08hyPiRionyunfan_home: What TimMc said, 2.2.0 is not out yet :)
10:09yunfan_homehyPiRion: i tried change the script's version number to 2.1 also got 403 forbidden
10:09yunfan_homei just heard that the 2.1 script has added a launch parameter which let the boot time faster
10:09yunfan_homeso want to try that
10:10TimMcyunfan_home: Delete the script you have, use the one I linked to.
10:10bosieis lein-midje 3.0.0 currently broken?
10:10bosiei followed the setup/installation and it throws an error
10:10yunfan_homeTimMc: ok will try
10:11yunfan_homeTimMc: aha, it works
10:11bosiemy project.clj: https://www.refheap.com/paste/13003
10:11yunfan_homeTimMc: i am trying clojure on my arm chromebook :]
10:13klangAm I using clojure in a strange setting, when I have it running on a remote host with an OS different from the computer I'm running Emacs (and nrepl) on?
10:14TimMcbosie: It looks weird that you have midje in both deps and plugins.
10:14TimMcwell... I guess that sort of makes sense
10:14bosieTimMc: lein-midje in plugins and midje in deps
10:15bosieTimMc: removing midje from deps yields the same exception
10:15AnderkentWhy are unbound variables logically true? Boggles the mind -.-
10:15nDuffAnderkent: because absolutely everything that isn't nil or false is true
10:15TimMcAnderkent: Makes sense to me.
10:15nDuffAnderkent: it's a very simple rule.
10:15yunfan_homei think because they treate 000000000 as false while the rest are true
10:16yunfan_homejust like forth does
10:16TimMcyunfan_home: No.
10:16TimMc&(boolean 0)
10:16lazybot⇒ true
10:17yunfan_homethis is very confuse
10:17yunfan_home&(boolean [])
10:17lazybot⇒ true
10:17nDuffyunfan: Not at all. Neither 0 or [] is the constant nil, or the constant false
10:17gfredericks[] is neither nil nor false
10:18nDuffyunfan: as I said, it's a very simple rule -- easier than having to remember how each different type is handled.
10:18yunfan_homenDuff: by confuse i mean this might confuse people from other programmming lang like me from python
10:18yunfan_homeanyway , the rule is really simple
10:18gfrederickshopefully it only confuses them once
10:18Anderkentwhy aren't unbounds nil then? Or why is nil false? It seems very inconsistent to have nil be false but undefined be truthy
10:18nDuffyunfan: *nod* -- Clojure is more predictable than Python in this respect.
10:19nDuffAnderkent: Because an unbound var is... an unbound var. Which is not the constant nil, or the constant false.
10:19jonas11235bosie: What exception do you get?
10:19gfredericksAnderkent: I don't think it's very typical to deal with vars that might be unbound
10:19AnderkentnDuff: yes I get the mechanics, what I'm asking is the *reason* for them
10:19nDuffAnderkent: Anyhow, in most use cases, dealing with unbound vars throws an exception
10:19nDuffAnderkent: ...and if you want to know if they're bound or not, that's what bound? is for
10:20bosiejonas11235: https://www.refheap.com/paste/13002
10:20Anderkentgfredericks: in which case why not make them nil by default
10:20nDuffHrm.
10:20AnderkentnDuff: except it doesn't if you just do (when my-var :true :false), and it happens to be undefined instead of nil
10:20nDuffI was wrong on the first half of that.
10:20joegallonDuff: are the exceptions (boolean ...) => false or true?
10:20joegallojk jk
10:20gfredericksit might be a useful distinction
10:20yunfan_homei guess an unbound variable is already a symbol?
10:20gfrederickse.g., I think you can default *read-eval* to unbound now?
10:20jonas11235bosie: is there any reason to use clojure 1.3.0? The current stable is 1.5.1
10:21nDuffyunfan: clojure.lang.Var$Unbound
10:21bosiejonas11235: tbh, i just did lein new
10:21nDuffAnderkent: Sure. It's enough of a corner case that I don't think it's worth complicating the language for, though.
10:21gfredericksAnderkent: there doesn't seem to be a strong argument either way -- like I said 99% of the time you're only dealing with bound vars.
10:21bosiejonas11235: changed to 1.5.1
10:21jonas11235bosie: paste your test as well, please
10:21nDuffAnderkent: If you want different behavior, bind your var to nil by default.
10:22AnderkentnDuff: it wouldn't be an issue if it was my var
10:22yunfan_homebosie: they say the boot time of lein2.1 with clojure 1.5.x is really fast
10:22bosiejonas11235: https://www.refheap.com/paste/13004
10:22bosieyunfan_home: i actually still only have lein2 preview
10:22yunfan_homecat wait to try but still waiting for download
10:22bosieyunfan_home: i guess 'lein upgrade' should get me up to date?
10:22Anderkentgfredericks: `declare` is still fairly common, which means you have to consider unbound vars
10:23yunfan_homebosie: well i just download the new script
10:23nDuffAnderkent: ...anyhow, if you're dealing with something where Unbound is a valid value... (if (and (bound? foo) foo) :true :false)
10:23nDuffAnderkent: ...but, well, that _is_ rare.
10:23bosieyunfan_home: trying the upgrade
10:24bosiejonas11235: any ideas?
10:24gfredericksAnderkent: yes but usually declare just resolves circular references between functions, and by the time either function runs both vars are bound
10:24AnderkentnDuff: it's actually (bound? (var foo))
10:24jonas11235bosie: you don't need the [] in the use clause
10:24hyPiRionoh, gfredericks: https://github.com/hyPiRion/hello-swearjure
10:24bosieyunfan_home: now on 2.1.1 and clojure 1.5.1
10:24yunfan_homebosie: how about the speed?
10:24bosieyunfan_home: insane
10:25bosieyunfan_home: jk. dont know
10:25yunfan_homevery fast?
10:25jonas11235bosie: the problem is not in the test but in the distance-matrix-to-position.core. Remove it from the use just as a test.
10:25bosiejonas11235: it actually works now
10:25bosiejonas11235: i didn't change anything on the code but upgrading lein helped
10:25gfrederickshyPiRion: oh boy oh boy oh boy
10:25jonas11235bosie: I only put [] in the use clause when I will use :only in it
10:26jonas11235bosie: nice to know :)
10:26bosieyunfan_home: startup time of 'lein midje' and 'lein test' seems about the same
10:26nDuffAnderkent: That it's not something I use often enough to remember despite writing production code in Clojure on a regular basis supports my point. :)
10:26yunfan_homebosie: i will try that later
10:26bosieyunfan_home: but autotest is blazing fast
10:27gfrederickshyPiRion: that's crazy-go-nuts; so are you convinced swearjure+ns-map+meta is clojure-complete?
10:27hyPiRiongfredericks: Well, I can't uberjar the thing, which is a bit sad
10:28hyPiRionI'm trying to figure out why
10:29hyPiRionExcept for that, it seems pretty clojure-complete
10:29hyPiRionIn a REPL everything is working
10:32supersymsigh... writing this boardgame is a nice challenge, there are too many ways to do stuff in clojure/lisp
10:32yunfan_homesupersym: also there're too many ways to do stuff, at least web framework, in python
10:33supersymoh .. yeah correct
10:33gfrederickshyPiRion: holy crap your project.clj is in swearjure
10:33gfrederickstechnomancy needs to see that
10:33supersymsay... when what would be a reason to have state... I understand the concept, but not in clojure... I'm lost again
10:33hyPiRiongfredericks: yeah, that's the best part :D
10:34supersymis that only when I want to persist data? whats the circumstances exactly
10:34hyPiRionProbably the longest project.clj ever,
10:35supersymand when is something 'side-effect free' then
10:35hyPiRionI stumbled upon a "Caused by: java.lang.ClassFormatError: Invalid method Code length 69270" when making it, so I had to compress the numbers.
10:35hyPiRionEssentially the thing became too large.
10:36gfrederickshyPiRion: haha. I tried writing an algorithm for the smallest rep for an int on an airplane, but got sidetracked by not having a number theory library
10:36gfredericksso I did `lein new numth` and then quit
10:36gfrederickssupersym: memoize uses state, to pull a random example out of a hat
10:37gfredericksI think most cookie middleware for ring does as well
10:37supersymthanks
10:37hyPiRiongfredericks: hah
10:38hyPiRionYeah, my algorithm isn't perfect, but it's good enough
10:38pellis_i'm trying to compare how much string splitting cost in clojure compared to other languages (including bare java)
10:38hyPiRionI'm essentially prime factorizing, and if the number is a prime, I check out if I can represent the number efficiently as (- (inc n) (*)) or (+ (dec n) (*))
10:39pellis_and i'm getting strange results.. probably due to the fact that I can't generate something that does a "for" loop efficiently enough
10:39gfrederickshyPiRion: yeah I was going to go for a branch-and-bound variant of that
10:39pellis_how can I do 1 million iterations of a piece of code without the iteration block affecting the run?
10:40gfrederickspellis_: clojure.string/split just uses the regex function, so it should be the same as java
10:41pellis_gfredericks, i'm getting 5 times slowness than Java though - is this all because of the for-loop i'm using (actually a 'loop' construct)
10:41gfrederickspellis_: why are you using a loop at all? are you using clojure.string/split?
10:41hyPiRiongfredericks: ah, nice. I'll need to clean up stuff and write up on how hello-swearjure works
10:41gfrederickshyPiRion: I still don't know if I should expect it to be tractable or not
10:42hyPiRiongfredericks: hahah
10:42pellis_gfredericks, i will try to paste it
10:42supersymaha.. now I get memoize, the tradeoff... sweetness
10:42hyPiRiongfredericks: I'll make sure to make it as evident as possible. The blog post, that is.
10:42pellis_http://pastie.org/7138264
10:43gfrederickshyPiRion: I'm curious if there are good huristics for really big numbers (thousands of digits)
10:43gfredericksI guess at worse you can just do something based on its binary rep
10:43nDuffpellis_: Any particular reason you're building your own for-loop macro rather than using a doseq range?
10:43gfredericksthat's a good upper bound for the branch-and-bound alg actually
10:44hyPiRiongfredericks: hmm, yeah
10:44nDuffpellis_: anyhow, discarding that question -- do you get anything if you compile with *warn-on-reflection* true?
10:44pellis_nDuff, i tried to be as close to the original java code as possible..?
10:45nDuffHuh. Actually, in that specific test, it shouldn't have to reflect to figure out that s is a string.
10:45hyPiRionI want to do something like what William Byrd did with miniKanren (code generation) and pick the smallest representation after a certain amount of tests
10:45hyPiRionrunsÆ
10:45hyPiRion*
10:45pellis_nDuff, no warnings
10:46nDuff*shrug*. Would want to decompile and look at the bytecode.
10:47pellis_nDuff, its an ugly code.. but i figured it will be the same so its just a throw-away thing so I didn't really invest much aesthetics into it.
10:47gfrederickspellis_: nDuff: might it be the boxed math and such?
10:47gfredericksI guess it'd be surprising if that was a lot compared to the string work
10:47ambrosebsHow do people normally hack on the CLJS compiler? I usually have a pom or project.clj I can boot vimclojure off, so I'm a bit lost..
10:47pellis_gfredericks, which math?
10:47pellis_inc?
10:47clojurebotoinc is octo-inc: (apply comp (take 8 (repeat inc)))
10:48gfrederickspellis_: the looping -- < and inc and such
10:48gfredericksif you're using primitives in the java version it's probably a bit faster
10:48pellis_in the java version is just a traditional C-style forloop
10:48nDuff*shrug*. AOT and decompile and we wouldn't have to guess.
10:48gfrederickshyPiRion: I get "No namespace: + found" when running `lein <X>`
10:48nDuffs/decompile/disassemble/
10:49pellis_i'm getting 600ms in Java, 2200ms in Clojure right now
10:49pellis_same thing in node.js: 70ms :)
10:49gfrederickspellis_: btw the time macro will do the timing logic for you
10:49pellis_and ruby 2900ms.
10:51hyPiRiongfredericks: what
10:52hyPiRionlein 2.1.1?
10:52pellis_i'll try warming up the JVM first
10:52hyPiRionWell, I'm running on 1.6.0_27 OpenJDK
10:53gfrederickshyPiRion: yep that fixes it
10:53hyPiRionwoop woop
10:54pellis_no change. so how would you run a piece of code X number of times repeatedly?
10:54pellis_where X is a very large number
10:54gfredericks(dotimes [n 1000] (foo))
10:54gfredericks,(let [a (atom 0)] (dotimes [_ 1000] (swap! a inc)) @a)
10:54clojurebot1000
10:55gfredericks,(time (dotimes [_ 100000] (clojure.string/split "foo and bar" #" ")))
10:55clojurebot"Elapsed time: 132.878713 msecs"\n
10:58pellis_gfredericks, i'll try that one, thanks
10:58gfrederickswhat on earth is LazilyPersistentVector about?
11:06Chousukegfredericks: IIRC it's an optimisation for small vector literals
11:06Chousukegfredericks: it's just an immutable array until you conj into it.
11:09gfredericksChousuke: ah ha
11:14ToBeReplacedhow do you clean out deftests in clojure-test-mode.el?
11:14ToBeReplacedeach time i recompile i just add new tests
11:16mpenetis there a particular reason why *.cljs file do not load clojure-mode ? (I know clojurescript-mode has been removed, I am trying to understand if it's intentional it doesn't do that now).
11:16mpenetnrepl breakage or something?
11:18tyleris there a function that will no-op when something is called on it?
11:18ToBeReplacednvm i must have done something wonky before with namespaces... i ns-unmapped then tried to recreate the problem and couldn't
11:18tyleror constantly return nil
11:18mpenettyler: (constantly nil)
11:18pl6306How do I make a typed array in clojure? For example String[]?
11:19gfredericks&(doc make-array)
11:19lazybot⇒ "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class obje... https://www.refheap.com/paste/13007
11:19tylermpenet: thanks
11:19gfredericks&(make-array String 12)
11:19lazybot⇒ #<String[] [Ljava.lang.String;@ee8a8a>
11:19gfredericksmpenet: I think clojurescript-mode is a separate package now?
11:20mpenetI think it has been deprecated
11:20nDuffmpenet: In current emacs live, it _does_ do that: packs/live/clojure-pack/config/clojure-conf.el:(setq auto-mode-alist (append '(("\\.cljs$" . clojure-mode))
11:20mpenetI could be wrong
11:20mpenetnDuff: yeah I know how to activate it. I was just wondering why
11:21mpenetit seems the regex could be tweaked a bit
11:22pl6306Why doesn't this work (make-array String "LOADED")
11:23nDuffpl6306: because "LOADED" is a sequence of characters, not a sequence of strings
11:24tylerwoah...
11:24tyler,(tree-seq seq? #(str "foo" %) '((1 7) 2 3))
11:24clojurebot(((1 7) 2 3) \f \o \o \( ...)
11:24tylerit elides it doh
11:24nDuffpl6306: Do you want an equivalent to (into-array "LOADED") or (into-array ["LOADED"])?
11:25pl6306The second.
11:25pl6306Thanks
11:36nzeePhotos, talks from Clojure/West event collated here. http://eventifier.co/event/ClojureWest
11:38jcromartieare talks posted yet?
11:38jcromartieoh yeah
11:43nzeePhotos, talks from Clojure/West event collated here. http://eventifier.co/event/ClojureWest
12:10dsopis there anykijnd of "standard" what people use for exception handling? just regular java exceptions with try/catch or some handler base things?
12:10winkhyPiRion: oh wow, hello-swearjure is damn impressive
12:10S11001001dsop: slingshot
12:10technomancyslingshot for catching, ex-info for throwing
12:12dsopS11001001: thx
12:14S11001001dsop: keep in mind that throwing is a side effect, and side effects and laziness don't mix
12:14dsopS11001001: yes sure, i wont throw withing lazy seqs or anything like that
12:15hyPiRionwink: Thanks! I'm not sure if the fact that I managed to pull it off shows is a good thing or not though.
12:15hyPiRionI mean, it's very revolutionary and stuff, but damn how amazing I am at procrastination.
12:16hyPiRion/s/shows//
12:19winkhyPiRion: :)
12:19arrdemhyPiRion: your swearjure hello world. wat.
12:20hyPiRionarrdem: Oh, just wiat
12:20hyPiRion*wait
12:21arrdemI mean I think I understand what you're doing here... but how did you come up with this abomination?
12:21sleetdropSystem Memory: Free: 3.45 GB; Used: 4.55 GB; Total: 8.00 GB; — [❙❙❙❙❙❙❙|❙❙❙❙❙]
12:21hyPiRionarrdem: http://clojure-log.n01se.net/date/2011-04-06.html#19:04 <-
12:22hyPiRionAnd yeah, it's not complicated once you grasp what I do the first.. uh, 34 lines or so
12:23technomancyonce you take enough spice and can grasp the ebb and flow of spacetime through the planes of causality it's pretty straightforward.
12:23hiredmanalso redbull
12:23technomancyyou know, like monads.
12:23arrdemsleep deprivation, stress and coffee is my prefference.
12:23arrdembut redbull can cause all three
12:24arrdemhyPiRion: I suppose something like this was inevitable given the number of language geeks in here... well done can't wait for more rediculus as this is
12:25hyPiRionarrdem: Well, I want to check out if it's possible to create a webserver written in Swearjure.
12:25arrdem.........
12:25hyPiRionI'm not entirely sure if that's doable though, so I have to figure that one out
12:25arrdemI promise you it is.
12:25arrdemthe question is do you want to write it.
12:26arrdemactually I need to understand how you access symbols first. I take that back.
12:26technomancyhyPiRion: so you think you can drop back to 1.0.0 and do it with only a single alpha token?
12:27technomancyif someone can do it without ns-map that's how you know they truly are the kwisatz haderach
12:27hyPiRiontechnomancy: Yeah, I think I can do it with ns-map only. Though I need to make my own leiningen version for that to make the project map working
12:29technomancyswearjure project.clj is going beyond the call of duty =)
12:29arrdemooh yeah
12:29arrdemhyPiRion: if you can cook up an anonymus recursive nth this is totally viable with just ns-map
12:30arrdemyour project.clj then just needs to create all the refers you need
12:30technomancyif only you could quote % somehow to let you nest #()
12:30hyPiRionarrdem: recursive nth? Why would I need that?
12:31hyPiRionI can just do (`[~@(param-here)] (number-here)) do simulate nth
12:31arrdemExcuse me while I try to wrap my lesser brain around that one.
12:31hyPiRiontechnomancy: yeah, not having nested function literals is horribly :(
12:31hyPiRionarrdem: It's actually not that complicated.
12:32arrdemwait... [] is IFn?
12:32hyPiRion,(let [alist (list 1 2 3 4)] [`[~@alist] (`[~@alist] 2)))
12:32clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
12:32hyPiRionyes
12:32hyPiRion,(let [alist (list 1 2 3 4)] [`[~@alist] (`[~@alist] 2))
12:32clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
12:32arrdemokat that's dead obvious then.
12:32arrdem,([ 1 2 3 4 ] 2)
12:32clojurebot3
12:32hyPiRionoh bleh, I've lost control of the parentheses now.
12:33arrdemyeow that's cute
12:43dnolenejackson: have you seen this http://research.microsoft.com/en-us/projects/fun/?
12:44nzeePhotos, talks from Clojure/West event collated here. http://eventifier.co/event/ClojureWest
12:44nDuffnzee: You've been repasting that for a while this morning.
12:44nDuffnzee: ...also, am I just missing something, or is there only a single talk's slides there?
12:44gfredericksnDuff: there's a github repo with a lot of slides
12:45nDuff...then someone trying to promote a web site with a much smaller set seems awfully spammy to me.
12:46nzeeI thought it will be relevant to you folks. sorry
12:48patbrownI've recently started looking into edn and the extensible reader. Is this a proper use case? Sharing the same edn data between client cljs and server clj, so that each platform can call their own respective internal math functions without extra plumbing?
12:49patbrownAnd can someone point me to an example of extending the reader in clojurescript? Clojurescript Up and Running eludes to it, but doesn't provide an example.
12:59ToBeReplacedsaw ex-info came up earlier... is there a best-practice established for the map?
13:00supersym,'not a literal'
13:00clojurebotnot
13:00supersym,'(not a literal)
13:00clojurebot(not a literal)
13:01azkanehey guys, is there a built in function that takes a list and a pred, and returns the first true element?
13:01gtraksome
13:01gtrak~(doc some)
13:01clojurebotdefmulti doc is (defmulti #^{:doc "docs for foo"} foo class)
13:02gtrak&(doc some)
13:02lazybot⇒ "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
13:02azkanenice, thanks!
13:02hyPiRionazkane: if you explicitly want "true", you can do (first (filter fn seq)), otherwise, some will do a similar job
13:02supersymhmmm quote is different in repl that instarepl
13:02gtrakazkane: implies your predicate ought to return the value
13:02supersymmake sense I guess
13:02supersym*than
13:03hyPiRion,(some (constantly :hey) [:what :is :this])
13:03clojurebot:hey
13:04hyPiRion,(first (filter (comp true? {:a true, :b :foo}) [:b :c :a]))
13:04clojurebot:a
13:04azkanecomp looks neat
13:04gtrakhyPiRion: just use boolean
13:05hyPiRionnot the same thing
13:05hyPiRion,(first (filter (comp boolean {:a true, :b :foo}) [:c :b :a]))
13:05clojurebot:b
13:06supersym<3 clojurebot
13:06gtrakI meant (boolean (some ...
13:06gtrakif you explicitly want true or false
13:06hyPiRionoh, right
13:07hyPiRionyeah, it really depends on what you want here
13:10borkdudeapparently another clojure book has made it: http://www.amazon.com/gp/product/B00BECVV9C/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B00BECVV9C&amp;linkCode=as2&amp;tag=httpwwwericro-20
13:24skoodgeambrosebs: do I have to annotate vars in their own namespace? I tried to use (ann ns/some-var some-type), but it did not seem to work
13:25tieTYThttp://www.techempower.com/blog/2013/03/26/everything-about-java-8/
13:25ambrosebsskoodge: it should work with qualified symbols. Perhaps aliases don't work?
13:26ambrosebsskoodge: the core annotations have (ann clojure.core/+ ...)
13:28skoodgeambrosebs: ok, I will try it with the fully qualified name then
13:28skoodgeis there any way to remove a type annotation that is currently active?
13:28ambrosebsskoodge: no.
13:28skoodgeI have already annotated the var in the other namespace and now would like to remove that annotation
13:28ambrosebsskoodge: restart your repl :/
13:28skoodgeso restarting the process it is?
13:28skoodgek
13:32pl6306What happens when clojure calls a private method on a class? Does it work and if not is there an idiomatic way of doing it via reflection to set it to be accessible first?
13:33hyPiRionpl6306: It won't work by default, but you can do reflection through clojure.reflection I think
13:33shriphanihi everyone. How do you guys deal with large blocks on text on the repl? On the shell I can pipe to less but I was wondering if there existed something convenient like that for the clojure repl.
13:33hyPiRionOr, if you know how to do reflection in Java, you can just use that
13:34pl6306I know how to do it java just wondering what it the default
13:35hyPiRiondefault is no private access
13:35hyPiRion(nor protected)
13:40noidipl6306, see the source of http://clojuredocs.org/clojure_contrib/clojure.contrib.java-utils/wall-hack-method
13:42dimovichhello all, how do I catch Ctrl+C from clojure?
13:43clgvdimovich: afaik repl-y does that
13:45dimovichclgv: I mean, from the terminal... not from repl
13:45dimovichI wanna save some stuff on program exit...
13:45dimovichmaybe there is some other way...
13:46clgvdimovich: yes. repl-y is repl front end which is a program and it catches Ctrl+C
13:47hyPiRiondimovich: look at the source of REPLy to look how it does that
13:47dimovichaha, ok... got it. Thx
13:50clgvdimovich: reply.signals is what you are looking for. usage example for interrupt in reply.eval-modes.nrepl
13:51mpenetpackt has a couple of clojure "cookbooks" planned it seems
13:51dimovichclgv: thx
13:52jonasendnolen: is walk-term really supposed to work like this or am I missing something? https://gist.github.com/jonase/5251620
13:53pl6306How does keyword parameters to function work? Say I want to allow for a function call but I don't want for an order of the parameter.
13:53joegallo(defn foo [{:as opts}])
13:53joegalloopts will be a map, and you can grab things out of it as you'd like
13:54joegalloyou call it like this
13:54joegallo(foo :bar baz :quux eggs :ham meat)
13:54hyPiRionjoegallo: you forgot the &
13:54joegalloheh, oops!
13:54pl6306Thanks! Just what I was looking for
13:54joegallo(defn foo [& {:as opts}] ...) ;; <-- note the & that i missed
13:55joegallothanks, hyPiRion
13:55hyPiRion,(let [f (fn [& {:as opts}] ((juxt :foo :bar) opts))] (f :hello 10 :bar 42 :foo :quux))
13:55clojurebot[:quux 42]
13:55hyPiRionnp
13:56dnolenjonasen: huh probably not
13:57jonasenis it supposed to do prewalk, postwalk or both?
14:01thm_proverin SWT, can the .getText method be caleld outside of the SWT thread, or does it also have to be called within the SWT thread?
14:03grebusanyone know of good mocking libraries for clojurescript?
14:03jonasendnolen: also, why is llist a macro? Is that necessary?
14:06dnolenjonasen: llist is old, probably for performance - we could provide a function variant as well. I never personally use llist explicitly tho.
14:10jonasendnolen: ok. I think the unifier/prep implementatin could be simplified if walk-term worked "as expected". (Maybe I should say as I expected :)
14:11jonasenI guess you don't use clojure.walk since it's not extensible.
14:20dnolenjonasen: and I think slower. ticket and patch / w tests welcome for walk-term. We use it a few places so this may or may not require other chagnes.
14:21jonasendnolen: I'll take a look at it then :). what about my earlier question: pre/post/both? It seems to do (mostly) both now
14:22jonasenor should I split it like clojure.walk does, i.e. (walk-term inner outer form)
14:22dnolenjonasen: note - I don't really care if it works like clojure.walk at all. And certainly any change that slows down it's specific use in core.logic is no go.
14:24jonasendnolen: ok
14:28pl6306If I wanted to change the default reflection behavior of clojure to make a method accessible first before invoking it. Is there a simple macro to do that?
14:29nDuffpl6306: I'm not sure I follow the question.
14:30nDuffCould you provide an example?
14:31dnolenjonasen: took a quick look, I believe the issue is how collections implement walk-term
14:33pl6306I want to do the equivalent in clojure but more generic an idiomatic. Method getSetMethod = obj.class.getDeclaredMethod("getSet"); getSetMethod.setAccessible(true);
14:34pl6306I figure a macro would be a good place to put the logic. However my skills in clojure isn't quite there yet
14:38nDuffpl6306: Could you back up a little? What's the larger picture?
14:38nDuffOh. Got it now.
14:39pl6306I want to write something that can allow me to invoke a private methond on a class
14:39pl6306instance
14:39nDuffYup; took me a moment to grok that.
14:42mpenetpl6306: you could use wallhack for that, or flatland/usefull I think
14:42petrrrrhey, i got a question what would be the easiest way to combine windows + clojure + lighttable?
14:42tieTYTdoes anyone here use one of the major ides to develop their clojure code? I'm not very happy with Intellij's La Clojure. Do the other ones work better?
14:43nDuffHmm, not finding it. If there's code in flatland, though, that'd be better than something I wrote ages ago and haven't maintained, anyhow.
14:44pl6306Thanks looks like wallhack is what I am gunning for
14:44mpenetpl6306: https://github.com/flatland/useful/blob/develop/src/flatland/useful/java.clj#L23
14:44nDufftieTYT: http://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/
14:44tieTYTthanks
14:44nDufftieTYT: Note that Emacs still owns the bulk of the marketshare, by a mile
14:44hyPiRiontieTYT: Well, most of Clojure programmers use Emacs. With autocomplete and paredit, I find it more efficient than e.g. Eclipse
14:44nDufftieTYT: ...and, to inject my own opinion, there are very, very good reasons for that.
14:45mpenet+1 on emacs, but I hear CCW is nice too
14:45nDuffmpenet: I'll take it seriously when its paredit supports slurp and barf, and not a moment before.
14:46mpenetnDuff: ah I thought it was a done thing already
14:46tieTYThyPiRion: does the autocomplete work on the java code?
14:46nDuffmpenet: I understand there's been rework that should make that easier, but I hadn't heard that it was done.
14:48hyPiRiontieTYT: the autocomplete isn't like Eclipse's autocomplete, no. It usually takes names from other (open) clojure files, which for my case is more than good enough
14:48nDuffwell, it also can take names from an active nREPL session
14:48mpenetit takes autocomplete from imports too
14:48nDuffwhich is where the real power is
14:49nDufftieTYT: Are you trying to find a single tool that's best-of-breed for both Java and Clojure?
14:49nDufftieTYT: My experience is that no such thing exists. IDEA for Java, Emacs for Clojure, and never the twain shall meet.
14:50tieTYTno just best for clojure
14:50nDufftieTYT: ...then why were you asking about autocomplete for Java code? Did you mean for Java _objects_?
14:50tieTYTyes
14:50tieTYTi meant interop code
14:50hyPiRionnDuff: as in (.toString "...")
14:51hyPiRionetc
14:53tieTYTyeah
14:53mpenetyes it works for method calls too.
14:54mpenetyou want nrepl + autocomplete + ac-nrepl for that
14:55tieTYTi think i'm going to try counter clockwise first
14:55tieTYTbecause learning emacs is its own project
14:55nDufftieTYT: ...if you use Emacs Live, it has all those things you need built in.
14:55tieTYTLive? Is that a plugin?
14:56nDufftieTYT: See https://github.com/overtone/emacs-live (or the video at http://vimeo.com/22798433)
14:57nDufftieTYT: anyhow, in my experience, CCW's paredit mode is a pain to use, whereas emacs' paredit is a thing of beauty and truth. YMMV -- the CCW one works fine for plenty of people -- but if you end up not using paredit at all because of it, that's a shame (and your productivity will be the worse for it).
14:57nDuff~paredit
14:57clojurebotparedit is not for everyone, but what you need to understand ís how to become the kind of person that paredit ís for.
14:59jcromartieparedit is the blue pill
14:59jcromartieI mean red pill
14:59tieTYTwhat's paredit?
14:59tieTYThttp://emacswiki.org/emacs/ParEdit ?
15:00jcromartietieTYT: that's it
15:02tieTYTah now that I know what this is
15:02tieTYTLa Clojure does this
15:02tieTYTwhat's wrong with CCW's?
15:03jcromartieI would trust the JetBrains implementation
15:03nDufftieTYT: Doesn't support slurp and barf -- or at least didn't a few months ago when I last looked at it again.
15:04nDufftieTYT: ...if you want to, say, move the next block into a do, the way I'd do that in emacs is to type "(do", followed by ctrl+right-arrow.
15:04nDufftieTYT: and that fixes indentation and everything.
15:05tieTYThm
15:05tieTYTok
15:05jcromartieparedit-mode takes the "code is data" idea and applies it to an editor context, so you can rearrange the structure of your code in whole logical instead of characters or arbitrary regions of text
15:06jcromartie"whole logical chunks"
15:08nDuff*nod*.
15:08tieTYT"SQL, Lisp, and Haskell are the only programming languages that I've seen where one spends more time thinking than typing."- Philip Greenspun
15:16tieTYTlast night I needed a function that did (and (.contains s x) (.contains s y) ...) I wrote this as a reduce. Is there a better way?
15:19pl6306What is clojure equivalent of int.class in java?
15:19nDuffpl6306: Integer/TYPE
15:20pl6306Thanks!
15:22tieTYTweird, i was just reading that article
15:34grebushm
15:37Glenjaminlate to the party, but i'm getting along fairly well with a poor man's paredit in sublime text
15:37Glenjaminit only has strict parens and a command to expand selection to current expression, but combining those with c&p seems quite usable
15:40tieTYTah yes, counterclockwise is way better than la clojure
15:41amalloyGlenjamin: you can survive by eating raw meat and sleeping in trees, but civilization is so much nicer; similarly with c/p and paredit
15:41Glenjamini'd love to grok emacs, but couldn't stomach learning clojure and emacs at the same time
15:42tieTYTGlenjamin: same boat as me
15:43Glenjaminso much muscle memory from other editors to unlearn :(
15:43grebus(instance? js/Object (js/Date.)) =>
15:43grebustrue, but (isa? (type (js/Date.)) js/Object) => false
15:43grebussorry about the double enter there
15:44MikeSethdoes anyone know if leiningen :repl-port item is something that existed in previous lein versions but was deprecated in favour :repl-options?
15:44MikeSeths/favour/favour of/
15:44hyPiRionMikeSeth: Well, it certainly is deprecated now at least
15:44hyPiRionIf not completely removed
15:44MikeSethhyPiRion: but it *was* there, correct?
15:45hyPiRionMikeSeth: yep
15:45MikeSethI am playing with sublimerepl and it tries to read that key, but that's no longer in use, so I'll have to fix the plugin for it to work
15:45hyPiRionhttps://github.com/technomancy/leiningen/blob/1.5.1/sample.project.clj#L101 <-
15:46MikeSeththought so
15:48MikeSethsublime2 is awesome btw
15:48MikeSethif not for the occasional hang that one of the plugins here seems to cause in repl
15:56patchworkHmm… looking for a fn like `some` that actually returns the found value
15:56patchworkAm I just missing it?
15:56patchworkscouring the docs...
15:56amalloy(comp first filter)
15:56Glenjaminis that lazy?
15:57patchworkamalloy: That looks good, but more like (comp first (partial filter predicate?)) yeah?
15:57amalloyno?
15:57clojurebotno is tufflax: there was a question somewhere in there, the answer
15:57amalloy(comp first filter) accepts exactly the same args that some does
15:58hyPiRion,((comp first filter) odd? (range 10)) ;; <<- patchwork
15:58clojurebot1
15:58patchworkAha, yeah! so do I avoid searching the whole list? I was about to make a loop that just breaks on the first found item
15:58Glenjamin(no, it's not lazy)
15:58patchworkAh
15:58patchworkYeah the whole point is to avoid searching the whole list for it
15:58amalloyGlenjamin: that is a nonsense claim
15:59mpenet,(doc filter)
15:59clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects."
15:59patchworkI don't see any reason why it wouldn't be lazy?
15:59Glenjaminah
15:59Glenjamini made pred have side effects
15:59Glenjaminto see if it was lazy
15:59Glenjamin>.<
15:59patchworkCool, thanks amalloy!
15:59Bronsa`well, it's lazy on chunks of 32 elements
15:59hyPiRionWell, if you take the first element, then you have to realize some of them, ait.
16:00amalloyBronsa`: or chunks of 1 element, or chunks of whatever size chunked-seq someone makes
16:00Glenjamineg. ((comp first filter) (fn [a] (prn 1) (= a 2)) [1 2 3 4]) prints 4 1s
16:00amalloyGlenjamin: try it with (list 1 2 3 4)
16:00Bronsa`amalloy: sure, right
16:00Glenjaminoh cool
16:00Glenjaminhad no idea about chunking
16:02patchworkAnyone know of anything like checkmarx for clojure? http://www.checkmarx.com/ Client is being demanding that their checkmarx doesn't work on our codebase
16:02patchwork(ppppppphh)
16:03amalloypatchwork: i use (constantly true): so far, it has always correctly identified that my software has at least one bug
16:03patchworkamalloy: I'll let them know!
16:04Glenjaminmy approach to security has always been to pay a 3rd party to "audit", and then show the client the certificate.
16:04Glenjaminymmv
16:04nDuffpatchwork: it's not security-focused, but there's kibit.
16:04nDuffpatchwork: that said, Glenjamin's approach sounds solid to me.
16:06RaynesMy approach to security has always been to let xeqi break it and then fix it.
16:06amalloywell, you're rock-solid on part 1, Raynes
16:06RaynesHeh, I've fixed most of the things he found. :p
16:06Rayneshttp://nelsonmorris.net/2012/09/06/breaking-lazybot-out-of-clojail.html
16:07technomancyif [ `rgrep read-string src | wc -l` != 0 ]; then echo booooogs; fi
16:07nDuff...
16:07nDufftechnomancy: with my #bash hat on, I'm very disappointed.
16:07ivaraasentrying to refactor array-utils ATM. macros are hard, damnit
16:07tieTYTlast night I needed a function that did (and (.contains s x) (.contains s y) ...) I wrote this as a reduce. Is there a better way?
16:08RaynesI don't follow.
16:08Bronsa`every?
16:08technomancynDuff: I make no claims at being good at bash; I only use it when I'm not allowed to use eshell
16:08RaynesDidn't you just write the function just now?
16:08nDufftechnomancy: rgrep -q read-string src && echo boooogs
16:08tieTYTcan't tell if anyone's replying to me or not
16:08RaynesI am..
16:09Bronsa`tieTYT(every #(.contains s %) [x y ..])
16:09RaynesAnd so is Bronsa`.
16:09tieTYTok i'm asking if there's a more idiomatic way I guess
16:09RaynesOh, you wanted to do the contains or arbitrary numbers of things?
16:09tieTYTevery isn't in the cheatsheet
16:09tieTYTRaynes: yes
16:09Bronsa`every?
16:09Bronsa`derp
16:09tieTYTah
16:10RaynesThen I think Bronsa` wins.
16:10Bronsa`sorry.
16:10tieTYTcool i knew there was a better way
16:10tieTYTmy way seemed so freaking verbose
16:11tieTYTwell not compared to java
16:20RaynesAnd the 13000th paste award goes to… https://www.refheap.com/paste/13000 … nobody because they didn't bloody well sign in.
16:21RaynesGuys, if you're not using conkeror there is a button in the top right for signing in. It's really easy and you only have to do it once per browser restart and it's one or two clicks to sign in after the initial sign up.
16:21gfredericks,(* 2 2 2 5 5 5 13)
16:21clojurebot13000
16:21hyPiRiongfredericks: oh, me too
16:22gfrederickshyPiRion: I have no idea what that means but I assume it's awesome.
16:22hyPiRiongfredericks: sec
16:22jcromartiegah, I'm making a mess of things, somebody help!
16:22RaynesStay calm and stop making a mess of things.
16:22gfredericksadd more parens
16:23Raynes(inc Raynes)
16:23lazybotYou can't adjust your own karma.
16:23RaynesDENIED.
16:23patchwork(inc Raynes)
16:23lazybot⇒ 25
16:23jcromartie)))))))))
16:23Raynes$karma gfredericks
16:23gfredericks(inc lazybot)
16:23lazybot⇒ 16
16:23lazybotgfredericks has karma 16.
16:23RaynesI always knew I was better than you.
16:23gfredericksyou're so square
16:23jcromartieshouldn't it be (dosync (alter Rayntes inc))
16:23RaynesI'm very circular.
16:23jcromartieor just swap!
16:23jcromartiebut really
16:23jcromartieso
16:24jcromartiethe eternal question: how to organize an application
16:24RaynesIf there aren't any circular dependencies you're probably not doing too bad.
16:24jcromartieI find myself reverting to the "class" design
16:24jcromartieI got that much
16:25jcromartiebut like, a namespace for each "type" in the data model
16:25gfredericksRaynes: you're a square and I'm a hypercube
16:25jcromartiewhere the data model is configuration of a news aggregation system
16:25RaynesI'm a companion cube.
16:26gfrederickshalf of my conversations degenerate into me making boring observations about natural numbers
16:26jcromartieand I'm just running around in circles making refs on hash maps with repository abstractions over certain keys in the map
16:26hyPiRion,(* (#(*%%%)(+(*)(*))) (#(*%%%)(#(+(*)%%)(+(*)(*)))) (#(+(*)(*%%(`[~@%&](+))))(+(*)(*))(+(*)(*)(*))))
16:26clojurebot13000
16:26jcromartieand it seems silly
16:26hyPiRionthere
16:27hyPiRionWow, that's actually quite compact.
16:27jcromartieHEY GUYZ HOW DO MAKE THE PERFECT ARCHIRTECTURE
16:27gfrederickshyPiRion: hah nice
16:27gfredericksjcromartie: queues probably
16:28jcromartielike, I'm trying to discover the one hidden secret design that will solve software design problems forever
16:28jcromartiebut let's be totally practical here
16:28gfredericksdata? protocols?
16:28gfredericksmonads?
16:28clojurebotmonads are "yea, though I should walk in the valley of imperative code, I shall fear no evil, for your monad comforts me" - seen in #haskell
16:28jcromartiedata is great
16:28hyPiRionjcromartie: Oh, you're making the sufficiently smart compiler.
16:28jcromartieand my data is really simple
16:29jcromartiebut let me be concrete here
16:30gfredericks,'(*%%%)
16:30clojurebot(* % % %)
16:30gfrederickshyPiRion: ^^ that's crazy weird
16:30gfrederickswell maybe just regular weird
16:31ystaelgfredericks: isn't all of computation essentially boring remarks about natural numbers?
16:31hyPiRiongfredericks: yeah, just as weird as ##(#([`{~% ~@%&}](+)) :a 1 :b 2)
16:31lazybot⇒ {:a 1, :b 2}
16:31gfredericksystael: I knew there had to be some way to justify my existence
16:31hyPiRionThere was another one too, but I can't remember which exactly.
16:31gfrederickshyPiRion: it hadn't occurred to me to use functions to reduce repetition in numeric literals
16:32jcromartieI have a few parts to the configuration: feed sources, content extraction rules, tag extraction rules, tag expansion rules, geographic points, some auxillary simple config parameters
16:32jcromartieso I can see this as one structure
16:32hyPiRiongfredericks: I've been thinking about it, but I'm not sure how to make a emitter for such functionality yet
16:32hyPiRionI did the previous one by hand, for instance
16:33jcromartieand the HTML interface is literally the only thing that will use the API to change this configuration
16:34jcromartieJSON/XHR, all that jazz
16:34hyPiRionBut like, the search space shouldn't be that large. Branch-and-bound or genetical algorithms sounds viable for this task.
16:35hyPiRionActually, genetical algos are probably overkill.
16:36jcromartieI can make a function that creates Compojure routes from a ref on the state, a key to store the objects in, a function to parse the HTTP parameters into a proper form, a function to sanitize items for output to JSON, and a function to validate a parsed item
16:36jcromartiethat seems reasonable right
16:37jcromartielike (make-json-api state-ref :feeds parse-feed render-feed validate-feed)
16:38jcromartiewhere is a non-trivial Clojure web app source code when you need one
16:40SegFaultAXjcromartie: Refheap and 4clojure are open source.
16:40jcromartieah yeah
16:40gfrederickshyPiRion: search space is big if you want to check all possible sums for a big number
16:41gfredericksso the question is how to avoid that search
16:41hyPiRiongfredericks: memoization of smaller numbers and branch-and-bound?
16:41gfrederickssounds intractible with a naive B&B
16:42gfredericksthere are a lot of possible sums of 10^1000; not sure memoization will help there
16:44hyPiRiongfredericks: well, if you use prime factorization as a precomputer upper bound, wouldn't that limit it somewhat?
16:44hyPiRion*precomputed
16:44gfredericksnot if you still have to do some minimal thing for all passible partitions, like check against the bound
16:45gfrederickshttp://en.wikipedia.org/wiki/Partition_(number_theory)
16:45gfredericksyou wouldn't have to check all partitions presumably, but just checking all 2-partitions would be intractable
16:46hyPiRionAh, I see.
16:46gfredericksnot to mention if you're targeting big-big numbers then factoring is barely an option anyhow
16:47avishaihi
16:47gfrederickshi
16:47avishaii'm using every?
16:47hyPiRionIf you reorder the numbers based on size and pick the lowest found for e.g. 10000 or so? Sounds like a good heuristic.
16:48avishaiand i'm wondering why it evaluates every element of the sequence even if one returns false
16:48hyPiRionavishai: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/
16:49gfredericksavishai: you mean realizing a lazy seq beyond what's necessary, or actually calling your predicate more than necessary?
16:49jcromartie,(every? println [1 2 3])
16:49clojurebot1\nfalse
16:50jcromartieavishai: I think it's something else that causes your seq to be realized
16:51jcromartie,(every? println (repeatedly #(println "generate")))
16:51clojurebotgenerate\nnil\nfalse
16:51avishaihmm
16:53MikeSethi updated sublimerepl doc with some hints on setting up a clojure repl
16:53tieTYThyPiRion: jeez, that seems scary
16:53tieTYTseems super unpredictable
16:54MikeSethin case anyone wants to take a look before wuub merges it
16:54tieTYTi mean it's literally predictable, but it seems hard to reason about if your functions aren't pure
16:54hyPiRiontieTYT: Well, it's not intended for impure functions
16:54hyPiRion,(every? odd? (map #(do (print \.) %) (range 64)))
16:54clojurebot................................false
16:55hyPiRion,(every? #(< % 32) (map #(do (print \.) %) (range 64)))
16:55clojurebot................................................................false
16:55tieTYTin what way is it not intended for that?
16:55tieTYTclojure makes it easy to write impure functions
16:56jcromartieyou shouldn't rely on laziness at a small scale, or even on the realization of a lazy sequence at all
16:56tieTYT*in clojure
16:56jcromartiei.e. if realizing your sequence too early is a problem, then maybe it's not a good fit for a sequence?
16:56jcromartieyea
16:57tieTYTjust seems slightly limiting to me
16:57tieTYTor does lazy-seq work exactly the way I want?
16:58acagle /flush
16:58hyPiRiontieTYT: Well, I am limiting because it decreases complexity. However, when I want to e.g. read 10 numbers from the terminal, I do use (doall (repeatedly 10 read))
16:59tieTYTbbl
16:59hyPiRionthe doall realizes the whole sequence.
16:59enquorayogthos: wrt to clj-pdf, I assume you wanted an html/css style set of layout directives and wrapped iText with those?
16:59yogthosenquora: it's not really html/css based
17:00enquoraperhaps block-based would be a better description
17:00yogthosenquora: yeah
17:00yogthosenquora: basically you make a tree of elements parent style will propagate to children unless they override it, etc
17:01enquoraIn fact, ConTeXt, the Dutch improvement on LaTeX, takes the same approach to layout description, or at least offers it as an alternative
17:01yogthosenquora: it tries to use sane defaults for stuff, and you can specify custom parameters as maps for each element as needed
17:01enquorayou needed tabular layouts?
17:02enquoraI'm getting my head around the semantics I need
17:03pl6306What is the difference between (repeatedly 7 (println "x")) and (repeatedly 7 #(println "x"))
17:03amalloypl6306: the second one works
17:03enquoraam going to rewind the clock and take a look at cl-pdf's layout semantics, as well as some work done by Joe Armstrong called erlguten
17:04pl6306Why?
17:04clojurebotwhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
17:04pl6306Also the function literal will it capture the vars defined in a let form?
17:04SegFaultAXpl6306: Read the doc, it explains exactly what repeatedly does.
17:04Bronsapl6306: #(println "x") returns (fn [] (println "x")) while (println "x") prints x and returns nil
17:05Bronsarepeatedly being a function, takes a function to be repeated, not a form
17:05pl6306if I define a function literal in a body of the let will it be able to form a closure around what is defined in let?
17:07Bronsa,(let [x 1] (#(identity x)))
17:07clojurebot1
17:08amalloyBronsa: ((let [x 1] #(identity x))) is IMO more convincing
17:09Bronsaamalloy: probabily, right
17:18pl6306Does repeatedly behave differently in REPL versus code? It being lazy does it mean it doesn't run in side defn body?
17:18pl6306What is the best practice of doing n side effects?
17:18pl6306(take nscens (repeatedly nscens #(println "repeat"))) overkill?
17:20TimMcpl6306: take is lazy as well
17:20pl6306That explains why it doesn't work. How can I just make a function body repeat
17:21pl6306Can't be that hard?
17:21TimMcYou just want side-effects, and not the return values?
17:21pl6306Yes
17:21Bronsa(dotimes [_ times] (println "foo"))
17:21TimMcdoseq might be useful
17:22pl6306Just what I needed
17:22tyleris it idem'potent or idempo'tent i hear most people say idem'potent but omnipo'tent is used in that word
17:28pl6306Is nested let form inside defn a bad idea?
17:28amalloytyler: http://www.merriam-webster.com/dictionary/idempotent, why ask us?
17:28SegFaultAXpl6306: Not necessarily.
17:29SegFaultAXpl6306: But it might be easier to condense them if it's possible.
17:29tyleramalloy: i do not belong to the cult of m-w.com
17:29tylerheh
17:32Raynes$dict idempotent
17:32lazybotRaynes: adjective: (computing) Describing an action which, when performed multiple times, has no further effect on its subject after the first time it is performed.
17:33SegFaultAXI pronounce it as a single word. Like if you google "define idempotent" and listen to the sound clip.
17:33RaynesToo bad you can't play sound in IRC. I'd hook it up to a pronunciation website.
17:33SegFaultAXMost people pronounce it like "idem...potent"
17:33SegFaultAXWhich sounds weird to me.
17:36matthavenerRaynes: there's always CTCP SOUND :)
17:36Rayneslol
17:44avishaihi
17:44avishaiagain...
17:44avishaiwhy is it that functional solutions to euler problems seems to have longer processing time then procedural solutions?
17:45avishaiam i doing it wrong?
17:45avishaior is this inherent?
17:55hyPiRionavishai: Well, that depends on the problem. pre-200 has many algorithm/data structure problems, in which there is a lot of knowledge about efficient procedural solutions
17:55hyPiRionafter 200, the solutions tend to be easier with either logic programming and/or functional programming
17:56hyPiRionThough a procedural program should in about the same order of magnitude
17:56hyPiRionshould run*
18:00avishai10x
18:01hyPiRionhm
18:03hyPiRionWell, minimal network (107) is just a minimal spanning tree, which both Kruskal and Prim's are like fairly well known, for instance.
18:05hyPiRion101 is just polynomial interpolation
18:06hyPiRionIt's kind of like, they are computer scientist stuff which have been optimized at the point in time where computational power was scarce.
18:14supersym`/q
18:41weavejesterDoes anyone happen to know why mapcat might evaluate a lazy seq?
18:41weavejesterI'm guessing it's not mapcat directly
18:42weavejesterBut the seq it's operating on isn't chunked, according to chunked-seq?
18:43weavejesterOh, but it is evaluating it 32 times, so that implies it is chunked somehow.
18:49weavejesterOhh, so (chunked-seq? x) is false, but (chunked-seq? (seq x)) is true
18:50weavejesterSo there must be a way of unchunkifying a seq somehow...
18:53hyPiRionweavejester: fogus had a solution for 1.1, not sure it still applies though
18:53amalloyweavejester: yes, many easy ways
18:54amalloywhich, now that i've said that, i can't remember at all. maybe (map first (take-while seq (iterate next coll)))?
18:54weavejesterHum...
18:54weavejester(type x) => clojure.lang.LazySeq
18:54weavejester(chunked-seq? x) => false
18:54weavejester(chunked-seq? (seq x)) => true
18:55amalloyweavejester: any sub-section of a seq can be chunked anyway
18:55amalloyinterrogating just the head can't tell you all you need to know
18:55weavejesterI wouldn't have expected the seq function to chunkify a lazy seq.
18:55amalloyweavejester: it didn't; that's the wrong way to think about it
18:56amalloyconsider (lazy-seq (generate-chunked-seq))
18:56amalloyobviously that is not chunked, and is a lazy-seq; equally obviously, when you seq it, you get back something chunked
18:56weavejesterOh, I see.
18:57weavejesterseq needs to realize the head, and it might be a chunked seq inside, so to speak.
18:57amalloyanother unchunking option: ((fn unchunk [coll] (lazy-seq (when (seq coll) (cons (first coll) (unchunk (rest coll)))))) coll)
18:58weavejesterIt seems odd this isn't in the core language, considering that lazy seqs are often used in I/O.
18:58RaynesOpen a Jira ticket and you might get your wish in a few years.
18:58weavejesterHeck, Clojure has clojure.core/line-seq
18:59weavejesterRaynes: That's not a huge incentive :)
18:59RaynesHence why I never make feature requests.
19:00amalloyweavejester: what does line-seq matter? it's not chunked
19:00weavejesteramalloy: I mean it's a lazy I/O seq
19:00amalloyso? it's not a chunked seq, so i don't see how it's related to putting unchunk in core
19:00amalloy(not that i think it would be a bad idea to do so)
19:01weavejesterWell, if clojure.core has I/O functions that return lazy seqs, that means it gives implicit approval to use lazy seqs with I/O.
19:02hiredmanobviously should be using reducers
19:02weavejesterReducers aren't lazy as far as I know? Or was that tongue-in-cheek?
19:05hiredmanreducers return a reducible collection without doing the work until the collection is reduced
19:06hiredmanhttps://gist.github.com/hiredman/4075459
19:06chessguy'evening ya'all
19:07hiredmanand reducers can manage resource life time without consumers needing to use with-open
19:09weavejesterhiredman: Ah right, yep. I think in my case unchunking the seq would be the better choice, however.
19:14weavejesterHmmmm… I've unchunked the seq, I think, and it's no longer loading 32 values, but it is loading 4. Why 4?
19:17amalloyinsufficient information to solve problem
19:18weavejesterThis works:
19:18weavejester(first (map #(do (prn %) %) (unchunk (seq [[1 2] [3 4] [5 6]]))))
19:18weavejesterBut this doesn't:
19:18weavejester(first (mapcat #(do (prn %) %) (unchunk (seq [[1 2] [3 4] [5 6]]))))
19:19weavejesterOr rather the first example just evaluates the head, but the second evaluates more.
19:19weavejester(first (mapcat #(do (prn %) %) (unchunk (seq [[1] [2] [3] [4] [5]]))))
19:20weavejesterCuriously mapcat evaluates the first 4 elements
19:20weavejestermap only evaluates the first 1
19:21SegFaultAXweavejester: Isn't part of the contract of mapcat that your mapping function returns a seq?
19:22weavejesterSegFaultAX: Yes… But I don't get what you're implying.
19:23amalloyweavejester: welllllll, [1] is itself a chunked seq, and the (apply concat ...) in mapcat may be trying to keep it chunked for you
19:23weavejesterOhhh! I bet it has to do with the definition of concat
19:23weavejesterBecause concat has: ([] [x] [x y] [x y & zs]) as it's arglists
19:24weavejesterSo from it's arglists alone, it needs to read three to know which to dispatch on
19:24SegFaultAXweavejester: Good call.
19:24amalloythat sounds right
19:24weavejesterAnd then the last is probably due to a (seq …), I guess.
19:25SegFaultAXweavejester: Out of curiosity, what are you working on?
19:26weavejesterBasically I have a log of data stored in groups of about 1000 in S3 objects.
19:26weavejesterSo I have a function like: (mapcat read-objects (list-keys bucket))
19:28weavejesterUnder normal circumstances, the result of (list-keys …) is chunked, so it reads 32 in. This means 32 calls to S3, and loading 32000 objects into memory just to get one value.
19:28weavejesterSo I unchunk list-keys like:
19:28weavejester(mapcat read-objects (unchunk (list-keys bucket)))
19:28weavejesterBut I'm still reading 4 objects instead of just the 1 when I try to get the first element of the sequence.
19:29weavejesterAnd I think that's because of the way concat is written: it must realize a minimum of 4 elements.
19:30weavejesterSo in short, I need to write my own stupid mapcat function :)
19:30hiredmanfor
19:30amalloyweavejester: have you tried using 'for? it might have different characteristics
19:31weavejesteramalloy: Can 'for concatenate?
19:31amalloyof course
19:31weavejesterI should have known :)
19:31brehautweavejester: mapcat is bind in the list monad; for is list monad comprehension notation
19:31amalloy&(mapcat identity [[1 2] [3 4]])
19:31lazybot⇒ (1 2 3 4)
19:31amalloy&(for [xs [[1 2] [3 4]], x xs] x)
19:31lazybot⇒ (1 2 3 4)
19:32weavejesterOh, duh, yes of course
19:32weavejesterI'll blame my current slowness on having had little sleep and having gotten up… 17 hours ago :)
19:32amalloybrehaut: i give you permission to pretend his "Oh, duh, yes of course" was in response to you; it's the only time you'll ever get that response from that statement
19:32brehauthaha
19:32brehautthanks
19:33weavejesterbrehaut: By list monad comprehension notation, do you mean do notation? It's been a while since I've done Haskell.
19:34brehautweavejester: yes
19:35brehautweavejester: although to confuse things haskell also has list comprehension notation that is specific to the list monad (and doesnt look like do/for)
19:36weavejester(first (for [xs (seq [[1] [2] [3] [4] [5]]), x xs] (do (prn x) x)))
19:36weavejesterAnd that works, without even needing an unchunk
19:37amalloyanother lovely reason to do all sequence processing with 'for
19:38hiredmanfor really is the best
19:40weavejesterI forget how to do the inc thing
19:40weavejesterinc amalloy
19:40amalloy(inc for)
19:40lazybot⇒ 1
19:40weavejester(inc amalloy)
19:40lazybot⇒ 44
19:40weavejesterExcellent
19:40hiredmanI have this thing I wrote that is sort of like https://github.com/Prismatic/plumbing, but it does the graph list comprehension style
19:41hiredmanso if you have {:x .. :y ..} and y depends on x, y is run on each element of x
19:43geraldocl newbie here. im trying my 1st project with clojure, swing eclipse windowbuilder for designing forms clojure for processing. when I was mixing clojure and java in the same package I could use just one project on eclipse
19:44geraldonow i followed the lein's wiki advice to separate the sources with java-source-paths. when I generate the project i cant use window builder
19:45geraldois it ok to mix java and clojre on the same package since cl will call java and not the oposite ? Or I need to create a separated project to edit java code ?
19:46stainI would normally say no, split it - but you are building GUI in Eclipse which would be interacting with the Clojure code..?
19:47stainI guess you should still try to split it.. it might force you to do a clearer model-view-controller split - but that is probably better in the long run
19:47geraldono
19:48geraldoeclipse is just to design and generate forms
19:48geraldothat ll be consumed by clojure
19:53tieTYTis it ok/possible to call some clojure in my java program to process data for me?
19:53tieTYTlots of examples of how clojure can call java code, but not the other way around
19:53tieTYTlet me google
19:54stainif you compile the clojure code (which lein will happily do), you will get lots of java classes, one per function I think
19:55stainjust the .class files.. but that should be enough. You can also implement a traditional java interface in Clojure
19:55tieTYTstain: http://stackoverflow.com/questions/2181774/calling-clojure-from-java
19:57staintieTYT: mm, the trouble is the typing of the parameters, so you need to do a bit of declarations
19:57brehautclojurebot:from java<reply>http://skillsmatter.com/podcast/scala/impromptu-rich-hickey-lightning-talk
19:57clojurebotNo entiendo
19:57brehautbah
19:57brehautclojurebot:from java is <reply>http://skillsmatter.com/podcast/scala/impromptu-rich-hickey-lightning-talk
19:57clojurebotRoger.
19:57tieTYTstain: i don't mind
19:57brehaut~from java
19:57clojurebothttp://skillsmatter.com/podcast/scala/impromptu-rich-hickey-lightning-talk
19:58tieTYTheh he looks like a dj
19:59brehauttieTYT, stain: alex ott's answer on that stack overflow is probably more likely to be what you need (its roughly what rhickey presents in that talk), rather than forcing gen-class upon yourself
20:00tieTYTand I just get the str from a legit clj file?
21:41ivanhas anyone implemented meta/with-meta in Python, perhaps with WeakKeyDictionary?
21:42ivanoh wait how would that even work, everything is mutable and unhashable
21:44ivanheh TypeError: cannot create weak reference to 'tuple' object
22:13n_b,(doc ..)
22:13clojurebot"([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get \"os.name\")) expands to: (. (. System (getProperties)) (get \"os.name\")) but is easier to write, read, and understand."
22:19bytechunkythe source of 'eval' basically is (defn eval [form] (. clojure.lang.Compiler (eval form))). Why is this not endless recursion?
22:19gfredericksyou can't spell "transparency" without "paren"
22:20gfredericksbytechunky: the . form is special
22:20gfredericksbytechunky: it's equivalent to (.eval clojure.lang.Compiler form)
22:20bytechunkygfredericks: oh and i always thought that would be (. clojure.lang.Compiler eval form)
22:21gfredericksthat might be possible too
22:21gfredericksclojure isn't necessarily the most idiomatic clojure code
22:21bytechunky*needs to think about that*
22:21bytechunky:D
22:22gfredericksfor two reasons
22:22Sgeohelp I think something's wrong with me
22:23SgeoI'm starting to not hate Java so much
22:23gfredericksSgeo: more parens
22:23SgeoOr, well, no
22:23SgeoStockholm syndrome
22:23gfredericksSgeo: have you been right-clicking to refactor things?
22:24SgeoJust to make properties out of fields
22:24SgeoI keep forgetting that this isn't C# where the field name can't share the property name
22:24SgeoBecause properties aren't "real" in Java
22:24hyPiRionSgeo: Java is okay for algorithm stuff. Not so much anything else.
22:24hyPiRionWell, at least from my point of view.
22:25gfredericksbytechunky: A) idiomacy evolves over time; B) some of clojure.core is defined prior to more advanced features
22:25gfredericksI expect this case is A
22:25ivaraasenhyPiRion: I dunno, man. Swing is pretty sweet if you're into BDSM.
22:26hyPiRionBDSM and mental disorders.
22:27hyPiRionI got to accept that it's pretty good at that
22:30corecodehi
22:30hyPiRioncorecode: hey there
22:30corecodei'm having trouble with nrepl; am i right here or is #emacs better?
22:31hyPiRionIt's better to be here, yeah
22:35jack_rabbitre there any plans to implement CL-style restarts in clojure? Those were one of my favorite features of CL.
22:35jack_rabbitAre*
22:39corecodefor some reason, (nrepl-send-string-sync "(eval '(clojure.repl/doc case))" (nrepl-current-ns)) doesn't return :stdout
22:40corecodebut if i don't include the namespace, it works.
22:42gfredericks,(count (flatten (nth (iterate #(vec (repeat 10 %)) [:x]) 5)))
22:42clojurebot100000
22:46gfredericksit takes 70 times longer to count ^that sort of structure than a flat (repeat 100000 :x)
22:47hyPiRionit's even faster to just return 100000.
23:10gfrederickshyPiRion: you're just thinking inside the box
23:11amalloygfredericks: are you sure it takes longer to count, and not just longer to generate lazily while iterating to count?
23:13amalloyi guess i don't understand the claim, because obviously the only difference is in generating the sequence, not in counting it once it's generated
23:56tyleris there a way to set max ram in leiningen?
23:58tylerah in sample prj file