2013-03-30
| 00:05 | tjgillies | trying to ask ruby people if theres datalog/linq stuff in ruby and i can almost see them scratching their heads |
| 00:05 | gtrak | tjgillies: you mean like a dsl? |
| 00:05 | gtrak | they love those |
| 00:06 | tjgillies | heh |
| 00:06 | tjgillies | [09:06:29pm] <lewis1711> tjgillies: "filter" is called "find_all" or "select" in ruby, mapping cons over two lists is the zip method. do you have a specific question? |
| 00:07 | tjgillies | i pasted some clojure example code in and someone asked me if i knew what blocks where |
| 00:07 | tjgillies | were* |
| 00:10 | tjgillies | im trying to use friend but when i reload-all on my main namespace all of a sudden i start getting No implementation of method: :read-session of protocol: #'ring.middleware.session.store/SessionStore found for class: ring.middleware.session.memory.MemoryStore |
| 00:10 | tjgillies | anyone ever run into that |
| 00:17 | `arrdem | is there a reason that lein 2.1.0 tests still use the (:use) semantics? I thought that #clojure had unofficially depricated use. |
| 00:18 | nonuby | hmm.. can you partial a defmulti? |
| 00:18 | `arrdem | you shouldn't... |
| 00:18 | `arrdem | I wouldn't think at any rate. |
| 00:19 | technomancy | `arrdem: just an oversight |
| 00:19 | hyPiRion | `arrdem: Like in the template, you mean? |
| 00:19 | `arrdem | technomancy: dibs on the patch! |
| 00:19 | `arrdem | XP |
| 00:19 | hyPiRion | so I guess :require :refer :all then |
| 00:19 | hyPiRion | `arrdem: fire it up |
| 00:20 | `arrdem | hyPiRion: yup, idiotic but there. |
| 00:20 | technomancy | you got it |
| 00:23 | `arrdem | done. |
| 00:25 | hyPiRion | `arrdem: Could you fix it for the other templates too? |
| 00:26 | `arrdem | hyPiRion: sure.. gimme 30 to try and turn this project in before the deadline |
| 00:26 | hyPiRion | App at least |
| 00:26 | hyPiRion | ok, sweet |
| 00:28 | gtrak | I made a little runtime disassembler library and lein-plugin: https://github.com/gtrak/no.disassemble/ |
| 00:35 | `arrdem | technomancy: I could hug you over lein packaging uberjar and the repl |
| 00:39 | technomancy | http://www.lakupo.com/qu/ghacks/userpics/philippe-hugs.jpg |
| 00:40 | `arrdem | lol |
| 00:41 | technomancy | http://www.lakupo.com/qu/ghacks/userpics/philippe-hugs.jpg |
| 00:41 | technomancy | oops |
| 00:41 | technomancy | http://www.lakupo.com/qu/ghacks/userpics/philippe-breakdance.gif |
| 00:44 | technomancy | one more and then I'm gone: http://p.hagelb.org/two-timing.gif |
| 00:45 | technomancy | good night everyone |
| 01:09 | ambrosebs | gtrak: cool! |
| 01:11 | tomoj | gtrak: I was just wishing for that recently |
| 01:13 | tomoj | unfortunately I don't understand bytecode |
| 01:14 | tomoj | but this would be the only way to tell whether you're getting boxing in a big composition that's supposed to transmit primitives, yes? |
| 01:15 | cvk_ | hi all |
| 01:17 | ambrosebs | tomoj: jvm.tools.analyzer could give some hints. I think the compiler inserts calls to RT/box, you could use emit-form to inspect the AST. |
| 01:17 | ambrosebs | tomoj: but gtrak's library is probably easier to digest. |
| 01:17 | tomoj | !! |
| 01:17 | tomoj | I was thinking exactly the opposite |
| 01:18 | cvk_ | hi all |
| 01:18 | cvk_ | i am just starting to learn clojure |
| 01:18 | cvk_ | any book recommendations? |
| 01:18 | ambrosebs | tomoj: well there's no disputing the bytecode :) |
| 01:19 | tomoj | maybe it's easier if you understand bytecode? :( |
| 01:21 | ambrosebs | tomoj: It seems easy enough to get the general idea of what's going on, especially if you're looking for whether boxed or primitive methods are being called. It looks like all types are explicit |
| 01:21 | ambrosebs | tomoj: just speculating of course. |
| 01:58 | tjgillies | does trampoline slow down startup time? |
| 02:03 | jasonjckn | tjgillies: yes |
| 02:03 | jasonjckn | tjgillies: https://github.com/flatland/drip |
| 02:04 | tjgillies | jasonjckn: thnx |
| 02:04 | tjgillies | jasonjckn: does it work with leiningen? |
| 02:06 | jasonjckn | tjgillies: i think so |
| 02:07 | jasonjckn | not sure |
| 02:09 | tjgillies | anyone know if theres a link to the different clojure datastructures and what they're good for? |
| 02:09 | tjgillies | the docs just have what methods work with them |
| 02:09 | tjgillies | but for example, im interested in what kinda of data hashsets are good at |
| 02:10 | tjgillies | curious why datomic uses them for result set |
| 02:10 | tjgillies | s/kinda of/kind of/ |
| 02:11 | tomoj | you mean java.util.HashSet in particular? |
| 02:12 | tjgillies | clojure.lang.PersistentHashSet |
| 02:12 | tjgillies | which im assuming is very similar |
| 02:12 | tjgillies | im not a ruby guy |
| 02:12 | tjgillies | java |
| 02:12 | tjgillies | freudian slip |
| 02:13 | tjgillies | doh |
| 02:13 | tomoj | well, a query result just is a set |
| 02:13 | tjgillies | my brain is shot, lonf week heh |
| 02:14 | tomoj | so my answer is "sets are good for sets" :( |
| 02:14 | tjgillies | whats the difference between hashset and set |
| 02:14 | tjgillies | thats my entire question |
| 02:14 | tjgillies | i realize sets are good for storing set data, i mean thats kinda obvious |
| 02:14 | tjgillies | why make an additional datastructure |
| 02:16 | tjgillies | from javadoc: This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. |
| 02:16 | tjgillies | maybe to have constant time on set operation? |
| 02:16 | tomoj | 'hash set' is just a class of implementations of sets |
| 02:16 | tomoj | &(class (set [1 2 3])) |
| 02:16 | lazybot | ⇒ clojure.lang.PersistentHashSet |
| 02:17 | tomoj | s/class/kind/ |
| 02:17 | tjgillies | ah |
| 02:17 | tomoj | it's sort of the default set, the other choice is a sorted one which has worse performance but the benefit of being sorted |
| 02:17 | tjgillies | so set and hashset are synonymous then essentially? |
| 02:18 | tjgillies | aaaah |
| 02:18 | tjgillies | gotcha |
| 02:18 | tomoj | 'set' _usually_ means a PersistentHashSet in clojure, yeah |
| 02:18 | xeqi | treeset? |
| 02:18 | tjgillies | ok so hashset is the default set which is unsorted |
| 02:18 | `arrdem | hyPiRion: other pull request in |
| 02:18 | tomoj | but anything that implements java.util.Set could be called a 'set' as well |
| 02:18 | `arrdem | 'evening gents, I'm lisped out for the night. |
| 02:18 | tjgillies | night |
| 02:18 | tjgillies | im lisped out as well, yet here i am ;) |
| 02:19 | tjgillies | (inc tomoj) |
| 02:19 | lazybot | ⇒ 8 |
| 02:19 | tomoj | e.g. I believe datomic actually returns java.util.HashSet results |
| 02:19 | tjgillies | you're right |
| 02:20 | tjgillies | with datomic we have persistent-persistent-datastructures ;) |
| 02:23 | tomoj | PHS has "effectively constant" (i.e. O(log n)..) operations while HashSet is really constant |
| 02:25 | tomoj | I sort of wish you could get a reducer of query results |
| 02:25 | tomoj | then let us choose whether we want to stick it in a HashSet or a PHS or don't stick it anywhere |
| 02:26 | amalloy | tomoj: well, j.u.HashSet is amortized-constant, not actual-constant, right? |
| 02:27 | tomoj | lazybot: karma amalloy |
| 02:27 | lazybot | amalloy has karma 47. |
| 02:27 | amalloy | it's weird because you can add in arbitrary objects which all hash-collide |
| 02:28 | tomoj | I dunno, but I'm assuming you're right :) |
| 02:36 | amalloy | i'm probably wrong about amortized-constant, but there are definitely weird corner cases somewhere |
| 02:45 | alex_baranosky | does robert.hooke work with protocol functions? |
| 03:00 | amalloy | alex_baranosky: probably not |
| 03:01 | amalloy | extending a protocol function does funny stuff to the var |
| 03:06 | amalloy | and technomancy hates protocols, so maybe he never tested it |
| 03:07 | tomoj | I can't imagine how it could possibly work |
| 03:12 | tomoj | oh, actually, it should be able to work, huh? |
| 03:15 | tomoj | looks like it only works for, uh, 'dynamic' implementors? |
| 03:15 | tomoj | i.e. not (deftype Type [] Protocol) |
| 03:15 | tomoj | https://www.refheap.com/paste/e7d587fdefa68621367eb0ad9 |
| 03:16 | amalloy | tomoj: now try extending a new type to the protocol and see if the hooke is still in effect |
| 03:16 | tomoj | nope |
| 03:16 | amalloy | my money is on it not working |
| 03:17 | tomoj | I see, I thought you meant the protocol var |
| 03:17 | tomoj | every time you extend-type all the protocol fn vars change |
| 03:19 | tomoj | guess that's so the caches are cleared |
| 03:25 | tomoj | hah: <p class="bdfl"><a name="11:33">11:33</a> <b>rhickey: </b>,((fn [[a b]] [b a]) [1 2])</p> |
| 04:07 | lnostdal | hi guys, the TIME macro is nice, but is there something more advanced around? .. say, something that lets me do something like: (dotimes [i 10000] (time :section-a (operation-a)) (time :section-b (operation-b))) which will print out totals for search section after all iterations – and similar? |
| 04:07 | lnostdal | totals for each* |
| 04:07 | Raynes | $google benchmarking clojure |
| 04:07 | lazybot | [How to benchmark functions in Clojure? - Stack Overflow] http://stackoverflow.com/questions/3041299/how-to-benchmark-functions-in-clojure |
| 04:07 | Raynes | Bah! |
| 04:08 | Raynes | $google criterium clojure |
| 04:08 | lazybot | [hugoduncan/criterium · GitHub] https://github.com/hugoduncan/criterium |
| 04:08 | Raynes | lnostdal: ^ This is presumably the most popular tool for benchmarking Clojure. |
| 04:08 | Raynes | Dunno if it does what you want in particular, but it might. |
| 04:08 | lnostdal | awesome; will check out, Raynes |
| 04:32 | finishingmove | $google real world haskell |
| 04:32 | lazybot | [Real World Haskell] http://book.realworldhaskell.org/ |
| 06:36 | Glenjamin | xeqi: are you about? I've got a quick peridot question |
| 06:37 | Glenjamin | currently the cookie jar only accepts one of the three date-time formats, noticable it doesn't support the one ring.cookies uses when you pass a clj-time object |
| 06:57 | Glenjamin | i'm thinking i'll put together a patch to use clj-time like ring-core |
| 08:00 | gtrak | tomoj: ambrosebs: yes, checking for primitives was a main reason I made it |
| 08:07 | pyykkis_ | hi, I'm trying to set nrepl not to pop up stack trace and added '(setq nrepl-popup-stacktraces nil)' to init.el |
| 08:08 | pyykkis_ | however, it doesn't to make any difference? Am I missing something? I also tried evaluating it with C-x-C-e, but stack traces are still popping up. |
| 08:09 | borkdude | Raynes what is your favorite web framework/lib for Haskell to build something simple? |
| 08:14 | papachan | hello |
| 08:18 | papachan | I am just trying to generate a jar from the book example Clojure Programming. but i cant load my class |
| 08:18 | papachan | http://paste.ubuntu.com/5661100/ |
| 08:50 | gtrak | tomoj: you could always look at the bytecode with javap, but that requires AOT, this works fine at a REPL |
| 08:54 | gtrak | it's good for convincing people of how eval works :-) |
| 09:12 | jemafeller | hello! |
| 09:12 | jemafeller | i have great news! |
| 09:12 | jemafeller | after I got really depressed over clojure vs scala vs java performance (each using its own typical Web framework) |
| 09:13 | jemafeller | I realized I was benchmarking Java and Scala each through running a jar, and clojure through 'lein run' |
| 09:13 | Pupnik | did that make clojures performance look really bad? |
| 09:13 | jemafeller | when I was about to ship the Clojure version to a different server I had to make an uberjar. then I thought to benchmark it one last time |
| 09:14 | jemafeller | and this time I was getting results the fastest! (fastest was Scala) |
| 09:14 | jemafeller | Pupnik, it made from 4700req/s to 6600req/s |
| 09:15 | jemafeller | Scala, using Scalatra did a 6200req/s |
| 09:15 | jemafeller | Java with drop wizard 5500req/s, and Node.js a pity 3090 req/s |
| 09:16 | jemafeller | Dropwizard is the heaviest of the lot, but I *am* trying to pick a standard for each platform (for clojure, I picked bare ring) |
| 09:17 | jemafeller | so its not really an apples to apples comparison - but I am picking what an average to intermediate developer would pick |
| 09:17 | jemafeller | Nodejs forced me to drop to a bare 'http' implementation too. |
| 09:18 | jemafeller | anyway, this is a great feeling. made the decision very easy right now. |
| 09:18 | weavejester | With regard to performance, Ring current piggybacks off Java servlets a fair bit for most adapters, so there's a fair amount of potential improvements to be made. |
| 09:19 | jemafeller | weavejester, what do you mean? |
| 09:19 | jemafeller | isn't everyone using Servlets in the Java world this way? |
| 09:19 | weavejester | Well, for instance, servlets parse cookies and parameters, and Ring parsing them with middleware, so there's some redundency going on there. |
| 09:20 | jemafeller | ah, I see |
| 09:21 | weavejester | Something that hooks into Ring more directly would be faster, although Ring+Servlets seem to be faster than a lot of things even with the redundency |
| 09:21 | weavejester | Out of interest, how did the "lein run" vs jar affect the Clojure results? |
| 09:21 | jemafeller | weavejester, if you mean how it works internally - I have no idea |
| 09:21 | jemafeller | I was sure there wasn't any difference |
| 09:22 | jemafeller | but when I ran the benchmarks on a standalone jar, I went from 4700r/s to 6600r/s |
| 09:22 | squidz | In clojure I want a function that takes other functions optionally as parameters. How can I evalutate those functions then. Example (defn myfun [& fns] (evaluate? fns))? Is there anything like this? |
| 09:23 | squidz | I dont want to use macro stuff is possible |
| 09:23 | jemafeller | I'm running on a Sun JDK 1.6 if that matters |
| 09:26 | hyPiRion | squidz: huh? ##(let [f (fn [x] (x))] (f #(pr 'foo))) |
| 09:26 | lazybot | ⇒ foonil |
| 09:27 | squidz | okay I see I just have to pass the function names without surrounding parens in the parameters. Then in the body of myfn call by surrounding with parens |
| 09:27 | hyPiRion | yeah |
| 09:28 | squidz | (defn myfun [& fns] (for [f fns] (f))) then => (myfun someotherfn) |
| 09:28 | jemafeller | is there any advantage of using future-like constructs over things like pmap and spinning a thread? |
| 09:29 | borkdude | would this be worth looking into? http://http-kit.org/ |
| 09:30 | jemafeller | borkdude, you mean in my case? |
| 09:30 | borkdude | jemafeller yes |
| 09:30 | borkdude | jemafeller never tried it myself though |
| 09:30 | jemafeller | borkdude, I did, but I filed it as 'low level' and more for concurrent connections. I love that i'm using Ring here and not a much lower level construct |
| 09:30 | azkane | squidz: if you want those functions to perform side effects you could do (doseq [f fns] (fns)), you can pass any number of arguments to it |
| 09:31 | jemafeller | in the same way I could have just dealt with "raw" Servlets or "raw" Netty |
| 09:31 | squidz | azkane: yeah thats what im doing. Im wrapping the calls up in a do. I was overthinking the problem when actually clojure makes it very simple. God I love it |
| 09:32 | jemafeller | at first I thought it was a stunt to get a "1M connections with Clojure" on HackerNews |
| 09:32 | borkdude | I'm wondering why most of the http-kit code is written in java |
| 09:32 | jemafeller | but later I saw it was a real maintained project :) |
| 09:32 | rebcabin_ | what is the difference between keywords :foo and ::foo? I'm in user namespace in repl; :foo prints as :foo and ::foo prints as :user/foo, and these seem "same only different" |
| 09:33 | borkdude | rebcabin_ those are namespace qualified keywords: http://kotka.de/blog/2010/05/Did_you_know_III.html |
| 09:35 | rebcabin_ | borkdude: ty |
| 09:36 | jemafeller | borkdude, as I noted, I think it was an attempt to maximize performance in a way that appear low-levelish |
| 09:49 | borkdude | cemerick congrats on one year of clojurebook ;-) |
| 09:50 | rebcabin_ | (= ::foo :user/foo ::user/foo) |
| 09:51 | jemafeller | If during a request, the server needs to download a file and run a C++ tool on it for analysis, every request, what would be the best way to do it? |
| 09:52 | jemafeller | on node.js it's clear since everything is async.. but on Clojure? |
| 09:53 | borkdude | rebcabin_ that's only true when evaluated from user |
| 09:53 | rebcabin_ | right! i see that |
| 09:56 | rebcabin_ | (in-ns 'bar) (clojure.core/= :user/foo ::user/foo) |
| 09:56 | rebcabin_ | ::foo ~~> :bar/foo |
| 10:06 | cemerick | borkdude: heh, thanks |
| 10:19 | rebcabin_ | I can write "identity" as "(fn [x] x)" but not as "#(%)" ... "#(%)" is something, but what is it? ((#(%) 42) fails with ~"can't cast to IFn"~ |
| 10:20 | rebcabin_ | oops one too many open paren: i meant "(#(%) 42)" |
| 10:22 | hyPiRion | rebcabin_: Try macroexpanding it |
| 10:22 | hyPiRion | ,'(macroexpand-1 '#(%)) |
| 10:22 | clojurebot | (macroexpand-1 (quote (fn* [p1__35#] (p1__35#)))) |
| 10:22 | hyPiRion | bleh |
| 10:22 | hyPiRion | ,(macroexpand-1 '#(%)) |
| 10:22 | clojurebot | (fn* [p1__70#] (p1__70#)) |
| 10:25 | squidz | when I try to pass a function as a parameter to another function in clojurescript and then try to call that function by surrounding it with parens, i get a error telling me that the function passed in as a paremeter isn't a function |
| 10:26 | squidz | is this a bug? |
| 10:28 | randomenduser | can I send code to be evaluated to an nrepl server (that's active in another terminal) via curl/netcat/telnet/whatever and see the output in that active terminal? |
| 10:34 | squidz | here is what is giving me a problem https://www.refheap.com/paste/13115 I guess the javascript isnt recognizing the parameter(named withparameters) as a function |
| 10:35 | squidz | is there a way I can hint that a function argument is of the type function for clojurescript? |
| 10:39 | rebcabin_ | hyPiRion: ty |
| 10:51 | pyykkis_ | hi, I'm trying to set nrepl not to pop up stack trace and added '(setq nrepl-popup-stacktraces nil)' to init.el |
| 10:51 | pyykkis_ | however, it doesn't to make any difference. Am I missing something? I also tried evaluating it with C-x-C-e, but stack traces are still popping up. Any help? |
| 11:02 | `arrdem | mornin |
| 11:03 | `arrdem | hyPiRion: thanks for the rebase help, that's the one git command I haven't mastered yet |
| 11:04 | hyPiRion | `arrdem: oh no problem, thanks for the fix :) |
| 11:15 | klang | pyykkis_: you need to M-x customize-variable and type in nrepl-popup-stacktraces to modify the value of the variable, I think. |
| 11:18 | klang | pyykkis_: Then, toggle the variable and save the state for future sessions (that will use the right notation in the file you have set custom-file to point at) |
| 11:27 | borkdude | redinger #(-> %) |
| 11:28 | borkdude | sorry I meant rebcabin_ |
| 11:29 | hyPiRion | or #(do %) too |
| 11:29 | hyPiRion | I with there were more succinct and evident names for stuff, really |
| 11:29 | rebcabin_ | borkdude & hyPiRion: nice! |
| 11:30 | hyPiRion | identity and partial in particular |
| 11:30 | borkdude | hyPiRion just id |
| 11:31 | borkdude | hyPiRion partial application, special reader macro for it? |
| 11:31 | hyPiRion | borkdude: nope, not in Clojure |
| 11:32 | borkdude | #$(+ 2) for example? |
| 11:32 | hyPiRion | I think Haskell implicitly do partial application, but Raynes would know more about that than I do |
| 11:32 | borkdude | hyPiRion Haskell has currying |
| 11:32 | hyPiRion | hm |
| 11:32 | borkdude | hyPiRion one reason this is not possible in clojure is the possibilty of varargs, if I remember correctly |
| 11:33 | rebcabin_ | in Haskell sometimes called sectioning: "+ 2" same as clojure (partial (+ 2)) |
| 11:33 | hyPiRion | borkdude: yeah, I know |
| 11:33 | borkdude | yes, what about having partial as: $(+ 2) would that work? |
| 11:34 | rebcabin_ | would work for me if just reader syntax for partial |
| 11:34 | rebcabin_ | $ i mean |
| 11:35 | pyykkis_ | klang: thanks, I'll try that |
| 11:35 | hyPiRion | Theoretically you could just make such one right now with tagged literals |
| 11:35 | borkdude | (map $(+ 2) (range 10)) instead of (map (partial + 2) (range 10)) |
| 11:35 | hyPiRion | Well, with #$ that is. |
| 11:36 | `arrdem | uergh custom readers... |
| 11:37 | `arrdem | hyPiRion: are #-prefixed readers less evil? I remeber looking at this a while ago and there are crobars involved for non-prefixed readers. |
| 11:38 | hyPiRion | `arrdem: I wouldn't say less evil. It just has the standard # before it. |
| 11:38 | hyPiRion | They were designed to represent data though, not shorten production code |
| 11:40 | `arrdem | yeah.. I get why custom readers make code less maintainable and the reader less stable but I for one would appreciate being able to do such a thing on occasion. |
| 11:41 | borkdude | well, we could always (def $ partial) and write ($ + 2) instead of $(+ 2) |
| 11:42 | hyPiRion | yeah, that's even better |
| 11:42 | xeqi | but I want my clojure to look like jquery |
| 11:42 | `arrdem | wat |
| 11:43 | hyPiRion | xeqi: and I want my Clojure to look like brainfuck |
| 11:43 | xeqi | aren't you succeeding? |
| 11:43 | hyPiRion | Can't satisfy everyone, eh |
| 11:43 | jouiswalker | lol |
| 11:43 | `arrdem | (nc hyPiRion) |
| 11:44 | hyPiRion | Here, let me inc myself |
| 11:44 | hyPiRion | ,'(inc hyPiRion) |
| 11:44 | clojurebot | (inc hyPiRion) |
| 11:44 | hyPiRion | oh dangit, he actually made lazybot ignore clojurebot. |
| 11:44 | `arrdem | bots ignore each other and themselves... |
| 11:45 | borkdude | are ibooks readable on anything other than an iOs device (which I don't own)? |
| 11:45 | `arrdem | if you want bf*ck in clojure it should be pretty doable.. |
| 11:45 | hyPiRion | xeqi: well yeah, I'm getting surprisingly close. Now I only need to figure out how to replace ns-map, and I have a working hello world without a single alphanum |
| 11:46 | hyPiRion | `arrdem: https://github.com/hyPiRion/hello-swearjure |
| 11:46 | hyPiRion | Even the project.clj is like that. |
| 11:47 | `arrdem | hyPiRion: oh I was talking about a literal brainf*ck implementation |
| 11:47 | `arrdem | not your arithmetic evil |
| 11:47 | hyPiRion | oh :( |
| 11:47 | borkdude | hyPiRion what is the rationale behind swearjure? |
| 11:48 | jouiswalker | that is so beautiful |
| 11:48 | hyPiRion | borkdude: Well, using many different characters is complecting your workflow. My goal is to reduce the amount of characters to decomplect work and make it simple. |
| 11:48 | hyPiRion | different characters. |
| 11:49 | `arrdem | that is the WORST rational I've heard in months |
| 11:49 | `arrdem | well done |
| 11:49 | hyPiRion | thank you |
| 11:49 | borkdude | hyPiRion are there any plans for a special keyboard (layout) to support swearjure |
| 11:49 | hyPiRion | I made it up just now. Seriously though, it's just for fun, there's no value behind it. |
| 11:50 | hyPiRion | borkdude: Don't give me ideas, man. |
| 11:50 | `arrdem | oh please forget ideas I can deliver on that one. |
| 11:51 | `arrdem | http://www.ergodex.com/mainpage.htm |
| 11:51 | `arrdem | do some statistics on the swearjure source and arrange keys appropriately |
| 11:51 | `arrdem | you're probably gonna want arrow keys, ( ) + and * |
| 11:52 | `arrdem | maybe [ ] ~ ` and @ |
| 11:52 | `arrdem | % can't forget % |
| 11:52 | hyPiRion | and # |
| 11:53 | `arrdem | that's like 80% less keyboard! think of all the time you'll save on hunting and pecking! |
| 11:53 | xeqi | ohh, it might even make a cell phone a decent dev environment |
| 11:53 | jouiswalker | we need to start translating shakespeare into this more efficient language |
| 11:54 | pyykkis_ | klang: d'oh, it turned out I was running an old version of nrepl.el. Thanks, your help led me eventually to the right direction. |
| 11:54 | jouiswalker | rhymes can probably be handled by emacs indentation |
| 11:57 | `arrdem | jouiswalker: as long as we're doing terible things with emacs lisp, lets impliment clojure on top of it! |
| 11:57 | `arrdem | then we get the best of the One True Editor and the better Lisp! |
| 11:58 | jouiswalker | lol |
| 12:12 | klang | pyykkis_: you are welcome :-) (my stacktraces are now turned off too, nice) |
| 12:35 | `arrdem | I love when libraries get abandoned... |
| 12:35 | jeremyheiler | `arrdem: It's the best. |
| 12:36 | jeremyheiler | What library are you looking at right now? |
| 12:36 | `arrdem | https://github.com/jkk/loom |
| 12:37 | `arrdem | I need some sort of directed graph structure for my compiler and that seems to be the only toolkit to fit the bill. |
| 12:37 | squidz | does anybody know why I cant use an optional parameter with (defn fn [fst & rest] ...) when rest is a function? When it isnt an optional parameter it works fine. Im using clojurescript btw |
| 12:38 | jeremyheiler | squidz: Don't name the varargs rest then? |
| 12:38 | jeremyheiler | `arrdem: Is there anything wrong with the lib? |
| 12:39 | `arrdem | jeremyheiler: probably not just laughing that there's a feature add pull request sitting unattended for two months |
| 12:39 | jeremyheiler | `arrdem: heh yeah |
| 12:39 | squidz | jeremyheiler: thats not the actual name of the parameter. That was just an example. My func signature looks like this (defn switch-view [content & withlisteners] ...) |
| 12:40 | jeremyheiler | squidz: How are you using withlisteners? That points to a seq. |
| 12:41 | squidz | jeremyheiler: I was just tryint to pass one function to it, with the plan that I could tack on further function if needed. Do I need to wrap the function into some kind of collection? |
| 12:42 | jeremyheiler | `arrdem: GitHub shows jkk hasn't had any activity on GitHub in the past 2 months, who knows. I know him personally, so I hope he's doing ok. |
| 12:43 | jeremyheiler | squidz: No, the varargs come in a seq, so if the function is the first optional arg, then you can grab it by saying (first withlisteners). |
| 12:43 | Raynes | borkdude: I was never fond of any of the Haskell web frameworks, but Yesod seems to be the most popular. |
| 12:44 | dnolen | ,((fn [x & r] [x r]) [1 (fn [])]) |
| 12:44 | clojurebot | [[1 #<sandbox$eval35$fn__38 sandbox$eval35$fn__38@18e865b>] nil] |
| 12:44 | dnolen | ,((fn [x & r] [x r]) 1 (fn [])) |
| 12:44 | clojurebot | [1 (#<sandbox$eval73$fn__76 sandbox$eval73$fn__76@74a506>)] |
| 12:44 | dnolen | squidz: ^ |
| 12:44 | dnolen | squidz: note that r is a seq containing the extra parameter |
| 12:46 | squidz | dnolen: jeremyheiler: this is what it looks like https://www.refheap.com/paste/13119 |
| 12:48 | dnolen | squidz: the problem is the for, for is *lazy*, you probably want doseq |
| 12:49 | squidz | dnolen: thanks dnolen that was exactly the problem |
| 12:49 | dnolen | squidz: np |
| 13:18 | borkdude | Raynes thanks |
| 13:18 | supersym | is there a good reference for clojure packages without all the personal forks? |
| 13:19 | borkdude | supersym there is clojuresphere and clojure toolkit (just google) |
| 13:19 | supersym | thnx :) |
| 13:21 | borkdude | supersym I meant http://www.clojure-toolbox.com/ |
| 13:31 | dean | Hey guys, just having a go at learning clojure. I'm trying to use core.logic to solve the irregularity of distributions problem (http://en.wikipedia.org/wiki/Irregularity_of_distributions). So far I have: http://pastebin.com/QJnNQ2Gr but when I try to run it I get: |
| 13:31 | dean | ClassCastException clojure.lang.LazySeq cannot be cast to clojure.lang.IFn clojure.core.logic.Substitutions (logic.clj:410) |
| 13:31 | dean | And i'm not really sure what it's referring to. |
| 13:34 | supersym | its expecting a function but you pass it a sequence? |
| 13:50 | jeremyheiler | Anybody here familiar with Kern, or parser combinators in general? I haven't been able to figure out how to repeatedly parse input with a single parser until the end. https://www.refheap.com/paste/13120 |
| 14:31 | thalassios_xelon | helo :)) i used to use (pst) to print stack trace,i updated in clojure 1.5.1 i think it doesnt work.. |
| 14:31 | thalassios_xelon | gow to print stack trace in clojure 1.5.1? |
| 14:32 | thalassios_xelon | it says CompilerException java.lang.RuntimeException: Unable to resolve symbol: pst in this context, compiling:(NO_SOURCE_PATH:1:1) |
| 14:33 | jeremyheiler | thalassios_xelon: (pst) is part of the clojure.repl namespace. Are you sure that it is loaded? |
| 14:34 | thalassios_xelon | i use counterclockwise |
| 14:35 | thalassios_xelon | (clojure.repl/pst) |
| 14:35 | thalassios_xelon | ClassNotFoundException clojure.repl java.net.URLClassLoader$1.run (:-1) |
| 14:35 | dnolen | thalassios_xelon: you need to require it first |
| 14:36 | thalassios_xelon | in the past it did it automatically |
| 14:36 | thalassios_xelon | they changed that? |
| 14:37 | thalassios_xelon | (:require clojure.repl/pst) |
| 14:37 | thalassios_xelon | CompilerException java.lang.ClassNotFoundException: clojure.repl, compiling:(NO_SOURCE_PATH:1:1) |
| 14:39 | dnolen | thalassios_xelon: (require 'clojure.repl) doesn't work at the REPL? |
| 14:40 | thalassios_xelon | what to write in my repl to see the stack trace? i used to just print (pst) |
| 14:40 | thalassios_xelon | (require 'clojure.repl/pst) |
| 14:40 | thalassios_xelon | FileNotFoundException Could not locate pst__init.class or pst.clj on classpath: clojure.lang.RT.load (RT.java:443) |
| 14:41 | thalassios_xelon | i just updated the counterclockwise,i dont know what happened |
| 14:43 | ivan | thalassios_xelon: 1.5 fixed a bug that dumped `pst` into every namespace |
| 14:44 | thalassios_xelon | ivan how to use it,in 1.5? |
| 14:45 | thalassios_xelon | what to write in my repl to see the stack trace? |
| 14:45 | hyPiRion | ,(require '[clojure.repl :refer [pst])) |
| 14:45 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 14:45 | hyPiRion | ,(require '[clojure.repl :refer [pst]]) |
| 14:45 | clojurebot | nil |
| 14:45 | hyPiRion | ,(pst) |
| 14:45 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable> |
| 14:45 | hyPiRion | like that, I suppose |
| 14:46 | thalassios_xelon | thx thx :) |
| 14:46 | hyPiRion | np |
| 15:28 | edbond | enlive question: how to select tag with text? [:title (html/text-pred #(re-matches #"2012" %))] returns () |
| 15:28 | edbond | please help |
| 15:29 | edbond | [:title] returns {:tag ... :content (".....2012....") } |
| 15:29 | tomoj | &(re-matches #"2012" "foo bar 2012") |
| 15:29 | lazybot | ⇒ nil |
| 15:31 | tomoj | perhaps use re-find instead? |
| 15:32 | tomoj | re-matches checks for a match to the whole string |
| 15:41 | edbond | tomoj: Yes, thanks a lot |
| 15:42 | edbond | docstring not helpful for non-java person |
| 15:45 | tomoj | always confuses me too |
| 15:49 | tomoj | why does nth work on Matchers? |
| 15:49 | tomoj | can't seem to make it useful |
| 15:50 | tomoj | oh |
| 15:50 | clojurebot | excusez-moi |
| 15:51 | tomoj | nope, still don't get it |
| 15:53 | amalloy | tomoj: so that you can destructure them |
| 15:53 | tomoj | but how? |
| 15:53 | amalloy | (not that i recommend actually doing this) |
| 15:53 | tomoj | &(let [[x] (re-matcher #"(foo)" "foo")] x) |
| 15:53 | lazybot | java.lang.IllegalStateException: No match found |
| 15:54 | tomoj | I guess you have to call some java method first? |
| 15:55 | tomoj | &(let [[x] (doto (re-matcher #"(foo)" "foo") .matches)] x) |
| 15:55 | lazybot | ⇒ "foo" |
| 15:55 | tomoj | I see.. |
| 15:55 | amalloy | &(let [[x y] (doto (re-matcher #"(foo)" "foo") .find))] [x y]) |
| 15:55 | lazybot | java.lang.RuntimeException: Unmatched delimiter: ) |
| 15:55 | amalloy | &(let [[x y] (doto (re-matcher #"(foo)" "foo") .find)] [x y]) |
| 15:55 | lazybot | ⇒ ["foo" nil] |
| 15:56 | tomoj | huh, I swear I tried ##(let [[x] (doto (re-matcher #"(foo)" "foo") re-find)] x) |
| 15:56 | lazybot | ⇒ "foo" |
| 16:14 | tomoj | gotta be a better way than this: https://www.refheap.com/paste/63a23eacdb4094df6ca3a6ed2 ? |
| 16:14 | tomoj | that doesn't make sense actually.. |
| 16:15 | tomoj | https://www.refheap.com/paste/0f28e38bf36a36f22b8ad09f4 |
| 16:15 | tomoj | problem is to try (bar), and then 1) if no error was thrown, call foo with the result, otherwise call bar with the error |
| 16:16 | tomoj | ..baz |
| 16:16 | tomoj | (try* (foo (bar)) (catch err (baz err))) sort of works |
| 16:16 | tomoj | except that foo might itself throw an exception |
| 16:17 | tomoj | guess this works https://www.refheap.com/paste/30804cfdcb8bdb4d0cdc942fa |
| 16:18 | tomoj | er, https://www.refheap.com/paste/91a4595205d72c37e133f3970 |
| 16:36 | tieTYT2 | is there something like case that doesn't work on constants? I'd like one that works on regexes |
| 16:36 | tieTYT2 | ah, cond maybe |
| 16:36 | bbloom | tieTYT2: condp = |
| 16:37 | bbloom | ,(condp = 10 "foo" :string (* 2 5) :ten) |
| 16:37 | clojurebot | :ten |
| 16:39 | tieTYT2 | nice |
| 16:40 | tieTYT2 | ,(condp = "foo" "foo" :string (* 2 5) :ten) |
| 16:40 | clojurebot | :string |
| 16:41 | bbloom | ,(condp = :x (do (prn 1) :x) "x" (do (prn 2) :y) "y") |
| 16:41 | clojurebot | 1\n"x" |
| 16:41 | hyPiRion | er |
| 16:41 | Raynes | hyPiRion: Jesus. |
| 16:41 | tieTYT2 | is there a predicate that sees if a regex matches a string? |
| 16:41 | Raynes | hyPiRion: That package was at my doorstep today when I moved in. |
| 16:41 | Raynes | Didn't you literally send it last night? |
| 16:41 | hyPiRion | Raynes: Hi, I know. |
| 16:41 | hyPiRion | I did |
| 16:42 | Raynes | Like, it got here in like 12 hours. |
| 16:42 | tieTYT2 | i always have to do a (not? (nil ... and I don't like that nesting |
| 16:42 | Raynes | That's completely insane. |
| 16:42 | hyPiRion | Amazon's fast |
| 16:42 | bbloom | hyPiRion: (find-doc "regex") |
| 16:42 | bbloom | er i mean tieTYT2 |
| 16:42 | bbloom | tieTYT2: (find-doc "regex") |
| 16:42 | Raynes | Oooh, you bought it on amazon? I thought you shipped it from Norway. |
| 16:42 | Raynes | Okay, that makes more sense since the Amazon warehouse is right here. |
| 16:42 | hyPiRion | I said I would surprise you |
| 16:43 | tieTYT2 | CompilerException java.lang.RuntimeException: Unable to resolve symbol: regex in this context, compiling:(NO_SOURCE_PATH:1) |
| 16:43 | tieTYT2 | oops |
| 16:43 | bbloom | tieTYT2: c'mon now, you can solve that one on your own |
| 16:43 | bbloom | this is me trying to teach a man to fish :-P |
| 16:43 | Raynes | I haven't had a chance to really look at the stuff yet because I'm unpacking. |
| 16:43 | Raynes | But I will. |
| 16:43 | hyPiRion | hah, no worries |
| 16:44 | tieTYT2 | i don't see anything in this list that's a predicate |
| 16:44 | bbloom | tieTYT2: what makes something a predicate? |
| 16:45 | tieTYT2 | it returns a boolean |
| 16:45 | bbloom | tieTYT2: what about if it returns a truthy value or nil ? |
| 16:46 | tieTYT2 | then I've gotta nest more parens which isn't ideal |
| 16:46 | bbloom | ,(if :not-a-boolean true false) |
| 16:46 | clojurebot | true |
| 16:46 | tieTYT2 | i'll just turn one of these into a predicate |
| 16:47 | tjgillies | anyone familiar with shoreleave know how to get a request object inside the remote function, it looks the only args it has are the args passed explicitly from the client |
| 16:48 | bbloom | ,(condp re-matches "xyz" #"a.*" :foo #"x.*" :bar) |
| 16:48 | clojurebot | :bar |
| 16:48 | bbloom | tieTYT2: is that not what what you want? |
| 16:49 | tieTYT2 | oh yeah that'll work |
| 16:49 | tieTYT2 | I was going to do this: |
| 16:49 | tieTYT2 | re-pred #(not (nil? (re-find %1 %2))) |
| 16:49 | hyPiRion | oh dear what |
| 16:49 | tieTYT2 | and then use re-pred in the condp as the pred |
| 16:49 | tieTYT2 | thanks |
| 16:49 | bbloom | tieTYT2: hence my question about what makes a predicate.... just because it doesn't end in a question mark doesn't mean it's not a useful as a predicate :-) |
| 16:50 | tieTYT2 | Yeah I thought those rules only applied to if, I didn't know they work everywhere that wants a predicate |
| 16:51 | tomoj | ,(macroexpand-1 '(condp re-matches "foo" #"f.*" 42)) |
| 16:51 | clojurebot | (clojure.core/let [pred__80 re-matches expr__81 "foo"] (if (pred__80 #"f.*" expr__81) 42 (throw (java.lang.IllegalArgumentException. (clojure.core/str "No matching clause: " expr__81))))) |
| 16:52 | tieTYT2 | ah |
| 16:52 | tomoj | if someone does (if (true? (pred x)) ...) or something in their macro, they failed |
| 16:53 | borkdude | In C# a Predicate is a function that expects 1 argument and returns a boolean. In Clojure I think any pure function of one argument can be a predicate |
| 16:54 | tomoj | (doc condp) |
| 16:54 | clojurebot | "([pred expr & clauses]); Takes a binary predicate, an expression, and a set of clauses. Each clause can take the form of either: test-expr result-expr test-expr :>> result-fn Note :>> is an ordinary keyword. For each clause, (pred test-expr expr) is evaluated. If it returns logical true, the clause is a match. If a binary clause matches, the result-expr is returned, if a ternary clause matches, its result-fn, which m |
| 16:54 | tomoj | "binary predicate" hmm |
| 16:55 | tomoj | I think "predicate" is more about connotation |
| 16:55 | hyPiRion | =, <, >, >=, <=, etc |
| 16:55 | tomoj | if I call "f" a predicate it just means I'm going to do (if (f ...) ...) |
| 16:56 | hyPiRion | There's no semantics within Clojure which defines a "predicate", though they use to end with ? |
| 16:57 | hyPiRion | condp is probably the only one which has the suffix-p from CL |
| 16:57 | borkdude | ,(doc some) |
| 16:57 | clojurebot | "([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)" |
| 16:57 | tomoj | I never know whether to name my predicate-sets with question marks or not |
| 16:58 | borkdude | tomoj ? means: returns a boolean, I think |
| 16:58 | tomoj | (def special-form? (into #{} (keys clojure.lang.Compiler/specials))) |
| 16:58 | tjgillies | anyone know where i can find docs on what options are available to function args e.g. (defn foo [:keys blah :as bar]) |
| 16:58 | borkdude | this is why it's some and not some? |
| 16:59 | tomoj | but who cares whether it actually returns a boolean? |
| 17:00 | tomoj | I mean, is there a problem having a question-marked fn _not_ return booleans? |
| 17:00 | tomoj | I guess if you're going to (frequencies (map special-form? syms)) or something you care.. |
| 17:01 | tjgillies | tomoj: it not very idiomatic ;) |
| 17:01 | tjgillies | it's* |
| 17:02 | hyPiRion | tomoj: Well, there's actually one place where it would fail pretty hard |
| 17:02 | hyPiRion | ,(keep #{:foo :bar} [:foo :baz :bar]) |
| 17:02 | clojurebot | (:foo :bar) |
| 17:02 | hyPiRion | ,(keep (comp boolean #{:foo :bar}) [:foo :baz :bar]) |
| 17:02 | clojurebot | (true false true) |
| 17:03 | tomoj | yeah, OK, (def special-forms ...) :) |
| 17:04 | hyPiRion | It's not insanely hard to punch in a `boolean` here or there though, that's all to it |
| 17:07 | bbloom | tomoj: you can think of a "binary predicate" as a normal predicate that takes a tuple of two values ;-) all functions can technically be thought of as having arity 1. hell, ignoring optimizaitons, clojurescript basically defines every function as (fn [& args]) and then switches on arguments.length |
| 17:07 | borkdude | I changed some functions to (boolean (some .. )) instead of (some ..) just to satisfy unit tests (is (…) true) |
| 17:08 | borkdude | but maybe I could have written (is (…)) or something? |
| 17:08 | Raynes | hyPiRion: Nice, you even sent me Hyperion. |
| 17:08 | bbloom | borkdude: some is an interesting special case |
| 17:09 | bbloom | (doc some) |
| 17:09 | clojurebot | "([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)" |
| 17:09 | bbloom | in theory, some is not foldable |
| 17:09 | bbloom | but some? is |
| 17:09 | borkdude | oh wait, I wrote (is (= … true)), but I could have written (is (true? ...)) |
| 17:09 | borkdude | or maybe even (is ...) |
| 17:10 | borkdude | no |
| 17:10 | bbloom | i've done (boolean (some xyz)) myself in a few cases so that my public API doesn't mandate the linear algorithmic complexity |
| 17:10 | tomoj | how is it not foldable? |
| 17:10 | mthvedt | do clojure closures capture var bindings? |
| 17:10 | bbloom | tomoj: it's LEFT foldable. it's not foldable in the reducers sense |
| 17:11 | tomoj | how not? |
| 17:11 | bbloom | b/c some returns the first value to return true from left to right on sequences |
| 17:11 | tomoj | I guess I'll try to provide a counter-example :) |
| 17:12 | bbloom | i guess some works on maps & in theory that would be foldable |
| 17:12 | bbloom | and sets too |
| 17:12 | borkdude | yes, I could have gotten rid of (boolean ..) by just writing (is …) in the tests |
| 17:13 | tomoj | https://www.refheap.com/paste/92633b5cf1a178e1e47a7422f ? |
| 17:13 | bbloom | ok i retract my statement :-P however, some still returns an element when you may want a public interface to return a boolean, so coercing isn't always a bad thing there |
| 17:13 | tomoj | actually, it should be (if ret (reduced ret) ret') or something? |
| 17:14 | tomoj | oh and I forgot the predicate, whatever.. |
| 17:14 | borkdude | bbloom agree, especially when I write some-test? I expect a boolean |
| 17:16 | tomoj | hmm, will vector folding stop on reduced? |
| 17:17 | tomoj | no |
| 17:17 | tomoj | combinef can't return a Reduced |
| 17:18 | tomoj | so you have to crank through the whole vector even if you find a truthy value in the first partition |
| 17:19 | tomoj | of course.. |
| 17:19 | tomoj | would need weird magic to do otherwise I guess |
| 17:20 | borkdude | unless the threads in which the partitioned work is done could notify when one truthy value had been found ;) |
| 17:21 | tomoj | I guess your reducef could check an atom that your combinef resets? |
| 17:21 | tomoj | checking for Reduced on every reducef is bad enough.. :( |
| 17:30 | tomoj | I wonder how high the cost of instantiating a closure every time you hit a Reduced might go |
| 17:54 | moominpapa | Hi, I was hoping someone could give me some advice. I'm getting a name conflict and I'm trying to figure out what's causing it. |
| 17:54 | moominpapa | The funny thing is a) I know what libraries are the problem (hiccup and clostache) |
| 17:55 | moominpapa | b) I don't seem to be able to replicate it outside of my project |
| 17:55 | moominpapa | Any advice on how to trace the issue? |
| 17:57 | hyPiRion | moominpapa: do you use any `use` or `require ... :refer [...]` within the code? |
| 17:58 | moominpapa | I've been through trying to remove every last one, and I thought I'd managed it. |
| 17:58 | hyPiRion | hum |
| 17:58 | moominpapa | The annoying thing is, it seems to be buried deep. |
| 17:59 | moominpapa | It seems to be something to do with wrap-stacktrace |
| 17:59 | hyPiRion | what's the error msg? |
| 18:02 | moominpapa | http://pastebin.com/8bqv8xmM |
| 18:04 | moominpapa | Semele is the name of my project. |
| 18:05 | hyPiRion | Well, clostache has a private escape-html (https://github.com/fhd/clostache/blob/master/src/clostache/parser.clj#L30), and hiccup has one |
| 18:06 | hyPiRion | I have no idea how they manage to clash though |
| 18:08 | moominpapa | Yeah, it's driving me nuts. |
| 18:08 | hyPiRion | moominpapa: https://github.com/noir-clojure/noir/issues/101 may lead you the right way |
| 18:08 | hyPiRion | Oooh, ooh. |
| 18:10 | hyPiRion | hm, moominpapa, try out lein clean first |
| 18:12 | tomoj | nice, hiccup is second google result for "hiccup" now? |
| 18:12 | moominpapa | Trying... |
| 18:15 | jeremyheiler | tomoj: I wonder how much of that is influence by search history. |
| 18:15 | bosie | |
| 18:16 | rebcabin | looking for idiomatic way to convert list of key-value vectors into map, e.g. not (reduce (fn [m [k v]] (merge m {k v})) {} '([:a 1] [:b 2])) |
| 18:17 | rebcabin | ... which did actually roll off the tongue, but yucch |
| 18:17 | tomoj | jeremyheiler: I have an alias that launches chrome with a brand new profile |
| 18:17 | tomoj | so unless they're looking at my IP or something.. |
| 18:17 | tomoj | #'hiccup.core/escape-html ? |
| 18:17 | jeremyheiler | ,(into {} [:a 1 :b 2 :c 3]) |
| 18:17 | tomoj | what the hell is that? |
| 18:17 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword> |
| 18:17 | tomoj | there shouldn't be a #'hiccup.core/escape-html |
| 18:17 | jeremyheiler | tomoj: nice |
| 18:18 | jeremyheiler | hmm, that was a guess |
| 18:18 | hyPiRion | jeremyheiler: not a bad one |
| 18:18 | rebcabin | jeremyheiler: into doesn't look right because it takes a vector of an even number of elements, not a list of 2-element vectors |
| 18:18 | jeremyheiler | (apply hash-map [:a 1 :b 2 :c 3]) |
| 18:18 | jeremyheiler | ,(apply hash-map [:a 1 :b 2 :c 3]) |
| 18:18 | clojurebot | {:a 1, :c 3, :b 2} |
| 18:18 | jeremyheiler | rebcabin: oops! i should probably read! |
| 18:19 | rebcabin | jeremyheiler: my input is a list of 2-element vectors, like '([:a 1] [:b 2]) |
| 18:19 | hyPiRion | ,(into {} '([:a 1] [:b 2])) |
| 18:19 | clojurebot | {:a 1, :b 2} |
| 18:19 | hyPiRion | so jeremyheiler is right, just read it incorrectly |
| 18:19 | rebcabin | ok lemme try |
| 18:20 | rebcabin | lovely, ty jeremyheiler and hyPiRion |
| 18:21 | tomoj | "Unable to resolve var: hiccup.core/escape-html in this context" hmm |
| 18:21 | jeremyheiler | np. next time i'll try to be less confused |
| 18:22 | hyPiRion | jeremyheiler: oh, don't you worry. Once I read a read a question which was like this "Is there a more idiomatic way to do (foo (bar x))?" |
| 18:22 | hyPiRion | And I answered "Why not just do (foo (bar x))?" |
| 18:22 | jeremyheiler | hyPiRion: hah |
| 18:22 | rebcabin | good one |
| 18:23 | rebcabin | my fancy-schmancy used destructuring and merge and reduce, boffo |
| 18:23 | rebcabin | triple overkill |
| 18:24 | jeremyheiler | rebcabin: Sometimes it takes overkill to realize there's a simpler solution. |
| 18:24 | hyPiRion | rebcabin: reduce-kv is a new one which is cool though, and would've been a "nice" fit for this case |
| 18:24 | rebcabin | i will take a look |
| 18:24 | hyPiRion | Well, not "nice fit", but it is a reduce over a map |
| 18:25 | rebcabin | nod |
| 18:27 | rebcabin | jeremyheiler: "invent then simplify" |
| 18:27 | jeremyheiler | rebcabin: def |
| 18:28 | moominpapa | Thankyou guys, lein clean was what I needed *doh*. Took a while to confirm it had fixed the problem. Now I can get back to the original problem :) |
| 18:29 | hyPiRion | moominpapa: ok, glad to know it worked! Happy hacking |
| 18:29 | moominpapa | Now I need to go and learn what, exactly, lein clean does now that there isn't a deps folder... |
| 18:30 | jeremyheiler | moominpapa: It just removes target/ I think. |
| 18:30 | hyPiRion | moominpapa: oh, what leiningen version do you use? |
| 18:30 | hyPiRion | We place stuff within ~/.m2/ these days |
| 18:30 | moominpapa | 2.0.0 |
| 18:35 | chessguy | hi all. i'm kind of a newbie to clojure, playing around with pedestal. can someone help me understand how to make a change in the library code and build it for my application? |
| 18:36 | gfredericks | just for testing, or would you want to push it up to clojars as well? |
| 18:36 | chessguy | just for testing for now |
| 18:40 | gfredericks | I can't remember if the lein checkouts feature is supposed to still work or not |
| 18:40 | moominpapa | It works |
| 18:40 | gfredericks | that's the classic way to do it at least |
| 18:40 | moominpapa | Used ittoday |
| 18:41 | chessguy | oh, i remember reading something about that. i'll go find that, thanks |
| 18:42 | moominpapa | It's in the readme. (As someone else told me a few years back.) |
| 18:42 | moominpapa | Actually, more embarrasingly, it was technomancy |
| 18:42 | kmicu | Or my env is evil or 'lein new pedestal-service helloworld' (v1.3.0-SNAPSHOT) gives me 'forbidden' instead of 'hello world'. |
| 18:48 | chessguy | kmicu: interesting. i've been playing with 0.1.2 and it's ok |
| 18:49 | chessguy | kmicu: how did you even get 1.3.0-snapshot? |
| 18:52 | kmicu | chessguy: examples from 'samples' like chat, helloworld-app which use pedestal 0.1.0 works good |
| 18:53 | chessguy | kmicu: ok... |
| 18:54 | kmicu | Can sbd with lein 2.1.2 try 'lein new pedestal-service helloworld', lein repl, (use 'dev), (start) and checkout localhost:8080? |
| 18:57 | chessguy | kmicu: that works for me |
| 18:58 | kmicu | chessguy: Do you have 0.1.3-SNAPSHOT in project.clj? |
| 18:59 | chessguy | kmicu: you mean like this? [io.pedestal/pedestal.service "0.1.3-SNAPSHOT"] |
| 18:59 | kmicu | yes |
| 19:00 | chessguy | kmicu: when i do that, 'lein deps' fails, saying it can't find the artifact |
| 19:06 | johnmn3 | g'day |
| 19:07 | johnmn3 | I figured this out once before, but I lost my code for it... how to get at the bytes of a file in clojurescript (javascript) |
| 19:07 | johnmn3 | I have the file object but I can't do a seq on it |
| 19:09 | kmicu | chessguy: 0.1.2 works for me, in that case latest pedestal version/HEAD is not ready ;] Good to know. Thx for response. |
| 19:15 | danneu | sup team |
| 19:21 | chessguy | kmicu: how did you get 0.1.3 ? |
| 19:23 | chessguy | hi danneu |
| 19:24 | kmicu | chessguy: from pedestal's github repo, they started 0.1.3 dev yesterday |
| 19:24 | kmicu | but it's not ready ;] |
| 19:24 | chessguy | ok |
| 19:28 | callenbot | just got done looking at Riemann |
| 19:28 | callenbot | this is some really cool stuff. |
| 19:28 | callenbot | is anybody using it for anything? |
| 19:33 | muhoo | hyPiRion: (-> x bar foo), is how i'd instinctively write that |
| 19:35 | muhoo | i got addicted to -> and ->> after watching ztellman over his shoulder as he worked on a problem. |
| 19:37 | hyPiRion | well, it really depends on the foo and bar |
| 19:43 | johnmn3 | Shouldn't this work? (.readAsText (js/FileReader.) my-file) |
| 19:43 | johnmn3 | as per: http://www.w3.org/TR/file-upload/#dfn-readAsText |
| 19:45 | johnmn3 | I'm trying to get to the byte level contents of the file |
| 19:48 | tomoj | that works |
| 19:49 | tomoj | well, except, doing it that way is useless :) |
| 19:50 | tomoj | but your problem isn't your cljs |
| 19:51 | johnmn3 | where am I going wrong? |
| 19:52 | tomoj | readAsText is void |
| 19:52 | tomoj | you have to attach event listeners to the FileReader |
| 19:53 | tomoj | see step 6+ in your link |
| 19:53 | johnmn3 | Then maybe I shouldn't be using a FileReader |
| 19:53 | johnmn3 | because I already have the file |
| 19:54 | johnmn3 | and I used a FileReader with the event listener to get to it before. |
| 19:59 | tomoj | dunno.. https://www.refheap.com/paste/8c683acc173571df9cd604d54 |
| 20:01 | johnmn3 | that works |
| 20:01 | johnmn3 | but just 3 weeks ago I had a way I could just get at the bytes of a file |
| 20:03 | johnmn3 | (something (slice. (make-file "asdfgh") 0 5)) |
| 20:03 | johnmn3 | -> "asdfg" |
| 20:03 | johnmn3 | something like that |
| 20:08 | tomoj | Blob.prototype only contains 'slice', which returns another Blob, so I don't see how that could be possible |
| 20:09 | johnmn3 | so there is no syncronous access to the contents of a blob? |
| 20:10 | tomoj | afaik, no |
| 20:10 | tomoj | dunno who you should ask, ##javascript? |
| 20:13 | squidz | what are clojures opinions on when it is best to use NoSQL instead of SQL Databases |
| 20:14 | Glenjamin | why is it that, this works: |
| 20:14 | Glenjamin | &(map #(Exception. %) ["a" "b" "c"]) |
| 20:14 | lazybot | ⇒ (#<Exception java.lang.Exception: a> #<Exception java.lang.Exception: b> #<Exception java.lang.Exception: c>) |
| 20:14 | Glenjamin | but this doesnt: |
| 20:14 | Glenjamin | &(map Exception. ["a" "b" "c"]) |
| 20:14 | lazybot | java.lang.ClassNotFoundException: Exception. |
| 20:15 | hyPiRion | Glenjamin: Same reason as this: |
| 20:15 | Glenjamin | squidz: do you have a problem that YesSQL isn't solving? |
| 20:15 | hyPiRion | ,#(Exception. %) |
| 20:15 | clojurebot | #<sandbox$eval36$fn__37 sandbox$eval36$fn__37@14fa4de> |
| 20:15 | hyPiRion | ,Exception. |
| 20:15 | clojurebot | #<CompilerException java.lang.ClassNotFoundException: Exception., compiling:(NO_SOURCE_PATH:0:0)> |
| 20:15 | Glenjamin | so Exception. isn't a function? |
| 20:15 | hyPiRion | Exactly |
| 20:15 | squidz | Glenjamin: so just going YesSQL until you hit a rough patch is when you should start looking at NoSQL=? |
| 20:16 | hyPiRion | It's a special form, therefore you have to wrap it |
| 20:16 | Glenjamin | if you have experience with SQL, and you don't have a pressing need - i'd say stick to what you know |
| 20:17 | muhoo | (Foo.) is sugar for (new Foo), right? |
| 20:17 | squidz | Glenjamin: alright, I guess I was hoping to be oohd and aahd , but what you say seems unsurprisingly reasonable |
| 20:17 | Glenjamin | but where possible, dont tie your core application logic to your choice of data storage |
| 20:18 | hyPiRion | muhoo: you can check |
| 20:18 | Glenjamin | redis is pretty cool for mixing alongside more traditional storage |
| 20:18 | hyPiRion | ,(macroexpand-1 '(Exception. foo)) |
| 20:18 | clojurebot | (new Exception foo) |
| 20:18 | squidz | Glenjamin: how would you suggest keeping the data storage from leaking into the application? |
| 20:19 | Glenjamin | model your domain entities as plain objects/records |
| 20:19 | tomoj | apparently noone on the internet has yet suggested the connection between nosql and nonapples O_o |
| 20:19 | Glenjamin | and have a set of functions for sending them to and from the data store |
| 20:19 | squidz | for sending maps to the datastore? |
| 20:20 | Glenjamin | the logic for how the record translates to storage, and vice versa all lives in one module |
| 20:20 | squidz | okay but by plain objects and records, do you mean clojure maps? |
| 20:21 | Glenjamin | probably defrecord |
| 20:21 | Glenjamin | which gives you a map-like thing with a type |
| 20:22 | squidz | so the additional type is worth abandoning the simplicity of plain maps? |
| 20:22 | Glenjamin | it's still a plain map |
| 20:23 | Glenjamin | http://clojure.org/datatypes |
| 20:23 | Glenjamin | it's basically a map, but slightly faster and you can extend protocols and things with it |
| 20:24 | squidz | okay. So I should shove all the converting/deconverting to either protocols/maps into one icky layer between the DB and the application? |
| 20:26 | Glenjamin | pretty much |
| 20:26 | Glenjamin | but write it from the application's POV |
| 20:27 | Glenjamin | so data/latest-posts, rather than data/posts {:order :date} |
| 20:27 | Glenjamin | etc |
| 20:28 | squidz | okay thanks for the pointers |
| 20:39 | muhoo | why use domina instead of jayq? |
| 20:40 | muhoo | if i alreafy have to use jquery anyway (for bootstrap, jui, etc) |
| 20:49 | augustl | what's the easiest way to get a byte array from a File in Cloure? Any built-in stuff for that? |
| 20:51 | tomoj | (.getBytes (slurp f)) ? |
| 20:51 | augustl | I'd rather not stringify it first |
| 20:52 | augustl | sounds like encoding errors waiting to happen.. |
| 20:52 | tomoj | (let [o (java.io.ByteArrayOutputStream.)] (io/copy f o) (.toByteArray o)) |
| 20:53 | tomoj | you're right about encoding errors |
| 21:09 | john2x | how do I add a local project as a dependency in project.clj? |
| 21:11 | hughfdjackson | at what point do PersistentHashTries become more effecient (timewise) than full-copies of Java Hashmaps? |
| 21:12 | hughfdjackson | i'm asking because i'm making a js equivalent (although i know mori is a thing ;) ) |
| 21:12 | hughfdjackson | and i want to know what state-of-the-art looks like in clojure-land |
| 21:28 | chessguy | so am i understanding correctly that clojure's ring is roughly equivalent to ruby's rack? |
| 21:34 | hyPiRion | Wow, Clojure 1.0.0 is like super duper fast |
| 21:40 | danneu | gee, Ring wiki on github is so good |
| 22:17 | gfredericks | hyPiRion: try using binding on random vars |
| 22:17 | gfredericks | just because you can |
| 22:18 | hyPiRion | oh, why? |
| 22:18 | gfredericks | hyPiRion: also you could try ##(apply * (repeat 400 2)) |
| 22:18 | lazybot | java.lang.ArithmeticException: integer overflow |
| 22:18 | gfredericks | hyPiRion: because it's fun? |
| 22:19 | gfredericks | chessguy: yes. |
| 22:19 | hyPiRion | huh, binding plus to minus works |
| 22:19 | hyPiRion | but it's just plussing though |
| 22:19 | hyPiRion | sad. |
| 22:19 | chessguy | gfredericks: thanks |
| 22:20 | hyPiRion | oh wait, not if I deref the var. gfredericks, have you worked with 1.0 before? |
| 22:20 | gfredericks | hyPiRion: + and - are probably inlined |
| 22:20 | danlarkin | ah 1.0, those heady times |
| 22:20 | gfredericks | I can't even remember if I worked with 1.0 or not |
| 22:22 | hyPiRion | gfredericks: Well, there's this super neat feature with 1.0, the ^ literal means `meta` if you have a space after it |
| 22:23 | hyPiRion | So with that abusement, I've shortened the Swearjure bootstrapping to this: https://www.refheap.com/paste/13135 |
| 22:31 | locks | that looks almost like brainfuck |
| 22:31 | hyPiRion | yeah, it is |
| 22:36 | gfredericks | hyPiRion: so I guess the change we need to sneak in is basically just a git-reset? |
| 22:37 | gfredericks | yo rhickey whaddayasay for old time's sake we make 1.6 == 1.0 |
| 22:37 | hyPiRion | heheh |
| 23:06 | Raynes | gfredericks: NaNNaNNaNNaNNaNNaNNaNNaN |
| 23:10 | hyPiRion | oh, the js/ruby talk |
| 23:11 | Raynes | Not bad hyPiRion, only took you 4 minutes. |
| 23:11 | uvtc | How can I get every element of a seq but the nth one? (I think I want a "`but-nth`" function...) |
| 23:12 | uvtc | I want to remove just the nth item, and have what's left. |
| 23:12 | hyPiRion | uvtc: use a combination of concat, take and drop |
| 23:13 | uvtc | hyPiRion: tanks! |
| 23:13 | hyPiRion | like, (concat (take Xs (dec n)) (drop Xs n)) should do, I think |
| 23:13 | hyPiRion | np |
| 23:22 | tieTYT2 | i'm writing a test and I'm with-redef'ing a function that uses an http client and returns a url. My test would be better if this function could return a different thing each time it's called. How can I do this? |
| 23:26 | tieTYT2 | even tho there's no threading involved. I'm wondering if I should use an atom that I increment each time i call it |