2012-08-20
| 00:09 | bubba424242 | hi any recommendation of a framework for building restful webservices -- similar to cherrypy |
| 00:13 | triggernz | A lot of the requirement for ordered maps is simply presentational |
| 00:14 | triggernz | I love to see maps in order in my repl , but otherwise I don't care |
| 00:14 | triggernz | Am I the only one? |
| 00:14 | nsxt | bubba424242: compojure? |
| 00:15 | bubba424242 | @nsxt ... looking @ compojure now ... I'm new to clojure :-) |
| 00:17 | technomancy | Gnosis-: just export LEIN_JVM_OPTS instead |
| 00:17 | technomancy | bubba424242: compojure is definitely the place to start |
| 00:18 | technomancy | bubba424242: or just ring if you don't have complicated routes |
| 00:18 | amalloy | triggernz: so, do you hate me for making maps print as #ordered/map ([1 2]) instead of as {1 2}? |
| 00:18 | bubba424242 | thanks @technomancy |
| 00:19 | amalloy | just ring, man? possible but kinda rough even for the simplest apps, i'd imagine |
| 00:20 | technomancy | if you have <4 endpoints it's great |
| 00:21 | xeqi | I use net.cgrand/mustache for small endpoints |
| 00:22 | technomancy | https://github.com/technomancy/chortles/blob/master/src/chortles/web.clj |
| 00:23 | xeqi | well if you only have one handler .... |
| 00:24 | xeqi | ~chortle |
| 00:24 | clojurebot | excusez-moi |
| 00:25 | technomancy | or two; adding (if (= :post (:method req)) ...) isn't horrible |
| 00:26 | technomancy | or even three with a cond, but with more than 4 you'd end up reinventing compojure |
| 00:28 | triggernz | No I don't mind at all |
| 00:30 | axle_512 | basically, compojure has a small dsl to deal with the task of parsing information from the request map, right? |
| 00:37 | xeqi | routing, and destructuring the request map |
| 00:38 | xeqi | though I guess routing is a special case of parsing information out |
| 00:39 | axle_512 | xeqi: thanks |
| 00:45 | triggernz | amalloy: where can I find ordered? |
| 00:45 | amalloy | $google github flatland ordered |
| 00:45 | lazybot | [flatland/ordered · GitHub] https://github.com/flatland/ordered |
| 00:48 | triggernz | Cool cool |
| 00:49 | axle_512 | For scraping sites, I really like enlive. I haven't tried it for rendering html. Anyone tried using it instead of hiccup? |
| 00:52 | Gnosis- | technomancy: so there's no problem with the flag itself, though? |
| 00:52 | Gnosis- | I asked because it seems like lein repl uses a lot of memory |
| 01:00 | amalloy | Gnosis-: 128MB is still way more than you'll need in most real-life apps. if i were worried about memory usage in my repl, i'd (a) set Xmx to like 30m, and (b) make sure to `lein trampoline repl` |
| 01:01 | Raynes | axle_512: I prefer Mustache over enlive. |
| 01:01 | Raynes | For templating, I mean. |
| 01:01 | Raynes | I imagine enlive is nice for scraping. |
| 01:01 | Gnosis- | amalloy: ah, thanks |
| 01:01 | Gnosis- | I'll try 30m and see if it breaks anything |
| 01:04 | axle_512 | Raynes: thanks… I'll have a look at mustache. (Not to be confused with cgrand/moustache, eh?) |
| 01:05 | amalloy | Gnosis-: unless you're working with large data structures, 30m is probably file; 4clojure runs on 60m because the server is a little cramped |
| 01:16 | michaelr` | good morning! |
| 01:28 | mk | michaelr`: mornin' |
| 02:20 | michaelr` | i need something like (with-auth-approved-user (do-stuff)), in case user is not approved it should be redirected somewhere else |
| 02:20 | michaelr` | is this a good case to use a macro? |
| 02:20 | michaelr` | to implement with-auth-approved-user |
| 02:28 | xeqi | michaelr`: you could either take a function, or make a macro |
| 02:28 | clj_newb_235242 | is there any record of anyone doing HFT with clojure? or does the Java GC just kill the possibility |
| 02:29 | xeqi | https://github.com/cemerick/friend/ chooses the macro direction if you want a comparison |
| 02:33 | michaelr` | xeqi: yeah, the syntax is more |
| 02:33 | michaelr` | friendly |
| 02:33 | michaelr` | :) |
| 02:35 | michaelr` | haha |
| 02:36 | michaelr` | clojure is really crazy (in the good sense) when refactoring |
| 04:33 | augustl | in ring, is it possible to make the nested params middleware add the data to something other than :params? |
| 04:33 | augustl | :params also contains URL parameters etc, I just want the nested params from the body, and not the URL params |
| 04:33 | augustl | it seems that :params is hard-coded, but I thought I'd ask anyway.. |
| 04:34 | weavejester | augustl: No, I don't believe so. Nested-params needs a bit of an overhaul, really. |
| 04:34 | weavejester | augustl: Unless you wrote middleware to wrap nested-params, or created your own nested-params. |
| 04:35 | augustl | ah, I could wrap it, good idea |
| 04:41 | ideamonk | How does one go about passing an operator as argument to a funciton ? I'd like to extract combine fn out and pass +/- as an argument to it here - http://cljbin.com/paste/5031f6d2e4b0ce7c4f973b53 |
| 04:42 | llasram | ideamonk: There's no such thing as an "operator" in Clojure. + and - are in fact functions you can pass as arguments :-) |
| 04:42 | algernon | ideamonk: (defn combine [f & l]), and then use (reduce f ...) |
| 04:42 | ideamonk | llasram algernon , trying |
| 04:43 | nbeloglazov | ideamonk: nested defn is a bad idea, why do use them? |
| 04:43 | llasram | ideamonk: BTW, looking at your code, nested `defn`s are almost certainly not what you want. Unlike `define` in scheme, the `defn` form explicitly always creates a var interned in the namespace -- ie, a top-level function |
| 04:44 | ideamonk | nbeloglazov new here :) |
| 04:44 | ideamonk | llasram oh! didn't know this about defn |
| 04:45 | ideamonk | Nice, so I end up with this - http://pastebin.com/raw.php?i=vFcvEE8V |
| 04:46 | llasram | Lookin' good! |
| 04:46 | ideamonk | Thx |
| 04:47 | llasram | Minor suggestion, (apply str ...) is more common than (reduce str ...). The latter will call `str` multiple times with each added substring, whereas the form will call it once with the lazy sequence of all the substrings |
| 04:48 | llasram | s,form,former, |
| 04:50 | ideamonk | I'm pretty new to clojure, is there a way to see the call chain to compare multiple ways of doing things ? |
| 04:52 | llasram | Well, you can use the standard Java profiling tools, maybe? I'm not sure really. What would be an example of what you have in mind, for some other language? |
| 04:53 | nbeloglazov | ideamonk: I also have 2 style suggestions. Dash-separated-lowercase-words names are used for functiona and variables in clojure. So 'value-for' and 'encryption-key' more idiomatic |
| 04:54 | ideamonk | llasram I actually meant best practices, I guess looking at apply & reduce implementations could help there |
| 04:55 | ideamonk | nbeloglaznov thx |
| 05:09 | nkkarthik | in the repl, how can i quickly find out what a function does? |
| 05:09 | clgv | nkkarthik: using `doc` for once |
| 05:10 | nkkarthik | I mean in clojure I can do (doc symbol?) in repl |
| 05:10 | eddie_ | Hi #clojure. I've written a little toy script... I'm just learning Clojure. What's the best place to request an easy code review? stackexchange? the ClojureMailingList? |
| 05:10 | nkkarthik | clgv: oops... sorry... this is meant for #racket... wrong window |
| 05:10 | nkkarthik | sorry folks |
| 05:10 | clgv | eddie_: make a paste and postz it here. someone usually will look at it |
| 05:11 | llasram | eddie_: Probably here, I'd say |
| 05:11 | llasram | See, two people can't both be wrong! |
| 05:11 | clgv | eddie_: if not and you have problems with the code try the ML |
| 05:11 | amalloy | ideamonk: there's more repetition in your encrypt/decrypt than i'd like - you might consider https://gist.github.com/3402511 instead |
| 05:11 | nkkarthik | clgv: thank you |
| 05:11 | ideamonk | yup, just removed that :) |
| 05:12 | ideamonk | amalloy http://pastebin.com/raw.php?i=BKE3VXZj |
| 05:13 | ideamonk | amalloy yours looks much better |
| 05:13 | amalloy | meh. yours prints better docstrings |
| 05:14 | amalloy | i'm not really sure about my decision to turn combine into a function-returning-lambda, since the only point there was to avoid typing #(combine f %1 %2), which is no longer repeated |
| 05:15 | ro_st | this looks interesting http://cell-lang.org/ |
| 05:15 | eddie_ | Here I put my simple script... if someone would find a few minutes for some advice, it would be really appreciated:: http://pastebin.com/DegSUaaE |
| 05:17 | amalloy | eddie_: you need function names or variable names that describe what you're doing. it just looks like so much gibberish without an explanation |
| 05:17 | clgv | eddie_: you should always add info what you are trying to do, as well as afew examples that show what output you expect for what input |
| 05:18 | clgv | eddie_: and do not use the old deprecated clojure.contrib lib |
| 05:18 | eddie_ | thank! |
| 05:18 | eddie_ | thanks! |
| 05:18 | amalloy | and foo looks like a reimplementation of ##(doc iterate), since all you're doing is applying a function to s N times |
| 05:18 | lazybot | ⇒ "([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects" |
| 05:45 | bjarte | Hi - has anyone a good solution for getting the cl/quicklisp and clojure to work well together in Emacs? |
| 05:57 | nz- | is there tool for emacs that would tell when my parenthesis are not balanced? |
| 06:09 | clgv | nz-: rainbow parrens? |
| 06:14 | nz- | clgv: http://www.emacswiki.org/emacs/RainbowDelimiters ? |
| 06:15 | clgv | nz-: idk, I am no emacs guys - but it has rainbow parens as far as I heard - probably some clojure-mode |
| 06:15 | Raynes | nz-: paredit will prevent them from ever becoming imbalanced in the first place if you don't mind a bit of a learning curve. |
| 06:15 | Raynes | bjarte: Don't use SLIME. Use nrepl.el instead. |
| 06:15 | Raynes | bjarte: Then you can continue having your cl configuration just the way you like. |
| 06:16 | nz- | Raynes: I tried paredit and didn't like it |
| 06:16 | Raynes | If you use SLIME with Clojure, you're going to have to use an old version of SLIME because of incompatibilities with swank-clojure and the fact that the SLIME team apparently does everything imaginable to make it impossible to follow development. |
| 06:16 | Raynes | nz-: Try longer. |
| 06:18 | ro_st | nz-: try longer, definitely. it makes lisp editing sane |
| 06:19 | Raynes | The day I need to think about whether or not my parens are balanced is the day I stop coding until my Emacs is fixed. |
| 06:19 | ro_st | i even use monger with clojure-swank (haven't gone nrepl.el yet) in emacs as a mongodb shell instead of the one mongo provides precisely because of paredit |
| 06:20 | cemerick | ro_st: more like, I wish other languages had parens too, so I could edit them as easily as Clojure with paredit-style features. |
| 06:20 | Raynes | cemerick: I've found paredit to be fairly useful with javascript and other languages with arg list parens. |
| 06:20 | ro_st | yes! i get so lost when i have to edit php because i can't select by form (C-M-space in emacs/paredit) |
| 06:21 | antares_ | I used to not like/get paredit, now I use it all the time |
| 06:21 | Raynes | cemerick: How do you get a library into maven central? |
| 06:21 | ro_st | M-r in paredit is also a huge help - replace parent form with current form |
| 06:21 | cemerick | Eclipse has an expand-selection command that mostly works across languages, but that's about it. |
| 06:21 | cemerick | Raynes: https://github.com/technomancy/leiningen/blob/master/doc/DEPLOY.md#deploying-to-maven-central |
| 06:27 | Raynes | cemerick: Do I need to send them a blood sample too to get registered? |
| 06:28 | cemerick | Raynes: Hah. It's a fair bit easier than many bizarre hoops one must jump through here and there. |
| 07:10 | robermann | hi, I'm trying "lein new noir my-website" but I get the error: "Could not transfer metadata noir:lein-template/maven-metadata.xml from/to clojars (http://clojars.org/repo/): Connection to http://clojars.org refused" |
| 07:10 | robermann | followed by: "Could not transfer metadata noir:lein-template/maven-metadata.xml from/to central (http://repo1.maven.org/maven2): Connection to http://repo1.maven.org refused" |
| 07:11 | robermann | Do you know if there is any problem with maven/clojars repos? |
| 07:12 | clgv | robermann: do you have some nasty firewall in-between? |
| 07:13 | robermann | yes, this being the second trouble option. I'm behind a HTTP proxy. |
| 07:15 | clgv | robermann: that's probably the reason. creating a noir project and running it worked like a charm overhere |
| 07:16 | clgv | one access to clojars was made |
| 07:23 | robermann | ok thank you clgv |
| 07:38 | robermann | ok, i got it. |
| 07:39 | robermann | on Windows: "set http_proxy=http://username:pwd@proxy.com:port" then "lein new noir test-noir" |
| 07:39 | robermann | thanks to https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/classpath.clj#L81 |
| 07:50 | clgv | robermann: good to know. maybe that should be written into the FAQ. searching it in source is not pretty userfriendly |
| 08:04 | robermann | clgv: of course you are right, I added the last entry on https://github.com/technomancy/leiningen/wiki |
| 08:05 | clgv | robermann: great! :) |
| 08:05 | clgv | (inc robermann) |
| 08:05 | clgv | $inc robermann |
| 08:05 | clgv | damn. doesnt work anymore ;) |
| 08:05 | lazybot | ⇒ 1 |
| 08:05 | lazybot | ⇒ 2 |
| 08:06 | clgv | uuuh. that's a hell of a timeout for such a simple task ^^ |
| 08:07 | robermann | :) |
| 08:16 | SomeGuy | Hello, anyone home? |
| 08:16 | clgv | ~anyone |
| 08:16 | clojurebot | Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..." |
| 08:17 | SomeGuy | I'm having a small problem completing problem 90 (cartesian product, http://www.4clojure.com/problem/90) on 4clojure and was hoping to get someone's advice on it. |
| 08:18 | SomeGuy | There are 3 tests cases listed and I started having a go at the second one and seem to have got most of the way there but I'm falling short at the last hurdle. Here is my current test |
| 08:18 | SomeGuy | ((fn [l r] (mapcat #(map (fn [a] (vector a %1)) l) r)) #{1 2 3} #{4 5}) |
| 08:18 | SomeGuy | This produces ([1 4] [2 4] [3 4] [1 5] [2 5] [3 5]) |
| 08:19 | clgv | SomeGuy: how much of a hint do you want? |
| 08:19 | SomeGuy | that would depend on how wrong I'm doing it |
| 08:20 | SomeGuy | if I'm not far off a small hint would do but I'm very much stabbing in the dark at the moment. |
| 08:20 | SomeGuy | I've tried creating a set from the results I have but it re-orders the result. |
| 08:20 | clgv | I mean I can name you the function/macro that does the main job with small code size |
| 08:21 | SomeGuy | Go for it I'm basically doing the exercisess to try and learn the functions anyway |
| 08:21 | clgv | to not spoil it for anyone I message you in private |
| 08:22 | SomeGuy | ok, not sure if it will work as I'm at work so I'm using a web client so it depends how sophisticated it is I suppose. |
| 08:23 | SomeGuy | I will see if I can get a client installed instead. |
| 08:24 | clgv | linux? macos? windowS? |
| 08:25 | SomeGuy | Windows |
| 08:25 | clgv | ah well. if you are not already an emacs guy, you can get setup pretty quickly with eclipse and counterclockwise |
| 08:26 | SomeGuy | I've just started using emacs but I haven't quite finished setting everything up yet. |
| 08:27 | bjarte | Raynes: thank you. |
| 08:28 | SomeGuy | Hmm acutally think work might be blocking me so I'll have to log back on later from home but thank you anyway. |
| 08:30 | kral | namaste |
| 09:01 | azkesz | Hi, is there a function/macro already defined for checking if a number is within a certain range ie. [0 to 10) |
| 09:01 | azkesz | like (and (>= n 0) (< n 10)) |
| 09:01 | clgv | azkesz: how about (<= 0 5 10) |
| 09:01 | @Chouser | (< -1 n 10) |
| 09:02 | clgv | &(<= 0 5 10) |
| 09:02 | clgv | ,(<= 0 5 10) |
| 09:02 | clojurebot | true |
| 09:02 | clgv | lazybot seems to have a bad day ^^ |
| 09:03 | azkesz | that's what I was looking for, thank you! |
| 09:03 | bendlas | Hey folks! |
| 09:03 | azkesz | so powerful |
| 09:04 | bendlas | I just wondered: Is there an apply for keyword functions to maps? |
| 09:04 | bendlas | Here is my definition for you to play around with: |
| 09:04 | @Chouser | i have wished for an actual inclusive/exclusive fn before, though. |
| 09:04 | bendlas | (defn apply-kw [f & args-kws] |
| 09:04 | bendlas | (let [args (butlast args-kws) |
| 09:04 | bendlas | kws (last args-kws)] |
| 09:04 | bendlas | (apply f (apply concat args kws)))) |
| 09:06 | clgv | bendlas: what? try it the other way round - what do you want to do? input -> output? |
| 09:06 | azkesz | ,(<= 0 9) |
| 09:06 | clojurebot | true |
| 09:06 | @Chouser | bendlas: I don't know of one, and it does seem like an awkward omission |
| 09:07 | bendlas | clgv: i want to apply a function with that takes keywords onto a map |
| 09:07 | azkesz | ,(pmap #(str (cond (<= 0 % 9) "0") %) [-1 0 1 9 10]) |
| 09:07 | clojurebot | #<SecurityException java.lang.SecurityException: no threads please> |
| 09:07 | azkesz | ,(map #(str (cond (<= 0 % 9) "0") %) [-1 0 1 9 10]) |
| 09:07 | clojurebot | ("-1" "00" "01" "09" "10") |
| 09:08 | bendlas | Chouser: has it come up before and turned down, or can I ask for a ticket at the mailing list |
| 09:08 | clgv | ,(map #(str (when (<= 0 % 9) "0") %) [-1 0 1 9 10]) |
| 09:08 | clojurebot | ("-1" "00" "01" "09" "10") |
| 09:08 | @Chouser | bendlas: I'm not aware of it being turned down. |
| 09:08 | azkesz | is when better? |
| 09:08 | azkesz | or preferred? |
| 09:09 | clgv | you dont have a second clause in your cond, so yes ^^ |
| 09:09 | azkesz | it makes sense, thank you clgv=) |
| 09:09 | @Chouser | bendlas: I'd have some questions about inputs. A seq with a map at the end, like your example? or maybe a seq and a separate map... |
| 09:09 | jkkramer | ~mapply |
| 09:09 | clojurebot | You could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args)))) |
| 09:10 | clgv | bendlas: you do this all for options? |
| 09:12 | bendlas | Chouser: i'd do varargs with a map at the end, as in my example, because it stays true to the spirit of apply itself |
| 09:12 | bendlas | and also it works for fns like (fn [arg1 arg2 & {:keys [kwa1 kwa2]}] ...) |
| 09:13 | bendlas | jkkramer: oh, so at least clojurebot already thought of it ^^ |
| 09:13 | bendlas | clgv: um ... yes? |
| 09:14 | clgv | bendlas: then you might wanna checkout clojure.options on github |
| 09:16 | azkesz | ,(map #(str (when (<= 0 % 9) "0") (int %)) [-2.1 -1 0 1 8.1 9 9.2 10 10.2]) |
| 09:16 | clojurebot | ("-2" "-1" "00" "01" "08" ...) |
| 09:17 | bendlas | clgv: thanks, but I'm not looking for a new syntax, right now ;-) |
| 09:17 | azkesz | ,(map #(str (when (<= 0 % 9) "0") (int %)) [9 9.2 10]) |
| 09:17 | clojurebot | ("09" "9" "10") |
| 09:17 | azkesz | looks like I'm back to using and? |
| 09:17 | clgv | bendlas: it's more than that - the additional syntax symbol was jsut needed for clean separation |
| 09:18 | azkesz | ,(map #(str (when (and (<= 0 %) (< % 10)) "0") (int %)) [9 9.2 10]) |
| 09:18 | clojurebot | ("09" "09" "10") |
| 09:19 | azkesz | still awesome:) |
| 09:19 | clgv | azkesz: why? |
| 09:20 | azkesz | I don't know, I would need [0..10) range |
| 09:20 | bendlas | clgv: still. I'm very happy with the way you *define* kw fns |
| 09:20 | bendlas | I just want to be able to easily apply them to maps, that's all |
| 09:21 | clgv | bendlas: passing options transitively and easily was another goal. the biggest was documentation of parameters though |
| 09:22 | azkesz | clgv, 0 inclusive, 10 exclusive, can't use only one operator (<= 0 n 10) |
| 09:22 | clgv | azkesz: if you need it often just make a function out of it ;) |
| 09:23 | azkesz | clgv, good idea but how would I represent the inclusive/exclusive? |
| 09:23 | azkesz | clgv, when as parameters |
| 09:23 | azkesz | (inrange n [0 10)) |
| 09:23 | azkesz | xD |
| 09:24 | clgv | humm thats one of the things you cant do literally, even with macros. the read wont like it ^^ |
| 09:24 | clgv | *reader |
| 09:24 | S11001001 | azkesz: I guess you are looking for common lisp? :) |
| 09:24 | azkesz | can't do it with macros? lol no way S11 |
| 09:24 | S11001001 | azkesz: you need reader macros to change the read syntax |
| 09:25 | azkesz | I see what you mean, clojure doesn't support that right? |
| 09:25 | clgv | azkesz: either you make several functions, or you provide one or two parameters for the inclusion/exclusion info |
| 09:25 | cshell | Is there a trick to getting clojure.repl/source to work in the repl? When I use it with repl defined functions, it returns nil |
| 09:25 | azkesz | clgv, (in-range n \[ 0 10 \) ) ? |
| 09:26 | clgv | cshell: it needs access to the source files -so no. but there is serializable-fn |
| 09:26 | azkesz | clhv, but it's kinda ugly |
| 09:26 | clgv | azkesz: that would do. but is that better than adiditional parameters? |
| 09:26 | cshell | clgv: thanks, what namespace is that in? |
| 09:27 | clgv | $google clojure serializable-fn |
| 09:27 | lazybot | [technomancy/serializable-fn · GitHub] https://github.com/technomancy/serializable-fn/ |
| 09:27 | azkesz | clgv, I don't know, how would the additional parameters look like? (in-range n incl 0 excl 10) ? |
| 09:27 | azkesz | clgv, or as keywords? :incl :excl ? |
| 09:27 | @Chouser | (between 5 <= n < 10) |
| 09:28 | bendlas | clgv: thanks for pointing me to it, but I'll pass. 300+ locs + new syntax is just too much complexity for my taste ... |
| 09:28 | azkesz | Chouser that looks way better :O |
| 09:28 | cshell | clgv, ah not in a clojure core one - so there's no clojure core way to get the source of the functions back in the repl without serializable-fn? |
| 09:28 | clgv | Chouser: I thought of that as well, but wont save much then |
| 09:28 | @Chouser | cshell: correct |
| 09:28 | clgv | bendlas: dont feel forced to - just a suggestion ;) |
| 09:28 | cshell | Chouser: thanks! |
| 09:29 | azkesz | Chouser would that have to be a macro or a function? |
| 09:29 | clojurebot | chouser: I really did wonder why you had all those photobombers on slide 2.... audio is so useful :) |
| 09:29 | @Chouser | repl/source is more of a cute hack than a real solution. |
| 09:30 | clgv | clojurebot: lol what?? |
| 09:30 | lazybot | clgv: Definitely not. |
| 09:30 | clojurebot | Gabh mo leithsc?al? |
| 09:30 | azkesz | lol |
| 09:30 | @Chouser | azkesz: 'between' could be a function |
| 09:30 | azkesz | ok I'll try that |
| 09:30 | @Chouser | I think clojurebot's talking about my Strange Loop talk from a couple years ago. Don't know why. |
| 09:31 | cshell | Chouser? |
| 09:31 | clojurebot | Why are you asking *him* |
| 09:31 | azkesz | S11001001, 201 from http://www.asciitable.com/index/extend.gif =) I don't get it |
| 09:32 | S11001001 | azkesz: http://csserver.evansville.edu/~sc87/s11-faq |
| 09:32 | cshell | I wonder what triggered clojurebot to say that |
| 09:32 | jcrossley3 | cshell: the singularity? |
| 09:33 | clgv | cshell: he seems to feel lonely ^^ |
| 09:33 | cshell | haha |
| 09:33 | azkesz | S11001001, that's awesome, thanks:) |
| 09:33 | cshell | does anyone have a need for a pure Clojure k-means clusterer? Or is there already one out there that I just haven't found yet? |
| 09:33 | azkesz | it was this: <azkesz> Chouser would that have to be a macro or a function? |
| 09:34 | azkesz | the trigger I mean, cshell |
| 09:35 | cshell | azkesz: cool, I didn't know he could trigger off more than one word |
| 09:35 | clgv | cshell: there is one on github afair |
| 09:40 | cshell | clgv: thanks - thet best one looks like clojure-cluster but it only seems to work with vectors and euclidean distance |
| 09:40 | cshell | I'm in the middle of making one that uses protocols so you can plug in different distance measures (ie. polar) and non vectors |
| 09:41 | azkesz | (defn between [num1 op1 num2 op2 num3] (if (and (op1 num1 num2) (op2 num2 num3)) true false)) |
| 09:42 | azkesz | oh i don't need the if? |
| 09:42 | azkesz | awesome! |
| 09:42 | azkesz | but can I make it accept infinite parameters? minimum of 3 and they have to be odd |
| 09:43 | clgv | azkesz: by using every? with your new built predicate? |
| 09:43 | clgv | azkesz: or do you meant sth different? |
| 09:44 | azkesz | I don't really get either |
| 09:44 | cshell | Also, I've been using IntelliJ/LaClojure for Clojure development - would it be better to learn Emacs/SLIME or stick with LaClojure and spend my time making that better? |
| 09:44 | nDuff | azkesz: (defn between [num1 op1 & rest] (and (apply op1 num1 rest) (apply op2 rest))) |
| 09:44 | cshell | I basically want the best REPL experience possible |
| 09:45 | nDuff | cshell: I'd suggest looking at Emacs Live |
| 09:45 | cshell | nDuff: by overtone? |
| 09:45 | mdeboard | cshell: If you want the best REPL experience possible, and you have to do work to make LaClojure better, then I'd say LaClojure wouldn't be the best REPL experience possible. |
| 09:45 | nDuff | cshell: Overtone is the project that prompted it, same maintainer, yes |
| 09:45 | mdeboard | Or of course you could just download Light Table playground :P |
| 09:46 | @Chouser | cshell: I love vim bindings, so I prefer emacs+evil. But I'm sad that the visual output available is so much more constrained than what IntelliJ could theoretically provide. |
| 09:46 | cshell | nDuff: How does Emacs Live compare to technomancy's starter kit? |
| 09:46 | @Chouser | azkesz: You can do infinite parameters |
| 09:47 | azkesz | nDuff, maybe that's not what I want? something like (between 0 <= n <10 <= x < 20 >= y >=-1 ) |
| 09:47 | cshell | mdeboard: lighttable looks sweet, but what is the best REPL experience today? |
| 09:47 | azkesz | Chouser, forsure but I'm trying to figure out how to process them |
| 09:47 | nDuff | azkesz: Indeed, that doesn't look like what you want, then. |
| 09:47 | mdeboard | cshell: "best" is unbelievably subjective. |
| 09:47 | cshell | ChanServ: yeah, IntelliJ could be really awesome, and it's one area where I think could use some help that I could provide cause LaClojure seems to be kinda dead right now |
| 09:48 | mdeboard | Chanserv |
| 09:48 | mdeboard | lol :P |
| 09:48 | cshell | Oops, Chouser I meant :) |
| 09:48 | @Chouser | cshell: If you like IDEs, you might find the eclipse plugin to be more active. |
| 09:49 | azkesz | clgv, I'm exploring your every? sugestion :) |
| 09:49 | cshell | mdeboard: agreed, and poor choice of words by myself :) The REPL in intellij is nice, but it can lock up and lose state - I want to experience that REPL where it's up for days and evolves and that's where you do all of your coding - Now, I just type into a file then run tests against it |
| 09:49 | @Chouser | lpetite is actually sponsored part-time by Relevance to work on counter-clockwise |
| 09:49 | cshell | Chouser: you mean counter clockwise? That's the one that's supported by Relevance, right? |
| 09:49 | @Chouser | :-) |
| 09:50 | cshell | haha |
| 09:50 | @Chouser | azkesz: you might want the 3-argument for of partition as well |
| 09:51 | @Chouser | form |
| 09:51 | clgv | (inc CounterClockWise) ;) |
| 09:51 | lazybot | ⇒ 1 |
| 09:51 | azkesz | chouser, that makes sense now=) |
| 09:52 | clgv | azkesz: oh, in the case you posted - forget my `every?` suggestion - I thought you had one range and multiple values to check against it |
| 09:52 | azkesz | ok |
| 09:52 | mdeboard | cshell: That's my normal workflow with Emacs/slime |
| 09:53 | cshell | mdeboard: How do you go back and get all the functions you've defined over that period? Is it just scrolling back through the buffer? |
| 09:54 | cshell | mdeboard: or did you mean you're entering into a file then running tests? |
| 09:54 | @Chouser | cshell: Maybe lighttable will get there, but no repl environment I've seen for Clojure helps as much as it seems like it could to transition "scratch" code entered at the repl into "saved" code in a project. |
| 09:55 | roma1n_p | Hi everyone, is there a Clojurescript xml parser that would let me treat xml fragments as a clojure data structure? (sort of like hiccup/crate in reverse)? |
| 09:55 | cshell | Chouser: exactly what I'm looking for - it seems that that would be very useful if you're doing days of dev in a REPL |
| 09:55 | @Chouser | Instead, I enter new functions I think I'll want later into a file (and eval them with a keystroke), and then test them at the repl |
| 09:55 | archaic | I wonder is it a goal of lighttable to be extensible in clojure, like emacs with elisp |
| 09:55 | mdeboard | archaic: I believe that it is, yes |
| 09:55 | cshell | Chouser: yeah, that's what I've been doing too - are you using emacs too? |
| 09:56 | @Chouser | sometimes I guess wrong and a "throwaway" function that I entered at the repl needs to be saved, and I end up copy-pasting |
| 09:56 | @Chouser | cshell: yes, emacs+evil |
| 09:56 | nz- | is there some good video tutorial on how to properly use repl/slime in development? |
| 09:56 | archaic | do you use paredit with evil? |
| 09:56 | mdeboard | cshell: I use a file as 'scratch', highlight, then slime-eval-buffer so I have access to it in the repl.] |
| 09:57 | @Chouser | archaic: yes |
| 09:57 | archaic | so do I, I think there is room for much better integration between them |
| 09:57 | @Chouser | mdeboard: does your repl buffer then only contain outputs, not the forms that generated them? |
| 09:57 | archaic | I have been thinking of a paredit type mode |
| 09:59 | @Chouser | Yeah, I switched to emacs expecting to be blown away by the slime repl environment. I wasn't. It's incrementally better than having a good text editor in one window and a console repl in another. |
| 09:59 | mdeboard | Chouser: I don't have the function bodies if that's what you're asking. (I've never been clear on what a form is in Clojure terms) |
| 10:00 | azkesz | ~form |
| 10:00 | clojurebot | (String/format "%s is (.format "%s |
| 10:01 | cmiles74 | Just catching up on this conversation; my two cents: I also write the function in my file, then evaluate, then test in the SLIME repl. Wash, rinse, repeat. |
| 10:01 | azkesz | looks broken, even if that's not what I wanted=) |
| 10:01 | mdeboard | but nothing can beat what Light Table is *aiming* for |
| 10:01 | @Chouser | mdeboard: I just mean if you type (prn foo) in your scratch buffer and send it, your repl buffer contains the *contents* of foo, but that is not preceded by the "(prn foo)". I'm just wondering if it gets confusing trying to remember what a particular chunk of otput came from. |
| 10:01 | mdeboard | Right now I'm using the InstaRepl in light table, after connecting to an existing project, and using my existing project's code to instantly evaluate the code I'm typing into the InstaRepl pane |
| 10:01 | mdeboard | Chouser: Yes it does confusing |
| 10:02 | cmiles74 | I would also like to see Light Table interleave scratch code and it's evaluated output. |
| 10:02 | mdeboard | http://ubuntuone.com/7RlW0Hth3sWo3Tx6aNCGxy |
| 10:03 | mdeboard | That's what I'm doing atm |
| 10:03 | mdeboard | (the last two lines are actual code, not toy) |
| 10:03 | hyPiRion | &(format "%s" :without-the-dot!) |
| 10:03 | lazybot | ⇒ ":without-the-dot!" |
| 10:03 | @Chouser | we pair a lot at work, and right now nothing beats sharing a tmix session for that. Unfortunately that means we prefer tools that run nicely in a terminal. |
| 10:03 | @Chouser | emacs wins |
| 10:03 | mdeboard | having it instantly evaluate is heaps better than the clojure-mode workflow. |
| 10:03 | @Chouser | Lighttable would need explicit pairing support, I think, before we could seriously consider it. |
| 10:04 | wmealing_ | vnc aint cool ? |
| 10:04 | wmealing_ | or nx |
| 10:04 | mdeboard | honestly I'm a little freaked out that I can `(use)' the project I'm connected to via the Table, I didn't know it oculd do that already. That's amazing. |
| 10:04 | cemerick | chouser: what do you mean re: "(prn foo)", etc? |
| 10:04 | cshell | Chouser: I was thinking of going to Emacs because I thought the REPL would blow me away as well - I also am interested in the pairing abilities |
| 10:05 | hyPiRion | The lighttable-stuff should be possible to do in emacs though. |
| 10:05 | cemerick | i.e. does SLIME not echo the expression that is evaluated? |
| 10:05 | hyPiRion | Or well, parts of it |
| 10:05 | mdeboard | hyPiRion: Exactly, parts of it |
| 10:05 | @Chouser | wmealing_: no, our attempts to use vnc haven't gone well. |
| 10:05 | mdeboard | hyPiRion: vim can do parts of it to, and intellij and eclipse and all. |
| 10:05 | @Chouser | cemerick: depends on how you use it. That's why I was asking. |
| 10:05 | wmealing_ | Chouser: is it vnc.. or something else |
| 10:06 | cshell | it's too bad that LaClojure can't "jack-in" to a remote repl like emacs |
| 10:06 | mdeboard | clojure-mode can jack in to a remote repl? |
| 10:06 | cemerick | chouser: Sorry, missed the beginning of the conversation. It seems like it should be able to…certainly a must have for a REPL IMO. |
| 10:06 | cshell | Can counter clockwise "jack-in" to remote repls? |
| 10:07 | cshell | it must if relevance is using it for their paired development |
| 10:07 | cemerick | cshell: yes; it uses the same REPL backend as leiningen, reply, and nrepl.el |
| 10:07 | @Chouser | cemerick: yes, thank you for apologizing for not being on #clojure *constantly*, or at the very least reading everything that's been said since you were last here, before posting. |
| 10:07 | @Chouser | your apology is accepted. Try to do better. |
| 10:07 | mdeboard | lol |
| 10:08 | cshell | I've noticed that cemerick responds whenever you explicitly type his name |
| 10:08 | wmealing_ | and if you say it three times |
| 10:08 | wmealing_ | he appears behind you |
| 10:08 | cshell | haha |
| 10:08 | wmealing_ | but only if you say it "chass" not "chase" |
| 10:09 | wmealing_ | (i think its chas, right ?) |
| 10:09 | cemerick | wmealing_: I wish people would stop doing that; I have work to do, and phasing all over the world to spook people wears me out. :-P |
| 10:09 | hyPiRion | mdeboard: exactly. I'd really like something like http://vimeo.com/36579366#t=1008 |
| 10:10 | mdeboard | hyPiRion: I think the vision ibdknox has for Light Table is dead on :) |
| 10:10 | @Chouser | cemerick: there is a fn provided by slime that evaluate a form and display the return value temporarily on a status line. I find I never use that fn. |
| 10:10 | cemerick | wmealing_: Yes, it's pronounced like "chaz" (though with a softer 'z' than if it were actually spelled that way, I'd say). It's hilarious when people pronounce it "chase". |
| 10:10 | cshell | Couldn't we put a hook on some of the def functions and capture everything that gets defined in the REPL and then have a function that spits it all back to us? |
| 10:10 | mdeboard | I pronounce it "Chuck" |
| 10:10 | cemerick | …or when people refer to my handle as if it had only three syllables, i.e. "semmerick" |
| 10:11 | @Chouser | cemerick: that's your name in my head |
| 10:11 | mdeboard | tumeric |
| 10:11 | cemerick | chouser: that's ok, I still don't have you and Chousuke straight in my head :-P |
| 10:11 | cshell | cemerick: I think of it as 'C-Em-er-ick' |
| 10:11 | @Chouser | heh |
| 10:11 | mdeboard | They're not hte same person? |
| 10:11 | mdeboard | huh. |
| 10:11 | hyPiRion | mdeboard: I was kind of let down by the 0.10-update, especially when one of the subtitles are "A new double click experience for Clojure" |
| 10:11 | wmealing_ | is that an emacs key combo there cshell ? |
| 10:11 | mdeboard | hyPiRion: Why |
| 10:12 | @Chouser | wait, when did I get capitalized? |
| 10:12 | cshell | wmealing_: haha, we should implement one to be |
| 10:13 | hyPiRion | mdeboard: I never use my mouse when I'm programming anymore - just a decent window manager and emacs, and I'm there |
| 10:13 | cshell | I always thought chouser stood for channel operator user and was just a bot until I saw him typing in chat :) |
| 10:13 | mdeboard | hyPiRion: I think he means you can double-click the jar file and be ready to go |
| 10:13 | magopian | i guess most of the people here are using emacs then? |
| 10:13 | mdeboard | hyPiRion: No other installation required |
| 10:13 | @chouser | cshell: ha! |
| 10:13 | mdeboard | hyPiRion: That's waht I took from it. |
| 10:14 | magopian | man, i really can't get back to emacs, i'm too deep in vim now |
| 10:14 | mdeboard | magopian: You know it's not zero-sum right |
| 10:14 | magopian | (haven't tried using it with clojure yet though, i'm using light table most of the time) |
| 10:14 | magopian | mdeboard: didn't get that |
| 10:14 | mdeboard | magopian: You can use both :P |
| 10:14 | magopian | mdeboard: oh ok |
| 10:14 | chouser | magopian: use the "evil" package. eetsveryniiiice |
| 10:15 | magopian | well, i'm pretty sure my brain would overload, and my fingers would just finished all mixed up for good |
| 10:15 | hyPiRion | mdeboard: Ah. I felt the screenshot in that subsection refered to clicking on projects in leiningen: http://www.chris-granger.com/images/lightable/projects.png |
| 10:15 | cemerick | Maybe someone that knows the incantation(s) can map ~survey? or something to http://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/ so that an easy answer can be given to anyone asking about preferred editors/etc? |
| 10:16 | magopian | oh nice cemerick thanks i'll read that ;) |
| 10:16 | cemerick | magopian: :-) |
| 10:16 | mdeboard | Damn light table is cool, constantly impressed. |
| 10:17 | azkesz | ~paste |
| 10:17 | clojurebot | paste is not gist.github.com |
| 10:17 | hyPiRion | ~gist |
| 10:17 | clojurebot | gist is forget ~paste |
| 10:17 | azkesz | clojurebot which one is it then? |
| 10:17 | hyPiRion | heheh. |
| 10:17 | chouser | clojurebot: survey? |
| 10:17 | clojurebot | survey is http://cemerick.com/2011/07/11/results-of-the-2011-state-of-clojure-survey/ |
| 10:18 | chouser | brb |
| 10:18 | hyPiRion | ~survey |
| 10:18 | clojurebot | survey is http://cemerick.com/2012/08/06/results-of-the-2012-state-of-clojure-survey/ |
| 10:18 | cemerick | stellar, thanks chouser |
| 10:18 | hyPiRion | there you go. |
| 10:18 | cemerick | or hyPiRion or whoever did it :-) |
| 10:18 | azkesz | chouser |
| 10:18 | hyPiRion | cemerick: I didn't. |
| 10:19 | azkesz | cljbin is dreaming |
| 10:19 | hyPiRion | "there you go." was probably a bad choice of words :) |
| 10:19 | scriptor_ | so…clojurebot did it on its own? |
| 10:19 | mdeboard | It's learning. |
| 10:19 | mdeboard | ~makemeasandwich |
| 10:19 | clojurebot | Excuse me? |
| 10:19 | mdeboard | darn. |
| 10:19 | azkesz | lol |
| 10:20 | azkesz | anyway, I did the between function but I don't like it because it's recursing, maybe I should use loop/recur or something |
| 10:21 | magopian | mdeboard: you missed the "sudo" |
| 10:21 | mdeboard | curses |
| 10:21 | chouser | azkesz: I have a version here that uses only every?, fn, and partition |
| 10:22 | azkesz | I didn't know how to use partition=) |
| 10:22 | magopian | partition <3 |
| 10:22 | scriptor | partition's fairly straightforward |
| 10:22 | scriptor | ,doc partition |
| 10:22 | clojurebot | #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)> |
| 10:22 | chouser | ,(partition 3 2 '(1 a 2 b 3 c 4)) |
| 10:22 | clojurebot | ((1 a 2) (2 b 3) (3 c 4)) |
| 10:22 | mdeboard | ##(doc partition) |
| 10:22 | lazybot | ⇒ "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to co... https://www.refheap.com/paste/4504 |
| 10:22 | mdeboard | See |
| 10:22 | azkesz | oh |
| 10:22 | mdeboard | Those docs need to get cleaned up imo. |
| 10:22 | azkesz | i used the 2 param one :/ |
| 10:22 | mdeboard | Impossible. |
| 10:23 | azkesz | the 3 param one which you said I should've used looks amazing, chouser |
| 10:23 | chouser | yep, pretty handy |
| 10:24 | hyPiRion | ,(map (fn [[a b]] (- b a)) (partition 2 1 (map #(*%%) (range)))) |
| 10:24 | clojurebot | (1 3 5 7 9 ...) |
| 10:24 | azkesz | there should be a site that gives newbies small "missions" to code certain things, would be awesome motivation to learn |
| 10:25 | hyPiRion | azkesz: like 4clojure? |
| 10:26 | scriptor | http://www.4clojure.com/ |
| 10:26 | azkesz | yeah like that but a bit better=) |
| 10:26 | nbeloglazov | azkesz: in what way? |
| 10:26 | chouser | azkesz: your mission, should you choose to accept it, is to write the clojure code necessary to make 4clojure better. |
| 10:26 | hyPiRion | azkesz: I'm pretty sure they're open for comments, so if you have any suggestions, you should fire away |
| 10:26 | azkesz | chouser, that's a big mission=) |
| 10:27 | scriptor | azkesz: better in what way though, different kinds of exercises? |
| 10:27 | azkesz | nbeloglazov, hyPiRion, I'll think about it, but something along the lines of what I was trying to do here, doing small things in more than 1 ways |
| 10:27 | mefesto | Hey everyone :-) |
| 10:28 | hyPiRion | azkesz: Ah, so more than one way of doing things? |
| 10:28 | scriptor | a lot of the 4clojure exercises can be solved in different ways |
| 10:29 | scriptor | for example, there's the way I usually do it, and then there's the good way |
| 10:29 | azkesz | hyPiRion, yeah for starters, but usually starting from one problem you can get ramnifications into other things you could be doing |
| 10:29 | magopian | scriptor: haha, same here ;) |
| 10:29 | mefesto | Is it possible with clojure.tools.cli to support multi-valued options like this? $ java -jar myapp.jar -c config.clj -H k1=v1 -H k2=v2 ... |
| 10:29 | mdeboard | How do you articulate to your fellow devs that a project could be handled better by using a language that lends itself to concurrent programming? |
| 10:29 | hyPiRion | It's usually the emacs way, the unix way, and the wrong way. |
| 10:29 | nbeloglazov | What does '(map #(*%%) (range))' do? I mean anonymous function? |
| 10:29 | mefesto | so that when i check the opts it has a vector representing all the -H options uses? |
| 10:29 | mefesto | used* |
| 10:30 | hyPiRion | nbeloglazov: #(*%%) = #(* % %) |
| 10:30 | azkesz | ,(#(*%%) 2 3) |
| 10:30 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: sandbox$eval113$fn> |
| 10:30 | mdeboard | nbeloglazov: I dunno what #(*%%) does but -- yeah |
| 10:30 | mdeboard | what they said. |
| 10:30 | hyPiRion | All the squares. |
| 10:30 | azkesz | ,(#(*%%) 2) |
| 10:30 | clojurebot | 4 |
| 10:30 | azkesz | how come it works without spaces? |
| 10:30 | hyPiRion | Because percent. |
| 10:30 | nbeloglazov | hyPiRion: hm, thanks. I always thought parser will parse *%% as 1 token |
| 10:30 | scriptor | azkesz: the reader considers each percent a separate thing |
| 10:30 | hyPiRion | ,[*%%] |
| 10:31 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0)> |
| 10:31 | hyPiRion | oh dangit. |
| 10:31 | hyPiRion | ,'[*%%] |
| 10:31 | clojurebot | [* % %] |
| 10:31 | scriptor | ,(#(*%1%2) 1 2) |
| 10:31 | clojurebot | 2 |
| 10:31 | nbeloglazov | ,'[*%a%b%c%&] |
| 10:31 | clojurebot | [* %a %b %c %&] |
| 10:31 | nbeloglazov | ,'[*%a%b%cbb%&] |
| 10:31 | clojurebot | [* %a %b %cbb %&] |
| 10:32 | hyPiRion | Treat every occurence of "%" as " %". |
| 10:32 | nbeloglazov | Hm, but why? :) |
| 10:32 | mdeboard | unless it's preceded by a space already. |
| 10:32 | scriptor | nbeloglazov: because the reader does it for you, each % gets put into a separate token |
| 10:33 | hyPiRion | mdeboard: " " and " " are semantically equivalent ;) |
| 10:33 | mdeboard | u rite |
| 10:34 | nbeloglazov | scriptor: I don't understand why reader does this. Who needs it? I think #(* % %) better than #(*%%) |
| 10:34 | azkesz | ,(#(*%1%%2) 4 5) |
| 10:34 | clojurebot | 80 |
| 10:34 | azkesz | ,(#(*%%1%%2) 4 5) |
| 10:34 | clojurebot | 320 |
| 10:34 | scriptor | nbeloglazov: I doubt it was intentional, just a by-product of how it was written, '%%' will never be used to represent a single value, so why not? |
| 10:35 | scriptor | nbeloglazov: also, I don't think code like #(*%%) is actually used much |
| 10:35 | hyPiRion | I really hope it isn't. |
| 10:35 | nDuff | scriptor: ...well, there _is_ a valid "why not", because you're limiting the set of potentially available syntax for new reader features to be added later without breaking backwards compatibility with documented parts of the language. |
| 10:37 | magopian | anybody working for relevance here? |
| 10:39 | hyPiRion | My personal opinion is that the reader has been kind of muddy lately. |
| 10:40 | chouser | hyPiRion: lately? has something changed to make it worse? |
| 10:41 | hyPiRion | ,(let [z# 10] `(~z# z#)) |
| 10:41 | clojurebot | (10 z__87__auto__) |
| 10:41 | hyPiRion | chouser: Well, maybe not muddy, but there are a lot of special cases not documented. |
| 10:42 | chouser | the official line has always been, I think, that one should only depend on what's documented. Everything else is subject to change. |
| 10:43 | chouser | So I wouldn't recommend #(*%%) in code you want to still work in future versions of Clojure. |
| 10:45 | hyPiRion | chouser: Well, inc' and dec' are names which according to the current documentation are invalid, yet they're in core. I don't know whether that means it's okay to create functions named foo' or not. |
| 10:46 | hyPiRion | Mind you, I don't feel that the reader is bad, but I just believe the special cases should be documented, so that we know what to expect and what not to. |
| 10:46 | chouser | well, that's a nice example. Perhaps the docs need to be updated. |
| 10:47 | casion | hyPiRion: why are those invalid? |
| 10:47 | hyPiRion | casion: From the doc: "Symbols begin with a non-numeric character and can contain alphanumeric characters and *, +, !, -, _, and ? (other characters will be allowed eventually, but not all macro characters have been determined)" |
| 10:47 | lucian | casion: i think it's because 'foo is reader for (quote foo) |
| 10:49 | cemerick | hyPiRion: No part of Clojure (including the reader) has a spec associated with it, which is what I think you're after. |
| 10:50 | chouser | well, that and generally things that are outside the scope of defined behavior are left undefined rather than explicitly erroring out. |
| 10:50 | cemerick | I suppose that's splitting semantic hairs, but oh well. |
| 10:50 | `fogus | Hi everyone! |
| 10:50 | casion | hyPiRion: I was under the understanding that the arbitrary precision operators were going to change |
| 10:50 | chouser | `fogus: hi! |
| 10:50 | casion | that's why they are with the ' |
| 10:51 | casion | they'll be removed at some future time and replaced with a different implementation |
| 10:51 | hyPiRion | Oh, many c's here now. |
| 10:51 | cemerick | casion: How did you get that impression? |
| 10:51 | `fogus | casion: They will? |
| 10:52 | casion | cemerick: I can't recall where I read it, but an example of using them I found online noted that |
| 10:52 | casion | which of course could be incorrect |
| 10:52 | casion | let me see if I can crawl my history and find it |
| 10:53 | azkesz | how do I check if something is a function aka IFn? |
| 10:53 | chouser | azkesz: ifn? |
| 10:53 | hyPiRion | ifn? or fn? |
| 10:54 | azkesz | IFn I guess |
| 10:54 | chouser | heh |
| 10:54 | azkesz | aka the interface? |
| 10:54 | azkesz | cause I'm trying to give relevant error when this happens: ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn |
| 10:54 | azkesz | ,(class defn) |
| 10:54 | chouser | The function "fn?" will return true for > but false for :keyword |
| 10:54 | clojurebot | #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/defn, compiling:(NO_SOURCE_PATH:0)> |
| 10:54 | casion | great, my browser search ignores single quote |
| 10:55 | magopian | azkesz: i think you're looking for "function?" aren't you? |
| 10:55 | azkesz | ,(fn? +) |
| 10:55 | clojurebot | true |
| 10:55 | azkesz | yes thank you |
| 10:55 | magopian | what's the difference between fn? and function? |
| 10:56 | hyPiRion | magopian: function? doesn't exist, whereas fn? does |
| 10:56 | hyPiRion | I suppose. |
| 10:56 | magopian | hyPiRion: http://clojuredocs.org/clojure_core/clojure.test/function_q |
| 10:57 | azkesz | ok i did it, chouser=) that between function with partition |
| 10:57 | chouser | azkesz: nice. |
| 10:57 | hyPiRion | magopian: Ah, I've never poked around in clojure.test |
| 10:58 | scriptor | magopian: looks like function? also checks if it's not a macro |
| 10:58 | azkesz | I wonder if I can limit the functions passed to only those relevant, like passing + instead of > wouldn't make sense, should I have a list of allowed functions ? |
| 10:58 | scriptor | from glancing at its source |
| 10:58 | hyPiRion | ,(clojure.test/function? 'concat) |
| 10:58 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.test> |
| 10:59 | hyPiRion | Well, function? seems to resolve symbols. |
| 10:59 | magopian | hyPiRion: i just found it using the quicksearch on clojuredocs, i'm a noob ;) |
| 10:59 | cemerick | hah |
| 10:59 | cemerick | I blame stuartsierra ;-) |
| 10:59 | stuartsierra | Wait what? |
| 10:59 | cemerick | lol |
| 10:59 | chouser | hah |
| 10:59 | azkesz | this is what I mean, with 4closure, start with one problem and then expand from it until there are not many variants that you'd like to follow , the root of the tree would be the problem, then expand from it (I should get a specific example) |
| 11:00 | cemerick | Where's that scoreboard!? :-D |
| 11:00 | cemerick | stuartsierra: s'ok, my fingerprints are all over it too :-P |
| 11:00 | azkesz | ,(fn? concat) |
| 11:00 | clojurebot | true |
| 11:00 | azkesz | ,(fn? 'concat) |
| 11:00 | clojurebot | false |
| 11:00 | stuartsierra | The internals of clojure.test are a wild hairy ball of cruft and ill-applied macrology. |
| 11:00 | casion | cemerick: ah damnit, my info was from 1.3 development… since it's been added it's standard now I guess |
| 11:01 | stuartsierra | I was under the influence of too much time on my hands. I take no responsibility. |
| 11:01 | cemerick | stuartsierra: and despite that, it keeps on chugging along… |
| 11:01 | casion | and according to this post by rich: ' is now a constituent character. That means it may appear as a character in symbols in other than the first position, as can # |
| 11:01 | hyPiRion | I was kind of hoping that "too much time" would lead to a good design. |
| 11:01 | stuartsierra | I know. Too big to fail now. |
| 11:02 | cemerick | stuartsierra: Better start pitching "Clojure 2.0" with breaking changes while you've got your hands in the gears. |
| 11:02 | stuartsierra | Oh I have a list. |
| 11:02 | cemerick | …or, caught in the gears? ;-) |
| 11:03 | azkesz | ,(clojure.test/function? concat) |
| 11:03 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.test> |
| 11:03 | azkesz | is that ns not loaded or something? |
| 11:03 | hyPiRion | seems like it's not. |
| 11:03 | cemerick | ,(require 'clojure.test) |
| 11:03 | clojurebot | nil |
| 11:03 | chouser | try the other bot |
| 11:03 | chouser | oh. or that. |
| 11:03 | cemerick | ,(clojure.test/function? 'concat) |
| 11:03 | clojurebot | true |
| 11:04 | azkesz | lol you loaded itnice |
| 11:04 | hyPiRion | seems scary |
| 11:05 | azkesz | ,(clojure.test/function? `'`'`'`'`'`'`'`''`concat) |
| 11:05 | azkesz | yeah I got the same :) |
| 11:05 | clojurebot | Execution Timed Out |
| 11:06 | azkesz | lol I didn't get that |
| 11:06 | azkesz | wonder how I stop it |
| 11:06 | nbeloglazov | ,`concat |
| 11:06 | clojurebot | clojure.core/concat |
| 11:06 | nbeloglazov | ,`'concat |
| 11:06 | clojurebot | (quote clojure.core/concat) |
| 11:06 | nbeloglazov | ,```concat |
| 11:06 | clojurebot | (clojure.core/seq (clojure.core/concat (clojure.core/list (quote quote)) (clojure.core/list (quote clojure.core/concat)))) |
| 11:07 | azkesz | oh i see what happens |
| 11:07 | nbeloglazov | Nice |
| 11:07 | hyPiRion | ,(require '[clojure.test :rename {function? fn?} :refer [function?]]) |
| 11:07 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 11:07 | hyPiRion | good. |
| 11:08 | azkesz | is there a deep count of elements in case of lists inside lists aka tree? |
| 11:09 | chouser | (count (flatten tree)) |
| 11:09 | chouser | one of those few valid uses of flatten |
| 11:10 | cemerick | …except maps are incredibly common tree nodes |
| 11:11 | cemerick | zippers subsume all, per usual |
| 11:11 | chouser | or just tree-seq |
| 11:11 | chouser | wait, zippers work across mixed collection types? |
| 11:11 | azkesz | any chance I could make this count in real time? since it doesn't seem to ever end the computation: (count (flatten '(clojure.test/function? `'`'`'`'`'`'`'`''`concat))) |
| 11:12 | azkesz | or something like have another thread report the current counter |
| 11:12 | azkesz | only if I make my own tree parser? |
| 11:13 | cemerick | chouser: sure |
| 11:13 | cemerick | enlive is built on top of zippers |
| 11:13 | chouser | oh, but it provides its own zipper fns then. The ones in clojure.zip don't handle mixed, just xml and vectors I think |
| 11:14 | azkesz | nvm, it won't work anyway: ##((count (flatten '(clojure.test/function? `'`'`'`''`concat)))) |
| 11:14 | lazybot | java.lang.ClassFormatError: Invalid method Code length 162965 in class file sandbox29188$eval38558 |
| 11:14 | cemerick | right, yes |
| 11:17 | casion | ,(time (count (re-seq #"\w+" (str '(:A (:B (:D) (:E)) (:C (:F))))))) |
| 11:17 | clojurebot | "Elapsed time: 75.789067 msecs" |
| 11:17 | clojurebot | 6 |
| 11:17 | casion | ,(time (count (flatten '(:A (:B (:D) (:E)) (:C (:F)))))) |
| 11:17 | clojurebot | "Elapsed time: 0.391996 msecs" |
| 11:17 | clojurebot | 6 |
| 11:17 | casion | lol |
| 11:18 | azkesz | maybe it's because of the regex thingy? |
| 11:18 | casion | the weird str version is always faster locally here |
| 11:18 | casion | by about 4-5% |
| 11:19 | casion | I'd assume it works correctly as collections are formatted properly? |
| 11:19 | chouser | one string with a space in it would break everything |
| 11:20 | chouser | maps would give different counts |
| 11:20 | azkesz | in this form: (= __ true) is it possible to get the exact value after the ___ and return it in place of the ___ ? by changing only the ___ ? |
| 11:20 | casion | chouser: there we go |
| 11:20 | pepijndevos | How can I make a synth that slides up/down when you change the freq? |
| 11:20 | casion | chouser: but if you know those aren't true, it does seem to be faster :) |
| 11:20 | azkesz | for example if "true" was "3" |
| 11:20 | nbeloglazov | ,(doc =) |
| 11:20 | clojurebot | "([x] [x y] [x y & more]); Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) as a value, not an identity, comparison." |
| 11:20 | casion | pepijndevos: how are you generating the waveform? |
| 11:20 | chouser | casion: I'd be surprised if that were generally true. clojure printer is pretty slow |
| 11:21 | nbeloglazov | azkesz: = returns only true or false. You can't return 3 |
| 11:21 | casion | chouser: I made a few tests with just nested collections of symbols and it's always faster here |
| 11:21 | casion | it's a silly idea anyway obviously |
| 11:22 | azkesz | nbeloglazov, but if I wanted to place some code in place of the ___ which would make any such form (= ___ x) where x can be anything, always return true |
| 11:22 | chouser | ah, yes. |
| 11:22 | chouser | azkesz: you're trying to trick 4clojure? |
| 11:22 | azkesz | nbeloglazov, doesn't seem to can be done by changing only the ___ |
| 11:22 | azkesz | lol |
| 11:23 | mdeboard | gangnam style |
| 11:23 | azkesz | chouser, I'm expanding a tree from the root problem of (= ___ true) :D that's just what I normally think of when I saw that |
| 11:23 | casion | oppan gungnam style! |
| 11:23 | casion | whoop whoop |
| 11:23 | chouser | azkesz: http://clojure-log.n01se.net/date/2011-09-19.html#14:21 |
| 11:24 | mdeboard | chouser: wow, lol. That is amazing. |
| 11:25 | casion | mdeboard: 안녕히 주무셨어요? |
| 11:25 | hyPiRion | hirr. |
| 11:26 | wmealing_ | casion: been going through my head, ALL DAY |
| 11:26 | wmealing_ | thanks for the reminder |
| 11:26 | mdeboard | casion: Nope |
| 11:26 | casion | :( |
| 11:26 | casion | I feel priviledged to have watched the premier of gungnam style |
| 11:27 | casion | and laughed my ass off for about 30 minutes, missing the first set |
| 11:27 | mdeboard | chouser: Can you just make that link the result for ~abstraction |
| 11:27 | mdeboard | ~abstraction |
| 11:27 | clojurebot | Pardon? |
| 11:27 | casion | gangnam* |
| 11:27 | chouser | why "abstraction"? |
| 11:28 | mdeboard | chouser: Aren't those "general solution" forms abstractions of all correct answers into a general form (for that solution 'signature') |
| 11:28 | mdeboard | ##(doc reify) |
| 11:28 | lazybot | ⇒ "Macro ([& opts+specs]); reify is a macro with the following structure: (reify options* specs*) Currently there are no options. Each spec consists of the protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodNa... https://www.refheap.com/paste/4507 |
| 11:29 | mdeboard | (reminding myself of reify) |
| 11:30 | chouser | ah, abstraction of 4clojure solutions. sure. |
| 11:35 | azkesz | I fail to understand this: #(reify Object (equals [_ _] (= %&))) but I've to admit initially I thought it would change .equals() to always return true regardless |
| 11:36 | chouser | azkesz: why did you stop thinking that? |
| 11:36 | azkesz | I didn't but I got stuck at %& no idea what that does |
| 11:37 | chouser | ah, yes. that's just a golfing trick. |
| 11:37 | azkesz | oh and also, I tried the (= 1 2) and false-d:) |
| 11:37 | azkesz | ok I guess, I did stop thinking that :/ I stand corrected lol |
| 11:37 | TimMc | ,'#(%&) ; azkesz here's the expansion |
| 11:37 | clojurebot | (fn* [& rest__27#] (rest__27#)) |
| 11:37 | TimMc | so that makes the fn literal take any number of arguments |
| 11:38 | azkesz | and use uniquely named var? |
| 11:38 | TimMc | Sure, but that's just for hygiene. |
| 11:38 | azkesz | what would you use if you didn't want it to be uniquely named? |
| 11:39 | TimMc | (= _) will always return true. (= %&) is a trick to both return true and make the fn literal take any # of args. |
| 11:39 | TimMc | azkesz: You wouldn't use a fn literal... |
| 11:39 | TimMc | (fn [& azkesz] (count azkesz)) |
| 11:40 | azkesz | oh |
| 11:40 | scriptor | ohh, I have no idea why I was thinking (= %&) would be equivalent to (apply = %&) |
| 11:40 | scriptor | it's still just one value, a list |
| 11:40 | chouser | scriptor: right |
| 11:40 | TimMc | ,(= 5) |
| 11:40 | clojurebot | true |
| 11:40 | azkesz | scriptor, that's quite helpful, was thinking the same |
| 11:40 | azkesz | ,(= (1 2 3)) |
| 11:40 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 11:41 | azkesz | ,(= '(1 2 3)) |
| 11:41 | clojurebot | true |
| 11:41 | scriptor | why can't it just return true? Or does it have to explicitly use %& somewhere? |
| 11:41 | TimMc | azkesz: The non-golfed version would be something like (fn [& ignore] (reify Object (equals [this other] true))) |
| 11:42 | TimMc | scriptor: The latter, otherwise it is nullary. |
| 11:42 | azkesz | how do you test that the reify worked? and would it work only for = or non overriden equals-es in subclasses (in case of using java methods) |
| 11:43 | azkesz | oh wait, it returns a function? |
| 11:44 | chouser | right, because 4clojure wants functions |
| 11:44 | azkesz | oh i see, it does reify and returns the true |
| 11:44 | TimMc | No, it returns a reified Object. |
| 11:44 | azkesz | ok i lost it |
| 11:44 | chouser | most 4clojure problems want a function of 1 or more args that returns a value that is equal to some test value |
| 11:44 | TimMc | The reified object's .equals returns true. |
| 11:44 | azkesz | timmc, ok i got it now=) |
| 11:45 | azkesz | ok so in my test case of (= ___ true) would not work :) |
| 11:45 | chouser | yeah, for that you'd just need the reify part, not the whole #(...) |
| 11:46 | chouser | except I'm not sure I quite understand what you want yet. |
| 11:46 | chouser | why does true work for ___? |
| 11:46 | chouser | doesn't |
| 11:46 | mk | 4clojure does a straight replacement. So sometimes you'll see answers where people give fragments. Presumably even something like "...))((..." would compile. |
| 11:47 | TimMc | mk: Yes, I was quite annoyed when I discovered that one of the solutions was "+ 2". |
| 11:47 | scriptor | heh, right, it pretty much takes anything could follow '(' |
| 11:47 | TimMc | It hink it has to be one or more valid forms, though. |
| 11:47 | gtrak | hey, is there a ring testing lib that has things like 'has-header?' |
| 11:48 | chouser | ditto. but once you accept that as the mechanism used, it opens a world of possibilities... |
| 11:48 | azkesz | chouser, I only mean that I was testing your code wrongly: 1. running it then testing (= 1 2) then 2. testing it on 4clojure for (= ___ true) problem, (but I didn't understand your last question) |
| 11:49 | mk | TimMc: amusing. Yeah, I think the best way to look at it is as "what would you type here" and not "pass me a function" |
| 11:52 | azkesz | ,(.equals #(reify Object (equals [_ _] (= %&))) 1) |
| 11:52 | clojurebot | false |
| 11:52 | azkesz | what am I missing?:) |
| 11:53 | chouser | ,(.equals (reify Object (equals [_ _] true)) 1) |
| 11:53 | clojurebot | WARNING: = already refers to: #'clojure.core/= in namespace: sandbox, being replaced by: #'clojure.core/= |
| 11:53 | clojurebot | true |
| 11:53 | mdeboard | ,(= #(reify Object (equals [_ _] (= %&))) 1) |
| 11:53 | chouser | whoa |
| 11:53 | clojurebot | #<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/=> |
| 11:53 | mdeboard | acked |
| 11:53 | mdeboard | hacked |
| 11:53 | hyPiRion | Sorry |
| 11:53 | hyPiRion | my fault, I uninterned = |
| 11:53 | hyPiRion | or wait |
| 11:54 | hyPiRion | nevermind. |
| 11:54 | chouser | ,(.equals (reify Object (equals [_ _] true)) 1) |
| 11:54 | clojurebot | true |
| 11:54 | mdeboard | ,(= 1 1) |
| 11:54 | clojurebot | #<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/=> |
| 11:54 | mdeboard | someone broke clojurebot |
| 11:54 | mdeboard | ##(= 1 1) |
| 11:54 | lazybot | ⇒ true |
| 11:54 | chouser | ,(require 'clojure.core) |
| 11:54 | clojurebot | nil |
| 11:54 | chouser | ,(= 1 1) |
| 11:54 | clojurebot | #<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/=> |
| 11:54 | chouser | ,(require 'clojure.core :reload) |
| 11:54 | clojurebot | nil |
| 11:54 | nbeloglazov | ,= |
| 11:54 | clojurebot | #<Unbound Unbound: #'clojure.core/=> |
| 11:54 | chouser | ,(= 1 1) |
| 11:54 | clojurebot | #<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/=> |
| 11:54 | chouser | shoot |
| 11:54 | mdeboard | :| |
| 11:55 | SegFaultAX | Needs a restart? |
| 11:56 | mdeboard | ,(.enumerate (reify Object (equals [_ _] true)) 1) |
| 11:56 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: enumerate for class sandbox$eval773$reify__774> |
| 11:57 | jsabeaudry | Anyone has had JVM |
| 11:57 | jsabeaudry | oops |
| 11:58 | chouser | ,(= 1 1) |
| 11:58 | clojurebot | true |
| 11:58 | chouser | someone fixed it |
| 11:58 | chouser | ,(= (reify Object (equals [_ _] true)) 1) |
| 11:58 | clojurebot | true |
| 11:58 | jsabeaudry | Anyone has had a jvm crash on libc frexp? Like such: http://pastebin.ca/2196808 |
| 12:00 | azkesz | ok i got it, the # form returned a function which in turn returned the reified object, and the form without the # (and the golf) returned just the object |
| 12:00 | azkesz | (.equals (#(reify Object (equals [_ _] (= %&)))) 3) |
| 12:00 | azkesz | ,(.equals (#(reify Object (equals [_ _] (= %&)))) 3) |
| 12:00 | clojurebot | true |
| 12:00 | azkesz | ,(.equals (reify Object (equals [_ _] true)) 3) |
| 12:00 | clojurebot | true |
| 12:02 | mdeboard | chouser: Can you explain what happened there |
| 12:02 | mdeboard | ,(.equals (reify Object (equals [_ _] true)) 1) |
| 12:02 | clojurebot | true |
| 12:02 | chouser | azkesz: right |
| 12:03 | azkesz | ,(reify Object (equals [_ _] true)) |
| 12:03 | clojurebot | #<sandbox$eval468$reify__469 sandbox$eval468$reify__469@79dd630a> |
| 12:03 | chouser | mdeboard: what part are you missing? |
| 12:04 | azkesz | what's this #<a b> ? |
| 12:04 | mdeboard | chouser: How that line you typed re-bound (?) the = symbol |
| 12:04 | mdeboard | ,#<"a" "b"> |
| 12:04 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unreadable form> |
| 12:04 | hyPiRion | ,(boo?) |
| 12:04 | clojurebot | true |
| 12:04 | hyPiRion | hmm... |
| 12:04 | azkesz | lol |
| 12:04 | hyPiRion | ,(booboo?) |
| 12:04 | clojurebot | true |
| 12:04 | nbeloglazov | :) |
| 12:04 | azkesz | ,(fn? booboo?) |
| 12:04 | clojurebot | #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:0)> |
| 12:04 | hyPiRion | heh. |
| 12:05 | azkesz | ,(macro? 'booboo?) |
| 12:05 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: macro? in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:05 | nbeloglazov | ,boo? |
| 12:05 | clojurebot | #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:0)> |
| 12:05 | azkesz | ,(fn? 'booboo?) |
| 12:05 | clojurebot | false |
| 12:05 | azkesz | ,(class 'booboo?) |
| 12:05 | clojurebot | clojure.lang.Symbol |
| 12:05 | azkesz | ,(class booboo?) |
| 12:05 | clojurebot | #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:0)> |
| 12:05 | chouser | mdeboard: I didn't do anything to clojure.core/= It was somehow unbound in clojurebot and then fixed again. I don't know what happened. |
| 12:05 | mdeboard | IRC bots are kind of like kittens. |
| 12:05 | azkesz | oh right, macro is no class=) |
| 12:05 | mdeboard | chouser: Weird |
| 12:05 | hyPiRion | Read the exception. |
| 12:06 | nbeloglazov | ,(and true false) |
| 12:06 | clojurebot | false |
| 12:06 | azkesz | ,(source booboo?) |
| 12:06 | clojurebot | Source not found |
| 12:06 | mdeboard | ,(or (and true false) (and false false)) |
| 12:06 | clojurebot | false |
| 12:06 | hyPiRion | ,(= 1 1) |
| 12:06 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: = in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:07 | azkesz | again? |
| 12:07 | hyPiRion | Okay, so I can in fact unintern it. |
| 12:07 | chouser | ,(meta #'booboo?) |
| 12:07 | clojurebot | {:macro true, :ns #<Namespace clojure.core>, :name and, :arglists ([] [x] [x & next]), :added "1.0", ...} |
| 12:07 | azkesz | lol |
| 12:07 | mdeboard | hyPiRion: Are you using some admin command or? |
| 12:07 | hyPiRion | mdeboard: Nope, just clojure commands. |
| 12:07 | azkesz | ,#'booboo? |
| 12:07 | clojurebot | #'clojure.core/and |
| 12:08 | azkesz | I need to lookup what #' does |
| 12:08 | chouser | ,(var boo?) |
| 12:08 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: boo? in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:08 | chouser | ,(var booboo?) |
| 12:08 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: booboo? in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:08 | chouser | heh, he got rid of it |
| 12:08 | chouser | azkesz: #'foo is just short for (var foo) |
| 12:08 | hyPiRion | ,(var boo?) |
| 12:08 | clojurebot | #'clojure.core/and |
| 12:09 | azkesz | oh thanks |
| 12:09 | chouser | var is a special operator |
| 12:09 | azkesz | you can talk to clojurebot on private ? |
| 12:09 | chouser | like if and quote |
| 12:09 | chouser | azkesz: yes, presumably that's what hyPiRion is up to |
| 12:10 | azkesz | ,(fn? if) |
| 12:10 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: if in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:10 | azkesz | i was wondering the same thing |
| 12:10 | azkesz | ,#'if |
| 12:10 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: if in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:10 | chouser | ,(doc if) |
| 12:10 | clojurebot | No entiendo |
| 12:10 | azkesz | lol |
| 12:10 | hyPiRion | What |
| 12:10 | hyPiRion | I don't think I did that. |
| 12:10 | chouser | azkesz: try (doc if) at a repl |
| 12:10 | azkesz | ok |
| 12:11 | azkesz | ,(var) |
| 12:11 | clojurebot | #<CompilerException java.lang.NullPointerException, compiling:(NO_SOURCE_PATH:0)> |
| 12:12 | azkesz | ,(var (var)) |
| 12:12 | clojurebot | #<CompilerException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:0)> |
| 12:12 | azkesz | ,(var '(var)) |
| 12:12 | clojurebot | #<CompilerException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:0)> |
| 12:12 | hyPiRion | ,(var var) |
| 12:12 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: var in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:12 | hyPiRion | ,(var +) |
| 12:12 | clojurebot | #'clojure.core/+ |
| 12:12 | azkesz | the errors were interesting |
| 12:15 | azkesz | ,#ssss"1" |
| 12:15 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: No reader function for tag ssss> |
| 12:15 | azkesz | can I have an example with that? |
| 12:21 | azkesz | this seems relevant: http://stackoverflow.com/questions/12022686/what-advantage-are-clojures-1-4-reader-literals-and-why-wont-sample-compile |
| 12:29 | hyPiRion | Oh well, who's in charge of clojurebot nowadays? |
| 12:29 | azkesz | that made me wonder if #_ is a reader form and also if I can use it for complement (looks like I can't) |
| 12:29 | azkesz | ,((complement #_ ) 1) |
| 12:29 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unable to resolve symbol: pr-str in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:29 | azkesz | makes sense, it's not a function=) |
| 12:30 | hyPiRion | azkesz: Read the exception |
| 12:30 | azkesz | hyPiRion that's different than what I got |
| 12:31 | hyPiRion | ,1 |
| 12:31 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unable to resolve symbol: pr-str in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:31 | azkesz | lol |
| 12:31 | azkesz | pr-str |
| 12:31 | azkesz | ,pr-str |
| 12:31 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unable to resolve symbol: pr-str in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:31 | azkesz | ,(pr-str 1) |
| 12:31 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unable to resolve symbol: pr-str in this context, compiling:(NO_SOURCE_PATH:0)> |
| 12:31 | hyPiRion | Just wait until it restarts, I kind of broke it. |
| 12:31 | azkesz | ok |
| 12:32 | azkesz | I wonder if I can do this: (= #dup true) |
| 12:33 | hyPiRion | azkesz: If you make a reader, it may be doable. It's not exactly correct use of readers though. |
| 12:33 | i_s | anyone know a good way to get the string output of clojure.pprint/pprint? |
| 12:34 | i_s | (or something similar) |
| 12:34 | _zach | i_s: (with-out-str ...) |
| 12:35 | azkesz | hyPiRion, like this here? https://gist.github.com/2399254 |
| 12:35 | i_s | _zach: cool, thank you |
| 12:35 | pepijndevos | overtone randomly broke down :( |
| 12:36 | hyPiRion | azkesz: I don't believe that's the correct usage - I thought they were for message passing from one clojure to another |
| 12:37 | hyPiRion | But I've not used them, so I may be wrong, of course. |
| 12:37 | hyPiRion | ,((complement #_ ) 1) |
| 12:37 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )> |
| 12:37 | azkesz | yeah that's the right error |
| 12:38 | azkesz | ,#_ 1 2 |
| 12:38 | clojurebot | 2 |
| 12:43 | nz- | how lein actually works if I have compiled the project and then change a single file and recompile? |
| 12:44 | hyPiRion | nz-: It looks at the timestamps of the files, I guess. |
| 12:44 | hyPiRion | That's what "make" do at least. |
| 12:44 | nz- | and notices that .clj is newer that .class? but what happens then? |
| 12:45 | S11001001 | nz-: it doesn't recursively recompile dependents if that's what you're asking |
| 12:45 | technomancy | nz-: it will only recompile the file that changed |
| 12:45 | S11001001 | nz-: put less stuff in macros |
| 12:45 | technomancy | (plus everything it requires) |
| 12:45 | technomancy | hyPiRion: right |
| 12:46 | nz- | currently I have situation where: lein clean; lein midje and lein clean; touch file.clj ; lein midje give different results |
| 12:46 | nz- | and midje runs bunch of unit tests |
| 12:49 | nz- | actually lein clean; lein compile; touch file.clj; lein midje gives different result than without touching |
| 12:50 | nz- | and file.clj is full of macro evaluations, that work if file is touched |
| 12:54 | azkesz | ,(require 'clojure.core :reload) |
| 12:54 | clojurebot | nil |
| 12:55 | nz- | the problem is that it should work like it is working when the file is touched |
| 12:55 | nz- | basically file.clj contains a bunch of call to these: https://github.com/budu/lobos/blob/master/src/lobos/migration.clj#L104 |
| 12:56 | azkesz | sounds like, if you clean but all were loaded, it won't do :reload on them, but if the file was modified it will (that's how I understand it) |
| 12:57 | nz- | :reload is repl thing? all these happen without repl |
| 12:58 | azkesz | you may be right, i'm new:) but I mean, whatever is the equivant of reload if not the require :reload itself |
| 13:00 | technomancy | nz-: you should never have to run compile by hand; it gets invoked automatically for you when needed |
| 13:00 | azkesz | what I know is that all "places" where that macro is used must be reloaded if the macro changed, else it'll use the old macro |
| 13:01 | azkesz | ":reload can be replaced with :reload-all to reload all libraries that are used either |
| 13:01 | azkesz | directly or indirectly by the specified library. " |
| 13:02 | azkesz | that means if I modify my macro file, a :reload-all on it should be done right? |
| 13:02 | hyPiRion | azkesz: In the repl, yes. |
| 13:03 | azkesz | hyPiRion, what are the other cases? |
| 13:04 | azkesz | oh like when a command line is invoked like lein something? |
| 13:06 | nz- | i think i shouldn't need any reloading, since I am just running the whole program via command line |
| 13:06 | technomancy | nz-: if you avoid AOT as much as possible a lot of these problems go away |
| 13:06 | azkesz | hyPiRion, if lein detects a changed file doesn't it run the same require/reload internally? |
| 13:06 | technomancy | do you have any gen-class or the like required? |
| 13:08 | tantamountain | I've got a little question—is it ever possible for clojure.string/split to return an empty collection, or nil? |
| 13:11 | nz- | I had :main foo.bar in project.clj, removing it seemed to help |
| 13:12 | hyPiRion | tantamountain: yeah, it can return an empty vector if the whole string matches the regex |
| 13:12 | tantamountain | Excellent! Thank you so much. |
| 13:13 | hyPiRion | ,(clojure.string/split "Hello world. This matches everything" #".+") |
| 13:13 | clojurebot | [] |
| 13:13 | azkesz | wow, didn't see that coming |
| 13:13 | nz- | yes, the :main directive seems to cause AOT compilation |
| 13:16 | nz- | but having gen-class on same place where :main was pointing doesn't cause this problem |
| 13:24 | nz- | technomancy: thanks for the hint! |
| 13:25 | nz- | now the next problem is how to have executable uberjar without :main |
| 13:25 | hyPiRion | without :main? |
| 13:25 | technomancy | you can do java -cp my-standalone.jar clojure.main -m my.main.namespace |
| 13:26 | nz- | i'd like to have java -jar package.jar |
| 13:26 | technomancy | can't do that without AOT unfortunately |
| 13:26 | nz- | :( |
| 13:26 | technomancy | the java CLI launcher is horrible |
| 13:26 | technomancy | in case it escaped your notice =\ |
| 13:27 | nz- | couldn't I have a some kind of java wrapper as a launcher? |
| 13:28 | technomancy | oh, there is the lein-otf plugin; you could try that |
| 13:29 | llasram | nz-: Oh yeah, if you're using lein2, I have a lein2-compatible fork: https://github.com/llasram/lein-otf |
| 13:30 | llasram | My version ultimately doesn't AOT any Clojure code at all, which gives me pedantry giggles, or something |
| 13:31 | llasram | You'll still need a :main, but you can say `:main ^:skip-aot my.cool.namespace` |
| 13:32 | nz- | llasram: that skip-aot is not mentioned in github readme, BTW |
| 13:38 | nz- | works like a charm |
| 13:39 | nz- | does otf give a performance hit compared to aot? |
| 13:42 | azkesz | ,(+ 1( (fn one [x] (+ ((fn two [y] (if (< y 10) (one (+ y 2)) (* y 2)) ) x) 7) ) 6)) |
| 13:42 | clojurebot | 42 |
| 13:42 | pjstadig | ~suddenly |
| 13:42 | clojurebot | CLABANGO! |
| 13:48 | lynaghk | ping: dnolen |
| 13:48 | dnolen | lynaghk: pong |
| 13:49 | lynaghk | dnolen: grammar of graphics in clojure needs to sit on my mind for a bit |
| 13:49 | dnolen | lynaghk: as in - it's still fermenting? |
| 13:49 | lynaghk | dnolen: just added you as a collaborator on the repo so you can check it out, if you want to take it for a spin. Everything it can do is in tests.clj. Might put together static examples + calling code on a plain HTML page later this week |
| 13:50 | lynaghk | dnolen: a fair bit is implemented, but the API is by no means finalized. In particular Hadley just put out a very interesting preprint about nesting graphics (a generalized approach to faceting, basically) |
| 13:50 | lynaghk | dnolen: so I will probably rewrite to incorporate that. |
| 13:50 | cemerick | wow, clojure-maven-plugin sets up tests such that unqualified use of resolve doesn't wok. |
| 13:51 | cemerick | work, even. |
| 13:51 | dhm | dnolen: where's the best discussion going on about clojurescript? |
| 13:52 | dnolen | lynaghk: yeah I saw that PDF, very cool. |
| 13:53 | nz- | llasram, technomancy: thanks for the help. |
| 13:53 | lynaghk | dnolen: how/where? Are you on that list? |
| 13:55 | dnolen | lynaghk: he posted it to the list. |
| 13:55 | dnolen | dhm: here or on the Clojure mailing list |
| 13:55 | dhm | thanks |
| 13:56 | lynaghk | dnolen: hmmm, I didn't know you were interested in the wonderful world of statistical graphics. |
| 13:57 | dnolen | lynaghk: well I sit right next to the NYT graphics desk so it's hard to not be interested. I don't do data graphics but I do love Tufte's writing on the subject. |
| 13:57 | lynaghk | dnolen: anyway, if you have time+interest, I'd love some feedback on the architecture of my current prototype. I'm trying to keep the design as straightforward as possible right now, but I'm interested to see what can change for improved performance (e.g., using reducers) |
| 13:58 | lynaghk | dnolen: you lucky bastard =) |
| 14:01 | dnolen_ | lynaghk: reducers on Clojure side or ClojureScript side? |
| 14:02 | lynaghk | dnolen_: either. I'm focusing on Clojure for static graphics at the moment, but will turn to cljs before the end of the year |
| 14:04 | dnolen_ | lynaghk: I've done a little bit of work in hopes to improve the performance of reducers in CLJS land - adding array-reduce was one step towards that end. |
| 14:06 | lynaghk | dnolen_: I haven't given it a ton of thought aside from "oh hey, this process is just calling map 20 times across the same data---maybe I should use reducers!". Getting the semantics + API solidified is more important. ggplot in R is pretty slow, so right now it's an easy bar = ) |
| 14:07 | lynaghk | dnolen_: anyway, I've got to run for now. I'll ping you if I make any interesting progress. |
| 14:07 | dnolen_ | lynaghk: later. |
| 14:09 | holo | hi |
| 14:11 | holo | there is a System/getenv function to get an env string. what is the most idiomatic way of doing the opposite? like System/setenv ? |
| 14:12 | technomancy | holo: unfortunately the JVM makes this basically impossible |
| 14:12 | technomancy | the environment is more or less immutable |
| 14:19 | holo | technomancy, i see. thanks |
| 14:22 | llasram | nz-: Oh, good point on the ^:skip-aot. Updated README |
| 14:23 | llasram | nz-: Performance: might be slightly slower, but I've never quantified it. Might be good to know! |
| 14:24 | technomancy | full AOT definitely speeds up boot |
| 14:25 | technomancy | nz-: another option is to do a full compile only upon release rather than putting it at the top-level of project.clj |
| 14:26 | S11001001 | technomancy, holo: if it's subprocess-related, I believe you can pass an environment with your spawns |
| 14:26 | technomancy | :aliases {"release" ["do" "compile" ":all," "uberjar," "clean"]} |
| 14:26 | nz- | technomancy: how to do that? with profiles? |
| 14:26 | technomancy | nz-: profiles or aliases |
| 14:28 | nz- | i still dont get why the aot made my program work incorrectly and partial recompilation made it work correctly |
| 14:28 | technomancy | there's a lot of magic in midje; that would be the first place I'd look |
| 14:29 | nz- | it was not midje, since running the actual program had same behavior, more likely i would point fingers at lobos |
| 14:29 | technomancy | but in general AOT is best reserved for "end of the line" |
| 14:29 | technomancy | oh, gotcha |
| 14:30 | acheng | korma question: anyone know how to use where...in without a subselect? |
| 14:31 | holo | S11001001, thanks |
| 14:32 | nz- | acheng: like this? https://github.com/RuuviTracker/ruuvitracker_server/blob/master/src/ruuvi_server/database/event_dao.clj#L22 |
| 14:34 | acheng | nz-: sure... if ids is coming in as a regular sequence and not the result of another select |
| 14:36 | nz- | lobos had some kind of thing where macros register stuff to an atom |
| 14:38 | gfredericks | ibdknox: ping |
| 14:40 | nz- | acheng: so what kind of sql select you would like as the result? |
| 14:41 | nz- | acheng: select * from tbl1 where id in (select some_id from tbl2) ? |
| 14:44 | lynaghk | ping: emezeske |
| 14:46 | acheng | nz-: ah ok. (where (in :foo (list 1 2 3))) works as you'd expect. thanks! |
| 14:47 | acheng | nz-: my initial test of it had an unrelated error. that's what my problem was |
| 14:50 | SegFaultAX | Has anyone heard of datomic being used in production? |
| 14:50 | SegFaultAX | Is it even production worthy? |
| 14:50 | azkesz | datomic, i like that, next on my list to learn |
| 14:51 | jsabeaudry | I'm getting a SIGV_MAPERR in 'JavaThread "C2 CompilerThread1" daemon'. Anyone knows anything about that thread? |
| 14:51 | SegFaultAX | azkesz: I just got done watching Hickey's presentation on it. It seems like it's full of some pretty fantastic ideas. |
| 14:51 | azkesz | yes indeed, I watched that twice , I still need to rewatch it after I learn some clojure=) |
| 14:52 | azkesz | it certainly seems better that what I wanted to use before, namely berkeleydb je |
| 15:03 | mattmoss | Is there a library fn for doing this pattern I keep repeating in my macros? (symbol (str "foo" "/" "bar")) |
| 15:04 | Chousuke | mattmoss: why would you do that? |
| 15:04 | mattmoss | in a macro |
| 15:04 | mattmoss | I could be stupid, too. |
| 15:05 | mattmoss | "foo" and "bar" are replaced by arguments to defmacro |
| 15:05 | Chousuke | you can do ~'foo/bar |
| 15:05 | Chousuke | to get the symbol as it is |
| 15:06 | mattmoss | ,(let [foo "hello" bar "world"] `(~'foo/bar)) |
| 15:06 | clojurebot | (foo/bar) |
| 15:06 | mattmoss | ,(let [foo "hello" bar "world"] `(~foo/bar)) |
| 15:06 | clojurebot | #<CompilerException java.lang.RuntimeException: No such namespace: foo, compiling:(NO_SOURCE_PATH:0)> |
| 15:07 | mattmoss | ,(let [foo "hello" bar "world"] `(~(symbol (str foo "/" bar)))) |
| 15:07 | clojurebot | (hello/world) |
| 15:07 | mattmoss | that's what I want |
| 15:10 | llasram | ,(symbol "foo" "bar") |
| 15:10 | clojurebot | foo/bar |
| 15:12 | mattmoss | well, mend me with yarn... |
| 15:13 | mattmoss | llasram: thanks. I missed the obvious. |
| 15:13 | llasram | happens to us all :-) |
| 15:16 | sindikat | hello everyone! how do i turn [[0 :a] [1 :b] ...] into [[1 :a] [2 :b] ...] by using map? can't find the solution |
| 15:16 | emezeske | lynaghk: yo |
| 15:17 | scriptor | sindikat: think about it, map gets passes a function, the function takes a single argument, an element in the list |
| 15:17 | xeqi | do you have a function to turn [0 :a] into [1 :a] ? |
| 15:17 | sindikat | xeqi: i could write an anonymous one |
| 15:17 | sindikat | (map #(+ 1 (first %)) (map-indexed vector [:a :a :a])) just returns (1 1 1) |
| 15:17 | nz- | ,(map (fn [[key value]] [(inc key) value]) [[0 :a] [1 :b]]) |
| 15:17 | clojurebot | ([1 :a] [2 :b]) |
| 15:18 | sindikat | aha |
| 15:18 | sindikat | (map #(vector (+ 1 (first %)) (second %)) (map-indexed vector [:a :a :a])) |
| 15:18 | llasram | ,(map-indexed vector (range 5)) |
| 15:18 | clojurebot | ([0 0] [1 1] [2 2] [3 3] [4 4]) |
| 15:18 | lynaghk | emezeske: hey dude |
| 15:18 | lynaghk | emezeske: writing up a lein cljsbuild issue right now. |
| 15:18 | llasram | sindikat: The issue is that map-indexed calls it's provided function with 2 args, not a 2-tuple as one arg |
| 15:18 | emezeske | lynaghk: uh oh! |
| 15:19 | sindikat | nz-: is that destructuring you used? |
| 15:19 | nz- | yep |
| 15:19 | lynaghk | emezeske: https://github.com/emezeske/lein-cljsbuild/issues/119 |
| 15:19 | sindikat | nz-: very elegant, thanks |
| 15:20 | nz- | ,(into [] (map (fn [[key value]] [(inc key) value]) [[0 :a] [1 :b]])) |
| 15:20 | clojurebot | [[1 :a] [2 :b]] |
| 15:20 | nz- | now it is vector and not a list |
| 15:22 | lynaghk | emezeske: I have to head out right now, but take a look at the issue. If it seems doable and you'd welcome a patch, I can put in a pull request later today. |
| 15:23 | emezeske | lynaghk: Sure |
| 15:23 | emezeske | lynaghk: I will try to comment on it later today |
| 15:23 | lynaghk | emezeske: cool, thanks man! |
| 15:32 | sindikat | nz-: why couldn't i use vec? because into lazily produces vector from the start, while vec instantly converts seq to vector? |
| 15:34 | nz- | ,(vec (map (fn [[key value]] [(inc key) value]) [[0 :a] [1 :b]])) |
| 15:34 | clojurebot | [[1 :a] [2 :b]] |
| 15:34 | nz- | seems to work also |
| 15:35 | nz- | basically i have used into before but not vec |
| 15:35 | sindikat | intuitively i think into is more correct way here than vec, but i can't explain |
| 15:38 | null- | clojurescript requires the JVM too right? |
| 15:39 | scottj | null-: for compilation, yes |
| 15:39 | null- | ok |
| 15:44 | SegFaultAX | nz-: The use of into in your example seems like a really bad idea. |
| 15:45 | sindikat | SegFaultAX: that is what i'm interested in too |
| 15:45 | SegFaultAX | sindikat: The answer is simple really. Using vec will happen as a single operation. |
| 15:45 | sindikat | so, my question is: if i want to use map over some vector to produce another vector, is the canonical way to just (vec (map ... some-vector)) ? |
| 15:45 | SegFaultAX | sindikat: Using into like that effectively expands into (reduce conj [] (map-indexed ...)) |
| 15:46 | SegFaultAX | sindikat: Which means you have a bunch of intermediate (read: throwaway) objects. |
| 15:46 | sindikat | SegFaultAX: you mean vec is more effecient then? |
| 15:46 | SegFaultAX | sindikat: I think so. |
| 15:48 | hyPiRion | ,(vec (map #(update-in % 0 inc) [[0 :a] [1 :b]])) |
| 15:48 | clojurebot | #<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: Long> |
| 15:48 | hyPiRion | ,(vec (map #(update-in % [0] inc) [[0 :a] [1 :b]])) |
| 15:48 | clojurebot | [[1 :a] [2 :b]] |
| 15:49 | SegFaultAX | sindikat: I'm almost certain, yes. The source for vec simply calls the clojure.lang.LazilyPersistentVector constructor. |
| 15:50 | SegFaultAX | hyPiRion: That seems like a bad idea for the same reason as above. |
| 15:52 | amalloy | SegFaultAX: (persistent! (reduce conj! (transient []) ...)) |
| 15:52 | nz- | SegFaultAX: what is wrong with into? |
| 15:53 | nz- | ah, ok |
| 15:53 | SegFaultAX | amalloy: Oh right. I guess what I said would only apply if it weren't a java collection. |
| 15:53 | amalloy | &(let [coll (doall (range 1000000))] (time (vec coll))) |
| 15:54 | lazybot | ⇒ "Elapsed time: 684.977221 msecs" [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90... |
| 15:54 | amalloy | &(let [coll (doall (range 1000000))] (time (into [] coll))) |
| 15:54 | sindikat | what is the way to produce the indexed vector from 1 in the first place? i don't want to use map-indexed and then increment every first element of the pair |
| 15:54 | lazybot | ⇒ "Elapsed time: 305.938821 msecs" [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90... |
| 15:54 | hyPiRion | There will probably be some cache here. |
| 15:54 | SegFaultAX | amalloy: Wow. Why is it so much faster? |
| 15:55 | hyPiRion | &(let [coll (doall (range 1000000))] (time (vec coll))) |
| 15:55 | eddie_ | hello #clojure. What approach you suggest for a simple webpage scraping? I think about: openstream, bufferedreader, inputstreamreader and then regex for the links... any better idea? Thank you so much... |
| 15:55 | lazybot | ⇒ "Elapsed time: 402.381485 msecs" [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90... |
| 15:55 | SegFaultAX | Oh, well that's much more reasonable. |
| 15:55 | hyPiRion | Never trust a single attempt. |
| 15:55 | nz- | &(let [coll (doall (range 1000000))] (time (into [] coll))) |
| 15:55 | S11001001 | eddie_: tagsoup or nekohtml |
| 15:55 | amalloy | *shrug* the important thing is you made performance recommendations without any idea what's actually faster |
| 15:55 | lazybot | ⇒ "Elapsed time: 321.234653 msecs" [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90... |
| 15:55 | nz- | still faster |
| 15:56 | SegFaultAX | amalloy: True. |
| 15:56 | SegFaultAX | amalloy: It was just a guess. |
| 15:56 | SegFaultAX | sindikat: It seems my assumptions were wrong. |
| 15:56 | amalloy | personally i prefer vec, because if (into [] x) is better than (vec x) there is literally no reason for vec to exist |
| 15:57 | SegFaultAX | amalloy: I really thought that constructor would have a more optimized implementation. |
| 15:57 | eddie_ | thank you so much S11001001 ... |
| 15:57 | amalloy | SegFaultAX: it does in some cases, although my understanding is there are some pitfalls |
| 15:57 | S11001001 | amalloy: aye :) |
| 15:58 | SegFaultAX | amalloy: I'd have thought it was just call conj on its internal vector like conj! is doing. |
| 15:58 | SegFaultAX | .conj, that is. |
| 15:58 | amalloy | eg, (vec some-java-array) seems to (sometimes?) just return a vector that wraps the underlying array, so that changes to the array appear as changes in the vector |
| 16:00 | sindikat | amalloy: to solve this mistery once and for all i created a question on StackOverflow: http://stackoverflow.com/q/12044181/596361 - any ideas on how can improve my question? seems sorta vague currently |
| 16:01 | hyPiRion | Oh dog |
| 16:01 | S11001001 | sindikat: into [] is not reduce conj, into uses transients when it can; also, into is safer |
| 16:01 | hyPiRion | ,(mapv #(update-in % [0] inc) [[0 :a] [1 :b]]) |
| 16:02 | clojurebot | [[1 :a] [2 :b]] |
| 16:02 | hyPiRion | tadaaa |
| 16:02 | hyPiRion | Why didn't I think of that before. |
| 16:03 | azkesz | what is a function that will do coll pred coll for each of their elements? |
| 16:03 | amalloy | sindikat: start by questioning why you want it to be a vector in the first place. usually you're fine with a lazy sequence |
| 16:03 | hyPiRion | azkesz: coll pred coll? |
| 16:04 | azkesz | hyPiRion, like map does but between two collections |
| 16:04 | sindikat | amalloy: in this particular situation i think i don't need a lazy seq, because i print the vector instantly after it is calculated |
| 16:04 | azkesz | hypirion, [1 2 3 4] + [5 6 7 8] => [6 8 10 12] |
| 16:04 | hyPiRion | ,(map + [1 2 3 4] [5 6 7 8]) |
| 16:04 | clojurebot | (6 8 10 12) |
| 16:04 | hyPiRion | ? |
| 16:04 | S11001001 | azkesz: you mean like covariant functor map? good luck |
| 16:05 | azkesz | hyPiRion lol, that's the one, why so simple darn it=) |
| 16:05 | dsrguru | anyone know of a good vim plugin for commenting and uncommenting clojure code? nerdcommenter doesn't seem to handle multiple semicolons well. |
| 16:05 | azkesz | S11001001, what did you mean? |
| 16:05 | S11001001 | azkesz: oh, never mind |
| 16:06 | sindikat | S11001001: what did you mean by "into is safer"? |
| 16:07 | S11001001 | ,(let [o (to-array [1,2,3]) v (vec o)] [(v 1) (do (aset o 1 42) (v 1))]) ; sindikat |
| 16:07 | clojurebot | [2 42] |
| 16:07 | dnolen_ | ibdknox: ping |
| 16:07 | aperiodic | dsrguru: I just use i#_ and/or <C-v>[movement]I; |
| 16:08 | sindikat | offtopic: how is that measuring elapsed time called as one word? |
| 16:09 | hyPiRion | measuring elapsed time? timetracking? |
| 16:09 | hyPiRion | It's very much dependant on context, I believe. ;) |
| 16:10 | Gnosis- | In my ns form, I have (:use [clojure.zip :as z]), but it doesn't seem to be working properly. It's defining both next and z/next as clojure.zip/next, when it should only be defining z/next, etc. |
| 16:10 | sindikat | hyPiRion: amalloy used it some minutes ago in the channel |
| 16:11 | dsrguru | aperiodic: well, how do you quickly uncomment? (both for ; and #_) |
| 16:11 | sindikat | hyPiRion: benchmark? |
| 16:11 | hyPiRion | sindikat: yeah |
| 16:12 | nz- | ,(doc mapv) |
| 16:12 | clojurebot | "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a vector consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments." |
| 16:14 | azkesz | ,(hash-map :keys [:a :b :a :c] :values [1 2 3 4]) |
| 16:14 | clojurebot | {:keys [:a :b :a :c], :values [1 2 3 4]} |
| 16:15 | emezeske | Gnosis-: You're sure that the naked "next" is not just clojure.core/next ? |
| 16:15 | hyPiRion | ,(zipmap [:a :b :c :d] [1 2 3 4]) ; azkesz: Is this what you want? |
| 16:15 | clojurebot | {:d 4, :c 3, :b 2, :a 1} |
| 16:15 | azkesz | yes thank god=) |
| 16:16 | azkesz | I've been failing to find that offline |
| 16:17 | azkesz | but I did remember some case where they used "keys", maybe to extract only the keys from a keymap, then that's something else which I don't want |
| 16:22 | azkesz | is there something like: (zipmap + [:a :b :a :a] [1 2 3 4]) ;=> [:a 8 :b 2] |
| 16:22 | Gnosis- | emezeske: I figured it out; I needed to use :require, not :use |
| 16:23 | emezeske | Gnosis-: Oh! Heh, my brain just translated :use to :require when it saw the :as stuff :) |
| 16:23 | amalloy | you probably want merge-with +, azkesz |
| 16:24 | azkesz | sounds good, I'll check |
| 16:24 | amalloy | &(apply merge-with + (for [[k v] (map vector [:a :b :a :a] [1 2 3 4])] {k v})) |
| 16:24 | lazybot | ⇒ {:b 2, :a 8} |
| 16:24 | Gnosis- | emezeske: it seems like Clojure should complain if it sees an :as with :use |
| 16:24 | sindikat | stupid question: how to create a lazy sequence from 1 to infinity? |
| 16:25 | amalloy | (iterate inc 1)? (rest (range))? |
| 16:25 | emezeske | Gnosis-: Yeah, I would have expected a complaint -- I didn't know :use would allow that. |
| 16:26 | azkesz | amalloy, wow I would not have guessed that with merge... |
| 16:28 | nz- | ,(doc iterate) |
| 16:28 | clojurebot | "([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects" |
| 16:30 | nz- | what does it mean that "f must be free of side-effects"? that the side effects are executed in unpredictable times? or that the iterate function doesn't work if f does side effects? |
| 16:31 | duck1123 | it really should be "SHOULD be free" It's legal to have side effects, but expect them to fire an unpredictable number of times |
| 16:41 | azkesz | ,(apply merge (for [k [1 2 3 6]] #{k})) ; is this supposed to happen? |
| 16:41 | clojurebot | #{1 #{2} #{3} #{6}} |
| 16:41 | SegFaultAX | azkesz: What are you trying to do exactly? |
| 16:42 | azkesz | SegFaultAX, just testing really |
| 16:42 | azkesz | SegFaultAX, I would've expected maybe #{ 1 2 3 6} |
| 16:42 | azkesz | ,(merge #{1} #{2}) |
| 16:42 | clojurebot | #{1 #{2}} |
| 16:43 | amalloy | merge is for maps. whatever it does on sets is just random coincidence |
| 16:43 | azkesz | ,(merge {:1 :1} {:2 :2}) |
| 16:43 | clojurebot | {:2 :2, :1 :1} |
| 16:43 | Raynes | ,(into #{1} #{2}) |
| 16:43 | clojurebot | #{1 2} |
| 16:43 | hyPiRion | ,(clojure.set/union #{1} #{2}) |
| 16:43 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set> |
| 16:43 | hyPiRion | ,(require 'clojure.set) |
| 16:43 | clojurebot | nil |
| 16:43 | hyPiRion | ,(clojure.set/union #{1} #{2}) |
| 16:43 | azkesz | but weren't sets based on maps? or I misforgot something=) |
| 16:43 | clojurebot | #{1 2} |
| 16:43 | SegFaultAX | Misforgot? |
| 16:43 | Raynes | He accidentally forgot not to forget. |
| 16:44 | Raynes | I guess. |
| 16:44 | azkesz | I remember something like sets having same key/val |
| 16:44 | SegFaultAX | Raynes: That's what I understood, too. |
| 16:44 | azkesz | I meant, that a merge between forgot and misunderstand :) |
| 16:45 | azkesz | I may wrongly remember that sets are internally hashmaps with same key/val |
| 16:45 | azkesz | so I figured that merge would've worked or something |
| 16:46 | azkesz | ,(sorted-set 1 2 1) |
| 16:46 | clojurebot | #{1 2} |
| 16:47 | azkesz | ,(class (sorted-set 1 2 1)) |
| 16:47 | clojurebot | clojure.lang.PersistentTreeSet |
| 16:47 | azkesz | ,(class #{1}) |
| 16:47 | clojurebot | clojure.lang.PersistentHashSet |
| 16:47 | Raynes | misunderforgot |
| 16:47 | azkesz | lol |
| 16:48 | hyPiRion | Sets are implemented as a hash map where key and value are the same value. |
| 16:49 | hyPiRion | But you shouldn't treat them as such. |
| 16:49 | scriptor | looks like it can use anything that's an IPersistentMap to store the elements |
| 16:49 | azkesz | ,(clojure.set/union (for [k [1 2 3 6]] #{k})) |
| 16:49 | clojurebot | (#{1} #{2} #{3} #{6}) |
| 16:49 | l1x | hey ho hi everybody |
| 16:49 | azkesz | ,(apply clojure.set/union (for [k [1 2 3 6]] #{k})) |
| 16:49 | clojurebot | #{1 2 3 6} |
| 16:49 | scriptor | but yes, that's just incidental, don't treat them as maps |
| 16:49 | azkesz | hyPiRion, cool |
| 16:49 | l1x | would sombody hit me with some hints why i fail here -> https://gist.github.com/3407691#comments |
| 16:50 | llasram | l1x: Because map returns a sequence? |
| 16:50 | llasram | s,sequence,lazy sequence, |
| 16:51 | emezeske | l1x: The problem probably has to do with a dynamic binding interacting badly with a lazy-seq |
| 16:51 | emezeske | l1x: Assuming that jmx/with-connection sets a dynamic binding behind the scenes |
| 16:52 | llasram | emezeske, l1x: Or even just keeps a connection open for its dynamic scope |
| 16:52 | l1x | so have you seen the error message in the comments section? |
| 16:52 | emezeske | llasram, l1x: Good point |
| 16:53 | emezeske | l1x: http://kotka.de/blog/2009/11/Taming_the_Bound_Seq.html |
| 16:53 | emezeske | l1x: http://cemerick.com/2009/11/03/be-mindful-of-clojures-binding/ |
| 16:53 | emezeske | l1x: Those might be helpful |
| 16:53 | l1x | kk |
| 16:53 | emezeske | l1x: The thing you need to think about is "when is getCanonicalName actually called" |
| 16:54 | emezeske | l1x: Part of the answer is "not while the connection is open" |
| 16:54 | l1x | wait, the first part is ok |
| 16:54 | l1x | (map (memfn getCanonicalName) (jmx/mbean-names "hadoop:*"))))) |
| 16:54 | l1x | this works perfectly |
| 16:54 | l1x | my problem is that i cant apply the second map to this ^ |
| 16:55 | l1x | and the error message is coming from the jmx layer saying there is no such a mbean |
| 16:55 | scriptor | jmx/mbean is a java method, right? |
| 16:55 | l1x | nope |
| 16:55 | l1x | this is the clojure lib |
| 16:55 | scriptor | ah |
| 16:56 | emezeske | l1x: How much do you understand about lazy sequences? |
| 16:56 | l1x | i have read the book this weekend |
| 16:56 | emezeske | l1x: So do you understand why a "with-" function and a lazy sequence might not work well together? |
| 16:57 | devinus | is there a way to install user plugins from the command line in lein2? |
| 16:57 | Raynes | devinus: No. |
| 16:57 | devinus | oh ;_; |
| 16:57 | Raynes | You just edit ~/.lein/profiles.clj |
| 16:57 | llasram | l1x: For a concrete suggestion, try wrapping what you have inside jmx/with-connection in a `doall` |
| 16:57 | l1x | emezeske: yep, cause you dont have the certain element of the lazy seq "computed" at the time you are calling the with- on it |
| 16:58 | l1x | llasram: ok i try that, i just dont understand why the first map work |
| 16:58 | l1x | and the second fail |
| 16:58 | l1x | (maybe the first time it is not a lazy seq) |
| 16:58 | emezeske | l1x: Are you trying things out in the REPL? |
| 16:58 | l1x | nope |
| 16:58 | l1x | lein project |
| 16:59 | emezeske | l1x: Okay. I was just going to mention that sometimes you need to carefully pay attention to what might cause a lazy-seq to be realized |
| 16:59 | scriptor | you can use the repl with a lein project |
| 16:59 | emezeske | l1x: E.g. printing it out,e tc |
| 16:59 | l1x | yep |
| 16:59 | maacl | Is there a way to embed a Incanter chart in a Hiccup page other than writing it out to disk? |
| 16:59 | l1x | emezeske: thx, i try with doall |
| 16:59 | emezeske | l1x: Good luck sir! |
| 17:00 | l1x | ;) |
| 17:00 | devinus | where does lein2 install plugins? |
| 17:01 | devinus | oh, .m2 it seems |
| 17:01 | nz- | devinus: i'd assume that they are with normal maven deps |
| 17:04 | devinus | what are some of the most useful/coolest lein2 plugins? |
| 17:04 | l1x | you guys are awesome |
| 17:04 | l1x | it works! :) |
| 17:04 | emezeske | l1x: sweet. :) |
| 17:05 | scriptor | devinus: can't name specific ones, but there's a list here https://github.com/technomancy/leiningen/wiki/Plugins |
| 17:06 | brainproxy | suggestions for helpful tools/libs for doing complex web-form validation .. prefer something that can be loosely coupled to ring/compojure rather than a framework |
| 17:09 | gtrak | is there like a clojure analogue to scheme's atom? ? |
| 17:09 | S11001001 | gtrak: the atom/list dichotomy isn't so clear in clojure, so I'm not sure it would have a useful universal meaning |
| 17:10 | S11001001 | gtrak: check out seq?, sequential?, and core.incubator's seqable? for some variants |
| 17:10 | gtrak | ah |
| 17:11 | S11001001 | ,(sequential? "abc") |
| 17:11 | clojurebot | false |
| 17:11 | S11001001 | but "abc" is `seqable?' |
| 17:11 | gtrak | ,(sequential? []) |
| 17:11 | clojurebot | true |
| 17:11 | nz- | devinus: lein-ring, lein-otf |
| 17:11 | gtrak | ,(sequential? {}) |
| 17:11 | clojurebot | false |
| 17:11 | gtrak | hmm |
| 17:11 | S11001001 | I strongly disfavor seq?, picking sequential? or seqable? depending on scenario |
| 17:12 | dnolen_ | gtrak: (not (coll? x)) is probably the closest |
| 17:13 | S11001001 | ,(coll? (map identity [42])) |
| 17:13 | clojurebot | true |
| 17:13 | S11001001 | mmm |
| 17:17 | azkesz | is there a function that would return the first element that satisfies the predicate? instead of true what some does |
| 17:18 | dnolen_ | azkesz: doesn't return true. |
| 17:18 | dnolen_ | azkesz: er I mean, some doesn't return true. |
| 17:18 | azkesz | sorry I meant every? |
| 17:19 | maacl | azkesz: (first (filter predicate... |
| 17:19 | azkesz | ,(some #(not= % nil) [ nil 1 nil ]) |
| 17:19 | clojurebot | true |
| 17:20 | duck1123 | that's because your predicate is returning true |
| 17:20 | azkesz | maacl, thanks that's works |
| 17:20 | azkesz | duck1123, i see what you mean, let me check |
| 17:21 | azkesz | ,(some #(if (not= % nil) :a :nota) [ nil 1 nil ]) |
| 17:21 | clojurebot | :nota |
| 17:21 | azkesz | ,(some #(if (not= % nil) :a nil) [ nil 1 nil ]) |
| 17:21 | clojurebot | :a |
| 17:22 | azkesz | ,(some #(when-not % :a) [ nil 1 nil ]) |
| 17:22 | clojurebot | :a |
| 17:22 | azkesz | ,(some #(when-not % %) [ nil 1 nil ]) |
| 17:22 | clojurebot | nil |
| 17:22 | duck1123 | ,(some identity [nil 1 nil]) |
| 17:22 | clojurebot | 1 |
| 17:22 | duck1123 | granted, that also kills false |
| 17:23 | azkesz | ,(some identity [ nil :a nil ] |
| 17:23 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 17:23 | azkesz | ,(some identity [ nil :a nil ]) |
| 17:23 | clojurebot | :a |
| 17:23 | azkesz | that's quite uber:D |
| 17:25 | azkesz | that solves this one=) http://www.4clojure.com/problem/73 |
| 17:26 | azkesz | I think the " Now you can move on to" is kinda random, I wasn't supposed to reach this Hard problem before completing all the easy ones |
| 17:28 | azkesz | I'm mind boggling watching the other solutions |
| 17:42 | azkesz | An Error occured: timeout |
| 17:42 | azkesz | ~guards |
| 17:42 | clojurebot | SEIZE HIM! |
| 17:42 | azkesz | 4clojure is down? |
| 17:43 | azkesz | nvm, it's kinda back but slow |
| 17:44 | azkesz | ok it's dead:) 502 Bad Gateway maybe I should watch a movie, thanks to all that helped! I'll be bac(k) |
| 17:46 | Raynes | amalloy: ^ |
| 17:47 | amalloy | Raynes: it started itself back up even as he was complaining. back to being fast before he left |
| 17:47 | Raynes | Cool. |
| 17:47 | nz- | what was the name of slime/swank replacement that somebody was making? |
| 17:48 | Raynes | nrepl.el |
| 17:50 | nz- | there was also something else |
| 17:50 | Raynes | nrepl.el times 2? |
| 17:50 | amalloy | ritz |
| 17:51 | Raynes | Oh. Didn't realize it was a replacement. |
| 17:51 | amalloy | it's more like a reimplementation |
| 17:51 | nz- | well something related at least |
| 17:51 | antifuchs | nz-: ritz. |
| 17:51 | antifuchs | yeah, ritz is quite neat. gotta polish up my branch a bit (: |
| 17:52 | antifuchs | it can talk to nrepl or to slime on the emacs side, which is pretty cool (: |
| 17:52 | antifuchs | (I prefer slime myself, so yay) |
| 17:53 | Raynes | I'm happy I can put SLIME far, far behind me. |
| 17:53 | scizo_ | \leave |
| 17:53 | scizo_ | oops |
| 17:54 | nz- | is ritz usable now? |
| 17:55 | antifuchs | nz-: it works for me, for superficial usage. hugod would know for sure |
| 17:56 | hugod | I've used it exclusively for well over a year |
| 17:56 | antifuchs | Raynes: yeah, that's what many people say and I don't doubt that. For me, it's 7 years of finger memory and slime-selector addiction (: |
| 17:56 | antifuchs | (if it hasn't been longer. getting old) |
| 17:56 | Raynes | antifuchs: Well, at least you aren't using swank-clojure. |
| 17:57 | Raynes | I feel bad for anyone who has to maintain that. |
| 17:57 | antifuchs | Raynes: hah, I did hack that into shape to use it with current slime (: |
| 17:57 | antifuchs | wasn't too horriffic, tbh! |
| 17:57 | antifuchs | (nooot that i'm volunteering!) ((: |
| 17:58 | devinus | i'm guessing nobody uses the jdk7 from oracle on OS X yet? |
| 17:58 | Raynes | wmealing_: If you're using emacs, nrepl.el is nice. |
| 17:58 | Raynes | If not, VimClojure is nice. |
| 17:58 | Raynes | If not Vim, CCW is nice. |
| 17:58 | Cr8 | devinus: I am, I think. |
| 17:58 | wmealing_ | Raynes: emacs at the moment |
| 17:58 | Cr8 | Yep. I am. |
| 17:58 | Raynes | When light table can save files properly and stop losing my bloody code, it'll be nice. |
| 17:58 | devinus | i get a lot of NullPointerExceptions with some packages |
| 17:58 | devinus | lein-ring for instance |
| 17:59 | Cr8 | devinus: hm. I've not had that issue with lein-ring, and I have used it. |
| 18:00 | Cr8 | I've got java -version "1.7.0_04-ea" |
| 18:00 | devinus | oh |
| 18:00 | devinus | i don't think that's the blessed OS X version |
| 18:01 | devinus | oracle has only released 1.7.0_06-b24 so far |
| 18:01 | Cr8 | I know I downloaded whatever the blessed version was |
| 18:01 | Cr8 | http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u4-downloads-1591156.html from here |
| 18:02 | Cr8 | ah.. |
| 18:02 | Cr8 | but I had openJDK above it in preferred order |
| 18:02 | Cr8 | in my prefpane |
| 18:02 | Cr8 | now I have java -version java version "1.7.0_06" |
| 18:03 | Cr8 | lein ring seems quite happy with that one too, though |
| 18:05 | nz- | well ritz didn't work |
| 18:05 | nz- | emacs says: symbol's value as variable is void: slime-ritz |
| 18:08 | wmealing_ | Raynes: nrepl.el is actually not bad..thanks |
| 18:08 | wmealing_ | and no problems getting it working out of the box |
| 18:11 | SegFaultAX | Speaking of 4clojure, what am I doing wrong? (fn [[h & t] n] (if (zero? n) h (recur t (dec n)))) http://www.4clojure.com/problem/21 |
| 18:13 | bdesham | hi all! I'm trying to parse XHTML with Clojure, but the parser complains that it doesn't recognize entities (e.g. " "). any idea where to start with this? |
| 18:13 | bdesham | I tried using enlive's parse function, but same thing |
| 18:13 | SegFaultAX | Hmm, (fn [coll n] (first (drop n coll))) worked. |
| 18:15 | Cr8 | ha, that's weird |
| 18:15 | Cr8 | I suppose the destructuring might be expanding nth in there |
| 18:16 | SegFaultAX | Cr8: In my solution above? |
| 18:16 | Cr8 | yeah |
| 18:17 | scriptor | SegFaultAX: what error are you getting? |
| 18:17 | Cr8 | yeah, that's what happens. |
| 18:17 | SegFaultAX | scriptor: Nth is forbidden or somesuch. |
| 18:17 | scriptor | SegFaultAX: yea, I just converted mine to use destructuring and got the same issue |
| 18:18 | SegFaultAX | scriptor: I just switched to using drop instead. |
| 18:18 | Cr8 | Destructuring wraps your body in a let form that is created by https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L3928 |
| 18:19 | Cr8 | which does inject nth in there if you use & |
| 18:26 | Cr8 | ,(clojure.walk/macroexpand-all '(fn [[h & t] n] (if (zero? n) h (recur t (dec n))))) |
| 18:26 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.walk> |
| 18:26 | Cr8 | beh |
| 18:26 | Cr8 | it expands to: (fn* ([p__786 n] (let* [vec__787 p__786 h (clojure.core/nth vec__787 0 nil) t (clojure.core/nthnext vec__787 1)] (if (zero? n) h (recur t (dec n)))))) |
| 18:37 | nz- | I tried to install slime-ritz but something went wrong, thing starter working when I removed *.elc files for slime-ritz |
| 18:47 | Roxxi | What's a good library for creating html in clojure... clj-html? |
| 18:47 | brehaut | hiccup |
| 18:48 | Roxxi | nice, thanks |
| 18:50 | TimMc | Roxxi: And there's enlive, which is crotchety and difficult, but backed by a nice concept. |
| 18:53 | Raynes | Enlive doesn't create html |
| 18:53 | Raynes | It modifies html. |
| 18:55 | nz- | got ritz running but for example C-c C-l (load file) doesn't seem to work |
| 18:55 | nz- | MalformedURLException |
| 20:07 | azkesz | ,(#( (and ((set (keys %2)) %1) (%1 %2)) ) :a {:a nil :b 2}) |
| 20:07 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 20:08 | azkesz | is there something like macroexpand but for anonymous functions? |
| 20:08 | azkesz | or some kind of eval with a depth maybe? |
| 20:09 | technomancy | ,#(identity %) |
| 20:09 | clojurebot | #<sandbox$eval59$fn__60 sandbox$eval59$fn__60@7d6c6f48> |
| 20:09 | technomancy | ,(read-string "#(identity %)") |
| 20:09 | clojurebot | (fn* [p1__89#] (identity p1__89#)) |
| 20:09 | amalloy | ,'#(identity %) is what technomancy meant the second time :P |
| 20:09 | clojurebot | (fn* [p1__114#] (identity p1__114#)) |
| 20:09 | technomancy | derp |
| 20:09 | technomancy | yes |
| 20:11 | azkesz | ,(read-string '(#( (and ((set (keys %2)) %1) (%1 %2)) ) :a {:a nil :b 2})) |
| 20:11 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.String> |
| 20:11 | azkesz | (read-string "(#( (and ((set (keys %2)) %1) (%1 %2)) ) :a {:a nil :b 2})") |
| 20:11 | azkesz | ,(read-string "(#( (and ((set (keys %2)) %1) (%1 %2)) ) :a {:a nil :b 2})") |
| 20:11 | clojurebot | ((fn* [p1__172# p2__171#] ((and ((set (keys p2__171#)) p1__172#) (p1__172# p2__171#)))) :a {:a nil, :b 2}) |
| 20:11 | technomancy | if you're having trouble debugging it, don't use #() yet |
| 20:12 | azkesz | ok |
| 20:13 | azkesz | it actually works if it's not anonymous |
| 20:13 | azkesz | ,(#( (and ((set (keys %2)) %1) (%1 %2)) ) :a {:a nil :b 2}) |
| 20:13 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 20:13 | azkesz | ,((fn [key map] (and ((set (keys map)) key) (key map)) ) :a {:a nil :b 2}) |
| 20:13 | clojurebot | nil |
| 20:14 | emezeske | ,'#(identity %) |
| 20:14 | clojurebot | (fn* [p1__257#] (identity p1__257#)) |
| 20:14 | emezeske | ,'#((identity %)) |
| 20:14 | clojurebot | (fn* [p1__284#] ((identity p1__284#))) |
| 20:15 | azkesz | oo |
| 20:15 | azkesz | ,(#( and ((set (keys %2)) %1) (%1 %2) ) :a {:a nil :b 2}) |
| 20:15 | clojurebot | nil |
| 20:15 | azkesz | emezeske, why thank you=) |
| 20:15 | emezeske | azkesz: thank technomancy! :) |
| 20:16 | azkesz | I missed it the first time i see |
| 20:16 | emezeske | At any rate, my personal taste for something that has multiple args, used multiple times, is to use a fn with well-named args |
| 20:17 | emezeske | But of course that's a matter of opinion :) |
| 20:17 | azkesz | I agree it's better for readability and I want that |
| 20:22 | azkesz | we need a better way to thank people, every time I thank someone I feel like I'm fakeing it, or somehow stealing something from them lol that's why I kinda try to avoid thanking, also because it feels like I nolonger feel obliged to them now that I thanked them:) besides thanks are always implied; but then there's the matter of them maybe waiting for a thank at least as a symbol of acknowledging |
| 20:22 | azkesz | that their help was well received |
| 20:22 | azkesz | ,(fn? thanks) |
| 20:22 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: thanks in this context, compiling:(NO_SOURCE_PATH:0)> |
| 20:23 | emezeske | azkesz: Sometimes people will ,(inc nickname) to sort of upvote them |
| 20:23 | azkesz | does clojurebot have any way of knowing who typed the command? |
| 20:24 | azkesz | that's good enough emezeske, even better :D |
| 20:25 | emezeske | (inc clojurebot) |
| 20:25 | lazybot | ⇒ 13 |
| 20:25 | azkesz | ,*ns* |
| 20:25 | clojurebot | #<Namespace sandbox> |
| 20:26 | azkesz | emezeske the nicks are not already defined right? |
| 20:26 | azkesz | only some |
| 20:26 | emezeske | azkesz: I don't know how it works. I think you can use any nick, and it will start at zero, but I have never experimented |
| 20:26 | azkesz | ,(ns-resolve *ns* aka) |
| 20:26 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: aka in this context, compiling:(NO_SOURCE_PATH:0)> |
| 20:27 | azkesz | ,(ns-resolve *ns* 'aka) |
| 20:27 | clojurebot | nil |
| 20:27 | brehaut | (inc not-a-real-nick-at-all) |
| 20:27 | lazybot | ⇒ 1 |
| 20:27 | emezeske | (dec not-a-real-nick-at-all) |
| 20:27 | lazybot | ⇒ 0 |
| 20:27 | azkesz | oh without the "," |
| 20:27 | azkesz | ok then, no headaches:) |
| 20:27 | azkesz | (inc emezeske) (inc technomancy) |
| 20:27 | lazybot | ⇒ 1 |
| 20:27 | azkesz | lol |
| 20:27 | azkesz | wonder if the first or last got it |
| 20:27 | brehaut | first |
| 20:27 | azkesz | or both, as it would by clojure |
| 20:28 | emezeske | technomancy is certainly > 0 |
| 20:28 | azkesz | ,emezeske |
| 20:28 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: emezeske in this context, compiling:(NO_SOURCE_PATH:0)> |
| 20:28 | brehaut | technomancy has karma by the bucket |
| 20:28 | azkesz | what is the query of the value? |
| 20:28 | brehaut | azkesz: its not running through the evaluator at all. its special lazybot magic |
| 20:28 | brehaut | $karma technomancy |
| 20:28 | lazybot | technomancy has karma 34. |
| 20:28 | azkesz | brehaut, you're right, got it |
| 20:28 | azkesz | (inc technomancy) |
| 20:28 | lazybot | ⇒ 35 |
| 20:28 | azkesz | ok done with my current thanks:D |
| 20:29 | azkesz | $karma emezeske |
| 20:29 | lazybot | emezeske has karma 1. |
| 20:29 | azkesz | $karma chouser |
| 20:29 | lazybot | chouser has karma 7. |
| 20:29 | azkesz | lol |
| 20:30 | azkesz | ,(println "test") |
| 20:30 | clojurebot | test |
| 20:30 | azkesz | i wonder if I can implement a function and have clojurebot inc karma :) |
| 20:30 | azkesz | ,(println "(inc chouser)") |
| 20:30 | clojurebot | (inc chouser) |
| 20:30 | lazybot | ⇒ 8 |
| 20:31 | azkesz | :-" |
| 20:31 | casion | lol |
| 20:31 | brehaut | that is in fact the only way you can dec your own karma |
| 20:32 | azkesz | interesting |
| 20:33 | brehaut | raynes really needs to fix that; i frequently need to dec myself |
| 20:34 | azkesz | $karma brehaut |
| 20:34 | lazybot | brehaut has karma 6. |
| 20:34 | azkesz | why do you need to? |
| 20:34 | brehaut | because i frequently say stupid and wrong things |
| 20:35 | azkesz | not-a-bot pass :) |
| 20:42 | azkesz | i can't make an alias in mIRC unless i put a space after the ' in: /thanks /say ,(thanks '$$1) |
| 20:43 | azkesz | wrong chan, soz:) |
| 20:43 | amalloy | the lazybot karma system is mostly for fun anyway. nobody answers questions in here just to boost their karma |
| 20:44 | azkesz | I dig that, but I feel it would help give more meaning to my thanks yous if I were to instead do that :) |
| 20:45 | azkesz | actually, I can just do the (inc nick) instead of defining a thanks fn in clojurebot and calling it |
| 20:46 | Cr8 | azkesz: I believe you can tell mIRC script to omit the space by using a pseudo-var |
| 20:46 | Cr8 | its something like |
| 20:46 | Cr8 | (thanks ' $+ $$1) |
| 20:46 | Cr8 | or $$+ |
| 20:47 | Cr8 | its been like, 8 years since I touched mIRC so =P |
| 20:47 | azkesz | that's the one, i received a similar reply on ##mirc : ' $+ $$1 |
| 20:48 | Cr8 | hell yeah, I'm surprosed I remembered that. |
| 20:48 | Cr8 | *surprised |
| 20:48 | azkesz | (inc Cr8) |
| 20:48 | lazybot | ⇒ 1 |
| 20:48 | azkesz | =) |
| 20:48 | Cr8 | $karma Apage43 |
| 20:48 | lazybot | Apage43 has karma 1. |
| 20:49 | azkesz | ChanServ |
| 20:49 | Cr8 | is my other nick |
| 20:49 | azkesz | great now i need to know how to /say $karma lol |
| 20:49 | Cr8 | apparently i got inc'd once in the past |
| 20:49 | Cr8 | I belive that's just $$ $+ karma |
| 20:49 | azkesz | ah so simple |
| 20:50 | azkesz | $$karma ChanServ |
| 20:50 | Cr8 | or maybe only the one $ =P |
| 20:50 | Cr8 | *Shrug* |
| 20:50 | azkesz | yep it was one |
| 20:50 | azkesz | $karma ChanServ |
| 20:50 | lazybot | ChanServ has karma 0. |
| 20:51 | azkesz | (inc Cr8) |
| 20:51 | lazybot | ⇒ 2 |
| 20:52 | azkesz | would be cool if the karma points were kept in context or something, or at least the date, or if chan is logged an url to the inc line :) |
| 20:52 | seaword | I am using Cheshire to output json and was wondering what people have done regarding clojure naming (e.g. { "first-name": "Fred" }) and typical JS conventions of { "firstName": "Fred" } or even { "first_name": "Fred" }. Do people typically stick with the clojure naming on the client side? |
| 20:53 | cshell | $karma cshell |
| 20:53 | lazybot | cshell has karma 0. |
| 20:53 | cshell | how do you get karma anyway? |
| 20:53 | aperiodic | bribes |
| 20:55 | gfredericks | ,(println "(inc gfredericks')") |
| 20:55 | clojurebot | (inc gfredericks') |
| 20:55 | lazybot | ⇒ 2 |
| 20:56 | azkesz | $karma gfredericks |
| 20:56 | lazybot | gfredericks has karma 6. |
| 20:56 | gfredericks | I wonder where the first one for gfredericks' came from |
| 20:56 | azkesz | the other is like your test nick? |
| 20:56 | gfredericks | I was just using it to demo self-karma-increases |
| 20:56 | emezeske | gfredericks prime |
| 20:56 | azkesz | lol |
| 20:56 | gfredericks | without devaluing my actual karma |
| 20:57 | azkesz | ,(false? nil) |
| 20:57 | clojurebot | false |
| 20:57 | emezeske | gfredericks: multiple personality disorder? |
| 20:57 | gfredericks | emezeske: multiple personality order. |
| 20:57 | emezeske | gfredericks: :) |
| 21:00 | azkesz | ,(#_ (range)) |
| 21:00 | clojurebot | () |
| 21:01 | azkesz | any chance we can do an alias for #_ ? :) |
| 21:02 | gfredericks | the reader isn't configurable |
| 21:02 | azkesz | ,(defn dont [ignored & others] (do others)) |
| 21:03 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 21:03 | gfredericks | you can define a macro equivalent to comment |
| 21:03 | azkesz | that would be an emulation=) |
| 21:03 | gfredericks | which is mostly like #_ |
| 21:03 | gfredericks | ,((comment (range))) |
| 21:03 | azkesz | can it be a function too? |
| 21:03 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 21:03 | azkesz | the double paranthesis, I had that above=) |
| 21:03 | gfredericks | azkesz: (constantly nil) is a function that ignores its inputs |
| 21:04 | gfredericks | (def don't (constantly nil)) |
| 21:04 | gfredericks | but you don't prevent evaluation of the arguments that way |
| 21:04 | azkesz | oh i see |
| 21:04 | azkesz | but i only wanted the first one ignored in the dont |
| 21:04 | azkesz | oh that's why the macro |
| 21:05 | blrandel | would anyone have any thoughts on whether core.logic might be an appropriate alternative for a use case where a rules engine is typically used? |
| 21:05 | gfredericks | blrandel: numbers! |
| 21:05 | gfredericks | be careful that it can do what you need numerically |
| 21:06 | azkesz | (inc gfredericks) |
| 21:06 | lazybot | ⇒ 7 |
| 21:06 | blrandel | gfredericks: ok, I'll keep that in mind - I'd like to write an 'expert system', but something like Drools just seems very heavy and enterprisey |
| 21:06 | gfredericks | azkesz: (defmacro with-note [note & exprs] (cons 'do exprs)) |
| 21:07 | azkesz | gfredericks, i see that if dont is a function this would timeout: (dont (apply + (range)) 1 2) |
| 21:07 | azkesz | but not if it's a macro |
| 21:07 | gfredericks | right |
| 21:10 | azkesz | that range I used earlier made my eclipse unresponsive, any chance I can launch another repl somehow and interrupt that infinite range ? I figure it must be in the same jvm |
| 21:16 | blrandel | azkesz: unresponsiveness is part of the eclipse experience, try to embrace it |
| 21:16 | azkesz | blrandel it happens rarely though, would u suggest a different environment ? |
| 21:17 | blrandel | as far as IDEs for clojure go, I think that's your best option |
| 21:21 | azkesz | great cause I got used to it |
| 21:22 | casion | eclipse the best option for clojure? |
| 21:22 | casion | surely you jest |
| 21:22 | azkesz | ide |
| 21:22 | azkesz | but I guess idea has plugin too |
| 21:22 | casion | still jesting without a doubt |
| 21:22 | azkesz | ,(fn? jest) |
| 21:23 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: jest in this context, compiling:(NO_SOURCE_PATH:0)> |
| 21:23 | blrandel | casion: as far as IDEs go - counterclockwise is further along than the intellij plugin? |
| 21:23 | azkesz | ,(defmacro with-note [note & exprs] (cons 'do exprs)) |
| 21:23 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 21:23 | casion | blrandel: no idea |
| 21:24 | casion | I'm not sure why emacs is excluded as an IDE in the context of any lisp |
| 21:24 | azkesz | gfredericks, i found an uglier way: (defmacro with-note2 [note & exprs] `(do ~@exprs)) |
| 21:24 | gfredericks | amalloy: I just got a permuto that doesn't diverge; it might be terrible though |
| 21:27 | azkesz | (inc gfredericks) |
| 21:27 | lazybot | ⇒ 8 |
| 21:27 | azkesz | (inc blrandel) |
| 21:27 | lazybot | ⇒ 1 |
| 21:28 | gfredericks | azkesz: you are inflating the currency |
| 21:29 | azkesz | yeah I'm starting to feel the weight of my doing |
| 21:29 | azkesz | this may be worse than saying thanks |
| 21:30 | azkesz | what's the ultimate currency? is it cpu time ? aka attention |
| 21:30 | gtuckerkellogg | I'm doing something wrong with clojopts (from amalloy). |
| 21:32 | gtuckerkellogg | If I run (-main "--help") it works as expected, but if I "lein bin" the program and use the --help option on the command line, I get nothing. Any thoughts? The -main function is here http://pastebin.com/433Vqmv9 |
| 21:34 | amalloy | sounds like lein bin isn't invoking your main in the way you expect; hopefully clojopts isn't involved at all |
| 21:36 | casion | ,(println "(println \",(println \\\"wee\\\"\")") |
| 21:36 | clojurebot | (println ",(println \"wee\"") |
| 21:36 | casion | clever |
| 21:36 | gtuckerkellogg | amalloy, hmm, I suppose you right |
| 21:37 | amalloy | gtuckerkellogg: what about lein run? maybe you're not specifying the right main-related options in project.clj |
| 21:38 | gtuckerkellogg | amalloy, oh, that's a good thought. Ill look into it. |
| 21:38 | azkesz | blrandel, heh timedout again, I guess you were right, it's just that I wasn't running the "right" code, I tried iterate now |
| 21:38 | casion | 1228Wendy1228 |
| 21:38 | gtuckerkellogg | i recently switched to lein 2, so that could well be a possibility |
| 21:38 | casion | 194 |
| 21:39 | casion | zzz |
| 21:39 | azkesz | blrandel, I mean, unresponsive eclipse |
| 21:39 | gtuckerkellogg | lein run --help works. |
| 21:39 | gtuckerkellogg | so that's it |
| 21:41 | blrandel | azkesz: you could try allocating more memory in eclipse.ini |
| 21:41 | azkesz | blrandel, I just noticed that killing eclipse wasn't enough to kill the repls that were using the cpu, had 2 by now eating ram too:) |
| 21:41 | azkesz | maybe it was a bad idea typing in repl: (iterate #(+ 4 %) 0) |
| 21:44 | azkesz | wow that was crazy, not that I see what iterate does:) |
| 21:45 | azkesz | ,(take 10 (iterate #(+ 4 %) 0)) |
| 21:45 | clojurebot | (0 4 8 12 16 ...) |
| 22:44 | saurik | (defrecord test []) -> "ClassCastException clojure.lang.Var cannot be cast to java.lang.Class clojure.lang.Namespace.referenceClass (Namespace.java:129)" <- it seems problematic that if someone in a different namespace that I happen to be using decides to create a variable that collides with one of my record names, my code will break. am I doing something wrong? |
| 22:50 | xeqi | &test |
| 22:50 | lazybot | ⇒ #<core$test clojure.core$test@19dfe6b> |
| 22:51 | xeqi | I think its cause test is already used for clojure.core, which gets used automatically in namespaces |
| 22:52 | xeqi | oh, nm.. misread what you said |
| 22:53 | xeqi | could always use refer instead of use, then you just have to watch clojure.core for name smashing |
| 22:54 | xeqi | * require, not refer |
| 23:16 | duck1123 | I need a way to make sure my js application only makes a single request for a resource. There's TrafficCop, but I'm wondering if there's a better ClojureScript-y solution. Should I use an atom? |
| 23:24 | saurik | xeqi: right, but clojure core actually has a ton of things in it, and more are added with each new version of clojure. it normally isn't a problem if I have variables (functions, data, bindings, lets, etc.), but with defrecord I run into pain |
| 23:24 | saurik | user=> (defprotocol test (a [this])) |
| 23:24 | saurik | WARNING: test already refers to: #'clojure.core/test in namespace: user, being replaced by: #'user/test |
| 23:37 | cgag | I'm getting "REPL server launch timed out." when running lein repl, anyone run into that before? It's worked fine in the past. |
| 23:49 | jkkramer | saurik: (ns example.core :refer-clojure :exclude [test]) |