#clojure log - Mar 27 2013

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

0:01 ivan: http://bugs.sun.com/view_bug.do?bug_id=4262078 says to JCP it

0:10 jonasen: dnolen: why is core.logic/llist a macro? (I made it a function and all tests pass)

0:15 Sgeo: People sometimes write a macro when a function would work. Don't know if that's the case here though

0:15 It is the case with whatchamacallit monad library

0:15 lift was made a macro instead of a function

0:26 n_b: Is there a clojure equivalent to rake?

0:43 rbxbx: n_b: I feel like most people use leiningen to those ends.

0:43 n_b: I 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

0:44 antares_: n_b: a custom Leiningen task can do that

0:45 n_b: Ah, 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_

0:45 rbxbx: cheers.

0:45 antares_: n_b: tasks and plugins are covered by https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md

0:53 firesofmay: Is it possible to do bulk require in clojure? like test.* :as t

0:53 and I refer all the ns inside test like t.app, t.core etc?

0:59 anyone?

0:59 clojurebot: Just 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 ..."

1:00 rbxbx: firesofmay what's your question? :require foo :as bar should work, no?

1:00 you can also use :use if you don't want to namespace it

1:01 (though that's typically frowned upon in production code)

1:01 firesofmay: rbxbx yes but I would like to do something like import foo.bar.* :as baz

1:01 rbxbx: for java imports?

1:01 firesofmay: rbxbx and then do bas.app1/fn , bas.app2/fn

1:01 rbxbx no for clojure ns

1:02 rbxbx I have many ns inside a directory and instead of doing require for all can i do :as on the directory itself?

1:02 amalloy: firesofmay: no

1:02 rbxbx: ah okay

1:02 firesofmay: amalloy okay

1:02 rbxbx: ^^^ what that guy said

1:03 well, amalloy. not yourself.

1:03 firesofmay: rbxbx amalloy so no way to do this except require each of them?

1:03 rbxbx: firesofmay I dare say you should ask yourself why that's necessitated.

1:04 firesofmay: rbxbx I am basically writing my tests for iPhone in clojure using calabash.

1:04 amalloy: well, i actually don't think it would be such a bad idea (whereas being able to :use or :import multiple namespaces would be)

1:04 firesofmay: rbxbx and I wanted to separate each view as its own ns

1:05 amalloy I don't want to do :use. wanted the require but was wondering if there is a way around bulk require.

1:06 rbxbx: firesofmay I'm not sure how to help. Sorry.

1:06 firesofmay: rbxbx no problem :)

1:40 hyPiRion: gfredericks, TimMc: Ping.

2:07 tyler: im trying to implement irc nick auto complete in clojure

2:08 anyone have any algorithm ideas?

2:09 arrdem: tyler: a trie is probably your best bet.. maybe a probability weighted trie at that.

2:10 that 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.

2:19 tieTYT2: would it be advantageous to have a repl that auto reloads files?

2:19 i never want to use an out of date one

2:19 or is there a shorthand way of reloading all the current namespaces I've required?

2:20 arrdem: tieTYT2: if you're in emacs there's got to be a way to re-eval files on buffer flush

2:20 if you find one share the snippet 'cause I want it.

2:21 in the more general case not sure. Noir did some magic to reload files at runtime but I don't think your average repl will.

2:21 tieTYT2: i see

2:22 well i use intellij's plugin (atm) not emacs

2:22 but it sounds like you want this feature too

2:22 arrdem: I mean.. if I spent 15 with the manual and google I could build it.. for emacs and nrepl.

2:22 as it is I relaod files when I save them anyway

2:23 tieTYT2: how?

2:23 clojurebot: with style and grace

2:23 tieTYT2: emacs script?

2:24 ivan: C-c C-k runs the command nrepl-load-current-buffer

2:25 arrdem: and C-c C-l is the general lisp-mode eval buffer

2:25 ivan: tools.namespace can reload everything you've required

2:26 arrdem: you can also enter (use 'my-ns :reload-all) to force clojure to read from source again

2:27 I 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.

2:28 tieTYT2: arrdem: well i use lein side by side with it

2:28 which is probably a bad idea

2:28 i think there's a bug in it

2:28 arrdem: it's an approach...

2:28 tieTYT2: in la clojure I mean

2:28 arrdem: mine was tmux with vim and lein for months

2:28 tieTYT2: it's hard to figure out how to start up a repl

2:29 arrdem: what OS are you on? windows, mac or a real Nix?

2:30 tieTYT2: ivan: cool. I'll look into that later

2:30 windows

2:31 arrdem: hum 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.

2:31 tieTYT2: IME learning a new editor can reduce your productivity for weeks

2:32 and since I'm also learning clojure at the same time, I'm not sure i could handle that

2:32 arrdem: hah I learned Vim, Tmux and Clojure at the same time this past summer. My productivity was in the tank for two week straight.

2:32 I absolutely understand not wanting to change environments.

2:33 tieTYT2: there's an eclipse and netbeans plugin i haven't tried yet

2:33 if they're better i may swithc

2:34 ivan: Emacs works fine on Windows

2:34 arrdem: with nrepl?

2:34 ivan: yep

2:34 arrdem: can't say I'm shocked...

2:34 ivan: though 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

2:35 git.cmd is the trainwreck, git.exe is reasonably fast

2:35 arrdem: yuck

2:35 and I thought that Eight Megabytes And Constant Swapping was bad on Linux...

3:02 DaReaper5: i need some help working with an input stream

3:03 i need to: create a zip input stream from an array of input streams

3:04 amalloy: DaReaper5: https://github.com/flatland/io/blob/develop/src/flatland/io/core.clj

3:05 ie, 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))

3:06 DaReaper5: really1?

3:06 that seems to easy

3:06 i need to return the zip to a client (this is a component on a clojure server)

3:06 amalloy: well, you still have to wrap it in a zipinputstream however

3:07 i'm just handling the array part

3:07 DaReaper5: oh i see

3:07 amalloy: but java.util.zip contains a wrapper that turns an inputstream into a zipstream

3:07 so that's like no work

3:07 DaReaper5: i hope

3:07 something like this:

3:08 zipInStream (java.util.zip.ZipInputStream. (io/input-stream allReports))

3:08 ?

3:08 allReports is my array

3:09 shouldnt i need to add each individually

3:09 and specify a name?

3:14 amalloy?

3:14 clojurebot: amalloy is <amalloy> just use juxt, it'll be great

3:14 amalloy: zip input streams are for reading zip files. you want to write a zip file, so you have to do something else entirely

3:15 DaReaper5: ya

3:15 i think i have to read the input stream like a buffer

3:15 for each one

3:15 ew

3:19 can i use io/copy to convert the inputstream to an outputstream

3:19 which i can just call toByteArray on?

3:20 arrdem: you should be able to..

3:21 if you have another object to act as an output buffer

3:27 tomoj: DaReaper5: example https://www.refheap.com/paste/80bad6da903cc2e6542b33d3d

4:23 piranha: is there a threading function in clojure core akin to ->, but which will call fns? Something like (... x #(func1 % arg1) #(func2 arg2 %))

4:23 arrdem: so -> is wacky when it comes to inline fns.

4:24 if you define an inline fn, then you need to parenthesize it in order for -> to invoke it correctly.

4:24 eg. #(println "foo") -> (#(println "foo"))

4:25 however if you have a bound function, say clojure.core/inc, you can just stick that in line and -> will deal with it.

4:25 there is the function comp, which is similar to -> in effects...

4:25 ,(doc comp)

4:25 clojurebot: "([] [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."

4:26 arrdem: ,((comp #(* 3 %) inc dec dec) 3)

4:26 clojurebot: 6

4:34 piranha: arrdem: hm, sure, comp looks like a good choice for that

4:35 arrdem: note what they are intended for tho.. comp returns a function which must be called while -> is intended for un-nesting expressions.

4:36 ,(-> {} (assoc :foo 1) (assoc :bar 2) (assoc :baz 3))

4:36 clojurebot: {:baz 3, :bar 2, :foo 1}

4:37 arrdem: is equivalent to (and macroexpands to) &(assoc (assoc (assoc {} :foo 1) :bar 2) :baz 3)

4:37 ,(assoc (assoc (assoc {} :foo 1) :bar 2) :baz 3)

4:37 clojurebot: {:baz 3, :bar 2, :foo 1}

4:44 piranha: arrdem: yes, well, I understand that

4:44 arrdem: in the end it seems for quick repl sessions ->> and wrapping all others in parens works best for me :)

4:44 i.e. (->> a (#(s/split % #"&")) (map #(s/split % #"=")) (into {}) (#(get % "url")) java.net.URLDecoder/decode)

4:44 tomoj: anyone thinking about reducer fusion?

4:45 piranha: ->> is better than -> because map in other case will require wrapping in fn, which means even more text

4:45 arrdem: tomoj: please elaborate

4:49 piranha: is it possible to somehow install package with lein without creating a project.clj with this package in dependencies?

4:49 like in python I would do 'pip install lxml' and the lxml will be available for use in repl

4:50 arrdem: yeah so in Lein 1.X that was doable

4:50 in Lein 2.X not so much....

4:50 piranha: eh :(

4:50 arrdem: you can add packages to your Lein profile for autoloading..

4:50 which gets you almost the same place

4:51 but 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.

4:52 anyone 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

4:53 wink: still alive? at work for nearly an hour already... silly americans 8)

4:53 kalasjohnny2000: when 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)

4:54 I run clojure 1.5.1, cljsbuild 0.3.0, lein 2.1.1

4:54 it seems to me that it\s a lazy dependency list that has to be realized

4:55 wink: piranha: 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 :)

4:56 kalasjohnny2000: wov, I check #leiningen.

4:56 piranha: wink: 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...

4:57 wink: piranha: yes, but if it's possible it needs to be documented. if not, it might be worth building.

5:02 tomoj: arrdem: ..you did ping him :)

5:04 arrdem: to elaborate, an example: (r/map inc coll) -> (reify CollReduce (coll-reduce [_ f val] (r/reduce (fn [ret v] (f ret (inc v))) coll)))

5:05 basically the idea is just to do some reducer transformations at compile time instead of runtime

5:05 Glenjamin: arrdem, wink if its for having in an arbitrary repl to play with, ~/.lein/profiles.clj seems like the right place

5:05 arrdem: tomoj: damnit who the shit uses non-prefix ping notifications

5:05 * arrdem coughs

5:05 tomoj: (well, I bet he's using erc, dunno his config — mine (the default) highlights on all mentions)

5:07 arrdem: ,(doc ret)

5:07 clojurebot: Huh?

5:08 tomoj: I'm thinking like collections containing primitives and supporting fast loops (matrices?)

5:09 arrdem: hum.. you're into deeper magic than I'm familliar with or can reason about at 4am local

5:09 tomoj: do 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

5:09 ah, OK

5:10 arrdem: so that'll work just fine for fixed dimensionality vector aditions and scalar multiplication

5:10 not sure if it's applicable to multiplication tho

5:12 well if you can inline your transpose? somehow..

5:12 tomoj: transpose is pretty close to free I think

5:12 arrdem: it should be

5:13 tomoj: hmm

5:13 arrdem: because A * B is the matrix M being the dot products of A[i] by col and B[i] by row

5:13 yay I learned something in linalg and remembered it!

5:13 isn't that what core.matrix is doing already tho?

5:15 tomoj: core.matrix is already trying to be a matrix library

5:15 s/trying to be //

5:15 arrdem: oh and this is just a more general reducer structure?

5:15 tomoj: well, yeah, and I'm not sure I like core.matrix :)

5:16 arrdem: seemed.. heavily engineered when I looked at it

5:16 but maybe I'm just too used to my own "lone hacker" style where I don't have to support anyone but myself XP

5:17 tomoj: I'm not too interested in protocols wrapping a bunch of java libraries

5:18 I want one very fast pure-clojure reducer-based impl, and a compatible CUDA impl, and that's it

5:18 with as few new protocols as possible

5:18 arrdem: if this thing runs on CUDA, my hat is off to you

5:20 tomoj: my bottleneck is matrix multiplication so I think it should be pretty easy to satisfy myself initially

5:20 whether you can really do a full reducer-based matrix library with compatible Clojure/CUDA impls.. no clue

5:24 arrdem: I

5:24 ejackson: tomoj that would be impressive

5:24 arrdem: '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?

5:24 tomoj: impressive as in "oh, that's cool" or as in "no way, that's impossible!"

5:25 hmm

5:25 generic arithmetic == a multimethod?

5:25 not going to put a multimethod in the inner matrix loop :)

5:26 arrdem: lol I wouldn't ask you to

5:26 tomoj: but 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

5:27 arrdem: this last weekend I was playing with doing a Protocol based CAS by defing protocols for + & -, another for * and a third for /

5:27 tomoj: instead of reduce-kv (fn [ret k v]) it'd be like reduce-complex (fn [ret real imag]) ?

5:27 arrdem: not sure.

5:28 tomoj: can only go up to the quaternions with primitives :)

5:29 ejackson: tomoj: i don't see why it shouldn't be possible!

5:29 arrdem: 0430 arrdem can't track quaternions

5:29 will add to reading stack

5:30 ciphergoth_: 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?

5:30 tomoj: oh, no, actually, you only get max 3 primitive args after the monoid

5:31 well if you're doing crazy inlining it doesn't matter anyway I suppose

7:38 ToBeReplaced: anyone use OData from clojure?

7:41 clgv: s/ToBeReplaced/NowReplaced/

7:42 oh that's a Microsoft format^^

7:43 ToBeReplaced: do you use ClojureCLR? then you could just use one of micrsofts libs (they have one, right?)

7:45 ToBeReplaced: i don't; it looks like i could use odata4j though

7:47 clgv: ToBeReplaced: is this for work or a hobby project?

7:48 ToBeReplaced: work

7:48 only consuming OData, not producing

7:50 clgv: ok, from the google code page it is not easy to tell how active this project is maintained

7:50 ToBeReplaced: seems like the best java option... odata.org lists is as the java implementation with no alternatives

7:51 clgv: ah ok. so you have no choice but to try it^^

7:52 ToBeReplaced: yep :)

8:30 ciphergoth: Hmm, 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?

8:32 weavejester: ciphergoth: The java.net.URL constructor does a little like what you want.

8:33 ciphergoth: bah. Think that HTTP should have allowed relative URLs in Location headers

8:34 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].

8:34 hmmmmmm

8:35 skoodge: ambrosebs: is there a type for sets in core.typed?

8:35 ambrosebs: skoodge: IPersistentSet

8:35 eg. (IPersistentSet Number)

8:35 skoodge: ah, ok, thanks

8:36 ambrosebs: skoodge: np. To be clearer, I mean clojure.lang.IPersistentSet.

8:38 skoodge: ambrosebs: 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...

8:40 ambrosebs: skoodge: I don't think I've documented it anywhere, so don't beat yourself up. My fault.

8:43 skoodge: ambrosebs: when I'm using a map in a homogeneous way, I guess (IPersistentMap a b) is the correct type, right?

8:43 ambrosebs: skoodge: correct

8:43 skoodge: great, thanks

8:47 TimMc: hyPiRion: PONG

8:50 hyPiRion: TimMc: https://github.com/hyPiRion/hello-swearjure

8:51 That a program printing "Hello, World!" in Swearjure with only meta and ns-map (the project.clj) is also swearjurized

8:52 TimMc: That is truly a work of great beauty.

8:52 hyPiRion: indeed

8:52 TimMc: The project.clj is a wonderful touch.

8:54 I look forward to the writeup... and the compiler.

8:55 hyPiRion: yeah, it's not all that complex really

8:55 I just have to remember what I did, I think.

8:55 TimMc: You got ahold of eval through ns-map?

8:55 Bronsa: ww-woah

8:56 hyPiRion: TimMc: yeah

8:58 TimMc: This all depends on arbitrary map ordering, then?

8:58 hyPiRion: hahah, yeah. That's why it's only working on Leiningen 2.1.x

8:58 lsoa: what does ^ mean in clojure?

8:58 TimMc: I'm not surprised it doesn't work as a jar.

8:59 lsoa: It's a way to attach metadata to a compile-time form.

8:59 lsoa: (let [^Server s (create-server (dissoc options...

8:59 TimMc: lsoa: It's used to attach doc strings, add type hints, make vars private...

8:59 lsoa: so this says s is of type Server

8:59 TimMc: Sort of.

8:59 hyPiRion: So the bootstrap part is essentially (defn -- [-] (meta -)), (defn *+ [*] (ns-map *)), then right after I define ++, which is essentially (defn ++ [+] (get-in (*+ (:ns (-- #'+))) [+ 1]))

9:00 skoodge: is it possible to rename java libraries loaded using import?

9:00 lsoa: an instance of class Server?

9:00 TimMc: lsoa: I mean yes, that's what it says, but the only impact is on interop forms.

9:00 lsoa: I see, thanks :)

9:01 TimMc: So if you call (.foo s), Clojure knows that's Server.foo

9:01 and doesn't have to emit code to do reflection

9:01 lsoa: ahh interesting

9:01 TimMc: lsoa: There's no actual type-checking.

9:02 &(let [^String x (apply + (range 5))] (* 2 x))

9:02 lazybot: ⇒ 20

9:02 TimMc: &(let [^String x (apply + (range 5))] (.toString x))

9:02 lazybot: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String

9:02 TimMc: &(let [x (apply + (range 5))] (.toString x))

9:02 lazybot: ⇒ "10"

9:03 TimMc: skoodge: Not using the ns form, but you can do it by hand right after it.

9:03 skoodge: how? By defining my own bindings using (def new-name old-name)?

9:04 TimMc: skoodge: https://github.com/baznex/imports/blob/v1.4.0/src/org/baznex/imports.clj#L59

9:06 ,(.importClass *ns* 'M java.lang.Math)

9:06 clojurebot: java.lang.Math

9:06 TimMc: ,(M/abs -5)

9:06 clojurebot: 5

9:06 TimMc: skoodge: ^

9:07 skoodge: TimMc: wow, nice snippet. Thanks a lot

9:07 TimMc: Mind you, this is slightly skeevy.

9:08 Theoretically, clojure.lang.Namespace/importClass could be renamed at any time.

9:15 hyPiRion: ,(importClass *ns* 'm java.lang.Math)

9:15 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: importClass in this context, compiling:(NO_SOURCE_PATH:0:0)>

9:15 hyPiRion: ,(.importClass *ns* 'm java.lang.Math)

9:15 clojurebot: java.lang.Math

9:15 hyPiRion: ohhhhh

9:17 TimMc: ,(.importClass *ns* '& java.lang.Math)

9:17 clojurebot: java.lang.Math

9:17 TimMc: ,(&/abs -5)

9:17 clojurebot: 5

9:18 hyPiRion: woop

9:18 ,(.importClass *ns* 'nil java.lang.Math)

9:18 clojurebot: #<NullPointerException java.lang.NullPointerException>

9:18 hyPiRion: oh well, worth a shot

9:18 ,(.importClass *ns* 'true java.lang.Math)

9:18 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol>

9:19 hyPiRion: ,(.importClass *ns* 'let java.lang.Math)

9:19 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class>

9:19 TimMc: ,(.importClass *ns* (symbol "true") java.lang.Math)

9:19 clojurebot: java.lang.Math

9:19 hyPiRion: I think I'll stop there for today

9:19 oh

9:19 supersym: :)

9:19 TimMc: ,(true/abs -5)

9:19 clojurebot: 5

9:19 hyPiRion: ,(true? true)

9:19 clojurebot: true

9:20 hyPiRion: ,(.importClass *ns* (symbol "let") java.lang.Math)

9:20 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class>

9:20 hyPiRion: boo

9:21 TimMc: ...interesting.

9:22 rkneufeld: hyPiRion: not sure if this is relevant to you at all, but here, have some math: https://github.com/alandipert/mathemagician

9:22 TimMc: hyPiRion: That doesn't look right.

9:23 rkneufeld: That looks like a subset of what org.baznex/imports does (or is planned to do).

9:24 hyPiRion: ,(symbol "let")

9:24 clojurebot: let

9:24 hyPiRion: ,(-> "let" symbol symbol?)

9:24 clojurebot: true

9:25 hyPiRion: We live in a strange world.

9:26 ambrosebs: skoodge: This should be useful https://github.com/clojuredocs/cds/blob/master/articles/ecosystem/core_typed/types.md

9:29 skoodge: ambrosebs: 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

9:30 ambrosebs: No, that would probably be a good idea for portability.

9:34 dnolen: ambrosebs: 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

9:34 ambrosebs: constants can refine the return type

9:37 ambrosebs: dnolen: that's cool. We can do it in TR and TC with function intersections. (Fn [(Value :a) -> String] [(Value "a") -> Number])

9:37 dnolen: ambrosebs: ah cool!

9:37 ambrosebs: dnolen: I had no idea Typescript didn't have generics :/

9:40 dnolen: so do some JS libraries have interesting/complicated types? continuations and such?

9:41 dnolen: ambrosebs: hmm, maybe

9:54 bosie: i tried to get lein midje running but it fails on me

9:54 https://www.refheap.com/paste/13002

9:54 even without any facts i get this error

10:04 TimMc: amalloy: Welp. It turns out that defrecords have a static "create" method taking a map. So that works.

10:05 A little reflection and there it is.

10:05 yunfan_home: hi i met 403 forbidden error when i try to using lein

10:05 its the latest version of lein 2.2

10:06 TimMc: yunfan_home: I'm not sure that's been released yet.

10:06 You probably downloaded the wrong script.

10:06 yunfan_home: since it download from amazon aws, i doubt if their bandwith limits exceed

10:06 TimMc: i use the scrip fromo the github repo

10:08 TimMc: yunfan_home: You downloaded it from the master branch?

10:08 Use this instead: https://raw.github.com/technomancy/leiningen/stable/bin/lein

10:08 hyPiRion: yunfan_home: What TimMc said, 2.2.0 is not out yet :)

10:09 yunfan_home: hyPiRion: i tried change the script's version number to 2.1 also got 403 forbidden

10:09 i just heard that the 2.1 script has added a launch parameter which let the boot time faster

10:09 so want to try that

10:10 TimMc: yunfan_home: Delete the script you have, use the one I linked to.

10:10 bosie: is lein-midje 3.0.0 currently broken?

10:10 i followed the setup/installation and it throws an error

10:10 yunfan_home: TimMc: ok will try

10:11 TimMc: aha, it works

10:11 bosie: my project.clj: https://www.refheap.com/paste/13003

10:11 yunfan_home: TimMc: i am trying clojure on my arm chromebook :]

10:13 klang: Am 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:14 TimMc: bosie: It looks weird that you have midje in both deps and plugins.

10:14 well... I guess that sort of makes sense

10:14 bosie: TimMc: lein-midje in plugins and midje in deps

10:15 TimMc: removing midje from deps yields the same exception

10:15 Anderkent: Why are unbound variables logically true? Boggles the mind -.-

10:15 nDuff: Anderkent: because absolutely everything that isn't nil or false is true

10:15 TimMc: Anderkent: Makes sense to me.

10:15 nDuff: Anderkent: it's a very simple rule.

10:15 yunfan_home: i think because they treate 000000000 as false while the rest are true

10:16 just like forth does

10:16 TimMc: yunfan_home: No.

10:16 &(boolean 0)

10:16 lazybot: ⇒ true

10:17 yunfan_home: this is very confuse

10:17 &(boolean [])

10:17 lazybot: ⇒ true

10:17 nDuff: yunfan: Not at all. Neither 0 or [] is the constant nil, or the constant false

10:17 gfredericks: [] is neither nil nor false

10:18 nDuff: yunfan: as I said, it's a very simple rule -- easier than having to remember how each different type is handled.

10:18 yunfan_home: nDuff: by confuse i mean this might confuse people from other programmming lang like me from python

10:18 anyway , the rule is really simple

10:18 gfredericks: hopefully it only confuses them once

10:18 Anderkent: why aren't unbounds nil then? Or why is nil false? It seems very inconsistent to have nil be false but undefined be truthy

10:18 nDuff: yunfan: *nod* -- Clojure is more predictable than Python in this respect.

10:19 Anderkent: Because an unbound var is... an unbound var. Which is not the constant nil, or the constant false.

10:19 jonas11235: bosie: What exception do you get?

10:19 gfredericks: Anderkent: I don't think it's very typical to deal with vars that might be unbound

10:19 Anderkent: nDuff: yes I get the mechanics, what I'm asking is the *reason* for them

10:19 nDuff: Anderkent: Anyhow, in most use cases, dealing with unbound vars throws an exception

10:19 Anderkent: ...and if you want to know if they're bound or not, that's what bound? is for

10:20 bosie: jonas11235: https://www.refheap.com/paste/13002

10:20 Anderkent: gfredericks: in which case why not make them nil by default

10:20 nDuff: Hrm.

10:20 Anderkent: nDuff: except it doesn't if you just do (when my-var :true :false), and it happens to be undefined instead of nil

10:20 nDuff: I was wrong on the first half of that.

10:20 joegallo: nDuff: are the exceptions (boolean ...) => false or true?

10:20 jk jk

10:20 gfredericks: it might be a useful distinction

10:20 yunfan_home: i guess an unbound variable is already a symbol?

10:20 gfredericks: e.g., I think you can default *read-eval* to unbound now?

10:20 jonas11235: bosie: is there any reason to use clojure 1.3.0? The current stable is 1.5.1

10:21 nDuff: yunfan: clojure.lang.Var$Unbound

10:21 bosie: jonas11235: tbh, i just did lein new

10:21 nDuff: Anderkent: Sure. It's enough of a corner case that I don't think it's worth complicating the language for, though.

10:21 gfredericks: Anderkent: 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:21 bosie: jonas11235: changed to 1.5.1

10:21 jonas11235: bosie: paste your test as well, please

10:21 nDuff: Anderkent: If you want different behavior, bind your var to nil by default.

10:22 Anderkent: nDuff: it wouldn't be an issue if it was my var

10:22 yunfan_home: bosie: they say the boot time of lein2.1 with clojure 1.5.x is really fast

10:22 bosie: jonas11235: https://www.refheap.com/paste/13004

10:22 yunfan_home: i actually still only have lein2 preview

10:22 yunfan_home: cat wait to try but still waiting for download

10:22 bosie: yunfan_home: i guess 'lein upgrade' should get me up to date?

10:22 Anderkent: gfredericks: `declare` is still fairly common, which means you have to consider unbound vars

10:23 yunfan_home: bosie: well i just download the new script

10:23 nDuff: Anderkent: ...anyhow, if you're dealing with something where Unbound is a valid value... (if (and (bound? foo) foo) :true :false)

10:23 Anderkent: ...but, well, that _is_ rare.

10:23 bosie: yunfan_home: trying the upgrade

10:24 jonas11235: any ideas?

10:24 gfredericks: Anderkent: yes but usually declare just resolves circular references between functions, and by the time either function runs both vars are bound

10:24 Anderkent: nDuff: it's actually (bound? (var foo))

10:24 jonas11235: bosie: you don't need the [] in the use clause

10:24 hyPiRion: oh, gfredericks: https://github.com/hyPiRion/hello-swearjure

10:24 bosie: yunfan_home: now on 2.1.1 and clojure 1.5.1

10:24 yunfan_home: bosie: how about the speed?

10:24 bosie: yunfan_home: insane

10:25 yunfan_home: jk. dont know

10:25 yunfan_home: very fast?

10:25 jonas11235: bosie: 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:25 bosie: jonas11235: it actually works now

10:25 jonas11235: i didn't change anything on the code but upgrading lein helped

10:25 gfredericks: hyPiRion: oh boy oh boy oh boy

10:25 jonas11235: bosie: I only put [] in the use clause when I will use :only in it

10:26 bosie: nice to know :)

10:26 bosie: yunfan_home: startup time of 'lein midje' and 'lein test' seems about the same

10:26 nDuff: Anderkent: 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:26 yunfan_home: bosie: i will try that later

10:26 bosie: yunfan_home: but autotest is blazing fast

10:27 gfredericks: hyPiRion: that's crazy-go-nuts; so are you convinced swearjure+ns-map+meta is clojure-complete?

10:27 hyPiRion: gfredericks: Well, I can't uberjar the thing, which is a bit sad

10:28 I'm trying to figure out why

10:29 Except for that, it seems pretty clojure-complete

10:29 In a REPL everything is working

10:32 supersym: sigh... writing this boardgame is a nice challenge, there are too many ways to do stuff in clojure/lisp

10:32 yunfan_home: supersym: also there're too many ways to do stuff, at least web framework, in python

10:33 supersym: oh .. yeah correct

10:33 gfredericks: hyPiRion: holy crap your project.clj is in swearjure

10:33 technomancy needs to see that

10:33 supersym: say... when what would be a reason to have state... I understand the concept, but not in clojure... I'm lost again

10:33 hyPiRion: gfredericks: yeah, that's the best part :D

10:34 supersym: is that only when I want to persist data? whats the circumstances exactly

10:34 hyPiRion: Probably the longest project.clj ever,

10:35 supersym: and when is something 'side-effect free' then

10:35 hyPiRion: I stumbled upon a "Caused by: java.lang.ClassFormatError: Invalid method Code length 69270" when making it, so I had to compress the numbers.

10:35 Essentially the thing became too large.

10:36 gfredericks: hyPiRion: 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:36 so I did `lein new numth` and then quit

10:36 supersym: memoize uses state, to pull a random example out of a hat

10:37 I think most cookie middleware for ring does as well

10:37 supersym: thanks

10:37 hyPiRion: gfredericks: hah

10:38 Yeah, my algorithm isn't perfect, but it's good enough

10:38 pellis_: i'm trying to compare how much string splitting cost in clojure compared to other languages (including bare java)

10:38 hyPiRion: I'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:39 pellis_: 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:39 gfredericks: hyPiRion: yeah I was going to go for a branch-and-bound variant of that

10:39 pellis_: how can I do 1 million iterations of a piece of code without the iteration block affecting the run?

10:40 gfredericks: pellis_: clojure.string/split just uses the regex function, so it should be the same as java

10:41 pellis_: 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:41 gfredericks: pellis_: why are you using a loop at all? are you using clojure.string/split?

10:41 hyPiRion: gfredericks: ah, nice. I'll need to clean up stuff and write up on how hello-swearjure works

10:41 gfredericks: hyPiRion: I still don't know if I should expect it to be tractable or not

10:42 hyPiRion: gfredericks: hahah

10:42 pellis_: gfredericks, i will try to paste it

10:42 supersym: aha.. now I get memoize, the tradeoff... sweetness

10:42 hyPiRion: gfredericks: I'll make sure to make it as evident as possible. The blog post, that is.

10:42 pellis_: http://pastie.org/7138264

10:43 gfredericks: hyPiRion: I'm curious if there are good huristics for really big numbers (thousands of digits)

10:43 I guess at worse you can just do something based on its binary rep

10:43 nDuff: pellis_: Any particular reason you're building your own for-loop macro rather than using a doseq range?

10:43 gfredericks: that's a good upper bound for the branch-and-bound alg actually

10:44 hyPiRion: gfredericks: hmm, yeah

10:44 nDuff: pellis_: anyhow, discarding that question -- do you get anything if you compile with *warn-on-reflection* true?

10:44 pellis_: nDuff, i tried to be as close to the original java code as possible..?

10:45 nDuff: Huh. Actually, in that specific test, it shouldn't have to reflect to figure out that s is a string.

10:45 hyPiRion: I 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:45 runsÆ

10:45 *

10:45 pellis_: nDuff, no warnings

10:46 nDuff: *shrug*. Would want to decompile and look at the bytecode.

10:47 pellis_: 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:47 gfredericks: pellis_: nDuff: might it be the boxed math and such?

10:47 I guess it'd be surprising if that was a lot compared to the string work

10:47 ambrosebs: How 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:47 pellis_: gfredericks, which math?

10:47 inc?

10:47 clojurebot: oinc is octo-inc: (apply comp (take 8 (repeat inc)))

10:48 gfredericks: pellis_: the looping -- < and inc and such

10:48 if you're using primitives in the java version it's probably a bit faster

10:48 pellis_: in the java version is just a traditional C-style forloop

10:48 nDuff: *shrug*. AOT and decompile and we wouldn't have to guess.

10:48 gfredericks: hyPiRion: I get "No namespace: + found" when running `lein <X>`

10:48 nDuff: s/decompile/disassemble/

10:49 pellis_: i'm getting 600ms in Java, 2200ms in Clojure right now

10:49 same thing in node.js: 70ms :)

10:49 gfredericks: pellis_: btw the time macro will do the timing logic for you

10:49 pellis_: and ruby 2900ms.

10:51 hyPiRion: gfredericks: what

10:52 lein 2.1.1?

10:52 * gfredericks lein upgrade

10:52 pellis_: i'll try warming up the JVM first

10:52 hyPiRion: Well, I'm running on 1.6.0_27 OpenJDK

10:53 gfredericks: hyPiRion: yep that fixes it

10:53 hyPiRion: woop woop

10:54 pellis_: no change. so how would you run a piece of code X number of times repeatedly?

10:54 where X is a very large number

10:54 gfredericks: (dotimes [n 1000] (foo))

10:54 ,(let [a (atom 0)] (dotimes [_ 1000] (swap! a inc)) @a)

10:54 clojurebot: 1000

10:55 gfredericks: ,(time (dotimes [_ 100000] (clojure.string/split "foo and bar" #" ")))

10:55 clojurebot: "Elapsed time: 132.878713 msecs"\n

10:58 pellis_: gfredericks, i'll try that one, thanks

10:58 gfredericks: what on earth is LazilyPersistentVector about?

11:06 Chousuke: gfredericks: IIRC it's an optimisation for small vector literals

11:06 gfredericks: it's just an immutable array until you conj into it.

11:09 gfredericks: Chousuke: ah ha

11:14 ToBeReplaced: how do you clean out deftests in clojure-test-mode.el?

11:14 each time i recompile i just add new tests

11:16 mpenet: is 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:16 nrepl breakage or something?

11:18 tyler: is there a function that will no-op when something is called on it?

11:18 ToBeReplaced: nvm i must have done something wonky before with namespaces... i ns-unmapped then tried to recreate the problem and couldn't

11:18 tyler: or constantly return nil

11:18 mpenet: tyler: (constantly nil)

11:18 pl6306: How do I make a typed array in clojure? For example String[]?

11:19 gfredericks: &(doc make-array)

11:19 lazybot: ⇒ "([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:19 tyler: mpenet: thanks

11:19 gfredericks: &(make-array String 12)

11:19 lazybot: ⇒ #<String[] [Ljava.lang.String;@ee8a8a>

11:19 gfredericks: mpenet: I think clojurescript-mode is a separate package now?

11:20 * gfredericks isn't very good at emacs

11:20 mpenet: I think it has been deprecated

11:20 nDuff: mpenet: 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:20 mpenet: I could be wrong

11:20 nDuff: yeah I know how to activate it. I was just wondering why

11:21 it seems the regex could be tweaked a bit

11:22 pl6306: Why doesn't this work (make-array String "LOADED")

11:23 nDuff: pl6306: because "LOADED" is a sequence of characters, not a sequence of strings

11:24 tyler: woah...

11:24 ,(tree-seq seq? #(str "foo" %) '((1 7) 2 3))

11:24 clojurebot: (((1 7) 2 3) \f \o \o \( ...)

11:24 tyler: it elides it doh

11:24 nDuff: pl6306: Do you want an equivalent to (into-array "LOADED") or (into-array ["LOADED"])?

11:25 pl6306: The second.

11:25 Thanks

11:36 nzee: Photos, talks from Clojure/West event collated here. http://eventifier.co/event/ClojureWest

11:38 jcromartie: are talks posted yet?

11:38 oh yeah

11:43 nzee: Photos, talks from Clojure/West event collated here. http://eventifier.co/event/ClojureWest

12:10 dsop: is there anykijnd of "standard" what people use for exception handling? just regular java exceptions with try/catch or some handler base things?

12:10 wink: hyPiRion: oh wow, hello-swearjure is damn impressive

12:10 S11001001: dsop: slingshot

12:10 technomancy: slingshot for catching, ex-info for throwing

12:12 dsop: S11001001: thx

12:14 S11001001: dsop: keep in mind that throwing is a side effect, and side effects and laziness don't mix

12:14 dsop: S11001001: yes sure, i wont throw withing lazy seqs or anything like that

12:15 hyPiRion: wink: Thanks! I'm not sure if the fact that I managed to pull it off shows is a good thing or not though.

12:15 I mean, it's very revolutionary and stuff, but damn how amazing I am at procrastination.

12:16 /s/shows//

12:19 wink: hyPiRion: :)

12:19 arrdem: hyPiRion: your swearjure hello world. wat.

12:20 hyPiRion: arrdem: Oh, just wiat

12:20 *wait

12:21 arrdem: I mean I think I understand what you're doing here... but how did you come up with this abomination?

12:21 sleetdrop: System Memory: Free: 3.45 GB; Used: 4.55 GB; Total: 8.00 GB; — [❙❙❙❙❙❙❙|❙❙❙❙❙]

12:21 hyPiRion: arrdem: http://clojure-log.n01se.net/date/2011-04-06.html#19:04 <-

12:22 And yeah, it's not complicated once you grasp what I do the first.. uh, 34 lines or so

12:23 technomancy: once you take enough spice and can grasp the ebb and flow of spacetime through the planes of causality it's pretty straightforward.

12:23 hiredman: also redbull

12:23 technomancy: you know, like monads.

12:23 * technomancy hides

12:23 arrdem: sleep deprivation, stress and coffee is my prefference.

12:23 but redbull can cause all three

12:24 hyPiRion: 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:25 hyPiRion: arrdem: Well, I want to check out if it's possible to create a webserver written in Swearjure.

12:25 arrdem: .........

12:25 hyPiRion: I'm not entirely sure if that's doable though, so I have to figure that one out

12:25 arrdem: I promise you it is.

12:25 the question is do you want to write it.

12:26 actually I need to understand how you access symbols first. I take that back.

12:26 technomancy: hyPiRion: so you think you can drop back to 1.0.0 and do it with only a single alpha token?

12:27 if someone can do it without ns-map that's how you know they truly are the kwisatz haderach

12:27 hyPiRion: technomancy: 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:29 technomancy: swearjure project.clj is going beyond the call of duty =)

12:29 arrdem: ooh yeah

12:29 hyPiRion: if you can cook up an anonymus recursive nth this is totally viable with just ns-map

12:30 your project.clj then just needs to create all the refers you need

12:30 technomancy: if only you could quote % somehow to let you nest #()

12:30 hyPiRion: arrdem: recursive nth? Why would I need that?

12:31 I can just do (`[~@(param-here)] (number-here)) do simulate nth

12:31 arrdem: Excuse me while I try to wrap my lesser brain around that one.

12:31 hyPiRion: technomancy: yeah, not having nested function literals is horribly :(

12:31 arrdem: It's actually not that complicated.

12:32 arrdem: wait... [] is IFn?

12:32 hyPiRion: ,(let [alist (list 1 2 3 4)] [`[~@alist] (`[~@alist] 2)))

12:32 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>

12:32 hyPiRion: yes

12:32 ,(let [alist (list 1 2 3 4)] [`[~@alist] (`[~@alist] 2))

12:32 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>

12:32 arrdem: okat that's dead obvious then.

12:32 ,([ 1 2 3 4 ] 2)

12:32 clojurebot: 3

12:32 hyPiRion: oh bleh, I've lost control of the parentheses now.

12:33 arrdem: yeow that's cute

12:43 dnolen: ejackson: have you seen this http://research.microsoft.com/en-us/projects/fun/?

12:44 nzee: Photos, talks from Clojure/West event collated here. http://eventifier.co/event/ClojureWest

12:44 nDuff: nzee: You've been repasting that for a while this morning.

12:44 nzee: ...also, am I just missing something, or is there only a single talk's slides there?

12:44 gfredericks: nDuff: there's a github repo with a lot of slides

12:45 nDuff: ...then someone trying to promote a web site with a much smaller set seems awfully spammy to me.

12:46 nzee: I thought it will be relevant to you folks. sorry

12:48 patbrown: I'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:49 And 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:59 ToBeReplaced: saw ex-info came up earlier... is there a best-practice established for the map?

13:00 supersym: ,'not a literal'

13:00 clojurebot: not

13:00 supersym: ,'(not a literal)

13:00 clojurebot: (not a literal)

13:01 azkane: hey guys, is there a built in function that takes a list and a pred, and returns the first true element?

13:01 gtrak: some

13:01 ~(doc some)

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

13:02 gtrak: &(doc some)

13:02 lazybot: ⇒ "([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:02 azkane: nice, thanks!

13:02 hyPiRion: azkane: if you explicitly want "true", you can do (first (filter fn seq)), otherwise, some will do a similar job

13:02 supersym: hmmm quote is different in repl that instarepl

13:02 gtrak: azkane: implies your predicate ought to return the value

13:02 supersym: make sense I guess

13:02 *than

13:03 hyPiRion: ,(some (constantly :hey) [:what :is :this])

13:03 clojurebot: :hey

13:04 hyPiRion: ,(first (filter (comp true? {:a true, :b :foo}) [:b :c :a]))

13:04 clojurebot: :a

13:04 azkane: comp looks neat

13:04 gtrak: hyPiRion: just use boolean

13:05 hyPiRion: not the same thing

13:05 ,(first (filter (comp boolean {:a true, :b :foo}) [:c :b :a]))

13:05 clojurebot: :b

13:06 supersym: <3 clojurebot

13:06 gtrak: I meant (boolean (some ...

13:06 if you explicitly want true or false

13:06 hyPiRion: oh, right

13:07 yeah, it really depends on what you want here

13:10 borkdude: apparently another clojure book has made it: http://www.amazon.com/gp/product/B00BECVV9C/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=B00BECVV9C&linkCode=as2&tag=httpwwwericro-20

13:24 skoodge: ambrosebs: 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:25 tieTYT: http://www.techempower.com/blog/2013/03/26/everything-about-java-8/

13:25 ambrosebs: skoodge: it should work with qualified symbols. Perhaps aliases don't work?

13:26 skoodge: the core annotations have (ann clojure.core/+ ...)

13:28 skoodge: ambrosebs: ok, I will try it with the fully qualified name then

13:28 is there any way to remove a type annotation that is currently active?

13:28 ambrosebs: skoodge: no.

13:28 skoodge: I have already annotated the var in the other namespace and now would like to remove that annotation

13:28 ambrosebs: skoodge: restart your repl :/

13:28 skoodge: so restarting the process it is?

13:28 k

13:32 pl6306: What 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:33 hyPiRion: pl6306: It won't work by default, but you can do reflection through clojure.reflection I think

13:33 shriphani: hi 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:33 hyPiRion: Or, if you know how to do reflection in Java, you can just use that

13:34 pl6306: I know how to do it java just wondering what it the default

13:35 hyPiRion: default is no private access

13:35 (nor protected)

13:40 noidi: pl6306, see the source of http://clojuredocs.org/clojure_contrib/clojure.contrib.java-utils/wall-hack-method

13:42 dimovich: hello all, how do I catch Ctrl+C from clojure?

13:43 clgv: dimovich: afaik repl-y does that

13:45 dimovich: clgv: I mean, from the terminal... not from repl

13:45 I wanna save some stuff on program exit...

13:45 maybe there is some other way...

13:46 clgv: dimovich: yes. repl-y is repl front end which is a program and it catches Ctrl+C

13:47 hyPiRion: dimovich: look at the source of REPLy to look how it does that

13:47 dimovich: aha, ok... got it. Thx

13:50 clgv: dimovich: reply.signals is what you are looking for. usage example for interrupt in reply.eval-modes.nrepl

13:51 mpenet: packt has a couple of clojure "cookbooks" planned it seems

13:51 dimovich: clgv: thx

13:52 jonasen: dnolen: is walk-term really supposed to work like this or am I missing something? https://gist.github.com/jonase/5251620

13:53 pl6306: How 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:53 joegallo: (defn foo [{:as opts}])

13:53 opts will be a map, and you can grab things out of it as you'd like

13:54 you call it like this

13:54 (foo :bar baz :quux eggs :ham meat)

13:54 hyPiRion: joegallo: you forgot the &

13:54 joegallo: heh, oops!

13:54 pl6306: Thanks! Just what I was looking for

13:54 joegallo: (defn foo [& {:as opts}] ...) ;; <-- note the & that i missed

13:55 thanks, hyPiRion

13:55 hyPiRion: ,(let [f (fn [& {:as opts}] ((juxt :foo :bar) opts))] (f :hello 10 :bar 42 :foo :quux))

13:55 clojurebot: [:quux 42]

13:55 hyPiRion: np

13:56 dnolen: jonasen: huh probably not

13:57 jonasen: is it supposed to do prewalk, postwalk or both?

14:01 thm_prover: in 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:03 grebus: anyone know of good mocking libraries for clojurescript?

14:03 jonasen: dnolen: also, why is llist a macro? Is that necessary?

14:06 dnolen: jonasen: llist is old, probably for performance - we could provide a function variant as well. I never personally use llist explicitly tho.

14:10 jonasen: dnolen: ok. I think the unifier/prep implementatin could be simplified if walk-term worked "as expected". (Maybe I should say as I expected :)

14:11 I guess you don't use clojure.walk since it's not extensible.

14:20 dnolen: jonasen: 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:21 jonasen: dnolen: I'll take a look at it then :). what about my earlier question: pre/post/both? It seems to do (mostly) both now

14:22 or should I split it like clojure.walk does, i.e. (walk-term inner outer form)

14:22 dnolen: jonasen: 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:24 jonasen: dnolen: ok

14:28 pl6306: If 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:29 nDuff: pl6306: I'm not sure I follow the question.

14:30 Could you provide an example?

14:31 dnolen: jonasen: took a quick look, I believe the issue is how collections implement walk-term

14:31 * nDuff is guessing that this is a Java interop question, and that the answer will either involve memfn or be of the form "Clojure's interop doesn't work that way, but you can [...]"

14:33 pl6306: I want to do the equivalent in clojure but more generic an idiomatic. Method getSetMethod = obj.class.getDeclaredMethod("getSet"); getSetMethod.setAccessible(true);

14:34 I figure a macro would be a good place to put the logic. However my skills in clojure isn't quite there yet

14:38 nDuff: pl6306: Could you back up a little? What's the larger picture?

14:38 Oh. Got it now.

14:39 pl6306: I want to write something that can allow me to invoke a private methond on a class

14:39 instance

14:39 nDuff: Yup; took me a moment to grok that.

14:39 * nDuff has done that before, but it wasn't very pretty.

14:40 * nDuff looks through his public gists

14:42 mpenet: pl6306: you could use wallhack for that, or flatland/usefull I think

14:42 petrrrr: hey, i got a question what would be the easiest way to combine windows + clojure + lighttable?

14:42 tieTYT: does 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:43 nDuff: Hmm, 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:44 pl6306: Thanks looks like wallhack is what I am gunning for

14:44 mpenet: pl6306: https://github.com/flatland/useful/blob/develop/src/flatland/useful/java.clj#L23

14:44 nDuff: tieTYT: http://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/

14:44 tieTYT: thanks

14:44 nDuff: tieTYT: Note that Emacs still owns the bulk of the marketshare, by a mile

14:44 hyPiRion: tieTYT: Well, most of Clojure programmers use Emacs. With autocomplete and paredit, I find it more efficient than e.g. Eclipse

14:44 nDuff: tieTYT: ...and, to inject my own opinion, there are very, very good reasons for that.

14:45 mpenet: +1 on emacs, but I hear CCW is nice too

14:45 nDuff: mpenet: I'll take it seriously when its paredit supports slurp and barf, and not a moment before.

14:46 mpenet: nDuff: ah I thought it was a done thing already

14:46 tieTYT: hyPiRion: does the autocomplete work on the java code?

14:46 nDuff: mpenet: I understand there's been rework that should make that easier, but I hadn't heard that it was done.

14:48 hyPiRion: tieTYT: 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:48 nDuff: well, it also can take names from an active nREPL session

14:48 mpenet: it takes autocomplete from imports too

14:48 nDuff: which is where the real power is

14:49 tieTYT: Are you trying to find a single tool that's best-of-breed for both Java and Clojure?

14:49 tieTYT: My experience is that no such thing exists. IDEA for Java, Emacs for Clojure, and never the twain shall meet.

14:50 tieTYT: no just best for clojure

14:50 nDuff: tieTYT: ...then why were you asking about autocomplete for Java code? Did you mean for Java _objects_?

14:50 tieTYT: yes

14:50 i meant interop code

14:50 hyPiRion: nDuff: as in (.toString "...")

14:51 etc

14:53 tieTYT: yeah

14:53 mpenet: yes it works for method calls too.

14:54 you want nrepl + autocomplete + ac-nrepl for that

14:55 tieTYT: i think i'm going to try counter clockwise first

14:55 because learning emacs is its own project

14:55 nDuff: tieTYT: ...if you use Emacs Live, it has all those things you need built in.

14:55 tieTYT: Live? Is that a plugin?

14:56 nDuff: tieTYT: See https://github.com/overtone/emacs-live (or the video at http://vimeo.com/22798433)

14:57 tieTYT: 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:57 ~paredit

14:57 clojurebot: paredit is not for everyone, but what you need to understand ís how to become the kind of person that paredit ís for.

14:59 jcromartie: paredit is the blue pill

14:59 I mean red pill

14:59 tieTYT: what's paredit?

14:59 http://emacswiki.org/emacs/ParEdit ?

15:00 jcromartie: tieTYT: that's it

15:02 tieTYT: ah now that I know what this is

15:02 La Clojure does this

15:02 what's wrong with CCW's?

15:03 jcromartie: I would trust the JetBrains implementation

15:03 nDuff: tieTYT: Doesn't support slurp and barf -- or at least didn't a few months ago when I last looked at it again.

15:04 tieTYT: ...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:04 tieTYT: and that fixes indentation and everything.

15:05 tieTYT: hm

15:05 ok

15:05 jcromartie: paredit-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:06 "whole logical chunks"

15:08 nDuff: *nod*.

15:08 tieTYT: "SQL, Lisp, and Haskell are the only programming languages that I've seen where one spends more time thinking than typing."- Philip Greenspun

15:16 last 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:19 pl6306: What is clojure equivalent of int.class in java?

15:19 nDuff: pl6306: Integer/TYPE

15:20 pl6306: Thanks!

15:21 * nDuff ponders how trying to explain paredit is reminiscent of Paul Graham's Blub Paradox at times

15:22 tieTYT: weird, i was just reading that article

15:34 grebus: hm

15:37 Glenjamin: late to the party, but i'm getting along fairly well with a poor man's paredit in sublime text

15:37 it only has strict parens and a command to expand selection to current expression, but combining those with c&p seems quite usable

15:40 tieTYT: ah yes, counterclockwise is way better than la clojure

15:41 amalloy: Glenjamin: you can survive by eating raw meat and sleeping in trees, but civilization is so much nicer; similarly with c/p and paredit

15:41 Glenjamin: i'd love to grok emacs, but couldn't stomach learning clojure and emacs at the same time

15:42 tieTYT: Glenjamin: same boat as me

15:43 Glenjamin: so much muscle memory from other editors to unlearn :(

15:43 grebus: (instance? js/Object (js/Date.)) =>

15:43 true, but (isa? (type (js/Date.)) js/Object) => false

15:43 sorry about the double enter there

15:44 MikeSeth: does anyone know if leiningen :repl-port item is something that existed in previous lein versions but was deprecated in favour :repl-options?

15:44 s/favour/favour of/

15:44 hyPiRion: MikeSeth: Well, it certainly is deprecated now at least

15:44 If not completely removed

15:44 MikeSeth: hyPiRion: but it *was* there, correct?

15:45 hyPiRion: MikeSeth: yep

15:45 MikeSeth: I 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:45 hyPiRion: https://github.com/technomancy/leiningen/blob/1.5.1/sample.project.clj#L101 <-

15:46 MikeSeth: thought so

15:48 sublime2 is awesome btw

15:48 if not for the occasional hang that one of the plugins here seems to cause in repl

15:56 patchwork: Hmm… looking for a fn like `some` that actually returns the found value

15:56 Am I just missing it?

15:56 scouring the docs...

15:56 amalloy: (comp first filter)

15:56 Glenjamin: is that lazy?

15:57 patchwork: amalloy: That looks good, but more like (comp first (partial filter predicate?)) yeah?

15:57 amalloy: no?

15:57 clojurebot: no is tufflax: there was a question somewhere in there, the answer

15:57 amalloy: (comp first filter) accepts exactly the same args that some does

15:58 hyPiRion: ,((comp first filter) odd? (range 10)) ;; <<- patchwork

15:58 clojurebot: 1

15:58 patchwork: Aha, 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:58 Glenjamin: (no, it's not lazy)

15:58 patchwork: Ah

15:58 Yeah the whole point is to avoid searching the whole list for it

15:58 amalloy: Glenjamin: that is a nonsense claim

15:59 mpenet: ,(doc filter)

15:59 clojurebot: "([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:59 patchwork: I don't see any reason why it wouldn't be lazy?

15:59 Glenjamin: ah

15:59 i made pred have side effects

15:59 to see if it was lazy

15:59 >.<

15:59 patchwork: Cool, thanks amalloy!

15:59 Bronsa`: well, it's lazy on chunks of 32 elements

15:59 hyPiRion: Well, if you take the first element, then you have to realize some of them, ait.

16:00 amalloy: Bronsa`: or chunks of 1 element, or chunks of whatever size chunked-seq someone makes

16:00 Glenjamin: eg. ((comp first filter) (fn [a] (prn 1) (= a 2)) [1 2 3 4]) prints 4 1s

16:00 amalloy: Glenjamin: try it with (list 1 2 3 4)

16:00 Bronsa`: amalloy: sure, right

16:00 Glenjamin: oh cool

16:00 had no idea about chunking

16:01 * Glenjamin goes to read docs

16:02 patchwork: Anyone 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:02 (ppppppphh)

16:03 amalloy: patchwork: i use (constantly true): so far, it has always correctly identified that my software has at least one bug

16:03 patchwork: amalloy: I'll let them know!

16:04 Glenjamin: my approach to security has always been to pay a 3rd party to "audit", and then show the client the certificate.

16:04 ymmv

16:04 nDuff: patchwork: it's not security-focused, but there's kibit.

16:04 patchwork: that said, Glenjamin's approach sounds solid to me.

16:06 Raynes: My approach to security has always been to let xeqi break it and then fix it.

16:06 amalloy: well, you're rock-solid on part 1, Raynes

16:06 Raynes: Heh, I've fixed most of the things he found. :p

16:06 http://nelsonmorris.net/2012/09/06/breaking-lazybot-out-of-clojail.html

16:07 technomancy: if [ `rgrep read-string src | wc -l` != 0 ]; then echo booooogs; fi

16:07 nDuff: ...

16:07 technomancy: with my #bash hat on, I'm very disappointed.

16:07 ivaraasen: trying to refactor array-utils ATM. macros are hard, damnit

16:07 tieTYT: last 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:08 Raynes: I don't follow.

16:08 Bronsa`: every?

16:08 technomancy: nDuff: I make no claims at being good at bash; I only use it when I'm not allowed to use eshell

16:08 Raynes: Didn't you just write the function just now?

16:08 nDuff: technomancy: rgrep -q read-string src && echo boooogs

16:08 tieTYT: can't tell if anyone's replying to me or not

16:08 Raynes: I am..

16:09 Bronsa`: tieTYT(every #(.contains s %) [x y ..])

16:09 Raynes: And so is Bronsa`.

16:09 tieTYT: ok i'm asking if there's a more idiomatic way I guess

16:09 Raynes: Oh, you wanted to do the contains or arbitrary numbers of things?

16:09 tieTYT: every isn't in the cheatsheet

16:09 Raynes: yes

16:09 Bronsa`: every?

16:09 derp

16:09 tieTYT: ah

16:10 Raynes: Then I think Bronsa` wins.

16:10 Bronsa`: sorry.

16:10 tieTYT: cool i knew there was a better way

16:10 my way seemed so freaking verbose

16:11 well not compared to java

16:20 Raynes: And the 13000th paste award goes to… https://www.refheap.com/paste/13000 … nobody because they didn't bloody well sign in.

16:21 Guys, 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:21 gfredericks: ,(* 2 2 2 5 5 5 13)

16:21 clojurebot: 13000

16:21 hyPiRion: gfredericks: oh, me too

16:22 gfredericks: hyPiRion: I have no idea what that means but I assume it's awesome.

16:22 hyPiRion: gfredericks: sec

16:22 jcromartie: gah, I'm making a mess of things, somebody help!

16:22 Raynes: Stay calm and stop making a mess of things.

16:22 gfredericks: add more parens

16:23 Raynes: (inc Raynes)

16:23 lazybot: You can't adjust your own karma.

16:23 Raynes: DENIED.

16:23 patchwork: (inc Raynes)

16:23 lazybot: ⇒ 25

16:23 jcromartie: )))))))))

16:23 Raynes: $karma gfredericks

16:23 gfredericks: (inc lazybot)

16:23 lazybot: ⇒ 16

16:23 gfredericks has karma 16.

16:23 Raynes: I always knew I was better than you.

16:23 gfredericks: you're so square

16:23 jcromartie: shouldn't it be (dosync (alter Rayntes inc))

16:23 Raynes: I'm very circular.

16:23 jcromartie: or just swap!

16:23 but really

16:23 so

16:24 the eternal question: how to organize an application

16:24 Raynes: If there aren't any circular dependencies you're probably not doing too bad.

16:24 jcromartie: I find myself reverting to the "class" design

16:24 I got that much

16:25 but like, a namespace for each "type" in the data model

16:25 gfredericks: Raynes: you're a square and I'm a hypercube

16:25 jcromartie: where the data model is configuration of a news aggregation system

16:25 Raynes: I'm a companion cube.

16:26 gfredericks: half of my conversations degenerate into me making boring observations about natural numbers

16:26 jcromartie: and I'm just running around in circles making refs on hash maps with repository abstractions over certain keys in the map

16:26 hyPiRion: ,(* (#(*%%%)(+(*)(*))) (#(*%%%)(#(+(*)%%)(+(*)(*)))) (#(+(*)(*%%(`[~@%&](+))))(+(*)(*))(+(*)(*)(*))))

16:26 clojurebot: 13000

16:26 jcromartie: and it seems silly

16:26 hyPiRion: there

16:27 Wow, that's actually quite compact.

16:27 jcromartie: HEY GUYZ HOW DO MAKE THE PERFECT ARCHIRTECTURE

16:27 gfredericks: hyPiRion: hah nice

16:27 jcromartie: queues probably

16:28 jcromartie: like, I'm trying to discover the one hidden secret design that will solve software design problems forever

16:28 but let's be totally practical here

16:28 gfredericks: data? protocols?

16:28 monads?

16:28 clojurebot: monads 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:28 jcromartie: data is great

16:28 hyPiRion: jcromartie: Oh, you're making the sufficiently smart compiler.

16:28 jcromartie: and my data is really simple

16:29 but let me be concrete here

16:30 gfredericks: ,'(*%%%)

16:30 clojurebot: (* % % %)

16:30 gfredericks: hyPiRion: ^^ that's crazy weird

16:30 well maybe just regular weird

16:31 ystael: gfredericks: isn't all of computation essentially boring remarks about natural numbers?

16:31 hyPiRion: gfredericks: yeah, just as weird as ##(#([`{~% ~@%&}](+)) :a 1 :b 2)

16:31 lazybot: ⇒ {:a 1, :b 2}

16:31 gfredericks: ystael: I knew there had to be some way to justify my existence

16:31 hyPiRion: There was another one too, but I can't remember which exactly.

16:31 gfredericks: hyPiRion: it hadn't occurred to me to use functions to reduce repetition in numeric literals

16:32 jcromartie: I 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:32 so I can see this as one structure

16:32 hyPiRion: gfredericks: I've been thinking about it, but I'm not sure how to make a emitter for such functionality yet

16:32 I did the previous one by hand, for instance

16:33 jcromartie: and the HTML interface is literally the only thing that will use the API to change this configuration

16:34 JSON/XHR, all that jazz

16:34 hyPiRion: But like, the search space shouldn't be that large. Branch-and-bound or genetical algorithms sounds viable for this task.

16:35 Actually, genetical algos are probably overkill.

16:36 jcromartie: I 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:36 that seems reasonable right

16:37 like (make-json-api state-ref :feeds parse-feed render-feed validate-feed)

16:38 where is a non-trivial Clojure web app source code when you need one

16:40 SegFaultAX: jcromartie: Refheap and 4clojure are open source.

16:40 jcromartie: ah yeah

16:40 gfredericks: hyPiRion: search space is big if you want to check all possible sums for a big number

16:41 so the question is how to avoid that search

16:41 hyPiRion: gfredericks: memoization of smaller numbers and branch-and-bound?

16:41 gfredericks: sounds intractible with a naive B&B

16:42 there are a lot of possible sums of 10^1000; not sure memoization will help there

16:44 hyPiRion: gfredericks: well, if you use prime factorization as a precomputer upper bound, wouldn't that limit it somewhat?

16:44 *precomputed

16:44 gfredericks: not if you still have to do some minimal thing for all passible partitions, like check against the bound

16:45 http://en.wikipedia.org/wiki/Partition_(number_theory)

16:45 you wouldn't have to check all partitions presumably, but just checking all 2-partitions would be intractable

16:46 hyPiRion: Ah, I see.

16:46 gfredericks: not to mention if you're targeting big-big numbers then factoring is barely an option anyhow

16:47 avishai: hi

16:47 gfredericks: hi

16:47 avishai: i'm using every?

16:47 hyPiRion: If you reorder the numbers based on size and pick the lowest found for e.g. 10000 or so? Sounds like a good heuristic.

16:48 avishai: and i'm wondering why it evaluates every element of the sequence even if one returns false

16:48 hyPiRion: avishai: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/

16:49 gfredericks: avishai: you mean realizing a lazy seq beyond what's necessary, or actually calling your predicate more than necessary?

16:49 jcromartie: ,(every? println [1 2 3])

16:49 clojurebot: 1\nfalse

16:50 jcromartie: avishai: I think it's something else that causes your seq to be realized

16:51 ,(every? println (repeatedly #(println "generate")))

16:51 clojurebot: generate\nnil\nfalse

16:51 avishai: hmm

16:53 MikeSeth: i updated sublimerepl doc with some hints on setting up a clojure repl

16:53 tieTYT: hyPiRion: jeez, that seems scary

16:53 seems super unpredictable

16:54 MikeSeth: in case anyone wants to take a look before wuub merges it

16:54 tieTYT: i mean it's literally predictable, but it seems hard to reason about if your functions aren't pure

16:54 hyPiRion: tieTYT: Well, it's not intended for impure functions

16:54 ,(every? odd? (map #(do (print \.) %) (range 64)))

16:54 clojurebot: ................................false

16:55 hyPiRion: ,(every? #(< % 32) (map #(do (print \.) %) (range 64)))

16:55 clojurebot: ................................................................false

16:55 tieTYT: in what way is it not intended for that?

16:55 clojure makes it easy to write impure functions

16:56 jcromartie: you shouldn't rely on laziness at a small scale, or even on the realization of a lazy sequence at all

16:56 tieTYT: *in clojure

16:56 jcromartie: i.e. if realizing your sequence too early is a problem, then maybe it's not a good fit for a sequence?

16:56 yea

16:57 tieTYT: just seems slightly limiting to me

16:57 or does lazy-seq work exactly the way I want?

16:58 acagle: /flush

16:58 hyPiRion: tieTYT: 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:59 tieTYT: bbl

16:59 hyPiRion: the doall realizes the whole sequence.

16:59 enquora: yogthos: wrt to clj-pdf, I assume you wanted an html/css style set of layout directives and wrapped iText with those?

16:59 yogthos: enquora: it's not really html/css based

17:00 enquora: perhaps block-based would be a better description

17:00 yogthos: enquora: yeah

17:00 enquora: basically you make a tree of elements parent style will propagate to children unless they override it, etc

17:01 enquora: In fact, ConTeXt, the Dutch improvement on LaTeX, takes the same approach to layout description, or at least offers it as an alternative

17:01 yogthos: enquora: it tries to use sane defaults for stuff, and you can specify custom parameters as maps for each element as needed

17:01 enquora: you needed tabular layouts?

17:02 I'm getting my head around the semantics I need

17:03 pl6306: What is the difference between (repeatedly 7 (println "x")) and (repeatedly 7 #(println "x"))

17:03 amalloy: pl6306: the second one works

17:03 enquora: am 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:04 pl6306: Why?

17:04 clojurebot: why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone

17:04 pl6306: Also the function literal will it capture the vars defined in a let form?

17:04 SegFaultAX: pl6306: Read the doc, it explains exactly what repeatedly does.

17:04 Bronsa: pl6306: #(println "x") returns (fn [] (println "x")) while (println "x") prints x and returns nil

17:05 repeatedly being a function, takes a function to be repeated, not a form

17:05 pl6306: if 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:07 Bronsa: ,(let [x 1] (#(identity x)))

17:07 clojurebot: 1

17:08 amalloy: Bronsa: ((let [x 1] #(identity x))) is IMO more convincing

17:09 Bronsa: amalloy: probabily, right

17:18 pl6306: Does repeatedly behave differently in REPL versus code? It being lazy does it mean it doesn't run in side defn body?

17:18 What is the best practice of doing n side effects?

17:18 (take nscens (repeatedly nscens #(println "repeat"))) overkill?

17:20 TimMc: pl6306: take is lazy as well

17:20 pl6306: That explains why it doesn't work. How can I just make a function body repeat

17:21 Can't be that hard?

17:21 TimMc: You just want side-effects, and not the return values?

17:21 pl6306: Yes

17:21 Bronsa: (dotimes [_ times] (println "foo"))

17:21 TimMc: doseq might be useful

17:22 pl6306: Just what I needed

17:22 tyler: is it idem'potent or idempo'tent i hear most people say idem'potent but omnipo'tent is used in that word

17:28 pl6306: Is nested let form inside defn a bad idea?

17:28 amalloy: tyler: http://www.merriam-webster.com/dictionary/idempotent, why ask us?

17:28 SegFaultAX: pl6306: Not necessarily.

17:29 pl6306: But it might be easier to condense them if it's possible.

17:29 tyler: amalloy: i do not belong to the cult of m-w.com

17:29 heh

17:32 Raynes: $dict idempotent

17:32 lazybot: Raynes: 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:33 SegFaultAX: I pronounce it as a single word. Like if you google "define idempotent" and listen to the sound clip.

17:33 Raynes: Too bad you can't play sound in IRC. I'd hook it up to a pronunciation website.

17:33 SegFaultAX: Most people pronounce it like "idem...potent"

17:33 Which sounds weird to me.

17:36 matthavener: Raynes: there's always CTCP SOUND :)

17:36 Raynes: lol

17:44 avishai: hi

17:44 again...

17:44 why is it that functional solutions to euler problems seems to have longer processing time then procedural solutions?

17:45 am i doing it wrong?

17:45 or is this inherent?

17:55 hyPiRion: avishai: 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:55 after 200, the solutions tend to be easier with either logic programming and/or functional programming

17:56 Though a procedural program should in about the same order of magnitude

17:56 should run*

18:00 avishai: 10x

18:01 hyPiRion: hm

18:03 Well, minimal network (107) is just a minimal spanning tree, which both Kruskal and Prim's are like fairly well known, for instance.

18:05 101 is just polynomial interpolation

18:06 It's kind of like, they are computer scientist stuff which have been optimized at the point in time where computational power was scarce.

18:14 supersym: `/q

18:41 weavejester: Does anyone happen to know why mapcat might evaluate a lazy seq?

18:41 I'm guessing it's not mapcat directly

18:42 But the seq it's operating on isn't chunked, according to chunked-seq?

18:43 Oh, but it is evaluating it 32 times, so that implies it is chunked somehow.

18:49 Ohh, so (chunked-seq? x) is false, but (chunked-seq? (seq x)) is true

18:50 So there must be a way of unchunkifying a seq somehow...

18:53 hyPiRion: weavejester: fogus had a solution for 1.1, not sure it still applies though

18:53 amalloy: weavejester: yes, many easy ways

18:54 which, now that i've said that, i can't remember at all. maybe (map first (take-while seq (iterate next coll)))?

18:54 weavejester: Hum...

18:54 (type x) => clojure.lang.LazySeq

18:54 (chunked-seq? x) => false

18:54 (chunked-seq? (seq x)) => true

18:55 amalloy: weavejester: any sub-section of a seq can be chunked anyway

18:55 interrogating just the head can't tell you all you need to know

18:55 weavejester: I wouldn't have expected the seq function to chunkify a lazy seq.

18:55 amalloy: weavejester: it didn't; that's the wrong way to think about it

18:56 consider (lazy-seq (generate-chunked-seq))

18:56 obviously that is not chunked, and is a lazy-seq; equally obviously, when you seq it, you get back something chunked

18:56 weavejester: Oh, I see.

18:57 seq needs to realize the head, and it might be a chunked seq inside, so to speak.

18:57 amalloy: another unchunking option: ((fn unchunk [coll] (lazy-seq (when (seq coll) (cons (first coll) (unchunk (rest coll)))))) coll)

18:58 weavejester: It seems odd this isn't in the core language, considering that lazy seqs are often used in I/O.

18:58 Raynes: Open a Jira ticket and you might get your wish in a few years.

18:58 weavejester: Heck, Clojure has clojure.core/line-seq

18:59 Raynes: That's not a huge incentive :)

18:59 Raynes: Hence why I never make feature requests.

19:00 amalloy: weavejester: what does line-seq matter? it's not chunked

19:00 weavejester: amalloy: I mean it's a lazy I/O seq

19:00 amalloy: so? it's not a chunked seq, so i don't see how it's related to putting unchunk in core

19:00 (not that i think it would be a bad idea to do so)

19:01 weavejester: Well, 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:02 hiredman: obviously should be using reducers

19:02 weavejester: Reducers aren't lazy as far as I know? Or was that tongue-in-cheek?

19:05 hiredman: reducers return a reducible collection without doing the work until the collection is reduced

19:06 https://gist.github.com/hiredman/4075459

19:06 chessguy: 'evening ya'all

19:07 hiredman: and reducers can manage resource life time without consumers needing to use with-open

19:09 weavejester: hiredman: Ah right, yep. I think in my case unchunking the seq would be the better choice, however.

19:14 Hmmmm… I've unchunked the seq, I think, and it's no longer loading 32 values, but it is loading 4. Why 4?

19:17 amalloy: insufficient information to solve problem

19:18 weavejester: This works:

19:18 (first (map #(do (prn %) %) (unchunk (seq [[1 2] [3 4] [5 6]]))))

19:18 But this doesn't:

19:18 (first (mapcat #(do (prn %) %) (unchunk (seq [[1 2] [3 4] [5 6]]))))

19:19 Or rather the first example just evaluates the head, but the second evaluates more.

19:19 (first (mapcat #(do (prn %) %) (unchunk (seq [[1] [2] [3] [4] [5]]))))

19:20 Curiously mapcat evaluates the first 4 elements

19:20 map only evaluates the first 1

19:21 SegFaultAX: weavejester: Isn't part of the contract of mapcat that your mapping function returns a seq?

19:22 weavejester: SegFaultAX: Yes… But I don't get what you're implying.

19:23 amalloy: weavejester: welllllll, [1] is itself a chunked seq, and the (apply concat ...) in mapcat may be trying to keep it chunked for you

19:23 weavejester: Ohhh! I bet it has to do with the definition of concat

19:23 Because concat has: ([] [x] [x y] [x y & zs]) as it's arglists

19:24 So from it's arglists alone, it needs to read three to know which to dispatch on

19:24 SegFaultAX: weavejester: Good call.

19:24 amalloy: that sounds right

19:24 weavejester: And then the last is probably due to a (seq …), I guess.

19:25 SegFaultAX: weavejester: Out of curiosity, what are you working on?

19:26 weavejester: Basically I have a log of data stored in groups of about 1000 in S3 objects.

19:26 So I have a function like: (mapcat read-objects (list-keys bucket))

19:28 Under 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:28 So I unchunk list-keys like:

19:28 (mapcat read-objects (unchunk (list-keys bucket)))

19:28 But I'm still reading 4 objects instead of just the 1 when I try to get the first element of the sequence.

19:29 And I think that's because of the way concat is written: it must realize a minimum of 4 elements.

19:30 So in short, I need to write my own stupid mapcat function :)

19:30 hiredman: for

19:30 amalloy: weavejester: have you tried using 'for? it might have different characteristics

19:31 weavejester: amalloy: Can 'for concatenate?

19:31 amalloy: of course

19:31 weavejester: I should have known :)

19:31 brehaut: weavejester: mapcat is bind in the list monad; for is list monad comprehension notation

19:31 amalloy: &(mapcat identity [[1 2] [3 4]])

19:31 lazybot: ⇒ (1 2 3 4)

19:31 amalloy: &(for [xs [[1 2] [3 4]], x xs] x)

19:31 lazybot: ⇒ (1 2 3 4)

19:32 weavejester: Oh, duh, yes of course

19:32 I'll blame my current slowness on having had little sleep and having gotten up… 17 hours ago :)

19:32 amalloy: brehaut: 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:32 brehaut: haha

19:32 thanks

19:33 weavejester: brehaut: By list monad comprehension notation, do you mean do notation? It's been a while since I've done Haskell.

19:34 brehaut: weavejester: yes

19:35 weavejester: although to confuse things haskell also has list comprehension notation that is specific to the list monad (and doesnt look like do/for)

19:36 weavejester: (first (for [xs (seq [[1] [2] [3] [4] [5]]), x xs] (do (prn x) x)))

19:36 And that works, without even needing an unchunk

19:37 amalloy: another lovely reason to do all sequence processing with 'for

19:38 hiredman: for really is the best

19:40 weavejester: I forget how to do the inc thing

19:40 inc amalloy

19:40 amalloy: (inc for)

19:40 lazybot: ⇒ 1

19:40 weavejester: (inc amalloy)

19:40 lazybot: ⇒ 44

19:40 weavejester: Excellent

19:40 hiredman: I have this thing I wrote that is sort of like https://github.com/Prismatic/plumbing, but it does the graph list comprehension style

19:41 so if you have {:x .. :y ..} and y depends on x, y is run on each element of x

19:43 geraldo: cl 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:44 now 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:45 is 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:46 stain: I would normally say no, split it - but you are building GUI in Eclipse which would be interacting with the Clojure code..?

19:47 I 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:47 geraldo: no

19:48 eclipse is just to design and generate forms

19:48 that ll be consumed by clojure

19:53 tieTYT: is it ok/possible to call some clojure in my java program to process data for me?

19:53 lots of examples of how clojure can call java code, but not the other way around

19:53 let me google

19:54 stain: if you compile the clojure code (which lein will happily do), you will get lots of java classes, one per function I think

19:55 just the .class files.. but that should be enough. You can also implement a traditional java interface in Clojure

19:55 tieTYT: stain: http://stackoverflow.com/questions/2181774/calling-clojure-from-java

19:57 stain: tieTYT: mm, the trouble is the typing of the parameters, so you need to do a bit of declarations

19:57 brehaut: clojurebot:from java<reply>http://skillsmatter.com/podcast/scala/impromptu-rich-hickey-lightning-talk

19:57 clojurebot: No entiendo

19:57 brehaut: bah

19:57 clojurebot:from java is <reply>http://skillsmatter.com/podcast/scala/impromptu-rich-hickey-lightning-talk

19:57 clojurebot: Roger.

19:57 tieTYT: stain: i don't mind

19:57 brehaut: ~from java

19:57 clojurebot: http://skillsmatter.com/podcast/scala/impromptu-rich-hickey-lightning-talk

19:58 tieTYT: heh he looks like a dj

19:59 brehaut: tieTYT, 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:00 tieTYT: and I just get the str from a legit clj file?

21:41 ivan: has anyone implemented meta/with-meta in Python, perhaps with WeakKeyDictionary?

21:42 oh wait how would that even work, everything is mutable and unhashable

21:44 heh TypeError: cannot create weak reference to 'tuple' object

22:13 n_b: ,(doc ..)

22:13 clojurebot: "([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:19 bytechunky: the source of 'eval' basically is (defn eval [form] (. clojure.lang.Compiler (eval form))). Why is this not endless recursion?

22:19 gfredericks: you can't spell "transparency" without "paren"

22:20 bytechunky: the . form is special

22:20 bytechunky: it's equivalent to (.eval clojure.lang.Compiler form)

22:20 bytechunky: gfredericks: oh and i always thought that would be (. clojure.lang.Compiler eval form)

22:21 gfredericks: that might be possible too

22:21 clojure isn't necessarily the most idiomatic clojure code

22:21 bytechunky: *needs to think about that*

22:21 :D

22:22 gfredericks: for two reasons

22:22 Sgeo: help I think something's wrong with me

22:23 I'm starting to not hate Java so much

22:23 gfredericks: Sgeo: more parens

22:23 Sgeo: Or, well, no

22:23 Stockholm syndrome

22:23 gfredericks: Sgeo: have you been right-clicking to refactor things?

22:24 Sgeo: Just to make properties out of fields

22:24 I keep forgetting that this isn't C# where the field name can't share the property name

22:24 Because properties aren't "real" in Java

22:24 hyPiRion: Sgeo: Java is okay for algorithm stuff. Not so much anything else.

22:24 Well, at least from my point of view.

22:25 gfredericks: bytechunky: A) idiomacy evolves over time; B) some of clojure.core is defined prior to more advanced features

22:25 I expect this case is A

22:25 ivaraasen: hyPiRion: I dunno, man. Swing is pretty sweet if you're into BDSM.

22:26 hyPiRion: BDSM and mental disorders.

22:27 I got to accept that it's pretty good at that

22:29 * arrdem-emacs cannot fathom why his code works fine in repl but dies on `lein run`

22:30 corecode: hi

22:30 hyPiRion: corecode: hey there

22:30 corecode: i'm having trouble with nrepl; am i right here or is #emacs better?

22:31 hyPiRion: It's better to be here, yeah

22:35 jack_rabbit: re there any plans to implement CL-style restarts in clojure? Those were one of my favorite features of CL.

22:35 Are*

22:39 corecode: for some reason, (nrepl-send-string-sync "(eval '(clojure.repl/doc case))" (nrepl-current-ns)) doesn't return :stdout

22:40 but if i don't include the namespace, it works.

22:42 gfredericks: ,(count (flatten (nth (iterate #(vec (repeat 10 %)) [:x]) 5)))

22:42 clojurebot: 100000

22:46 gfredericks: it takes 70 times longer to count ^that sort of structure than a flat (repeat 100000 :x)

22:47 hyPiRion: it's even faster to just return 100000.

23:10 gfredericks: hyPiRion: you're just thinking inside the box

23:11 amalloy: gfredericks: are you sure it takes longer to count, and not just longer to generate lazily while iterating to count?

23:13 i 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:56 tyler: is there a way to set max ram in leiningen?

23:58 ah in sample prj file

Logging service provided by n01se.net