#clojure logs

2012-11-28

00:48clj_newb_234after I create a java.awt.Font object, is there a wya to get a list of all displabyel glyphs ?
00:52clj_newb_234(. font getNumGlyphs)
00:52abpgood mornin
00:53tomojwell, there's a canDisplay(char c), and there's only, what 65k chars? :/
00:56tomojclj_newb_234: https://www.refheap.com/paste/7f2aa59ebc3a126d9f6225e3f
00:56clj_newb_234tomoj: is there a way to enumerate line 3?
00:56clj_newb_234why is line 3 a bunch of constants?
00:56tomojline 3 is the return value
00:56clj_newb_234oh
00:56clj_newb_234i'm an idiot
00:57clj_newb_234thanks :-)
00:59tomojbugs me that we don't have a range protocol
00:59tomoj..rarely
01:02clj_newb_234tomoj hmm
01:02clj_newb_234that code outputs way more than (. font getNumGlyphs)
01:04clj_newb_234134 51406 134 51406 134 51406
01:05clj_newb_234134 = (. font getNumGlyphs)
01:05clj_newb_23451406 = number that passes the filter
01:09tomojoh. I don't even know what a glyph is, sorry
01:09jyfl987hi , i have a problem when installing leining on my linode vps
01:10jyfl987it just failed with saying " at clojure.main.main(main.java:37) "
01:11tomoj"canDisplay: Checks if this Font has a glyph for the specified character."
01:11tomojI see
01:11abpjyfl987, probably it couldn't fetch the clojure jar?
01:11tomojhow'd it get a stacktrace into clojure.main then?
01:11abpjyfl987, are you behind a proxy?
01:12jyfl987abp: wait , let me paste the full error log
01:12abptomoj, um yea
01:12abptomoj, should drink my first coffee before trying to be helpful ;)
01:14jyfl987abp: http://dpaste.com/hold/838214/ here its
01:16tomojwild guess, did you do `sudo apt-get install leiningen`?
01:16jyfl987nope i use the github edition
01:16abpjyfl987, are you using lein repl on a project?
01:16jyfl987i clone that and follow the inst in the readme file's building section as it recommend
01:17jyfl987i want to got a try of noir
01:17abpjyfl987, no you said while installing?
01:17jyfl987i mean installing plugin
01:17jyfl987the noir's site told me to use that
01:18abpjyfl987, then better paste your project.clj, looks like leiningen is choking on that.
01:18jyfl987lein plugin install lein-noir 1.2.1
01:18jyfl987then how can i do lein run?
01:18abpjyfl987, If you're using lein2 you don't need to explicitly install anything
01:18jyfl987it seems that it would fail each time
01:18abpjust declare it in your project.clj
01:19jyfl987oop, then run that by manual? that would cause losing all the magic :[
01:20abpjyfl987, let me see what that plugin does
01:20tomojI wouldn't clone lein
01:20tomojjust do what it says in the "Installation" part of the readme
01:20jyfl987my repo dont have leiningen
01:20abpjyfl987, and for lein2 the readme of lein noir says For Leiningen 2 run instead (you may also specify the lein-noir version to use in profiles.clj):
01:20abplein new noir my-website
01:22abpjyfl987, lein2 should fetch necessary plugins by itself.
01:23jyfl987well to use lisp syntax is pleasure, but recently i almost downloaded hundreds MB of files for the tools behind, and still got an error message :[
01:23tomojyou cloned lein from github and followed the 'building' instructions?
01:23jyfl987abp: but mine has fetched the plugins by itself
01:24jyfl987tomoj: yep
01:24tomojdon't do that
01:24jyfl987and my platform is ubuntu 12.04 on linode
01:24jyfl987what?
01:24clojurebotWhat is 2d6
01:24tomojI'd `rm -rf .lein` (unless you put anything in ~/.lein/profiles.clj you want to save)
01:24tomojthen go back to the leiningen readme and follow the "Installation" instructions
01:24tomojyou don't need to clone
01:24jyfl987so can you give me a workable instructions
01:25jyfl987would try
01:25tomojhttps://github.com/technomancy/leiningen/
01:25tomojwhere it says "Installation"
01:25tomojstart with "1. Download the script"
01:26tomojI think you got a too-new version of leiningen
01:26jyfl987ok done
01:27tomojand.. same error? :(
01:28jyfl987havent arrive that step :]
01:29jyfl987jyf@li527-239:~$ lein plugin install lein-noir 1.2.1
01:29jyfl987The plugin task has been removed.
01:29jyfl987that's what it return
01:31abpjyfl987, you still don't need to install that plugin
01:32jyfl987abp: then how can i got the plugin?
01:32abpby using it
01:32abpit will be fetched automatically
01:32jyfl987so it will analyzing your code before running it?
01:33abpI mean "lein new noir my-website"
01:34jyfl987oop, thanks
01:34jyfl987to you both :]
01:35jyfl987another question is what do you use clojure for?
01:36jyfl987yesterday i run a fibonacci 36 on my workmate's nexus 7, amazing its time costs!
01:41abpjyfl987, I don't use Clojure, I only sit in here, waiting for people to ask things. :P
01:43jyfl987abp: well i am not joking
01:43jyfl987just want to know its profits
01:48tufflaxjyfl987, personally I think this is a very strong aspect of clojure http://www.infoq.com/presentations/Simple-Made-Easy
01:49abptufflax, jyfl987 Yep I recommend everyone to watch this, too.
01:55jyfl987i have read the book "hacker and painter" and worked for web site years, i feel the lisp familly its really suite for web usecase. so i started learning lisp langs
01:55jyfl987recently i want to setup a really site, it would have so many change and view as i could assume
01:56jyfl987so i want to know if clojure could do it
01:56jyfl987i used to hate java
01:56jyfl987but jvm is cool to me, i am a forth fans, i like stack based machine :]
01:57jyfl987but the time costs made me shocked
01:58jyfl987i was worried the performances
01:59tufflaxjyfl987, what was your experiment? the fib 36 thing, what was the code
02:02jyfl987tufflax: i live on python
02:03jyfl987had a kink of should i use py or clj to done that? for using py, i knew its limitation which i would met
02:17abpjyfl987, I've been learning and trying things with Clojure for one and a half year now. I've written a data converter at work and will do web services, a swing application and web applications with server- and client-side in Clojure at work. At home I'm working on my own set of libraries.
02:17tomojhmm
02:17tomoj"Internal reduce solves the lazily dangling open resource problem"
02:17tomoj"We need reducible I/O sources."
02:18jyfl987abp: so you're java world guys?
02:18tomojI guess we have no way to take two reducers and get a third
02:19tomojso it's not really a problem that a reducible I/O source does the I/O every time it's reduced
02:20abpjyfl987, after a lot of languages I arrived at Java, yes. Have done it 3 or 4 years. Had no lisp, scheme or ml knowledge before starting Clojure. Had a lot of brief looks at Scala before discovering Clojure.
02:21jyfl987abp: ok ,got it, why you have time to answer people's question? is it the code are compiling? :]
02:21abptomoj, don't know whom you quote but that's dead right. I/O at a file level is really alien to Clojure processes. It's easily doable but doesn't integrate great like everything else. :)
02:22tomojhttp://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html
02:22abpjyfl987, my legs aren't in a very good condition right now. I've got a few days of to recover. :P
02:22Sgeo__Wait, does reducers do things sort of like Haskell Iteratees?
02:23abptomoj, ah, yes. Didn't remember that part.
02:23jyfl987abp: greate company !
02:23tomoj"... a problem solved similarly by Haskell's enumerators and iteratees. (Note that unlike iteratees, reducers do not allocate wrappers per step)"
02:23tomojbut you could theoretically zip two async reducers into a third
02:23abpjyfl987, german health system.
02:24tomojand if you zipped an io reducer with itself for example, you'd do all the io twice
02:24abpjyfl987, I had an accident with my bike, so it's nothing enjoyable.
02:24tomojthough I guess there are space leak problems zipping even push seqs, anyway..
02:25Sgeo__Hmm. You should be able to map onto things that aren't collections >.>
02:26jyfl987abp: oop, you're in german, is it true that your goverment would gave startup founder greencard?
02:26Sgeo__Examples: (map f g) where g is a function could be (comp f g)
02:26tomojheh
02:26Sgeo__Because you're mapping f onto the result of g
02:27Sgeo__Or promises: (map f somepromise-or-future) as returning a new promise or future that will result in f applied to the result of somepromise-or-future
02:27abpjyfl987, I don't know about startup specific immigration. The immigration law is relaxed.
02:27tomojbut that seems more confusing without static types
02:28jyfl987just heard that from my friends
02:28tomojI do wish (= [4 -2] (map [+ -] [1 2] [3 4]))
02:29tomojwell, that doesn't really work out
02:30tomojsince collections can really be functions
02:31Sgeo__"The reducer fns are curried, and they can be easily composed:"
02:31abp,(map (juxt + -) [1 2] [3 4])
02:31clojurebot([4 -2] [6 -2])
02:31abptomoj, isn't that close enough?
02:31Sgeo__..why haven't I thoguht of writing functions that may or may not be curried before?
02:32abpSgeo__, because your type system prevented it? :P
02:32tomojabp: no?
02:33tomoj&(map #(%1 %2 %3) [+ -] [1 2] [3 4])
02:33lazybot⇒ (4 -2)
02:33tomojhmm.. $ is a valid symbol
02:34Sgeo__Hmm.
02:35tomojhttps://www.refheap.com/paste/3711749c6a766e8d801ef611d
02:35abptomoj, ok. :x
02:35Sgeo__eww at all those arglists
02:36Sgeo__I guess the fear is that apply is slow?
02:36tomojyeah
02:38tomojI think IFn in core.cljs has 20 arities
02:38tomoj21
02:45abptomoj, why isn't there a scaffolding macro for high arity fns?
02:46tomojdunno
02:46tomojI've been thinking about building macro combinators and the multiarity case is a looming threat
02:55abptomoj, for macros building fns, do you know of a good way to keep fns capabilities besides destructuring? So, mostly the optionals: meta docstring and name. There's clojure.tools.macro/name-with-attributes. But I don't think that's what I want.
02:56tomojnope, I just copied the bits of defn I needed :/
02:57tomojbut why doesn't name-with-attributes work for you?
02:58abptomoj, I need to process the argument list before building an fn. That defeats the purpose of name-with-attributes because it's complected.
02:59abptomoj, I think the fn built should be what get's passed as the name arg.
03:03abptomoj, I've looked for fn and fn* and thought it all was implemented in Java. Thanks for pointing me to defn. :)
03:04tomojfns don't get docstring/metadata you know?
03:05abptomoj, oh, thats sad. :x
03:06tomojI mean, you can put metadata (and a :doc string) on a fn, but no one looks at it
03:06abptomoj, yeah, with-meta only.
03:06tomojyeah, but even then, e.g. (def foo (with-meta identity {:doc "identity"}))
03:06tomoj(doc foo) will not show that docstring
03:06clojurebotTitim gan éirí ort.
03:07tomojbecause doc looks for metadata in the var
03:08abptomoj, wow, I'm fucked. :D
03:09tomojhave to do (def ^{:doc "identity"} foo identity)
03:09tomoj(which is why name-with-attributes gives you the meta on the name)
03:11abptomoj, sure, but I don't even def. So there will never be (doc ..) support. What about tools that produce documentation? Can I pass them fns and they find :doc meta on the fn?
03:11abp,(meta (with-meta (fn []) {:doc "x"}))
03:11clojurebot{:doc "x"}
03:13tomojthe only tools I know that produce documentation look at nothing more than var :doc metadata and comments
03:13tomojit would seem very odd to pass a fn to something that produces documentation
03:14tomojwhy would you want documentation for a fn that's not accessible by a var?
03:16Sgeo__Maybe it's accessible by a var but the assignment of the fn to the var shouldn't have to deal with placing the doc
03:16Sgeo__As in, (def f (create-some-fn-with-dynamically-generated-documentation 1 2 3 4 5))
03:17tomojhmm.. so write defmeta which copies the meta from the fn :/
03:22abptomoj, I want to define whole applications in terms of special fns, so doc support would be useful.
03:27Rayneswat
03:28abpRaynes, javascript?
03:28dimovichhello all
03:28dimovichwondering, why does:
03:28dimovich(def urls ^{:limit 3} '("http://google.com")) (meta urls) => {:line 1}
03:29dimovichwhat am I doing wrong?
03:29dimovichthe meta is not saved in the var...
03:29RaynesThe metadata goes before the name.
03:29RaynesAlso, you're looking up metadata on the list, not the var itself.
03:30Raynesdimovich: https://www.refheap.com/paste/7101
03:31dimovichi see...
03:31Raynesabp: purple?
03:32dimovichthanks a bunch for the answer
03:32abpRaynes, so, ClojureScript?
03:33RaynesAluminum?
03:39jyfl987abp: btw, can i talk noir related question here ?
03:40abpjyfl987, sure. I don't use it, but others in here. And Raynes maintains it. :P
03:44jyfl987abp: cool, ask author is the best way
03:52RaynesI'm very unlikely to be able to answer questions about Noir. Best luck is with the google group.
04:36tomojSgeo__: #(apply vector %1 (map inc %&)) is (with one sample each..) 15x slower than #(vector %1 (inc %2) (inc %3))
04:36Sgeo__:/
04:37tomoj(((comp c/args c/rest) #(map inc %)) vector) is only 1.11x slower than apply
04:38tomojwhere c is this ns I'm working in
04:38Sgeo__Hmm
04:38tomojr/map doesn't work there
04:41tomojit seems like you should be able to apply to a reducer..
04:46tomojyou can't seq them either. both of those probably make sense
05:00andrewmcveigh|woIs there a function that merges two array-maps and returns an array-map? merge & into both give me a hash-map.
05:02tomojmerge is kind of like a funny name for conj
05:02tomojbut..
05:02tomojarray maps will do that
05:03tomoj&(class (merge (array-map 1 2) (array-map 3 4)))
05:03lazybot⇒ clojure.lang.PersistentArrayMap
05:03andrewmcveigh|wohmm...
05:05tomoj&(class {0 1, 2 3, 4 5, 6 7, 8 9, 10 11, 12 13, 14 15})
05:05lazybot⇒ clojure.lang.PersistentArrayMap
05:05tomoj&(class (assoc {0 1, 2 3, 4 5, 6 7, 8 9, 10 11, 12 13, 14 15} 16 17 18 19))
05:05lazybot⇒ clojure.lang.PersistentHashMap
05:05andrewmcveigh|woSo, if I have more than 8/9 entries
05:05andrewmcveigh|woit merges to a hash-map.
05:06tomojwhy do you want an array map?
05:07andrewmcveigh|woBecause I need to keep order in the map.
05:08tomojgoogle flatland ordered-map
05:08tomojI hope you're on the jvm?
05:09andrewmcveigh|woyeah.
05:09andrewmcveigh|wocheers.
05:09bozhidartomoj: LinkedHashMap preserves the insertion order of memory serves me right
05:10tomojthose aren't persistent collections
05:11tomojbut, thanks, don't think I had that class in my memory
05:12tomoj"This technique is particularly useful if a module takes a map on input, copies it, and later returns results whose order is determined by that of the copy. (Clients generally appreciate having things returned in the same order they were presented.)"
05:12tomojtrue..
05:12tomojI've always sort of ignored the fact that my json comes out scrambled
05:13tomojhurray flatland
05:13andrewmcveigh|woI get the feeling that array-maps are not really used...
05:13tomojthey're automatically used for.. at least small literal maps
05:13tomojfor efficiency
05:14tomojbut eventually hash-maps are faster
05:14andrewmcveigh|woYeah, I think after 8 entries the {} syntax makes a hash-map.
05:25andrewmcveigh|woIs there something funky about clojure.core/reduce1 or is it just because of the java call?
06:16borkdudemy lighttable instance keeps showing the shiny "waiting" logo on startup and hangs
06:16borkdudeanyone else who has this problem?
06:17borkdudeah, removing ~/.lighttable did it
06:37si14can I ask a question about core.logic here? :)
06:38borkdudeyes
06:38borkdude(I wouldn't know what better place)
06:39si14I've tried to emulate Mendelian laws in it yesterday: https://gist.github.com/4155884 how can it be done better? how can I transform this to emulate more than 1 gene?
06:40si14of course I can map this run* over a sequence of genes and generate permutations in plain Clojure, but it's not so interesting
07:26clgvsi14: well, write a unification over a list of genes with your inherito predicate
07:29michaelr525hello
07:40tgoossensas an exercise i'm making my own "distinct" function. i don't understand why it stops working at a certain point:
07:41tgoossens,(map first (group-by identity [1 2 1 3]))
07:41clojurebot(1 2 3)
07:41tgoossens,(map first (group-by identity (range 10)))
07:41clojurebot(0 1 2 3 4 ...)
07:41tgoossensbut
07:41tgoossensstarting from (range 32)
07:41tgoossensit goes wrong
07:41tgoossens,(map first (group-by identity (range 32)))
07:41clojurebot(0 1 2 3 4 ...)
07:42tgoossens,(map first (group-by identity (range 33)))
07:42clojurebot(0 32 1 2 3 ...)
07:42tgoossenswhy is that 32 on the second place??
07:42lazybottgoossens: Definitely not.
07:43tgoossensi'm mind blown
07:44babilentgoossens: My intuition tells me that it is related to chunked sequences
07:45tgoossensmm
07:45babilen,(map first (group-by identity (vec (range 32))))
07:45clojurebot(0 1 2 3 4 ...)
07:46tgoossens,(map first (group-by identity (vec (range 33))))
07:46clojurebot(0 32 1 2 3 ...)
07:46babilenstill :) the 32 just yells "chunked sequence"
07:46tgoossensis it a bug in group-by?
07:47tgoossensbecause to me it does not follow its contract
07:47tgoossens"The value at each key will be a vector of the
07:47tgoossenscorresponding elements, in the order they appeared in coll."
07:48tgoossens,(group-by identity (range 33))
07:48clojurebot{0 [0], 32 [32], 1 [1], 2 [2], 3 [3], ...}
07:49babilenyeah, I've just started investigating in the same direction
07:50tgoossensif so i'll file a bug report perhaps
07:50tgoossensit would be my first time i do that, where can I do it? :D
07:52babilentgoossens: http://dev.clojure.org/jira/browse/CLJ (you need an account though)
07:57p_lcan someone point me why nrepl's symbol-completion breaks on stuff imported by leiningen?
08:00babilentgoossens: group-by is correct, but the resulting datastructure (map) doesn't ensure a certain order of its items -- You might want to sort those first or use an ordered map (such as flatland's ordered)
08:01babilen,(map first (sort (items (group-by identity (vec (range 32))))))
08:01clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: items in this context, compiling:(NO_SOURCE_PATH:0)>
08:01tgoossensi think that is not true
08:01tgoossens,(group-by identity (range 34))
08:01clojurebot{0 [0], 32 [32], 1 [1], 33 [33], 2 [2], ...}
08:03babilen,(map first (sort (group-by identity (range 33))))
08:03clojurebot(0 1 2 3 4 ...)
08:03tgoossensno not exactly
08:03tgoossensbecause
08:04tgoossens[1 1 3 2] -> [1 3 2]
08:04tgoossensmust keep the order of occurence
08:04tgoossensi'll just submit the bug report , i just wrote it
08:04abp,{:a 1 :b 2 :c 3}
08:04clojurebot{:a 1, :c 3, :b 2}
08:05abptgoossens, Clojures maps have no ordering guaranteed.
08:05babilentgoossens: The promise of order is *not* about the k,v pairs of the dictionary but of the internal order of they items
08:05babilen*its
08:06tgoossensi don't get it
08:06tgoossenshow do you explain
08:06tgoossens,(group-by identity (range 33))
08:06clojurebot{0 [0], 32 [32], 1 [1], 2 [2], 3 [3], ...}
08:06andrewmcveigh|womaps aren't ordered, but their vals are.
08:07abptgoossens, group-by returns a map
08:07tgoossensoh
08:07babilenThat's perfectly fine -- All the values are in the order in which they are inserted. As you only have a single one the order is not important. The order of the dictionary itself is not guaranteed
08:07tgoossensoh
08:07tgoossensi get it
08:07tgoossens"the key"
08:07tgoossens[1 1] has two distinct keys, 0 and 1
08:08babilentgoossens: Think about the case that multiple items have the same key -- They would keep their order in the vector that is the value of the key in the map
08:13babilen,(group-by #(Character/isUpperCase %) "bBaAdDcCYyXy")
08:13clojurebot{false [\b \a \d \c \y ...], true [\B \A \D \C \Y ...]}
08:14babilentgoossens: ^^^ for example -- But you still don't have any guarantee about the order of 'true [..]' and 'false [..]'
08:14tgoossensmm
08:14tgoossensok
08:18clgvtgoossens: just destructure the group-by resut with true and false
08:19tgoossensi'll play with it a bit more thanks!
08:20p_lergh. I think knowing CL and being used to SLIME is working against me with Clojure
08:29michaelr525p_l: did you try using ritz?
08:30p_lmichaelr525: so far I went through nrepl.el, nrepl+ritz, counterclockwise and la clojure w/ leiningen plugin
08:30sthuebnerp_l, michaelr525: ritz-swank is very decent and works well enough with SLIME
08:31p_lsthuebner: does it support a version of slime that wasn't best pals with dinosaurs?
08:31p_l(i.e. if it doesn't support current snapshots of SLIME, I'm not touching it. Too much work repairing my environment again)
08:31michaelr525haha
08:36sthuebnerp_l: it supports SLIME 2011-11-13. I tried with snapshot, but there seemed to be a problem with emacs from trunk at the time I was trying it. Didn't take a second shot
08:37p_lsthuebner: afaik that's from before protocol change
08:37sthuebnerp_l: you may wan't to test it with a recent snapshot of SLIME. If it's not working: sorry I talked you into it ;)
08:37sthuebnerp_l: no idea
08:39p_l.act
08:39p_loh well
08:39p_lI'll try at home
08:39p_lthough it will undoubtedly blow memory
08:41sthuebnerp_l: good luck!
08:47FoxboronGreat
08:47FoxboronGet SICP, Joy of Clojure and Clojure Programming on my doorstep, from amazone.
08:47FoxboronSICP and Joy was fucking bent as they didnt manage to stack them properly
08:47Hodappblugh
08:48p_lheh. I got my SICP for £1 in pretty good condition
08:56p_ljust look through university thrift bookstores :)
08:57Foxboronhttps://pbs.twimg.com/media/A8yuqgtCMAARlum.jpg:large
08:57FoxboronWasnt that bad when i opened it up, but srsly. packing books this way D:?
08:57AimHerep_l, yeah, but do you often get really good textbooks of the SICP ilk in those?
08:57AimHereAbout the only really good technical book I found was a first-edition K&R once
08:57p_lAimHere: depends on area, and whether they scrapped good subjects recently? :)
08:59HodappI found 2nd edition K&R for a couple dollars at a Christmas bazaar once
09:01Foxboronwow
09:01FoxboronEven tho i dont like K&R, thats quite cheap
09:03Hodappand I was too unfamiliar with it to realize I'd acquired quite a gem of a book until about 6-7 years later
09:03AimHereIt has the advantage of being thin
09:03Hodappthe bigger advantage is in the language itself that a thin book can express
09:03AimHereFor a time, until ebook readers became commonplace, it was the rule that computer books were as thick and heavy as possible
09:04AimHereTherefore sellers were inclined to price them by the kilo
09:04p_lsomeone here haven't seen medical or physics textbooks
09:05bluegrayhowdy, trying to get this going: https://github.com/hugoduncan/hornetq-clj
09:05bluegraybut I have no idea how to configure hornetq
09:05bluegraylooking for some pointers before I get lost in the docs ;)
09:13bhenryif i have a clojure program that uses java.io.File/createTempFile how can i rename that file when i want to send it in an email attachment later?
09:29solussdgood morning everyone! I need help naming a function. It works like get-in, but handles sequential collections along the way and returns a seq of seqs reflecting the nested structure of the sequential datastructures. e.g. (myfunction {:a [{:b {:c 5}} {:b {:c 6}} [{:b {:c 9}}]]} [:a :b :c]) => (5 6 (9))
09:30solussdI was considering "get-across-in". :)
09:32dfanget-all-in ?
09:33solussdi like that better
09:37edlichIf I compare the Sudokusolver in http://rosettacode.org/ Clojure (41 Lines) is only beaten by Prolog (26 lines). Could this be real?
09:38solussdprolog is designed to tackle problems like that
09:39edlichIs it using trial and error?
09:39edlichI do not understand the code... http://rosettacode.org/wiki/Sudoku#Prolog
09:40dfanIt's basically describing what a vaild solution looks like and then it's Prolog's responsibility to find one
09:40edlichI mean there is no solving talk (but sorry wrong forum for this ;-)
09:41solussdit's not trial and error, it's constraint-based
09:41edlichBut can it be started?
09:42solussdIt's been a long time (college) since I played w/ prolog. I can't read that. :)
09:43edlich;-) ok thanks for all the other answers.
09:43edlichWas just curious...
09:43edlich(But of course logic is important for Clojurianers...)
09:44solussdthere is core.logic one of these days I'll dig into it.. :)
09:45edlichyes, must be important... (god let time rain...)
09:47clgvedlich: what is your exact question?
09:48edlichThe exact question is: is the sudoku solver (rosettacode.org) in Prolog (that beats Clojure in lines) able to start and solve any given problem?!
09:48edlichOr is it just trial and error or a general description, what the solution looks like (the latter would be unfair).
09:48clgvedlich: probably. why not? backtracking is a built-in in logic programming
09:50edlichok, then you can somehow feed the problem(1, [[_,_,_... to it. to the code above?!
09:50dfanIt is a description of what the constraints on a valid Sudoku solution are
09:50dfanAlong with an additional constraint which is the squares that have already been filled in for a specific problem
09:51edlichYes but this is unfair. It also must solve a real world example.
09:51clgvedlich: a sudoku solver in clojure with logic programming: http://dosync.posterous.com/friendlier-shorter
09:51dfanOf course it solves real world examples
09:51edlichups. This is cool stuff. Thanks.
09:51edlichindeed looks a little equal to prologe
09:52edlichFantastic. You really made my day.
09:53clgvedlich: thank david nolen for writing that snippet and core.logic ;)
09:53edlichI will if I ever meet him.
09:55bryanlIs there a more succinct method for entering in math equations in clojure: https://gist.github.com/4156559
09:55bryanlI've been doing it the long way
09:56clgvbryanl: incanter has a macro for infix -> prefix notation
09:57clgvbryanl: incanter.core/$=
09:58bryanlclgv: thanks for the pointer, i'll go take a look
09:59bryanlclgv: that's exactly what i was looking for
09:59bryanlthanks!
10:00edlichIs incanter better then R, Julia or the python libs?
10:01clgvedlich: incanter cant beat R since it has only some basic statistic tests. but I like it for charts since it's clojure ;)
10:02edlichI thought Colt leverages Incanter up in this field...
10:03clgvedlich: huh? isnt Colt just for matrix multiplications and other matrix related operations?
10:03edlichNo it has more.
10:03edlichhttp://acs.lbl.gov/software/colt/api/cern/jet/stat/package-summary.html
10:04clgvthere is no "statistic test" in that package
10:05clgvjust probability distributions and some other functions ^^
10:05edlichyes true
10:05edlichlooks like a missing incanter feature...
10:06borkdudeClojure on R
10:06clgvwell. you can easily "shell out" to R if you need more ;)
10:06babilenI found incanter to be quite unreliable and cumbersome for chart rendering and am still looking for a good alternative
10:07clgvbabilen: I did some rewriting of chart implementations but didnt get to release them yet...
10:07edlichBut bridging C and Fortran zu Clojure will surely be no fun...
10:07clgvbabilen: unluckily they are based on incanter 2.4
10:08babilenclgv: 2.4 ?
10:08clgvuhh 1.2.4 ^^
10:09babilenclgv: Yeah, that is unfortunate. Did you by chance fix the "disappearing labels" bug?
10:10clgvbabilen: no. I did not experience that one. I tried to make charts more composable and to have better "dynamic charts"
10:10babilenclgv: It is just that I have the impression that Incanter development slowed down significantly and that not many people work on it. Sure there was a release spurred by some of the discussions on the ML, but in general it doesn't necessarily strike me as a library that I want to depend on.
10:11josteinkmpan: *nudge*
10:12babilenclgv: Ok - I gave up when I ran into https://groups.google.com/forum/?fromgroups=#!topic/incanter/g2k2M6JllYE and am now investigating Processing
10:13babilenclgv: But it looks as if I will keep on using matplotlib in Python until something reasonable appears in Clojure... :(
10:13dimovichwhenever I modify my project, I need to reconnect the repl to get the new changes...
10:13dimovichis there a way to automatically pull the new changes into the repl?
10:14zerokarmaleftdimovich: depends on what kind of changes you're making
10:14antoineBhello, in cljs i can use: cljs.core.map(function(x) { x; }, [1, 2, 3])
10:14dimovichmodifying some source code in the ns I'm currently in the repl
10:14zerokarmaleftin general C-c C-l will reload the current file
10:14antoineBbut i can use an array of Node?
10:15antoineBi get : [unsupported: no toString() function in type object]
10:16zerokarmaleftdimovich: if i redef'd a bunch of functions then i'll reload the file, otherwise i selectively eval so it gets updated in the repl
10:17dimovichthanks for the tips
10:24antoineBok, i make a mistake the type i was using was HTMLCollection, where i think it was array
10:25antoineBjust extend-type HTMLCollection like it is for array in github.com/clojure/clojurescript/master/src/cljs/cljs/core.cljs
10:59FrozenlockAny updates on if/when the clojure conj videos will be available?
11:00katratxoFrozenlock: https://twitter.com/clojure_conj/status/273614269029941250
11:00pjstadigFrozenlock: https://twitter.com/clojure_conj/status/273614207822487554
11:01pjstadiggah! you beat me
11:01katratxo;)
11:01FrozenlockTerrific, thanks!
11:01Frozenlock(Shame it's still empty)
11:34richoI'm trying to create an image with Graphics2D and serve it up via noir.. but it looks like toString on ByteArrayOutputStream is doing some encoding magic which breakt he image. How do I server up a ByteArray with noir ?
11:40dimovichwhat's the best way to test the matching of a string literal against a collection of strings?
11:41antoineBdimovich: depends what you want, if you to know if there is almost one match, there is a function for that
11:41antoineB*if you want to know
11:42dimovichI got a chunk of an url and need to test if it matches a list of urls
11:42dimovichtrue false is enough
11:43antoineBhttp://clojuredocs.org/clojure_contrib/clojure.contrib.seq-utils/find-first
11:43antoineBmacth the whole list?
11:44mbcevAre there any opinions surrounding UI with Clojure? I know there are tie ins to Swing (besides just making standard Java calls) and Processing, is there anything else? And would you recommend one framework vs another?
11:44TimMcFrozenlock: It usually takes about 5 months.
11:44dimovichstop on first positive
11:44TimMcdimovich: Are you doing routing for a web app?
11:44dimovichno... just some crawling and data extraction
11:45antoineBdimovich: find-first is what you need, for matching the url part to an url you can use regex
11:46dimovichfor regex I need re-pattern but it doesn't escape the string...
11:47FrozenlockTimMc: A little longer than I was hoping :(
11:48antoineBdimovich: http://clojuredocs.org/clojure_core/clojure.core/some
11:48antoineBonly true false result
11:49dimovichyeah, some is what I need
11:49antoineB,(contains? "abcd" "b")
11:49clojurebotfalse
11:50dimovich(re-find (re-pattern "hello?") "hello?") => "hello"
11:50dimovich(re-find (re-pattern "hello\\?") "hello?") => "hello?"
11:50dimovichhow do I automatically escape regex strings?
11:51antoineBhttp://clojuredocs.org/clojure_contrib/clojure.contrib.str-utils2/contains_q look at the source (notice this is not the standard library)
11:51dimovichantoineB: cool, this is perfect... thanks
11:52mrromandimovich: maybe just use .contains from java.lang.String ?
11:54dimovichmrroman: yep
12:01gtrakwould anyone pick Shiro over Friend at this point or something else for clojure-security?
12:01mrromanmbcev: There is also SWT. This is nice alternative to Swing.
12:41SegFaultAXGood morning ladies and gents. How's everyone doing today?
12:48TimMcDespising ExtJS.
12:49mdeboardTimMc: Employer mandate?
12:49TimMcYeah.
12:49mdeboardThat's the best
12:50mdeboardDid they buy a license before talking to the devs? That's my favorite.
12:50TimMcI can't even articulate what I hate about it yet -- but there's something deeply wrong with the design.
12:51TimMcOh, we talked about it first. I recommended against it. "Let's just try it", and the thing grew like a tumor.
12:51TimMcI've recommended against using it on public-facing sites, by the way -- it's riddled with XSS holes.
12:53SegFaultAXTimMc: What's your preferred framework? I'm quite interested in AngularJS, but I haven't used it yet.
12:53TimMcI haven't worked with any JS frameworks. I'm not really sure there's a reason to.
12:54TimMcAngular did look intriguing.
12:56SegFaultAXTimMc: I find that, apart from reducing some of the boilerplate, js frameworks are really useful for organizing and structuring increasingly larger applications.
12:57SegFaultAXMaybe it's just a matter of inexperience on my part, but I feel like there is this hidden threshold in JS where it flips from being reasonable and manageable to complete shit.
12:59SegFaultAXdnolen: Do you build lots of large javascript-heavy applications?
12:59TimMcSegFaultAX: Remember to distinguish between frameworks and libraries.
12:59mdeboarddnolen: For us amateurs however, the code organization SegFaultAX mentioned is a huge plus.
12:59TimMcExt is a framework, through and through -- no cherrypicking of Ext into other apps, and no cherrypicking of other libs into Ext.
12:59dnolenSegFaultAX: I've built very large JS applications in the past yes.
12:59mpenetimo there is no silver bullet, it all depends on the your task
13:00mpenetsometimes low level is better, sometimes angularjs like is good
13:00TimMcI feel like require.js, jquery, and a nice CSS grid would get us all the benefits of Ext without the disgustingness.
13:00mdeboardTimMc: Yuck
13:01SegFaultAXmpenet: The problem I struggle with is js isn't really designed for large applications. It lacks certain (what I consider to be basic) language-level features that make that task reasonable. Modules are my go-to example.
13:02mpenetSegFaultAX: I agree, there is no standard way to do this anyway, most of the time JS devs reinvent this in some way or another
13:02mpenetSegFaultAX: Which almost always ends up in a house of cards
13:03SegFaultAXmpenet: Yes! :(
13:03S11001001,(class (into-array ["hi"])) ; nDuff
13:03clojurebot[Ljava.lang.String;
13:03S11001001nDuff: you don't have to remember
13:03raeknDuff: semicolon at the end... :)
13:11sundbphow do i set a breakpoint with nrepl-ritz?
13:14hugodsundbp: C-c C-x C-b on the line you want to break at
13:14nDuffS11001001: I wasn't sure that my problem was within the quotes; thus, knowing how to look up the class name didn't provide certainty. Clearly, though, such was in fact the case.
13:15sundbphugod: ok, cool
13:16sundbphugod: doesn't seem bound. what's the function and i can see if bound at all?
13:19hugodsundbp: slime-line-breakpoint or slime-java-line-breakpoint (in .java source)
13:19hugodsundbp: provided in the slime-ritz.el package
13:19sundbphugod: for nrepl those are still the functions?
13:19S11001001nDuff: multi-step process of elimination
13:20hugodsundbp: ritz for nrepl doesn't support breakpoints yet
13:20sundbphugod: ok. i see
13:21hugodsundbp: breakpoints in nrepl will be simple to add - just haven't got to it yet
13:22sundbpsundbp: break on exception seems to leave the nrepl session hanging. says "b-o-e calling nil nil"
13:23justixI'm trying to get clojure-test-mode working. My project is structured in according to default lein projects with a /src and /test directory but for some reason "C-c t" tries to make a new file in /src instead of /test/path/to/ns.clj. is this a common issue?
13:34sundbphugod: switched to ritz-swank and now b-o-e does the right thing
13:36hugodsundbp: was that ritz-nrepl 0.6 you were trying?
13:37sundbphugod: yes
13:37sundbphugod: i typed wrong nick, if you missed this is what i see: sundbp: break on exception seems to leave the nrepl session hanging. says "b-o-e calling nil nil"
13:39borkdudewhat is the paredit command for )) "foo") -> ) "foo" ))
13:39hugodsundbp: mm, I've seen that in 0.5, but not in 0.6 :(
13:40langmartinborkdude: that's called "slurp"
13:40langmartinM-s
13:40zerokarmaleftborkdude: slurp-forward from the second )
13:40sundbphugod: list packages shows: nrepl-ritz 0.6.0 installed
13:40borkdudeah, so I have to move backwards first if my cursor is on "foo"?
13:41hugodsundbp: it will be the lein-ritz plugin that makes a difference for this
13:42borkdudewhy is this invalid clojurescript? (set! (.innerText (.getElementById js/document "myP")) "foo")
13:42sundbphugod: $ grep lein-ritz ~/.lein/profiles.clj
13:42sundbp{:user {:plugins [[lein-ritz "0.6.0"]
13:42langmartinborkdude: sorry, C-right is the binding for it. I can type paredit bindings, but my verbal brain can
13:42langmartin't do them
13:42ro_stborkdude: .-innerText
13:43borkdudero_st why the minus?
13:44ro_st.innerText becomes x.innerText()
13:44ro_st.-innerText becomes .innerText
13:44ro_stfun, ain't it
13:44borkdudero_st ah I see
13:45borkdudero_st I was trying the -> macro before, does it work with properties instead of methods?
13:46ro_st(set! (.-innerText (.getElementById js/document "thing")) "woohoo!")
13:46ro_stthat should work?
13:46borkdudero_st that works, yes
13:46borkdudero_st but can we rewrite it with ->?
13:47ro_stif the macroexpansion of -> makes it look like the above, then yes :-) -engineer answer-
13:47ro_stargh. http://melpa.milkbox.net/packages/ is returning a 403. can't install packages to emacs
13:48borkdudelike this: (-> js/document (.getElementById "myP") .-innerText (set! "foo"))
13:49borkdudeyes, it works
13:49borkdudefinally :-) -. did it
13:50ro_stspelunking in cljs, finally? :-)
13:51borkdudejust trying some little things, nothing special
13:55ro_stso no google+ killer yet
13:56borkdudero_st does it need a killer? I hardly use it :)
13:57ro_stme neither. picked the first massive js app i could think of :-)
13:58ro_stfinally caving and installing nrepl.el
14:10borkdudewhat is the best way to print/str a (finite) lazy seq?
14:11borkdudewrap it in a seq call works, but why?
14:14Raynes&(pr-str (range 10))
14:14lazybot⇒ "(0 1 2 3 4 5 6 7 8 9)"
14:14Raynesprn works
14:14Raynesborkdude: Get anything out of the Haskell blog post?
14:16borkdudeRaynes ah the pr-family is what I should use, tnx
14:17borkdudeRaynes I thought it was interesting, but I have to dig into Haskell deeper to totally get it. It seems like a lot of work to parse JSON, but you get typesafety in return
14:17borkdudeRaynes I like your style of writing
14:18borkdudeRaynes applicative functors are definitely something I will read about more
14:20borkdudeI'm trying to wrap my head around why lazy evaluation is something most FP academia prefer
14:23borkdudeis this allowed in clojurescript?
14:23borkdude(def fib (lazy-cat [0 1] (map + fib (rest fib))))
14:23borkdude(js/alert (pr-str (take 20 fib)))
14:24borkdudeI get an error… maybe Haskell would tell me this before the compiler claimed to have succesfully compiled this? ;-)
14:24p_llol
14:33borkdudeI notice replacing with concat still doesn't work. maybe it has trouble understanding the recursive definition of the lazy list?
14:35TimMcborkdude: It fails with a type error, so yes.
14:35TimMc(yes, Haskell would catch that)
14:36tomojwhy is it a type error if it works in clojure?
14:36TimMcIt doesn't work in Clojure.
14:37TimMcClassCastException clojure.lang.LazySeq cannot be cast to java.lang.Number
14:37borkdudeit works here
14:37TimMcOh, I know what I did wrong...
14:37TimMcStupid nth.
14:41borkdudewhy do I always find strange bugs by trying out almost the first thing in a new technology I'm trying out
14:41borkdude-I'm trying out, that was duplication
14:42borkdudein the F# console I found a bug by typing in "1" as an expression, it crashed
14:42p_lhaha
14:42p_lsounds like a gift
14:42piskettia superpower
14:44TimMcYou've got a bright career in QA.
14:44TimMcor pentesting, probably
14:46p_ljust as long as he isn't supposed to be the user
14:47borkdudeis there a document that lists what is and isn't possible in clojurescript?
14:48redingerborkdude: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
14:48redingerIt may not be what you are looking for, but it always helps me when things don't go as expected
14:50borkduderedinger tnx
14:52mklappstuhlHey
14:53mklappstuhlI'm trying to give kibit a spin so I added it to my ~/.lein/profiles.clj like so:
14:53mklappstuhl{:user {:plugins [[lein-kibit "0.0.7"]]}}
14:54mklappstuhlrunning "lein kibit" returns an error that the given task is not available though
14:57tomojborkdude: curious, what was the error?
14:58borkdudetomoj in javascript?
14:58clojurebotjavascript is beautiful, you're just too conformist to appreciate its quirks: http://tinyurl.com/7j3k86p
15:00jonasenmklappstuhl: weird. What does "lein version" report?
15:00mklappstuhlLeiningen 1.7.1 on Java 1.6.0_24 OpenJDK 64-Bit Server VM
15:01mklappstuhljonasen, -.-
15:01borkdudedoh
15:01mklappstuhljonasen, thanks ;)
15:01Raynescemerick: Hope I didn't scare you too bad with the Haskell.
15:01jonasenmklappstuhl: np
15:01Raynescemerick: I'm assuming the ceremony involved surprised you?
15:03borkdudeI'm not continuing clojurescript until this mystery is solved
15:03jonasenmklappstuhl: the latest version requires lein 2. I should fix that.. either by mentioning it in the README or by actually supporting lein 1.x
15:04borkdudelein 1 or 2 it is the special case in clojure, just like f [] = [] in haskell
15:05borkdudeRaynes can't they make an abstraction for the "empty" cases in Haskell, f [] = [] seems boilerplate to me ;)
15:07mklappstuhljonasen, works fine, took 2 min
15:08borkdudeRaynes like f belongs to the group of such and such operations and [] is the identity in this group, so I don't have to specify that case
15:08mklappstuhljonasen, nice thing you built there btw :)
15:09XPheriortechnomancy: Remember that issue you opened for Korma a while back?
15:10jonasenmklappstuhl: thanks
15:11cemerickRaynes: terrified
15:12cemerickReading the post was something like "ok...ooookayy...buh?...WTF!?" :-)
15:12Raynescemerick: :p
15:12borkdudecemerick the hardest part of reading Haskell are those terrible infix operations ;)
15:12TimMc'strue
15:12tomojborkdude: yeah, with your fibs
15:13cemerickborkdude: I can cope there.
15:13borkdudetomoj actually now I get a lazyseq in the console, but it contains null
15:13Raynescemerick: You should see that FromJSON instance without the applicative functor stuff.
15:13RaynesYour face would explode
15:13cemerickheh
15:14kaoD_this is probably a stupid question, but anyways...
15:14kaoD_what is my best shot at overriding some object's behavior?
15:14borkdudeRaynes cemerick maybe it's more work, but you should take into account what the type system can do for you, does it save time in the future, less bugs?
15:14kaoD_let me explain this further
15:14borkdudeRaynes cemerick or is it just a pain in the ass until the end
15:15kaoD_e.g. I want a vector with the ability to index negative indices
15:15cemerickReally, the worst part was the last example, of arbitrary key lookup
15:15kaoD_so I have to reimplement nth
15:15Raynescemerick: I keep thinking there is a better way to do that, but I haven't found one.
15:15cemerickborkdude: Yeah, I'm familiar with the tradeoff, to some extent; used scala for a while some years ago
15:15kaoD_my best shot is reifying IPersistentVector and implementing ALL methods?
15:15borkdudekaoD_ You should use Python for that :P
15:15Raynesborkdude: I think the type system is very fun and useful, but it makes stuff like json parsing utterly horrid.
15:16kaoD_borkdude: or any other dynamic-obect language, I know, but... had to ask
15:16cemerickkaoD_: Just use a map?
15:16kaoD_cemerick: I can't see what you mean
15:17kaoD_I want this object to still behave as a vector, btw
15:18cemerickI'm far more optimistic about the post-hoc typing and verification potential of Typed Clojure (/ Racket). No up-front penalty, pay the price of typing when you know what benefit you're hoping to get from that effort.
15:18cemerickkaoD_: negative indices sound as edge-case-y as e.g. a sparse vector
15:19cemerickwhich is also modeled naturally as a map
15:19kaoD_cemerick: okay, then it was probably a bad example
15:19kaoD_I do have a certain algorithm to re-sort a vector deterministically
15:19cemerickkaoD_: You can definitely do what you want (proxying APersistentVector is probably easier) but it sounds a bit sketchy.
15:20cemerick"re-sort"?
15:20kaoD_yep, have it sorted in other order
15:20cemerickits values, you mean?
15:20kaoD_nope, its indices
15:21kaoD_I do have a function f(index_sorted) = index_original_vector
15:21ttimvisheris there a library function that trims a string to a maximum length at word boundaries?
15:21kaoD_so I thought I could implement this function on top of nth so the new sort order is implicit and the vector is still the same
15:21kaoD_which is O(1)
15:22kaoD_which is cool for huge arrays
15:22kaoD_*vectors
15:22kaoD_see where I'm going?
15:22ttimvisherie (trim-at-boundary 10 "a quick brown") => "a quick"
15:22kaoD_ttimvisher: does Java implement something like that? probably
15:22borkdudethis cljs compiles to this javascript, any pointers what's wrong? https://www.refheap.com/paste/7122
15:23tomojyou can't (def fib (concat x fib))
15:24kaoD_cemerick: I know that shit is a bit sketchy and I should probably just use the mapping function myself instead of hacking into PersistentVector
15:24llasramOoh -- I think applicative functors are exactly the formalization I've been looking for for a problem I'm facing
15:24kaoD_but I just wanted to know if it could be done
15:24tomoj(lazy-cat x fib) works because it doesn't evaluate 'fib until later
15:24llasramRaynes: Thanks for the reference!
15:24Raynesllasram: ?
15:24RaynesOh.
15:25ttimvisherkaoD_: you'd think that. i don't see anything obvious in google yet.
15:26borkdudetomoj good point
15:26borkdudetomoj I should probably give up on trying this until we have lazy-cat?
15:26cemerickkaoD_: It's definitely doable, and maybe isn't particularly difficult, but the result definitely won't be a sane vector.
15:27cemericke.g. vectors are associative just like maps, so you'd get into issues where (not= (v 0) (first v))
15:27cemerickI dunno what that might break.
15:28kaoD_cemerick: I planned on reimplementing the whole interface chain
15:28kaoD_so that the association is still valid
15:29kaoD_if the vector internal structure isn't used anywhere outside these interfaces I should be fine, right?
15:29kaoD_ttimvisher:
15:29kaoD_&(.substring "012345" 0 4)
15:29lazybot⇒ "0123"
15:29kaoD_you wanted that, right?
15:29kaoD_stop Googling and check JavaDoc FFS ! :P
15:29cemerickHow could you square the fact that (first v) will return what (v -5) might return?
15:30kaoD_cemerick: humm, you might've missed the explanation of my real use case
15:30cemerickprobably
15:30kaoD_I'm just reordering the indices
15:30kaoD_that was a (probably bad) example
15:31kaoD_I do have a function f(index_sorted) = index_original_vector <- so wrapping this function around ANYTHING that accesses vector's indices should be fine
15:31kaoD_indices would still be 0 <= i < length
15:31kaoD_they're just re-mapped
15:32borkdudekaoD why not just use that function to access the elements?
15:33cemerickIndeed, just change the indices you're using to do lookups.
15:34tomojborkdude: I hadn't noticed we didn't
15:34tomojI wonder if it was mistakenly left out?
15:34tomojit's excluded in cljs/core.clj
15:34cemerickkaoD_: hacks aside, you're describing a map :-)
15:34kaoD_cemerick: yeah but I still want it to behave as a vector
15:34cemerickThe fact that the keys happen to be a set of contiguous integers is happenstance.
15:35cemerickwhy?
15:35clojurebotcemerick: because you can't handle the truth!
15:35kaoD_I just want to avoid actually reordering the vector
15:35tomojbut I don't see why the exact def from core.clj wouldn't work
15:35kaoD_I'm trying to shuffle a vector deterministically
15:35kaoD_but I don't want to actually shuffle it
15:35kaoD_because my vector might be freakin' HUGEEEEEEEE
15:35kaoD_doing it like this adds a bit overhead to accessing
15:35kaoD_but anyways, the operation is O(1)
15:36kaoD_much better than O(my god that vector is huge)
15:36kaoD_and I want it to be chainable so I can shuffle it many times without much overhead
15:36cemerickwell, you can definitely subclass APV to apply a mapping to indices on lookup, seq creation, etc.
15:36kaoD_and still feel as a vector
15:37cemerickBut, premature optimization. Don't bother until you actually need to.
15:37kaoD_cemerick: this is just a mental exercise, I don't really care about optimization
15:37kaoD_in fact I don't even really care about this problem
15:37kaoD_it was just posted somewhere and it made my mind start wondering what would be the most optimized version
15:38kaoD_about reimplementing APV, that's what I thought...
15:38kaoD_thanks for your time!
15:38borkdudekaoD a total function of the indices to the shuffled indices (a map of index to index) only adds a near constant extra overhead
15:38kaoD_borkdude: yup, that's what I'm trying to do?
15:39kaoD_I know it's optimized... now I just want to know if I can make it happen and make it still feel as a vector
15:39kaoD_oh, you mean
15:40kaoD_<borkdude> kaoD why not just use that function to access the elements?
15:40kaoD_yep, I said that earlier
15:40kaoD_it's a possibility
15:40kaoD_but
15:40kaoD_(nth (range 5) (my-function 3 237 4) doesn't feel as good as (nth (range 5) 4)
15:41kaoD_and I dare you chain that and make several shuffles
15:41kaoD_(nth (range 5) (my-function 3 237 (my-function 3 237 (my-function 3 237 (my-function 3 237 4)))) ?????? PLEASE NO
15:41kaoD_specially when it has to be in every call
15:41borkdude(nth (range 5) (my-map 4)) would do it
15:42kaoD_I would still have to: 1. create the map
15:42kaoD_2. use (nth (range 5) (my-map 4)) everywhere
15:42kaoD_3. chain using (nth (range 5) (my-map (my-map (my-map 4))))
15:42kaoD_4. create SEVERAL maps when the parameters for the shuffling functions aren't the same
15:43kaoD_5. it only works with nth... what's going to happen when I try to print the vector?
15:43kaoD_6. FFS, that's not even kewl!
15:44kaoD_7. I just want to pass around that object and make it still behave as if it was shuffled
15:44ttimvisherkaoD_: not quite. "a quick brown" 10 => "a quick"
15:44kaoD_but still behave as a good ole vector
15:44ttimvishernotice the break at the word boundary, even though there were more characters available
15:45tomojRaynes: what if you want to pull out a nested field? (w/ aeson)
15:45ttimvishersubstring works if you don't care about word boundaries. :)
15:45kaoD_oh I see
15:45kaoD_you'll have to DIY
15:46borkdudekaoD_ maybe you could write it as a lazy sequence instead of a vector (just an idea, not sure if it will work)
15:46ttimvisherkaoD_: looks like it :)
15:47kaoD_borkdude: I thought about that too
15:47kaoD_but I want random access
15:48kaoD_I don't want a sequence, I want a vector
15:48kaoD_I want to keep types
15:50Raynestomoj: It'd be basically the same.
15:50tomojah right, ((v .: "foo") .: "bar) <*> ... ?
15:51RaynesNot quite.
15:51RaynesIt's a monad, so you'd do ((v .: "foo") >>= (.: "bar"))
15:52akhudekAmazing. The compiler is telling me that I'm passing -2 arguments to core$max.
15:52Raynesakhudek: You're pretty good at this then.
15:52Raynes:p
15:52tomojoic
15:53tomojI wonder why I get "Couldn't match expected type `Text' with actual type `[Char]'" trying to use .:
15:53Raynestomoj: It expects Text, not a string. Use the OverloadedStrings extension.
15:53RaynesOr you can import Data.Text and pack your strings, but that's a pain in the ass.
15:54tomojoh, should have looked at your final code, thanks
15:56TimMcakhudek: macros take 3 extra args behind the scenes
15:57tomoj3?
15:57TimMcWait, sorry -- max is a fn.
15:58borkdudeRaynes did you know there is a Haskell to js compiler?
15:58RaynesTimMc: You didn't have your orange juice toda did you?
15:58Raynestoday*
15:58TimMctomoj: 2? >_>
15:58mpenetborkdude: there are several
15:59TimMcRaynes: You can tell, huh?
15:59mpenetborkdude: but Fay is the hot thing atm
15:59clojurebotRoger.
16:00borkdudempenet ah, ok cool. I was only familiar with this one http://uu-computerscience.github.com/uhc-js/
16:00brehautRaynes: im a little rusty, but is foldM .: v ["foo" "bar"] the equiv of that bind thing you showed earlier?
16:00mpenetborkdude: haste, ghcjs, fay, and another one I can't remember
16:01mpenetborkdude: and some lookalikes, ex roy
16:01Raynesbrehaut: A hideous version of it, but I think so.
16:01brehauthaha
16:03mpenetborkdude: fay and roy are nice, they are usable in real world apps, not sure about the others
16:04brehautmpenet: borkdude: roy is however close to becoming more useable; puffnfresh has been rewriting the type system, and there is talk of a standard library
16:04mpenetbrehaut: Yup I saw some commits flying today :)
16:04brehautoh nice :) thats even closer than i realised
16:04mpenetbrehaut: I like roy a lot
16:04brehautmpenet: likewise
16:05mpenetbrehaut: fay is nice as well if you want to integrate with server side haskell
16:05mpenetyou can shore types prety much
16:05mpenetshare*
16:05mpenetsince it's very close to "real" haskell
16:06brehautinteresting. i should have a look at it
16:06borkdudegreat info
16:06borkdudetnx
16:06scriptordo fay and roy have different niches?
16:07mpenetI use haskell as a test keyword on an analytics app I am working on, Fay is trending big time lately
16:07mpenetscriptor: roy learning curve is minimal
16:07brehautmpenet: have you looked at funscript at all?
16:07mpenetscriptor: and more appealing to scala people I would guess
16:07brehautmpenet: its very new, and from F# people
16:08mpenetbrehaut: never heard of it
16:08mpenetI will have a look thanks
16:08brehautmpenet: based on what ive heard aboout the stdlib, i imagine the 'appeals to scala people' is going to increase :P
16:08mpenetbrehaut: Yeah and it's getting integrated with Play I think
16:08brehautmpenet: its very much F#-like → JS style
16:08borkdudeit would be sick to build a json parser in to-js compiled haskell though
16:09brehauti actually want roys type checker as a stand alone library so i can use it as a schema language for json
16:10brehauttalking of roy http://turtle-roy.heroku.com
16:12mpenetThat said I have high hopes for typed clojure, once it matures.
16:13FrozenlockHow does the leiningen standalone works? I can't seem to give it any arguments: "no main manifest attribute, in leiningen-2.0.0-preview10-standalone.jar"
16:13gf3brehaut: Is that even possible?
16:13brehautgf3: why wouldnt it be?
16:14gf3brehaut: I suppose I just don't know enough about language implementation, but I thought a lot of that would depend on the actual language in use?
16:15brehautgf3: what do you mean by 'the actual language in use'?
16:15gf3brehaut: For example, you wouldn't be able to simply tack on Roy's type checker to something like JavaScript
16:16Raynescemerick: Delta finally refunded my tickets. :D
16:18brehautgf3: well, no not without writing some code. but a type checker as a library is not really any different to any other validation library that you could apply to some data
16:18brehautgf3: i'd particularly want it for JSON (ie, data only) rather javascript
16:18brehaut(that is ~typescript from MS incidentally)
16:18gf3brehaut: Cool—I was just curious
16:43brainproxywoohoo, roman numerals parsing in clojure: https://gist.github.com/4163403
16:44brainproxyhad fun today with Alex Miller and the other clojurians at St. Louis Clojure Lunch Cljub
16:44RaynesUgh
16:44RaynesCljub? Really?
16:44RaynesPeople need to get over the j.
16:44brainproxyhehe, yeah....
16:51TimMcClsub
16:51tomojalready dropped the tld from my ns names. datomic's tendency to require full qualification makes me want to drop my domain too and put the project name as the first ns segment :/
16:51dfanNit: That to-roman isn't taking a decimal, it's taking an integer
16:52TimMctomoj: I feel blessed to have a short domain name to use: timmc.org
16:52dfan147 is an integer, "147" is the decimal representation, "CXLVII" is the Roman numeral representation
16:52TimMcNow if I can just establish a business presence in Monaco, maybe I can get tim.mc
16:53seangrovetomoj: Datomic or codeq?
16:54lynaghk`seangrove: I just saw your reflex question from the other day. It works fine in cljs, though the cljs compilers that lein cljsbuild 0.2.8 and 0.2.9 use break it mysteriously (this has since been fixed in cljs master).
16:55lynaghk`seangrove: w.r.t. reflex in general, all it really does is wire up a ton of callbacks for you, so you don't have to do it manually. All of the caveats of using callbacks (they highjack the execution thread when someone just changes an atom, you can tie yourself up in infinite loops, &c. &c.) still apply.
16:56seangroveYeah, I'm just finding that UI programming is hellish, looking for a sane way of containing it
16:57seangroveTesting Shoreleave's pubsub now, but I haven't seen too much in the way of recommended approaches to building maintainable ui's in cljs
16:58lynaghk`seangrove: yeah, we have our own not-yet-open-sourced pubsub system
16:59lynaghk`seangrove: the problem is inherently pretty hellish---I haven't found a real general solution that I'm super happy with
17:00seangroveI'm wondering if at some point it might be a fun project to read Interface Builder's nib files into a structure that works with a cljs library
17:00seangroveBasically taking the approach that objective-j did to take advatnage of all the existing tooling
17:01seangroveBut it might be too tied to the objective-c way of doing things, not sure. Anyway, a project for another day
17:01lynaghk`seangrove: that's a project for another man-year =P
17:08tomojseangrove: datomic
17:24hugoddnolen: I'm getting ({:nn {:mx _.0}} :- (not-pathc (_.0 [:nn :mx]))) as a result from run* - I'm wondering if I'm doing something wrong, or if defc is missing something
17:24hcumberdaleHi ;)
17:27tgoossensmutual recursion, it screws up my mind :p
17:27Chousukehow come? It's just functions calling each other.
17:28tgoossensi just heard it for the first time (trampoline and stuff). So maybe i still have to place it :p
17:29Chousukeoh, trampoline
17:29Chousukeyeah, trampoline is a bit weird
17:29tgoossenscannot think of something useful to do with it
17:29kaoD__tgoossens: www.4clojure.org helped me get past some issues learning
17:29tgoossensprobably show up when i need it
17:29tgoossenskaod: well it is at 4clojure in encountered p
17:30tgoossens*i encountered it
17:30Chousuketgoossens: non-stack-growing mutual recursion can be very useful in eg. modeling state machines.
17:30Chousukeyou just write functions that represent each state and then call back and forth
17:30tgoossenshmm yes
17:30tgoossensi see
17:30tgoossenscool
17:30p_leh, what wretched times have came that people don't remember what "trampoline" means :D
17:31tgoossensthat's actually a pretty good example
17:31dnolenhugod: I need to see a minimal case
17:31tgoossensits like
17:31Chousuketgoossens: but the way trampoline works is pretty simple. instead of recursing directly you write functions so that they return continuations
17:31tgoossensask a state "what is the next state"
17:31tgoossensand trampoline will keep doing this
17:32tgoossensuntil it ends (no function anymore)
17:32Chousukeso when the function ends, its stack is unwound and its continuation is returned to the trampoline, which calls the continuation.
17:32tgoossensis that correct?
17:32hugoddnolen: ok, I'll try and put one together
17:32Chousuketgoossens: trampoline is necessary in clojure because clojure can't do general TCO
17:32tgoossensTCO?
17:32clojurebotyes please
17:33hcumberdale,(flatten (map (fn [[x y]] y) '(["x" (a b c)] ["y" (d e f)])))
17:33clojurebot(a b c d e ...)
17:33Chousuketgoossens: tail call optimization (or elimination)
17:33tgoossensah yes
17:33tgoossensso like
17:33tgoossensthe (loop recur)
17:33Chousukeyeah, that's the self-recursion case of TCO
17:34tgoossensi tried to read macro's but they are quite complex
17:34Chousukewhich macros?
17:34tgoossensloop for example
17:34hcumberdaleAny better way to write this? ,(flatten ...
17:35tgoossensor maybe it is just me not being familiar with it so "hard" is a better word perhaps.
17:35Chousukehcumberdale: if you have only one level of nestirng, try (mapcat second whateverC)
17:36Chousuketgoossens: many macros are very straightforward once you have a mental model of what is actually going on
17:36hcumberdalewow Chousuke, thx
17:36Chousukesome aren't though...
17:36mbcevquick question regarding some code I read in the "Joy of Clojure" book. There's a bit describing loop and they have something along the lines of (loop [sum 0, x x-initial] (if (pos? x) (recur (+ sum x) (dec x)))) my question is does [sum 0, x x-initial] set sum to zero and x to x-initial? I know the loop takes 2 arguments which is why recur gives back both, what happens to the 2 and x-initial and how does clojure know that those aren't required arguments?
17:37Chousukembcev: they are the initial values
17:37TimMc~flatten
17:37clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
17:37TimMchcumberdale: ^
17:37Chousukembcev: loop takes a binding vector, like let
17:37TimMchcumberdale: Wait, that doesn't mention "for", which is another thing to use instead of mapcat.
17:38hcumberdaleWow, there is really mapcat in the reference
17:38hcumberdale;)
17:38mbcevChousuke: well what if in a different example I just opted for [x y] where x and y were defined by an outer let or what have you.
17:38AimHere "A map of the cat, sir?" she asked, horrified.
17:39TimMcSurely you're joking.
17:39Chousukembcev: what do you mean?
17:39Chousukembcev: the form of a binding vector is [name value, name2 value, ...], commas being optional
17:39tgoossenslol
17:40mbcevChousuke: oooohhh, got it. So it's because loop is a special form right? and thus takes a binding vector as you said, not just any ol vector like when I define my own function.
17:41Chousukembcev: pretty much
17:41mbcevChousuke: Thanks! <3
17:41Chousukembcev: loop is a macro, actually, but it uses a special form internally.
17:42jebberjebwith clojure-ring, if I've :gen-class :extends HttpServlet, is there a way to get a reference to the servlet so I can invoke .forward()?
17:42Chousuke,(macroexpand '(loop [[x y] example] dostuff (recur 1 2)))
17:42clojurebot(let* [G__66 example vec__67 G__66 x ...] (loop* [G__66 G__66] (clojure.core/let [[x y] G__66] dostuff (recur 1 2))))
17:43hcumberdaleIs there a contains? for string?
17:43hcumberdaleOr do I have to use some?
17:43Chousukehcumberdale: use java string methods
17:43Chousukeor regexp patterns.
17:44hcumberdaleChousuke to check if a list contains a string?
17:44Chousukeoh, that
17:44joegallo_,(some string? [1 2 3])
17:44clojurebotnil
17:45Chousukeusing some is good for that.
17:45joegallo_(some string? ["abc" 1 2])
17:45mbcevChousuke: OHHH thank makes more sense; I'll look at the source next time. Herp derp. Thank you.
17:45joegallo_,(some string? ["abc" 1 2])
17:45clojurebottrue
17:45Chousuke,(some #{"foo"} '("a" "list" "foo")) this is idiomatic as well
17:45clojurebot"foo"
17:46hcumberdaleChousuke right, but does not output true or false/nil
17:46Chousukehcumberdale: that doesn't matter
17:46Chousukeif you need a boolean, just call boolean on the result :P
17:46Chousukebut most of the time you can just use the result as is
17:47Chousukeso long as you're not actually searching for the literal false
17:47hcumberdale,(if nil "x" "y")
17:47clojurebot"y"
17:47hcumberdale,(if "foo" "x" "y")
17:47clojurebot"x"
17:52jebberjebwhat is ring.util.servlet.proxy$javax.servlet.http.HttpServlet$0
17:53hcumberdalethe #clojure IRC channel is so awesome
17:53rattboi^^ this is true
17:54hcumberdaleWriting so much clojure code since i've taken a lot barriers thx to the people here
18:02black_joeCan someone help me with my problem in Clojure? The example is a bit tricky.
18:02black_joehttp://pastebin.com/FFqeHT5K
18:02black_joeIt gets into an infinite loop with the following parameters:
18:02black_joe(make-struct '("list" ("x" "b")) '("t" "x"))
18:02black_joeBut the or should handle that.
18:06AimHereYou tried using empty? instead of (= foo '())?
18:06AimHereI think it's slightly more idiomatic
18:07black_joeI will try that.
18:07tomojnot slightly
18:07black_joeI usually use a home-cooked function called bad?, but I threw that away for debugging purposes.
18:07brehaut,(when (seq [1 2 3]) :true)
18:07clojurebot:true
18:07brehaut,(when (seq []) :true)
18:07clojurebotnil
18:08brehautusing seq to test the positive case rather than empty? to test the negative case is a bit more idiomatic if you are using both branches
18:08black_joeempty? has no effect. It plunges into an infinite loop, collecting nil on the conj.
18:10metellusblack_joe: I think there might be an extra closing paren in your if
18:10metellusso the recur part is always happening, rather than being the else case
18:11devnim trying to update a clojurescript dependent library and am running into errors when running the tests
18:11devnhttps://github.com/devn/hiccups
18:11devnAnyone mind taking a peek?
18:11black_joemetellus: Man... That was a pretty silly mistake. I've been messing with this for quite a while. Thanks.
18:12devn"actual: java.lang.AssertionError: Assert failed: set! target must be a field or a symbol naming a var
18:13devntargetexpr"
18:13AimHereblack_joe, I see your problem
18:13AimHereblack_joe, you've got one too many right parens at the end of your if
18:13AimHereSo it's just doing the if, then throwing the answer away, and then always recurring
18:14bbloomdevn: that's a compile error, right? what line is it on?
18:14AimHereblack_joe, oh, someone's seen it
18:14black_joeYeah. That was actually helpful. It works now.
18:14AimHereGet your code indented properly!
18:15AimHereYou'd see it!
18:15black_joeAimHere: It's just sloppy because I was debugging. Adding / subtracting lots of stuff.
18:16devnbbloom: analyze.clj #570
18:16bbloomdevn: i mean in your code
18:16devnbbloom: i just bumped the clojurescript version again, should be on the most recent release
18:17bbloomdevn: I can find what line the message is on in cljs :-)
18:17devnbbloom: oh, heh, well, im guessing you can also read the stacktrace
18:18devnim seeing it around line 12 in test/hiccups/test_runner.clj
18:18devnthis isn't "my" code -- just trying to get it up to date
18:19bbloomdevn: I've been meaning to replace the asserts and throws in analyze and emit with proper error-raising functions, so that you can get some line numbers....
18:20devnbbloom: yeah, sorry i don't have much more info at the moment
18:20bbloomdevn: so line 12 in test runner is running the compiler
18:20bbloomdevn: need to know what line is failing to compile
18:20devnthere isn't a ton of code in this lib. does anything stand out to you?
18:20devnbbloom: yeah, understood that as soon as i hit return
18:20devnim hunting
18:22devnbbloom: any suggestions on narrowing it down?
18:24bbloomdevn: get a local checkout of cljs' master and i'll give you a patch in a few minutes to help :-)
18:24devn!!! :)
18:24devni've got one handy
18:25devnbbloom: if it's any help at all, this was the error I was getting against a year-old version of clojurescript:
18:25devn actual: java.lang.IllegalArgumentException: No implementation of method: :-requires of protocol: #'cljs.closure/IJavaScript found for class: clojure.lang.MapEntry
18:32devnbbloom: fire when ready
18:32bbloomdevn: testing
18:33devnbbloom: thanks for the help
18:34bbloomnp, this has been bugging me too :-)
18:34bbloomdevn: good error messages are hard to do.
18:35devn:)
18:37Sgeo__If I'm making an API with an event loop, should I have events run in their own threads?
18:37Sgeo__Hmm, probably not
18:37Sgeo__Actually, I have no idea what I should do
18:37bbloomSgeo__: are you doing much IO?
18:38Sgeo__IO but with a server somewhere via an SDK
18:38bbloomdevn: waiting for some test runs :-)
18:38Sgeo__I do want to be able to sleep, the way that something might pause for 5 seconds in a game
18:38Frozenlo`Uh Oh... I get a "REPL server launch timed out". Is there some argument I can give Leiningen to allow a longer time?
18:38LicenserSgeo__ I'd say just go with a simple no thread stuff untill you notice it's a bottleneck
18:38bbloomSgeo__: generally the rule for an evented system is 1 IO thread per network card, so for most server processes: exactly 1 IO thread
18:38bbloomSgeo__: plus 1 message queue worker thread
18:38bbloomaka event pump thread
18:39Sgeo__event pump?
18:39Sgeo__Would that be my wait function?
18:39bbloomevent loop
18:39bbloompump
18:39bbloomwhatever you want to call it
18:39Sgeo__So, 2 threads
18:39Sgeo__Does Lamina have functions for pausing for a bit... not sure if that's what I even mean
18:41bbloomdevn: try this patch https://gist.github.com/4165569
18:42devnSgeo__: maybe something like defer?
18:42Sgeo__There's no receive-and-close in Lamina? :(
18:42devnlamina.executor
18:42bbloomSgeo__: generally, you won't write the IO thread yourself if you have an evented IO library
18:42Sgeo__bbloom, I'm wrapping around a C library
18:42devnbbloom: applying...
18:43aperiodicFrozenlock: set :repl-options {:timeout 60000} (or higher as needed) in your project.clj
18:43bbloomdevn: I'm gonna vet it a bit more myself and then put it up on jira
18:44Sgeo__Err, what I want is read-channel followed by close
18:45Frozenlockaperiodic: It works! Thanks!
18:47devnbbloom: actual: java.lang.AssertionError: Assert failed: set! target must be a field or a symbol naming a var at line 7 test/hiccups/core_test.cljs
18:47bbloomdevn: there you have it :-) go look at that line
18:48Sgeo__Questions: Are futures lighter-weight than Threads? Will several running futures that are blocking on stuff (perhaps with Thread/wait or just deref-ing a future or promise) interfere with each other?
18:51devnbbloom: seems like it's a problem with the way macros are getting pulled in?
18:52hcumberdalehow to write a list to a file
18:52hcumberdaleeach item a line
18:52devnmy guess is (defmacro deftest [] ...) in test_macros.clj
18:53bbloomdnolen: i put up two good cljs patches for you to check out :-)
18:55devnbbloom: that is way better btw. thank you.
18:56devnbbloom: do you think my issue could be related to the use of `.` in hiccups.test.test-macros/deftest
18:56dnolenbbloom: nice, last patch looks awesome
18:56dnolenbbloom: will take a closer look soon thanks much.
18:57bbloomdnolen: just struck me: can probably do better to catch all exceptions
18:58dnolenbbloom: what do you mean?
18:58bbloomdnolen: 1 sec, ill show you
19:03dnolenhugod: I note that the following gist reproduces a similar constraint reification you mentioned earlier - https://gist.github.com/4165678 - this actually makes sense if you program allows this to happen.
19:03dnolenbbloom: gotta run, but let me know
19:13Sgeo__Apparently I could use a java.util.Timer
19:13Sgeo__Any Clojure libraries have a nice idiomatic interface around it, or should I just write one myself?
19:13hcumberdaleclojure/data/xml/flatten-elements NoClassDefFound
19:13hcumberdaleWTF...
19:14tanzoniteblackSgeo__: is there a reason you need to have manual control of threads, as opposed to using futures, pmap, agents, or some similar native control structure?
19:15bbloomdevn: looking at your thing now
19:15bbloomdevn: yeah, deftest on line 3 in test-macros
19:15bbloomthat is old syntax
19:15Sgeo__tanzoniteblack, want to use an event-driven library in a synchronous fashion. I do have a use for manual sleeping: To be able to write games where things happen after a certain amount of time.
19:15bbloomit's trying to set a method
19:15bbloombut you have to set a property
19:15bbloom(.-foo bar) vs (.foo bar)
19:15bbloomdevn: however, should be able to use real def there
19:16nDuffSgeo__: I've got a wrapper around Timer somewhere.
19:16nDuffSgeo__: ...actually, think I've already gisted it.
19:16bbloom`(def ~(symbol "goog.global" (str "test-" (name nm))) [] ......
19:16bbloomdevn: ^^
19:17nDuffSgeo__: https://gist.github.com/a7d911dc0df88c3c3c8f
19:20hcumberdaleHow can I modify a file with clojure?
19:20hcumberdaleXML -> Modify -> Save
19:21hcumberdaleBetter to save a new file, right?
19:26nDuffhcumberdale: that's true regardless of the language.
19:27nDuffhcumberdale: ...create-and-rename is safer than overwrite because it's atomic on sane filesystems, whereas overwriting is almost never so.
19:31Sgeo__How do I make sure things on the resource-path get included into the uberjar?
19:31hcumberdalewhat are the clojure.java.io writer options?
19:31hcumberdaleto create/overwrite a file?
19:32Sgeo__Oh, maybe it does, hmm
19:34Sgeo__Ok, why does the SNAPSHOT.jar contain the dependencies I need while SNAPSHOT-standalone.jar does not?
19:44tanzoniteblackhcumberdale: http://clojuredocs.org/clojure_core/clojure.java.io/iofactory lists 2 options, but I'm not sure if there's a list of available options you can provide anywhere
19:45hcumberdaletanzoniteblack solved it, thx
19:51Sgeo__nDuff, why proxy instead of reify?
19:51mbcevSo I was under the impression that loop & recur did constant-space recursion (and I'm sure they do). Running out of memory; wondering what it is that I'm doing wrong? I don't think I'm holding anything in memory that I shouldn't be...
19:56tanzoniteblackmbcev: can you give some more info about what you're doing and what's happening (maybe some code?)
19:56antoineBmbcev: do you mean that recur do tail call recursion?
19:56mbcevCan I post a pastebin link?
19:57tanzoniteblackmbcev: please
19:57antoineByes
19:57mbcevpastebin.com/KpkzmaL3
20:00mbcevAlso just noticed I copy-pasted my "test" code. when x = 10 in mod-test it does give me the 2520. When I set it to 20, heap overflow.
20:02tanzoniteblackmbcev: it doesn't especially look to me like you're keeping much in memory at all, so I'm unclear as to why you're getting that error. And running it on my machine it calculates quite quickly
20:02antoineBdo a try catch and print "val"
20:03mbcevantoineB: try catch where?
20:04antoineBin the loop
20:04antoineBtry { (if ....) } catch ...
20:05mbcevoh and print val on the catch? kay, hold on
20:05antoineByes
20:06tanzoniteblackmbcev: what is the error message you're getting, and how are you running clojure
20:08mbcevIt's still running, will let you know when it errors out on me. Also, I'm using LightTable in Windows. Just seemed a nice repl for the time being.
20:11antoineBmbcev: do you test on the exact same code as pastebin? because it does'nt feet the problem
20:11tanzoniteblackmbcev: it's possible that the problem is either with lighttable (which is still in alpha) or in how you're executing
20:11antoineBmod-test test to 0 to 10 instead of 0 to 20
20:12antoineBtanzoniteblack: mbcev: how do you start the repl?
20:12mbcevOh odd, I just excited it using lein and it executed quite quickly
20:12mbcevperhaps it is an issue with light table afterall
20:13tanzoniteblackmbcev: you should report that (along with your code) to lighttable as a bug so they can look into it
20:14tanzoniteblackmbcev: until then, if you're just learning Clojure, you might be happier trying a little bit more stable development environment
20:14mbcevYeah, will do. Thank you guys! I was pretty sure I wasn't crazy, but I just had to make sure.
20:16Sgeo__With Lamina, I want to use map*, but the function might return a result-channel, so how do I make a new channel that isn't a bunch of result channels but rather values?
20:16antoineBmbcev: i get 232792560
20:17antoineBmbcev: make sure the repl you lunch is on the jvm, not on a javascript vm (where lighttable run)
20:17mbcevtanzoniteblack: is there a repl you'd recommend? I just really don't feel like setting up cygwin for emacs/vim.
20:18mbcevantoineB: I got the same thing when using lein instead of lightable haha
20:18antoineBok
20:18Sgeo__mbcev, there are Windows versions of emacs and vim
20:18tanzoniteblackmbcev: "I got the same thing when using lein", does that mean you're still having the issue?
20:18tanzoniteblackmbcev: and personally I use nrepl in emacs hooked to a lein instance
20:19mbcevtanzoniteblack: no sorry, I meant I got the same value of "232792560" and in miliseconds flat
20:19antoineBmbcev: so lein repl works, and lighttable repl run out memory?
20:20mbcevantoineB: correct
20:20antoineBhttp://himera.herokuapp.com/index.html here is a javascript vm repl
20:22antoineBthat give me a result
20:23mbcevI'll look into the windows instances of emacs and hooking that into lein, also Himera. Thanks guys. Bleh; I use windows for a ton of stuff so as much as I love myself some linux; it's just too much of a pain in the butt for me to be dualbooting or cygwin and managing that stuff. Nothing is "simple" in the windows world (imho) and I hate it, but I gotta deal for now.
20:24tanzoniteblackmbcev: Ubuntu in a virtual box isn't bad, but you might also consider an alternative ide like counterclockwise for eclipse if you're not already familiar with emacs
20:25seangroveWondering if shoreleave pubsub could be extended a bit so that listeners could only listen to some subset of nodes on a map
20:25seangroveProbably would be an easy helper function
20:25hcumberdale,(first [nil, "x", nil])
20:25clojurebotnil
20:27mbcevtanzoniteblack: maybe I'll setup ubuntu in a VM and setup seemless mode on my laptop or something. I'm familiar with emacs&vim, I just have never had good experience with them in windows so I just didn't really want to bother.
20:36Sgeo__wtf
20:36Sgeo__"When we map* a function over a channel, we’re effectively saying that the original channel exists to feed messages into the downstream channel."
20:36Sgeo__Maybe I want to use the channel's results directly for other reasons?
20:37Sgeo__This is utterly bizarre.
20:38Sgeo__It's effectively mutating its input
20:38Sgeo__map* I mean effectively mutating the input channel
20:41tomojyes
20:41tomojit's tricky
20:41tomojI mean, I think it's tricky to write a library like that without bizarreness
20:43tomojalso then I think if you close the map channel, the source closes, by default?
20:54mefistomaybe a noobish question... so you got ns3 which has a symbol "thingy" in it . ns2 does :use ns3, and ns1 does :use ns2. can you refer to "thingy" without any ns qualifier in ns1?
20:54tomojno
20:55mefistoso ns1 would have to use ns3 directly for that?
21:02tomojyeah
21:03mefistotomoj: ok thanks
22:03Sgeo__If I make a thing with reify and pass it into a function that is ultimately C code, do I have to worry about the thing I made being garbage collected?
22:07Sgeo__What's the equiv. for Java?
22:08Sgeo__All I really need to do is color black or green pixels based on a data structure
22:08brehautSgeo__: java2d ?
22:09Sgeo__Oh hey Java has something built in I think
22:09jyuis clojure run on osgi?
22:09brehautjyu: clojure _web_ stuff?
22:10jyua typical restful service, is it possible run the clojure program on the osgi as a bundle
22:11brehautyou can run it from anything that wants a .war if you want
22:11brehauteg tomcat
22:11brehautbut you dont have to
22:11TimMcjyu: I'm not really clear on what OSGI is, but I know nDuff has been working with it.
22:12jyuequinox
22:12brehautTimMc: i dont think anyone is 'clear' on what osgi is ;)
22:13brehauti think its fair to say that clojure programmers prefer to avoid crazy-pants complication where possible
22:16bbloomis there a quick function to create a comparer from a key? ie if I want to compare two maps by the value of an :ordinal key or something like that?
22:16bbloomthe best i got is: #(compare (:ordinal %1) (:ordinal %2))
22:16seangroveI'm trying to pass the contructor to another function in cljs as an argument
22:17bbloomseangrove: you should pass a factory function instead
22:17seangrovee.g (new-control! goog.ui.Zippy (css-node ".header") (css-node "content"))
22:17seangrovewoops, goog.ui.Zippy.
22:18seangrovebbloom: So I'd have to wrap all of the constructors I'd like to pass with another function and pass that?
22:18bbloomseangrove: yeah, because the call site needs to use the "new" operator
22:18seangrovedamn
22:18bbloomunless you know what you're going to get is ALWAYS a constructor
22:18seangroveI can make it a macro though
22:18bbloomin that case you might be able to use the 'new keyword
22:18seangroveYeah, just trying to DRY up some of the google closure ui stuff internally
22:18bbloomer special form
22:19brehaut(comp (partial apply compare) (partial map :ordinal)) ;; bbloom
22:20brehaut; (not serious)
22:20bbloomseangrove: (Foo. bar) is shorthand for (new Foo bar), but Foo. is not shorthand for "new Foo"
22:20bbloombrehaut: heh
22:20seangroveAh, I see
22:21brehautactually, its not quite right (comp (partial apply compare) (juxt (comp :ordinal first) (comp :ordinal second)))
22:22brehautbah
22:22brehaut(comp (partial apply compare) (partial map :ordinal) vector)
22:22brehauti think thats it
22:22seangrovebbloom: I suppose that if new is a special form, it's not going to be easy to do something like:
22:23seangrove(defn new-control! [class args] (apply new [class args])) (new-control goog.ui.Zippy "arg-1" "arg-2" true)
22:23bbloombrehaut: far simpler: (defn key-comparer [key] (fn [a b] (compare (get a key) (get b key))))
22:23seangrove(typos aside)
22:23brehautbbloom: free all the points!
22:23bbloomseangrove: heh yeah that won't work at all
22:23hcumberdalegood n8
22:23hcumberdale;)
22:23seangroveMacro would do fine though, I think
22:23bbloomseangrove: factory functions are going to be preferable to work with in almost every way
22:25seangroveYeah, I could probably do it without too much hassle
22:26bbloombrehaut: I want these in core :-) https://www.refheap.com/paste/7131
22:26bbloomI use sorted collections pretty frequently
22:27bbloomi wish that sorted collections printed differently...
22:44am2605Noob paredit question: How do I remove an extra set of [], eg [[abc] [def]] - I want to remove the outer ones?
22:45brehautM-s
22:45echo-areaam2605: So it becomes [abc def]?
22:45brehautwith the whatsitecalled not inside one of the inner forms
22:46am2605brehaut: thanks! that worked
22:46am2605echo-area: I was after [abc] [def]
22:46echo-areaOh
22:47nsideanyone has experience with building a runtime seesaw canvas path?
22:52jyfl987is there any db represent like a tree db?
22:52nsidehere's a snippet of my path-building macro http://pastebin.com/QTCMhDsa
22:52nsidejyfl987: what do you mean by represent?
22:53jyfl987looks? act?
22:53jyfl987i am sorry, english is not my native language
22:53seangrovejyfl987: firebase, kind of, if I understand you correctly
22:53seangroveI think I'm slowly recreating the declarative ui wheel here...
22:54jyfl987let me explain it, do you know redis?
22:54nsideyou could serialize the entire tree in a text file
22:54seangroveBut maybe that's not a bad thing, I don't know
22:54nsideredis i know
22:54jyfl987then you know the dict type , isnt it?
22:55jyfl987but the dict's value couldnt be any complex type, what i want is something like redis's dict type which support store another dict in its value
22:55jyfl987i think its like a tree
22:56jyfl987when i read practical common lisp, it has the example by using lisp itself as the db
22:57jyfl987but its just load/store the entire db in a file, which i think for really use case, its not a good solution
22:57nsideby dict are you referring to a specific redis binding?
23:00jyfl987wait i'll check redis's term
23:00nsideredis itself is a key value store (probably what you're referring to as a dict)
23:01jyfl987nside: its hashes in redis Term
23:01jyfl987i am a python engineer, so i call all hash as dict :]
23:01nsidewhat are you trying to serialize?
23:02nsidea tree? a map?
23:04bbloomis there a reasonable way to get a sorted-map which is sorted by values
23:06nsidebbloom: there's an example there http://clojuredocs.org/clojure_core/clojure.core/sorted-map-by
23:06bbloomnside: that example seems bugged… results doesn't change, so if you assoc a new value in, it won't keep the map sorted
23:07nsidebbloom: that makes sense
23:08nsidewhy not resort after insertion?
23:10bbloomnside: i'm implementing an incremental algorithm that would have to re-sort at each step
23:10bbloomnside: was hoping to keep the collection sorted during the process
23:11nsidehow large is your map?
23:12bbloomnside: i'm expecting the upper bound to be roughly 200 or so
23:12nsidethat tiny. unless that's in a render loop or something similar i'd just re-sort every time
23:13jkkramerbbloom: https://github.com/clojure/data.priority-map
23:13nsidenice
23:14bbloomnside: it's an N^2 algorithm, so it may be up to 40,000 iterations
23:14bbloomnside: although it should be roughly linear in practice
23:14bbloomjkkramer: thanks! i'll look at that
23:14nsideseems like that lib will work
23:15bbloomnside: jkkramer: I was looking at PersistentTreeMap.java and it seems like everywhere the comparer is called, both keys and values are available. it's kinda a shame that the built in maps don't support sorting by value
23:16nsideafaik sorting by key is the common implementation for most platforms
23:17bbloomnside: yeah, but the underlying data structure can support both. it's just not exposed
23:17nsidei hear you
23:17nsidecan someone help me with a very simple macro? i've posted it here http://pastebin.com/QTCMhDsa
23:18nsidethis is to create a seesaw canvas path runtime
23:18nsidei suspect i need to delay the evaluation of move-to or something like that
23:19bbloomnside: is 'path a macro too?
23:19nsideyep
23:19nsideit's at the bottom
23:19nsideof the paste
23:19bbloomnside: ah below, yeah, need these ordered correctly in your source files :-)
23:20nsidethis macro is in seesaw
23:20nsidei might just re-implement it actually
23:20nsidewithout the lookup to path-ops
23:20bbloomnside: what is move-to ?
23:22nsidesomething that gets translated into .moveTo
23:22bbloomnside: why bother making it a macro?
23:23nsidei was wondering that too
23:23bbloomheh
23:23bbloomi'd need much more context to debug this
23:23bbloombut in general: the fewer macros the better
23:23nsideyeah but seesaw forces that one on me
23:23bbloomand if your macro gets complex at all, make a function and then call that function from the macro
23:23jkkramernside: (defmacro make-path [[x y]] `(path [] (~'move-to ~x ~y)))
23:24RaynesCause that makes it all okay again
23:24Raynes;)
23:25nsidejkkramer: that worked!
23:25jkkramernside: it's looking up the path op by symbol, and it seems you're passing it a fully qualified symbol ('some-ns/move-to) instead of an unqualified one ('move-to)
23:27nsidei'm new to this clojure business but i love it
23:28nsidewhat ide are people using?
23:36TimMcnside: I don't know about IDEs, but emacs and vim are ever-popular.
23:37nsidei'm curious about light table
23:37TimMcCounterclockwise (CCW) is an Eclipse plugin, if that's your poison.
23:37nsideis anyone using it?
23:37nsidei tried vim and CCW so far
23:38TimMcLight Table isn't even close to done. Interesting to play with, though.
23:38TimMcI won't find it useful until it has paredit.
23:41nsidek
23:41RaynesDoesn't mean it isn't useful.
23:41RaynesIf it works for you, go for it.
23:43nsidei'm too green to use it in its current state i think
23:43RaynesI have some blue paint here if you need it.
23:43Sgeo__Lamina + protocol-monads + ??? = PROFIT
23:44TimMcSgeo__: Have you been huffing paint fumes?
23:44nside:)
23:44Sgeo__Maybe 3 lines of code to bring Lamina into the monad world
23:45TimMc"Protocol monads" sounds like the wild ravings of someone on a psychedelic trip. I must say I'm intrigued, however...
23:45Sgeo__TimMc, it's Jim Duey's monads implementation
23:49wingyi have a datomic query that should fetch all items belonging to a item type (which is of type "db.type/ref") .. what should i put as value in :where [?item :item/item-type ?item-type]
23:49wingyshould it be the id or the item type entity?
23:56jyfl987nside: i am not trying to serialize, but just store/request them like redis
23:57nsidejyfl987: i'll need more context to help
23:58jyfl987nside: redis's hash type can only store string/int as its value, right?
23:58jyfl987it cant store complex type
23:58nsidecant you send it a blob?
23:59jyfl987nside: cant , because i might change partly each time just like redis's hash should be used