2012-09-13
| 00:07 | gtuckerkellogg | technomancy: thanks. For some reasons nrepl-jack-in starts an nrepl server, but doesn't connect my clojure buffer to it |
| 01:08 | MZAWeb | Hi. I need to convert #{{2 2} {3 1} {1 4}} to #{2 2, 3 1, 1 4} |
| 01:09 | Raynes | That isn't a map. |
| 01:09 | Raynes | That is a set. |
| 01:09 | Raynes | You can't have duplicate elements in a set. |
| 01:10 | MZAWeb | actually I need key value |
| 01:11 | Raynes | If you want to convert that set to a map, ##(into {} #{{2 2} {3 1} {1 4}}) |
| 01:11 | lazybot | ⇒ {2 2, 3 1, 1 4} |
| 01:11 | MZAWeb | oh, cool, I think that's it |
| 01:12 | MZAWeb | Indeed. |
| 01:12 | MZAWeb | Thanks a lot |
| 01:17 | l1x | hey guys, how could i write a function which takes all numbers except 0 and 1? |
| 01:18 | l1x | is there an idiom for this? |
| 01:20 | l1x | i was thinking (when-not ((= n 0) or (= n 1)) ...) |
| 01:23 | amalloy | (complement #{0 1}) |
| 01:26 | l1x | ,(and true false) |
| 01:26 | clojurebot | false |
| 01:27 | l1x | ,(let [n 1] (and true (= n 1)) |
| 01:27 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 01:27 | l1x | ,(let [n 1] (and true (= n 1))) |
| 01:27 | clojurebot | true |
| 01:27 | l1x | good |
| 01:28 | amalloy | what result were you worried you might get? |
| 01:29 | l1x | i want to exclude some numbers from some functions |
| 01:41 | l1x | amalloy: https://github.com/l1x/euler/commit/8ff8a72b129baed081f62fef41e0d2656b2175c3#L0R184 |
| 01:41 | l1x | let me know if there is a better way of doing that |
| 01:42 | amalloy | (or (or x y) z) is just (or x y z) |
| 01:42 | amalloy | (if x false true) is (not x) |
| 01:45 | l1x | interesting, i tried and x y z and it was not working |
| 01:45 | l1x | let me try with or |
| 01:46 | amalloy | the same equivalence applies to and |
| 01:49 | l1x | (if (and (not (= n 1)) (not (= n 2)) (= (sum-of-factorials n) n)) true false)) |
| 01:50 | l1x | yeah it works with and |
| 02:05 | cark | would it be possible to have lein 1 and lein 2 coexist ? |
| 02:05 | cark | i mean on a single home rather than on a single project |
| 02:22 | amalloy | cark: easy. just name the executables (symlinks, whatever) lein1 and lein2 |
| 02:25 | amalloy | (or, indeed, anything you want. my point is, just install them both; they don't conflict in any way) |
| 02:26 | cark | cool thanks ... i have some old projects that i still need to maintain, but don't want to upgrade |
| 02:40 | tomoj | huh, the clojure JIRA flowchart clearly shows patch submission coming _after_ the issue is verified by a clojure/core member and vetted by a clojure committer |
| 02:54 | no7hing | i'm trying to destructure a map to some keys in a macro, but all the symbols/keys are nil |
| 02:54 | no7hing | the map itself is there allright |
| 02:59 | cark | do you have a short gist showing your problem ? |
| 03:00 | clgv | no7hing: please make a gist where you show how your macro call should look like and what the expansion should be. |
| 03:01 | clgv | and your current implementation of course |
| 03:01 | no7hing | writing it |
| 03:16 | no7hing | the gist https://gist.github.com/3712523 |
| 03:17 | no7hing | i *could* just do (:body body#) later on, but i might need the other keys too - and actually am curious what i'am doing wrong ;) |
| 03:17 | cark | action# is not action |
| 03:18 | hiredman | ,`action# |
| 03:18 | clojurebot | action__27__auto__ |
| 03:18 | no7hing | when i just use action the macro uses namespace/action |
| 03:18 | cark | you should pass the full map as a parameter then destructure yourself |
| 03:19 | clgv | no7hing: so action/action# is the problem? |
| 03:19 | no7hing | yes |
| 03:19 | no7hing | it's nil later on |
| 03:19 | clgv | ah right |
| 03:19 | cark | or destructure like this : |
| 03:19 | clgv | no7hing: well, do you really want to inject those names implicitely? in general that is discouraged |
| 03:20 | cark | (fn [{action# :action}] |
| 03:20 | no7hing | haven't thought of that |
| 03:20 | clgv | cark: that wont work either since he cannot use it in the body |
| 03:21 | cark | oh indeed, didn't read the rest of it ! |
| 03:22 | no7hing | btw the choice of body as a key in the map and for the passed in function body is poor |
| 03:22 | no7hing | don't let that distract you |
| 03:23 | clgv | no7hing: if I were you, I would pass the whole map and let the user destructure it |
| 03:23 | clgv | no7hing: otherwise it's likely that you curse yourself soon because you need an additional attribute from the map which you did not destructure |
| 03:26 | cark | how about (fn [{:keys [~'action]}]) then goal is to capture the action "variable" right ? |
| 03:26 | no7hing | famous last words: the three keys will never change; apart from that i'am trying to keep the passed in function as small as possible |
| 03:26 | no7hing | yes |
| 03:27 | cark | well then there you go i think |
| 03:27 | Guest94126 | cark: thats the implicit name capturing I meant before. (I forgot what the officil term was). |
| 03:28 | no7hing | it |
| 03:28 | no7hing | 's not working anyway :D |
| 03:30 | cark | working for me ! |
| 03:30 | no7hing | umm |
| 03:31 | cark | https://gist.github.com/3712581 |
| 03:36 | no7hing | thanks for helping guys |
| 03:53 | sunkencityryleh | what is the current best way of communicating with a repl from vim? |
| 03:54 | sunkencityryleh | I'd like to launch swank or whatever with lein and then send stuff to eval from a region |
| 04:11 | Guest94126 | sunkencityryleh: do you use vim-clojure? |
| 04:12 | sunkencityryleh | Guest94126: I just downloaded slimv for vim |
| 04:13 | sunkencityryleh | Got it sort of running, but not quite, it doesn't seem to load much of clojure |
| 04:13 | Guest94126 | sunkencityryleh: I heard that vim-clojure is actively developped |
| 04:17 | kral | namaste |
| 04:17 | sunkencityryleh | OK, I'll look into vim-clojure |
| 04:32 | lpetit | Bonjour tout le monde ! |
| 04:32 | Raynes | Whatever you said right back at ya! |
| 04:33 | lpetit | ;) I said "Hello everybody" |
| 04:34 | cark | oh you're french |
| 04:34 | cark | should've been oblivious with your name ! |
| 04:35 | lpetit | cark: so because I speak french, I'm French ? :) |
| 04:36 | cark | nope, i'm from belgium and speak franch |
| 04:36 | cark | french |
| 04:36 | cark | so you're not ? |
| 04:37 | lpetit | In Counterclockwise editor tabs (revealing the name of the edited file), how about displaying the namespace in reverse order ? e.g. for namespace "somebody.someproject.core" it displays "core.someproject.somebody" ? So that when there are a lot of tabs open, what disappears first is the end of the displayed string (which contains less context that the start) ? |
| 04:37 | lpetit | cark: no, I am. I was just kidding |
| 04:38 | cark | lpetit: only a french person talks english with such an accent =) |
| 04:39 | lpetit | cark: (blush) (and blame my parents ;) ) |
| 04:39 | lpetit | so true, btw |
| 04:39 | cark | haha |
| 04:40 | cark | anyways just kidding, as long as people understand... who cares |
| 04:41 | ro_st | if we were all exactly the same, what point would there be to more than one of us :-) |
| 04:41 | lpetit | I wish I had a good english accent. |
| 04:42 | antares_ | lpetit: a more common approach is to abbreviate initial ns parts, e.g. s.s.core |
| 04:42 | antares_ | I believe Eclipse itself can do that, IDEA can, too |
| 04:43 | lpetit | antares_: already does the abbreviation, but sometimes it's still too long. So right now I'm adding an option for people to switch back to old behavior (which is just displaying the file name). But while doing it, the above mentioned idea occurred to me |
| 04:45 | antares_ | lpetit: sounds like if you are completely out of space, only displaying the rightmost part is the best idea |
| 04:45 | antares_ | reversing is likely to be even more confusing |
| 04:45 | lpetit | antares_: probably, yes |
| 04:46 | ro_st | can you not hover a tab to see the full path or ns? |
| 04:46 | ro_st | (not a ccw user, just curious) |
| 04:48 | lpetit | ro_st: you can, indeed, but some people have lots of open editors and don't want to move their mouse over each tab, wait for the slight delay before the popup shows up, etc. |
| 04:48 | ro_st | yeah |
| 04:53 | cark | in emacs, i have it so that it will only show what's different so if i have cark.data.lenses and cark.example.lenses it will show lenses<data> for the former and lenses<example> dor the later |
| 04:53 | clojurebot | have you heard about the bird? is<reply>The bird, bird, bird, the bird is the word. |
| 04:53 | cark | dor/for |
| 04:55 | borkdude | what can I tell people about the usage of clojure, any numbers? |
| 04:59 | lpetit | cark: sounds great |
| 04:59 | cark | i wonder how you could find such numbers |
| 05:04 | ro_st | the google group has 5k+ members |
| 05:04 | KIMAvcrp | hi |
| 05:05 | antares_ | ro_st: I think it has closer to 7K |
| 05:05 | ro_st | oh right :-) |
| 05:05 | KIMAvcrp | I found something strange using enfocus and a browser connected repl |
| 05:06 | KIMAvcrp | if I user set-attr to set the value of a field the browser does not update the change |
| 05:06 | KIMAvcrp | manual changing with (.-value (dom/getElement ...) "text") does work |
| 05:06 | KIMAvcrp | any idea ? |
| 05:07 | ro_st | does the code work when you run it in a compiled cljs context? |
| 05:07 | ro_st | paste the code on refheap as well, please |
| 05:10 | KIMAvcrp | it doesnt work in the compiled context |
| 05:10 | KIMAvcrp | heres the code |
| 05:12 | KIMAvcrp | https://www.refheap.com/paste/0b3021f60da47e24a572de369 |
| 05:12 | ro_st | "press" is telling enfocus to look for a tag named press |
| 05:12 | ro_st | ie, <press /> |
| 05:12 | ro_st | do you not perhaps want .press or #press instead? |
| 05:13 | KIMAvcrp | saw it just the instance |
| 05:13 | ro_st | you can also use :keywords instead of "strings" now |
| 05:13 | KIMAvcrp | strangely dom/getElement works with "press" |
| 05:13 | ro_st | what do you have in html? class="press" or id="press" ? |
| 05:13 | ro_st | getElement will find id="press" |
| 05:14 | ro_st | # is a css selector thing, the js vm knows nothing about it |
| 05:14 | ro_st | be nice once the js vm does have getElementsByCSSSelector :-) |
| 05:15 | ro_st | KIMAvcrp: https://github.com/robert-stuttaford/demo-enfocus-pubsub-remote/ |
| 05:18 | borkdude | is this table correct, did I forget anything important? https://www.dropbox.com/s/9w16xwjd4x88u46/comparison.png |
| 05:18 | borkdude | it's in dutch but I think you can figure out what the words mean |
| 05:18 | borkdude | it's not so much about language features that are theoretically possible, but about the learning experience |
| 05:18 | borkdude | so what concepts will you meet, when working in a language |
| 05:18 | ro_st | homoiconicity |
| 05:22 | KIMAvcrp | in the html <input type="text" name="press" id="press" value="1" size="1"/> |
| 05:22 | KIMAvcrp | but if i use "#press" or :#press as selectors again the browser window doesn't change |
| 05:23 | KIMAvcrp | is (em/set-attr :value "5") right ? |
| 05:24 | ro_st | set-prop |
| 05:24 | ro_st | for :value |
| 05:24 | ro_st | that one caught me as well |
| 05:24 | ro_st | using attr you'll see the html source view in chrome updates, but the actual rendered view doesn't |
| 05:25 | ro_st | this is because set-attr affects the dom but doesn't trigger the form side of things. set-prop does |
| 05:26 | borkdude | gtg |
| 05:30 | cark | how would i go about creating a set, where identity is on a function of the set item rather than the set item itself ? |
| 05:31 | KIMAvcrp | thank you @<ro_st> |
| 05:31 | KIMAvcrp | it works |
| 05:31 | KIMAvcrp | btw: is there a better way to require libraries in the live-repl as via the ns macro ? |
| 05:32 | cark | something like (set-by :id [{:id 1 :name "paul"} {:id 2 :name "john"}]) |
| 05:32 | ro_st | so you want a set of the ids, here? |
| 05:32 | ro_st | (set (map :id items)) |
| 05:33 | cark | nope i want a set where adding {:id :name "cark"} would "overwrite" {:id 1 :name "paul"} |
| 05:33 | cark | nope i want a set where adding {:id 1 :name "cark"} would "overwrite" {:id 1 :name "paul"} |
| 05:33 | ro_st | ah, that you'd have to implement yourself |
| 05:34 | cark | =( |
| 05:34 | ro_st | a gatekeeper fn that checks and replaces |
| 05:34 | KIMAvcrp | why don't you use a map from :id to :name instead of a set |
| 05:35 | ro_st | yeah |
| 05:35 | ro_st | map keys have to be unique |
| 05:35 | ro_st | (assoc m (:id item) item) would replace |
| 05:35 | cark | that's only an example, i'm storing an "object" that can only be queried for id via a function |
| 05:36 | cark | and i want to have set capabilities |
| 05:36 | cark | but that's no big deal, i can work around it |
| 05:36 | ro_st | yeah |
| 06:07 | Guest94126 | lpetit: hello overthere |
| 06:08 | lpetit | Guest94126: Hello stranger |
| 06:11 | Guest94126 | stranger? damn. have to relogin then ^^ |
| 06:12 | clgv | lpetit: better now. |
| 06:13 | clgv | lpetit: it's a pity I cant use CCW 0.10.0 at work, yet. this "build all" error makes it unusable in that project... :( |
| 06:14 | lpetit | clgv: remember me the issue number please |
| 06:14 | clgv | lpetit: 425 |
| 06:14 | clgv | the new one ;) |
| 06:15 | lpetit | clgv: It's on my todo list for today. |
| 06:15 | ro_st | *helps lpetit with his english* "remind me" |
| 06:15 | clgv | lpetit: hooray! :D |
| 06:15 | lpetit | ro_st: that's what happens when I type too fast |
| 06:16 | lpetit | I meant when I type too quick :-P |
| 06:16 | lpetit | clgv: but first I'm currently working on correct support for tagged literals |
| 06:30 | lpetit | clgv: that's the focus of the day |
| 06:52 | KIMAvcrp | hi |
| 07:02 | clgv | lpetit: can you answer me a question about the nrepl setup of CCW? |
| 07:02 | lpetit | clgv: sure |
| 07:02 | lpetit | and also cemerick could be of some help |
| 07:03 | clgv | lpetit: do I have access to the nrepl namespaces from the CCW repl? |
| 07:03 | cemerick | clgv: yes |
| 07:03 | cemerick | The server-side of it, anyway. |
| 07:04 | clgv | lpetit: so it is on the classpath and I might get problems if I want to use a different nrepl version in my project? |
| 07:04 | lpetit | clgv: no, it is only added to the class path if it is not found in your project's java build path |
| 07:05 | clgv | lpetit: interesting. thx. |
| 07:05 | lpetit | clgv: anyway, this will probably evolve in the (near) future, when CCW will use a (yet to be implemented) Leiningen Eclipse Launcher |
| 07:06 | xeqi | does ccw implement the "describe" and "file-load" ops? |
| 07:06 | cemerick | It uses them when available, yes. |
| 07:06 | lpetit | cemerick: time to enlighten me |
| 07:06 | lpetit | (I only have a vague idea of what's happening under the hoods) |
| 07:07 | cemerick | lpetit: See REPLView.getAvailableOperations, and usages of it. |
| 07:07 | clgv | lpetit: I want to migrate that debug-repl macro (or "break it's called in slime) to use nrepl. so that I can connect with a CCW replview |
| 07:08 | clgv | xeqi: what's "describe"? |
| 07:08 | lpetit | cemerick: i will |
| 07:10 | xeqi | cemerick: thanks, I was hoping to use ccw as a refrence point when looking at the nrepl.el impl |
| 07:10 | xeqi | clgv: an op code used under the hood by nrepl to determine what other op codes the server accepts |
| 07:11 | cemerick | xeqi: FWIW. REPLView and its helpers are in dire need of a refactoring. Typical Java pig-pile in there. |
| 07:12 | clgv | cemerick: can I initialize an nrepl server similar to clojure.main/repl via :init? |
| 07:13 | cemerick | clgv: no; nrepl is a network service, not an in-process thing bound to *in*, *out*, etc. See clojure.tools.nrepl.server. |
| 07:14 | clgv | cemerick: yeah. knew that. but I thought, maybe the is some way to do an initialization of threadlocal storage for its execution thread |
| 07:15 | cemerick | clgv: Sorry, what are you trying to do? |
| 07:15 | clgv | cemerick: you know `debug-repl` or `break` ? |
| 07:15 | cemerick | Sure, the SLIME stuff. |
| 07:17 | clgv | both start a clojure.main/repl or similar. I would like to replace that with the nrepl server. one nrepl-server per `debug-repl` statement. I would suspend the executing thread until a (resume) is evaluated |
| 07:17 | lpetit | cemerick: sure thing, REPLView could be refactored. But now may not be the time. I think the right time will prompt when it's too difficult to work with the current codebase anymore |
| 07:17 | cemerick | lpetit: Yeah, not in any hurry to actually do it. :-) |
| 07:18 | cemerick | clgv: Sure, definitely doable. |
| 07:18 | cemerick | You shouldn't need to start another server, though. |
| 07:18 | cemerick | Another connection, yes. |
| 07:19 | clgv | cemerick: how would you mange different contexts in a multithreaded application then? |
| 07:19 | clgv | just one server and one connection while representing context as data in a given variable? |
| 07:20 | cemerick | No, one server, many connections. |
| 07:21 | clgv | may use case looks like the following: debug-nrepl starts a server if there is none, stores the context info and prints connection info to the repl. I connect via CCW's repl view to the nrepl and can start to investigate. |
| 07:22 | cemerick | Each break would need to prep a queue, and hijack the newly-connected client's "eval" messages into that queue to be evaluated in the break context. |
| 07:25 | clgv | cemerick: what's the reason not to start multiple servers on different ports do that each active break has a random port that is printed to stdout for the user to connect to? |
| 07:27 | cemerick | Why bother with another server? |
| 07:28 | cemerick | You still need the same sort of coordination between the paused execution context and the new incoming client messages. |
| 07:29 | ejackson | how do I disconnect from an nrepl attached via nrepl-jack-in in emacs ? Preferrably killing the server so I cant start another ? |
| 07:29 | xeqi | ejackson: kill the *nrepl-server* buffer |
| 07:30 | ejackson | xeqi: thanks |
| 07:32 | cemerick | xeqi: Nice post re: pedantic. :-D |
| 07:33 | clgv | cemerick: where would I start to implement this? a custom handler for nrepl? |
| 07:33 | xeqi | cemerick: heh, I was wondering if I was just rewriting the readme at one point |
| 07:34 | cemerick | xeqi: to some extent you were, but that's fine; no one reads READMEs. |
| 07:37 | cemerick | clgv: Aside from the suspension functionality of (break), you're probably looking at some middleware to intercept "eval" messages from a client that connects and joins that "debug context". |
| 07:38 | cemerick | That said, I do always hope that someone (else ;-) will get around to implementing debug-repl in conjunction with proper JVM breakpoints, rather than the (break) approach that SLIME used. |
| 07:41 | clgv | humm still not sure if nrepl's session could be used for storing the context |
| 07:42 | cemerick | clgv: You can store anything in the session you want — it's just an atom. |
| 07:42 | clgv | the descriptors give a nice usage summary though ^^ |
| 07:43 | cemerick | Yeah, once I flesh them out more, a script will be used to dump a listing of the ops supported by the available middlewares. |
| 07:44 | clgv | humm you get the initial session by connection and after that you clone it to get more? |
| 07:45 | clgv | but overall it seems more complicated than I thought. got to postpone the idea |
| 07:56 | mccraig | ibdknox: i made a (tiny) patch for korma, which doesn't affect current behaviour, but allows it to use connections opened elsewhere https://github.com/korma/Korma/pull/88 . does that seem reasonable ? |
| 07:59 | cark | I just pushed a first public version of the little lenses library i was working on. Lenses are also known as functional references. there is a little tutorial included as well, i'd love to see îf some people would use these. it's at https://github.com/cark/data.lenses |
| 08:01 | clgv | cark: your readme is contradicting. it says no clojars upload but provides an entry for a project.clj ;) |
| 08:01 | cark | you need to install in the local repository |
| 08:01 | clgv | ah ok |
| 08:02 | cark | i *think* lein install is all that's required to do that |
| 08:02 | cark | maybe a lein deps first |
| 08:19 | ordnungswidrig | hi all, I'm looking for an simple web application idea which i can use for a liberator tutorial. I'm bored by all that todo-list-tutorials. |
| 08:21 | cark | a super-hero powers database |
| 08:22 | cark | everybody loves suyper-heroes |
| 08:23 | ordnungswidrig | cark: nice idea |
| 08:24 | cark | you get 2 sets, 2 entity types, and relation between them, good for demonstrating your rest api |
| 08:25 | ordnungswidrig | cark: you mean heroes and super powers? |
| 08:25 | cark | yes |
| 08:25 | ordnungswidrig | i think that can work out |
| 08:26 | cark | it's actually many to many, so i guess 3 entity types |
| 08:26 | cark | anyways |
| 08:26 | ordnungswidrig | cark: depends on your model. it would be two http resource collections. |
| 08:27 | cark | for many-to-many you may require a hero-power collection too |
| 08:28 | cark | but it's just a tutorial, you could make it so that flying power for superman is different than flying power of err ... metalman |
| 08:28 | cark | what's his name =/ |
| 08:29 | clgv | ironman? ;) |
| 08:29 | cark | indeed =) |
| 08:29 | cark | i suck at super-heroes =) |
| 08:29 | clgv | it is different: one is natural the other technical ;) |
| 08:29 | cark | if you ask me, neither is ! |
| 08:30 | ordnungswidrig | cark: is there a encyclopedia of superhero? |
| 08:30 | cark | ordnungswidrig: i suck at super-heroes ! i wouldn't know that ! |
| 08:33 | cark | you only need a couple heroes and powers for a tutorial, you can even make them up |
| 08:33 | cark | http://www.superherodb.com/characters/ |
| 08:34 | cark | where you learn that superman has super smell ... |
| 09:11 | naeg | why does (bit-shift-right 30 8) => 0 but (bit-shift-right 0011110 8) => 18 ? |
| 09:13 | jsabeaudry | naeg, because 30 != 4680 |
| 09:14 | naeg | jsabeaudry: ,(Integer/parseInt "0011110" 2) |
| 09:14 | chouser | ,(format "%o" 0011110) |
| 09:14 | clojurebot | "11110" |
| 09:14 | chouser | octal |
| 09:15 | naeg | oh, i thought that was binary |
| 09:15 | chouser | 2r0011110 |
| 09:17 | jsabeaudry | chouser, oh nice I wasn't aware of binary litterals in clojure thanks! |
| 09:17 | chouser | arbitrary radix literals up to, I think, 36 |
| 09:18 | chouser | jsabeaudry: but that means you haven't read the book. tsk tsk. |
| 09:19 | jsabeaudry | elementary my dear chouser ;) |
| 09:45 | naeg | blog post about checking for a winner in connect four in clojure: http://programmablelife.blogspot.co.at/2012/09/clojure-connect-four-1-checking-winner.html |
| 09:45 | naeg | would be great if someone could give me some feedback before i put it on HN, etc. |
| 09:50 | casion | naeg: reading |
| 09:51 | naeg | casion: i'm just adding two code line explanations to the bitboard algo... |
| 09:52 | casion | I'm confused by your bitboard |
| 09:52 | naeg | casion: the picture? |
| 09:53 | casion | sec, app broke |
| 09:53 | clgv | naeg: doall + map for printing is not ideal ^^ |
| 09:53 | naeg | clgv: I guess I should use doseq? |
| 09:53 | clgv | naeg: if you print the array brackets anyway, you could just use pprint ^^ |
| 09:54 | clgv | naeg: yeah, doseq |
| 09:54 | naeg | I now remember why I did it: just as a quick hack because map didn't really execute the printlns |
| 09:54 | clgv | ,(pprint (repeatedly 5 (range 10))) |
| 09:54 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: pprint in this context, compiling:(NO_SOURCE_PATH:0)> |
| 09:54 | clgv | ,(use 'clojure.pprint) |
| 09:54 | clojurebot | nil |
| 09:55 | clgv | ,(pprint (repeatedly 5 (range 10))) |
| 09:55 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn> |
| 09:55 | clgv | ,(pprint (repeat 5 (range 10))) |
| 09:55 | clojurebot | ((0 1 2 3 4 ...) |
| 09:55 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 09:55 | clgv | damn... |
| 09:55 | naeg | clgv: I don't have pprint available |
| 09:56 | clgv | it's in clojure.pprint and usually available in a repl |
| 09:57 | casion | naeg: why is there a a vector board and bitboard in the same vector? |
| 09:58 | naeg | casion: because of insert and the game loop (which I didn't show here) |
| 09:59 | casion | naeg: ok, that was confusing me quite a bit |
| 09:59 | clgv | naeg: how did you benchmark? |
| 09:59 | naeg | casion: really? why would it mather? |
| 09:59 | naeg | matter* |
| 09:59 | naeg | clgv: there's a paragraph about performance, but not really benchmarking |
| 09:59 | casion | naeg: because I read code top to bottom? |
| 09:59 | casion | in the bitboard example if I seen a 2d board rep, I'm sitting here wondering why it's there and if/why it's used |
| 09:59 | clojurebot | It's greek to me. |
| 10:00 | clgv | naeg: you should at least wrap the code in dotimes and measure the time of the repeated executions ^^ |
| 10:00 | naeg | casion: that's just for us humans to better understand it. in the code it's just passing around longs |
| 10:01 | naeg | clgv: i did that and put the average time into the article |
| 10:01 | casion | naeg: not when the person reading it has spent dozens of hours using bitboards ;) |
| 10:02 | naeg | casion: then that algorithm shouldn't be too hard to grasp ;) but I'm confused by his explanation (which differs from mine: http://stackoverflow.com/questions/7044670/how-to-determine-game-end-in-tic-tac-toe/7046415#7046415) |
| 10:02 | casion | naeg: I was having trouble following you epdating 2 board representations |
| 10:02 | casion | updating* |
| 10:03 | casion | my mistake I think, I took the header for that section too strictly |
| 10:04 | naeg | casion: I can't follow you? I need two boards, because each player has his own pieces |
| 10:05 | casion | naeg: I was getting tripped by the vector board being in that example, that's all |
| 10:05 | casion | quite simple and silly :) |
| 10:06 | naeg | ok. I just want to be sure it's understandable, you see ;) but I think I mentioned that I use 3 boards |
| 10:07 | casion | you do, as I said it's my deficiency |
| 10:09 | casion | naeg: when you explain the board checking in bitboards, it maybe helpful to label the rows when explaining the steps |
| 10:09 | casion | '0110100 & 0011010 = 0010000' row 2, '0111100 & 0011110 = 0011100' row 1, etc.. |
| 10:10 | naeg | casion: label what exactly with what? |
| 10:10 | casion | I gave an example, ctrl-f the stuff in quotes |
| 10:12 | casion | the logic section is nead |
| 10:12 | casion | neat* |
| 10:12 | naeg | casion: label like that? |
| 10:12 | casion | yeah |
| 10:12 | casion | that's more clear I think |
| 10:12 | naeg | casion: indeed, thanks. I like the logic solution the most actually |
| 10:12 | naeg | it's also the one I put the most thinking in myself |
| 10:17 | naeg | clgv: removed all the doall's, thanks :) |
| 10:29 | naeg | casion: would you say you understood everything I tried to explain? |
| 10:32 | aib | How would I go about using this library in "lein repl"? https://github.com/clojure/algo.monads |
| 10:33 | casion | I don't totally understand the code in the logic example yet |
| 10:34 | casion | I get how it's doing the search, but how the code is achieving is has me constantly referring to core.logic docs |
| 10:35 | casion | I've never used core.logic (or any logic programming) so, I'm not sure if I'm the target audience for that or not |
| 10:36 | clgv | aib: you got a project setup? |
| 10:36 | aib | clgv: nope, just want to play around in the REPL |
| 10:37 | clgv | aib: leiningen 2? |
| 10:37 | jweiss | is there a simple way to use defrecord, but have it error out if you try to access a field that wasn't part of the original definition? the normal behavior is to return nil. for instance if i fat-finger :foo as :floo in (myrec :floo) - i want an exception instead of nil. |
| 10:37 | naeg | casion: I don't even know how exactly core.logic works internally, if that is what you mean. But I'm able to work with it (since I know how Prolog works internally) |
| 10:37 | aib | Leiningen 1.7.1 on Java 1.7.0_07 Java HotSpot(TM) Client VM. I need an update? |
| 10:38 | clgv | aib: I do not know if you can specify dependencies in a file under ~/.lein/ |
| 10:38 | naeg | casion: but you understood it from a "user" perspective, so core.logic is like a black box with which he could work |
| 10:38 | clgv | aib: with lein2 you can define profiles in ~/.lein/profiles.clj |
| 10:39 | aib | clgv: I can't just type (use 'clojure.algo.monad) as my first REPL command or something? |
| 10:39 | clgv | aib: there you could add the desired libs as :dependency in the :user profile |
| 10:39 | aib | hmm |
| 10:39 | clgv | aib: you can - but it wont find anything ;) |
| 10:39 | aib | ahh |
| 10:39 | the-kenny | If I do a subvec on a large vector, will it stop the large vector from being gc'd when I don't reference it anymore? |
| 10:41 | aib | well, let me play around a bit with lein2 first. thanks :) |
| 10:41 | clgv | the-kenny: yeah. it holds onto it. otherwise it would be O(n) instead of O(1) |
| 10:41 | the-kenny | clgv: Okay, thanks |
| 10:44 | casion | naeg: I don't know logic programming _at all_, and it seems that it's a pre-requisite to understand algo-3's implementation. If that was your intent then I can't comment… but if you intended on explaining to someone with no logic programming experience, then it's not working for me |
| 10:45 | aib | erm, https://cloud.github.com/downloads/technomancy/leiningen/leiningen-2.0.0-SNAPSHOT-standalone.jar returns Access Denied :/ |
| 10:45 | aib | ah, leiningen-2.0.0-preview10 |
| 10:45 | xeqi | aib: you need to use `lein new` and make a project, add [org.clojure/algo.monads "0.1.0"] to the :dependencies, and `lein repl` in the project will let you use it |
| 10:46 | aib | xeqi: okies, thanks :) |
| 10:47 | clgv | xeqi: do you really need to? I think you should be able to add it as dependency to the :user profile |
| 10:47 | clgv | the same you do with :plugins you always need on that machine |
| 10:47 | xeqi | clgv: perhaps, though do you really want algo.monads accessible everywhere? |
| 10:48 | clgv | xeqi: well he can define a different profile then :user e.g. :monads and use "lein2 with-profiles :monads repl" |
| 10:49 | clgv | without the ":" I think ^^ |
| 10:50 | xeqi | heh, thats not really any simpler |
| 10:51 | clgv | but if he doesnt want a project it's the only way |
| 10:51 | naeg | casion: I actually wanted people with no experience in LP to understand it |
| 10:51 | naeg | will have to re-work that paragraph then |
| 10:53 | clgv | is clojure.core/require threadsafe? |
| 10:54 | naeg | casion: I just read through it again, and I don't know what I could add beside explaining +fd |
| 10:54 | xeqi | sure, but if a project isn't desired, no reason to use a build tool designed for projects |
| 10:54 | casion | naeg: that's exactly the part that I'm struggling with, lines 17-18 |
| 10:55 | casion | and 7 |
| 10:55 | clgv | xeqi: well lein doesnt necessarily need a project to start a repl. a better solution would be to add pomegranate and use it to get the deps to play with |
| 10:55 | casion | infd and +fd, and I'm having trouble even finding docs for it |
| 10:55 | naeg | casion: for all those lines I just wrote what the line as a whole does, not what each function does. could that be the source of your confusion? |
| 10:56 | naeg | casion: those functions are alpha |
| 10:56 | xeqi | eh, pomegranate doesn't do any dependency tracking of whats already on the classpath; it might work, or it might pull in a completely different version of clojure |
| 10:56 | naeg | only documentation is the source code and examples you find in the web |
| 10:56 | clgv | xeqi: no I mean he could get the monads lib via pomegranate ^^ |
| 10:56 | xeqi | it'll pull in all transative dependencies |
| 10:57 | xeqi | and some of the org.clojure stuff uses 1.3.0-alpha versions |
| 10:57 | casion | naeg: yeah, lines 17 and 18 have different descriptions for the same function (17 declaring, 18 'making sure') so I'm trying to find out what infd does |
| 10:57 | clgv | I dont think it is that buggy. leiningen uses it and it's advertised especially for that purpose |
| 10:57 | naeg | casion: well, declaring and making sure is the same. those are just rules |
| 10:58 | clgv | though I haven't used it much, yet |
| 10:58 | xeqi | clgv: given a full dependency list it will work out what transative deps to use |
| 10:58 | xeqi | which is how lein does it |
| 10:58 | casion | naeg: well, I don't work with logic, so when I see 'declare' I think some sort of constant, and 'making sure' I think of a conditional |
| 10:58 | naeg | casion: I'm reverting it to a draft again, so make sure either to not reload the tab or copy the content somewhere. I'm leaving now, add a few more explanations later that evening and then publish it. do you think it's suitable for planet clojure? |
| 10:58 | xeqi | but if you're adding to the classpath, and just give it one dep, it might pull in a different transative version of a dependency already on the classpath |
| 10:59 | casion | maybe in this domain it's semantically the same, but I wouldn't know that :( |
| 10:59 | clgv | xeqi: so it's not safely usable for this: https://github.com/cemerick/pomegranate#add-classpath-usage |
| 10:59 | naeg | casion: it's the same. I wrote a note about your confusion, you're probably not the only one |
| 10:59 | clgv | ? |
| 10:59 | casion | naeg: sure, it seems overall good to me :) |
| 10:59 | casion | I learned some things from it for sure |
| 11:00 | naeg | casion: it's not meant for "clojure experts", that's why I wasn't sure |
| 11:00 | naeg | but as you said, I think even clojure experts might learn one or two things from it |
| 11:01 | naeg | (especially if they haven't done anything with core.logic yet) |
| 11:01 | casion | naeg: I'm not a clojure expert, and I learned from it… even the logic part (though I'm still not 100% clear on it) |
| 11:01 | naeg | casion: thanks for all your input and bye all |
| 11:01 | xeqi | always safely, no, but it should work most of the time |
| 11:01 | xeqi | or work well enough |
| 11:01 | casion | thanks to you too :) |
| 11:03 | clgv | xeqi: do you know whether clojure.core/require is threadsafe? I have to use it from different threads since I must resolve functions from symbols |
| 11:05 | xeqi | no idea, haven't done any work on clojure internals |
| 11:07 | clgv | ok. I try to find out ^^ |
| 11:07 | uvtc | What's a good way to provide a user-editable config file for your Clojure project? |
| 11:08 | uvtc | A resources/config.properties file? |
| 11:09 | nDuff | uvtc: Depends. If you're trying to interoperate with the Java world, a properties file makes sense. If you don't care about that, using the Clojure reader can certainly be handy. |
| 11:10 | uvtc | Hm. Just have your users edit a config.clj file. |
| 11:10 | uvtc | nDuff: Thanks. |
| 13:22 | cemerick | dnolen: thanks for the quick patch turnaround. Greatly appreciated. :-) |
| 13:23 | dnolen | cemerick: np |
| 13:35 | thorbjornDX | hash-map from two seqs: (hash-map (interleave seq1 seq2)) ? Or is there a better way. |
| 13:36 | dnolen | thorbjornDX: zipmap |
| 13:36 | thorbjornDX | dnolen: thanks :) |
| 13:38 | thorbjornDX | dnolen: from the source, it looks like this will go until one of the seqs gives nil, is that correct? |
| 13:39 | borkdude | ,(zipmap [nil 1 2 3] [1 2 3 4]) |
| 13:40 | clojurebot | {3 4, 2 3, 1 2, nil 1} |
| 13:40 | thorbjornDX | borkdude: oh, hm. What does the '(if (and ks vs)' in the function definition do then? |
| 13:41 | dnolen | ,(zipmap [:foo :bar :baz] (range)) |
| 13:41 | clojurebot | {:baz 2, :bar 1, :foo 0} |
| 13:41 | thorbjornDX | ,(seq nil) |
| 13:41 | clojurebot | nil |
| 13:41 | borkdude | thorbjornDX dnolen why use English if we can speak clojure |
| 13:42 | thorbjornDX | borkdude: english can be a bit verbose, especially for abstract cs |
| 13:42 | dnolen | thorbjornDX: yes the shortest sequence limits the size of the map. |
| 13:43 | thorbjornDX | dnolen: that's what I expected, thanks ;) |
| 13:43 | thorbjornDX | ,(next '()) |
| 13:43 | clojurebot | nil |
| 13:43 | thorbjornDX | ,(rest '()) |
| 13:43 | clojurebot | () |
| 13:44 | thorbjornDX | ok, things are getting more clear now |
| 13:44 | borkdude | gtg, bye |
| 13:44 | abalone | in cljs and clj, .replace affects all occurrences. in the generated js, it affects only the first. where should i report this? |
| 13:45 | dnolen | abalone: it's an interop call, there's no promise about that stuff. |
| 13:46 | abalone | oj |
| 13:46 | abalone | oh |
| 13:46 | abalone | thanks |
| 13:51 | TimMc | Hey, anyone ever seen a metadata destructuring proposal? |
| 13:52 | TimMc | I don't feel a need for it, but I'm curious if anyone else has. |
| 13:53 | cemerick | Very occasionally, but the extra line of code hasn't bothered me enough to suggest adding the necessary complexity to the language. |
| 14:07 | Licenser | Out of curiosity what book should I give a clojure beginner? (no programming experience) |
| 14:08 | ystael | cemerick: I am trying to add an nrepl server endpoint to an existing Java server application. Is the advice you gave in February in https://groups.google.com/d/msg/clojure/6jEdlYSX_zg/Q33_egSaxxEJ still current? |
| 14:09 | ivan | Licenser: I'm not sure Clojure is a good idea for someone with no programming experience until Light Table is productive |
| 14:09 | cemerick | ystael: should be, yup |
| 14:10 | Licenser | ivan well it's just baby steps for now so the current LT's live repo is enough for a few month I guess :) |
| 14:10 | ystael | cemerick: cool, thanks |
| 14:10 | scriptor | Licenser: I think I saw one online thing that used clojure but aimed at complete beginners |
| 14:10 | scriptor | can't remember the name though |
| 14:11 | ivan | Land of Lisp? |
| 14:11 | Licenser | scriptor yea the one with the robot right? |
| 14:11 | scriptor | Licenser: yep |
| 14:11 | casion | a lot of colleges start with scheme as a first language (mit does still I think?) |
| 14:11 | scriptor | I think |
| 14:11 | casion | many start with java... |
| 14:11 | Licenser | scriptor we're past that one :) |
| 14:11 | casion | why not start with clojure? :) |
| 14:11 | cvkem_ | Hi, I recently noticed that dynamic generated code via (eval (read-string ...)) |
| 14:11 | Licenser | casion my point exactly! |
| 14:11 | technomancy | I'm not sure starting programming with a book that is spread across 3 or 4 different languages is such a good idea =\ |
| 14:12 | casion | technomancy: 3-4 languages? |
| 14:12 | technomancy | casion: Land of Lisp focuses on CL with some chapters for Scheme and Clojure IIRC |
| 14:13 | scriptor | I get the impression that most clojure books assume about the same level of programming experience |
| 14:13 | adu | which languages? |
| 14:13 | casion | did someone mention land of lisp? |
| 14:13 | casion | I'm a bit lost |
| 14:13 | casion | oh, someone did |
| 14:13 | adu | ivan |
| 14:14 | curiousgeroge | Hi, I am interested in Clojure. Have done some work in haskell years ago. On what type of projects is a FP languages such as clojure a good fit? |
| 14:14 | adu | casion: I think scheme makes a great first language, the function names are long, verbose, and unambiguous |
| 14:14 | casion | Land of Lisp is the sole reason why I tried clojure instead of CL or scheme |
| 14:14 | technomancy | curiousgeroge: anything where you can use the JVM, so as long as you don't need a low memory ceiling, fast startup time, realtime, or zippy numerics. |
| 14:14 | Hodapp | I'd love to get through SICP sometime. |
| 14:14 | Hodapp | but... bleah, busy |
| 14:14 | casion | it scared me away from cl pretty fast :| |
| 14:15 | technomancy | casion: interesting. I only read the sample so I thought it was biased in favour of CL. |
| 14:15 | technomancy | the Clojure port of Casting SPELs by the same author was a bit half-baked |
| 14:15 | wastrel | what's Land of Lisp ? |
| 14:15 | curiousgeroge | technomancy: hm okey cool |
| 14:15 | casion | technomancy: it is, heavily |
| 14:15 | adu | CL has obscure, 3LA, and archaic names mixed in with long-verbose-names, and clojure somehow has short, clear, names, I don't know how |
| 14:15 | casion | and it made (makes?) CL look terrible IMO |
| 14:15 | technomancy | casion: oh, but it didn't have the intended effect then? interesting =) |
| 14:15 | ChongLi | curiousgeroge: it's also worth learning clojure for a different perspective |
| 14:15 | technomancy | heh |
| 14:15 | casion | at least to a C programmer |
| 14:15 | wastrel | oic land of lisp is a cl book |
| 14:16 | curiousgeroge | i do ruby and javascript daily |
| 14:16 | ChongLi | curiousgeroge: have you ever done a lisp before though? |
| 14:16 | technomancy | curiousgeroge: the only thing Clojure can't do that Ruby can is proper unixy glue stuff. |
| 14:16 | curiousgeroge | ChongLi: no, i am also interested in lisp. was going to buy then I decided to go with vim instead of emacs so I never picked up lisp |
| 14:16 | Licenser | I kind of get the feeling that most clojure books aim at seasoned programmers :( |
| 14:17 | adu | also, I think I might use Clojure as the basis for an algorithm database, because of it's beautiful metadata notation |
| 14:17 | ChongLi | it really broadens your mind to learn a lisp like clojure and all that entails |
| 14:17 | ChongLi | homoiconicity, macros etc. |
| 14:17 | curiousgeroge | is it less code with clojure? than for eg ruby? |
| 14:17 | scriptor | curiousgeroge: that's a tricky thing to measure |
| 14:17 | curiousgeroge | of course it depends |
| 14:17 | technomancy | curiousgeroge: usually less, but the important thing is that it's clearer. |
| 14:17 | curiousgeroge | but you always get a feeling |
| 14:17 | curiousgeroge | technomancy: ah cool |
| 14:18 | ystael | Licenser: part of the problem is that the "out-of-the-box" experience of clojure is difficult for many people ... i would not want to explain to a non-programmer how to get started writing clojure programs |
| 14:18 | nDuff | clearer certainly in the sense that there's less spooky action at a distance -- something Ruby is rife with |
| 14:18 | Licenser | ystael for the moment I'm pretty happy with just writing a few simple functions |
| 14:18 | ChongLi | clojure includes a ton of cool macros and really great ideas |
| 14:18 | ChongLi | like making abstractions the default rather than concrete data structures |
| 14:19 | ChongLi | and making keywords functions that look themselves up in a map |
| 14:20 | ystael | curiousgeroge: many things you do with object-model metaprogramming in ruby are instead done with syntactic metaprogramming (macros) in clojure |
| 14:20 | ChongLi | curiousgeroge: have you watched any of rich hickey's talks? |
| 14:20 | ystael | the end result in expressive power is comparable but the way you get there feels different, and in some ways macros are a lot easier to understand |
| 14:21 | curiousgeroge | ChongLi: nope none |
| 14:21 | ChongLi | curiousgeroge: ah, you should |
| 14:21 | curiousgeroge | ChongLi: will definetelly do that |
| 14:22 | casion | ystael: I've had the opposite experience |
| 14:22 | casion | I've never tried a language that was as easy to get going with as clojure, but maybe that's because I'm using os x |
| 14:22 | ChongLi | he does a very good job of conveying his ideas on values and pure functions |
| 14:23 | technomancy | casion: wow, really? |
| 14:23 | technomancy | compared to which others? |
| 14:24 | ChongLi | curiousgeroge: http://www.infoq.com/presentations/Value-Values |
| 14:24 | ChongLi | one of his more recent ones |
| 14:25 | casion | technomancy: compared to java, python, c, c++, lua, objc |
| 14:25 | curiousgeroge | ChongLi: thanks! |
| 14:25 | ChongLi | curiousgeroge: it's a very interesting way of categorizing languages |
| 14:25 | casion | obviously you can get hello world working in osx pretty damn fast with c/objc… but getting a sane environment is stupid. |
| 14:25 | ChongLi | instead of looking so much at syntax, rich looks at semantics |
| 14:25 | technomancy | casion: interesting. I don't know the others, but I've always found Python to be very accessible and much better-documented than Clojure |
| 14:25 | casion | and dealing with python 3 on os x is a huge pain |
| 14:26 | technomancy | oh sure, the 2-vs-3 split would probably kill you there |
| 14:26 | technomancy | I was only thinking of 2 |
| 14:26 | ChongLi | this tends to lump all of the imperative languages together in a more obvious way |
| 14:26 | casion | technomancy: most material I've seen these days is on 3 |
| 14:26 | technomancy | kind of surprised you had a harder time with lua too though |
| 14:27 | casion | lua is easy to get going to learn I guess |
| 14:28 | technomancy | I guess if you're embedding it in a larger system it could be hard |
| 14:28 | casion | but having a sensible environment to learn in, not so much |
| 14:28 | casion | and installing clojure-mode or CC is dead simple comparatively |
| 14:28 | casion | (for an environment) |
| 14:28 | technomancy | yeah I guess you have a leg up on Clojure if you already use emacs |
| 14:29 | ChongLi | UnsatisfiedLinkError ~/test2/target/native/linux/x86_64/liblwjgl.so: ~/test2/target/native/linux/x86_64/liblwjgl.so\ |
| 14:29 | ChongLi | : wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch) java.lang.ClassLoader$NativeLibra\ |
| 14:29 | ChongLi | ry.load (ClassLoader.java:-2) |
| 14:29 | ChongLi | what am I doing wrong here? |
| 14:29 | ChongLi | hehe |
| 14:29 | ChongLi | I'm trying to (import org.lwjgl.opengl.Display) |
| 14:30 | casion | ChongLi: you're on a 64-bit system aren't you? |
| 14:30 | ChongLi | yeah |
| 14:30 | ChongLi | I figured the libraries in the x86_64 directory would be 64-bit binaries |
| 14:30 | ystael | technomancy: What is the morally correct way to specify repositories/mirrors build-system-wide as opposed to in a single project.clj? Are these settings still ignored from profiles.clj? |
| 14:31 | ChongLi | everything in target/native was put there by lein |
| 14:31 | ChongLi | lein deps |
| 14:31 | ChongLi | :dependencies [[org.clojure/clojure "1.4.0"] |
| 14:31 | ChongLi | [org.lwjgl/lwjgl "2.7.1"] |
| 14:31 | casion | ChongLi: you're getting the wrong lwjgl version it seems |
| 14:31 | ChongLi | [org.lwjgl/lwjgl-util "2.7.1"] |
| 14:31 | ChongLi | [org.lwjgl/lwjgl-native-platform "2.7.1"]] |
| 14:31 | TimMc | ChongLi: Please use a pstebin (such as refheap.com) |
| 14:31 | TimMc | *pastebin |
| 14:31 | ChongLi | sorry |
| 14:31 | technomancy | ystael: you can put :mirrors in ~/.lein/profiles.clj now |
| 14:32 | ystael | technomancy: awesome! time to update the build agents |
| 14:32 | ChongLi | there's a lot of different versions of lwjgl on clojars and maven |
| 14:32 | ChongLi | I don't know which one works |
| 14:32 | technomancy | ystael: pretty sure that's working anyway, best to double-check |
| 14:32 | casion | ChongLi: afaik, you have to make sure you're using the x86_64 version, which is fairly new |
| 14:33 | ChongLi | I don't know which one is officialy |
| 14:33 | ChongLi | all these on clojars seem to be uploaded by whoever |
| 14:36 | casion | ChongLi: I have no idea how to help you beyond that. you would probably get a better answer in #jme or #java |
| 14:37 | ChongLi | oh I think I solved it |
| 14:37 | ChongLi | just used 2.8.4 |
| 14:40 | ChongLi | so yeah I just needed to use the latest version |
| 14:40 | ChongLi | thanks :) |
| 14:51 | cvkem_ | Dynamic generated code based on (eval (read-str s)) is inefficient. Does anyone know whether (load-string s) return code that performs better? |
| 14:52 | technomancy | cvkem_: why do you say it's inefficient? |
| 14:52 | cvkem_ | By inefficient I mean that the code needs a print-dup method to get its data (if it is something like a java.sql.date |
| 14:54 | cvkem_ | technomancy, Furthermore the dataset is translated to a text-file. In my use-case this textfile is too large to fit in a single class-file which causes trouble. |
| 14:55 | cvkem_ | I was wondering whether load-string produces different code. |
| 14:55 | technomancy | I don't know what you're talking about, but Clojure only has a single compiler. |
| 14:57 | cvkem_ | I thought so too. But for some reason the code works fine and with large data if I compile it, while the code produce by eval requires me to make an implementation of print-dup before it accepts java.sql.date as data. |
| 14:57 | cvkem_ | Did not think of the solution myself, but saw a post by Stuart Sierra that exactly described the errors I got. |
| 14:58 | amalloy | `(str (java.util.Date.)) will compile fine: it's a list containing: the symbol str, and a list containing the symbol java.util.Date. -- compare to `(str ~(java.util.Date.)), which won't compile well at all: it's a list containing: the symbol str, and a Date object |
| 14:59 | amalloy | usually the right solution is to generate actual code instead of objects embedded in lists, not to invent ways to print/read the objects you accidentally embedded in your code |
| 15:01 | cvkem_ | amalloy, I'm trying use dynamic generated clojure code to let me play in an interactive way with my database. I started using eval, but it crashes if the data passed in exceeds a 65k boundary. |
| 15:02 | cvkem_ | ... and 64k is reached easily when you expand everything via a print-dup I guess. |
| 15:09 | Clojure | Does anyone know if Datomic supports authentication between services running on different nodes? |
| 15:10 | lpetit | Clojure: you should really choose another nickname than Clojure, IMHO |
| 15:10 | Clojure | Thought i did, having issues with Colloquy this morning... |
| 15:10 | cgag | i like it |
| 15:11 | ohpauleez | basically, what he says goes |
| 15:11 | cgag | very authoritative |
| 15:11 | Clojure | :) |
| 15:11 | ohpauleez | It's Clojure's word vs yours |
| 15:11 | casion | he'll be very popular, eveyone comes in here to talk about him |
| 15:11 | ohpauleez | we'll see who wins |
| 15:11 | gfredericks | quick quick assemble your questions |
| 15:11 | firesofmay | Hi, running lein command I am getting java error out of no where. -> http://pastebin.com/vNnQLStN |
| 15:11 | gfredericks | Clojure: why can't we have a clojure.core/update? |
| 15:11 | ohpauleez | Clojure is now a self-writing-macro AI |
| 15:11 | firesofmay | any ideas what could be wrong? |
| 15:11 | hiredman | ~clojure |
| 15:11 | clojurebot | clojure is the best way to learn java |
| 15:11 | hiredman | ~clojure |
| 15:11 | clojurebot | clojure is a very attractive hammer with a nice heft to it |
| 15:12 | casion | best part is I can tab complete Clojure now |
| 15:12 | technomancy | firesofmay: maybe using gcj by accident or something? |
| 15:12 | Clojure | I guess I should be offering answers instead of asking questions |
| 15:12 | firesofmay | technomancy, gcj? I was running it fine. And suddenly this happened. |
| 15:12 | technomancy | Clojure: why hasn't the patch to speed up multimethods been applied I mean come ooooooon |
| 15:13 | technomancy | firesofmay: what does `java -version` say? |
| 15:13 | technomancy | also, `lein version` if you can |
| 15:13 | Clojure | technomancy: works on my machine |
| 15:13 | firesofmay | technomancy, java version "1.7.0_03" |
| 15:13 | firesofmay | OpenJDK Runtime Environment (IcedTea7 2.1.1pre) (7~u3-2.1.1~pre1-1ubuntu3) |
| 15:13 | firesofmay | OpenJDK 64-Bit Server VM (build 22.0-b10, mixed mode) |
| 15:13 | technomancy | hm; it's not that then |
| 15:13 | technomancy | could be a misbehaving plugin |
| 15:14 | firesofmay | technomancy, lein is 2.x i am not sure which exact version. |
| 15:14 | firesofmay | technomancy, I recently ran an update on unbuntu btw. |
| 15:15 | firesofmay | ubuntu* |
| 15:16 | firesofmay | technomancy, any ideas what I should do? |
| 15:18 | technomancy | firesofmay: it looks like a problem with your JDK. maybe try falling back to java 6 to see if that helps? |
| 15:18 | firesofmay | technomancy, I have this in my profiles.clj btw : |
| 15:18 | firesofmay | mankaj@mankaj:~/src/ios-moby-testing$ cat ~/.lein/profiles.clj |
| 15:18 | firesofmay | {:user {:plugins [[lein-difftest "1.3.8"] |
| 15:18 | firesofmay | [lein-marginalia "0.7.1"] |
| 15:18 | firesofmay | [lein-pprint "1.1.1"] |
| 15:18 | firesofmay | [lein-swank "1.4.4"] ]}} |
| 15:18 | firesofmay | technomancy, oh okay. |
| 15:21 | xeqi | firesofmay: theres a similiar bug I found on google for another project https://bugs.eclipse.org/bugs/show_bug.cgi?id=389533 ; last comment mentions updating to a different version |
| 15:22 | firesofmay | xeqi, sounds like it's the same problem. will try this and let you know if works. |
| 15:28 | firesofmay | xeqi, thanks a lot that worked :) |
| 15:28 | firesofmay | technomancy, its a bug with java update. had to remove and re-install java as pointed out by xeqi in above link. :) |
| 15:29 | technomancy | ouch, that sucks |
| 15:29 | technomancy | just an Ubuntu fubar? |
| 15:31 | firesofmay | technomancy, its working. I guess the ubuntu update didn't get the latest package and that had some bug. removing and installing again did it (weird!) |
| 15:34 | technomancy | =\ |
| 15:34 | zmaril | Let's say I want to hack on two clojure projects at once and I want to connect them via leiningen |
| 15:34 | xeqi | checkouts |
| 15:35 | zmaril | Ah! Yes! That was the word. I've done this before, but I forgot what it was called. |
| 15:35 | zmaril | Thank you! |
| 15:47 | firesofmay | how would you convert a string to a vector with , seperated values like ex : "wool,word,work" to ["wool", "word", "word"] ? |
| 15:47 | scriptor | firesofmay: http://clojuredocs.org/clojure_core/clojure.string/split |
| 15:47 | firesofmay | scriptor, thanks. |
| 15:48 | Sweden_jack | ["wool" "word" "work"] right? |
| 15:48 | hfaafb | commas are allowed |
| 15:49 | Sweden_jack | no I mean "work" |
| 15:49 | scriptor | I think he means the word/work |
| 15:49 | hfaafb | WOOPS |
| 15:49 | firesofmay | Sweden_jack, scriptor, its what I wanted. :) |
| 15:49 | abalone | when would you use clojure.string vs .split ? |
| 15:50 | scriptor | .split doesn't return a seq, right? |
| 15:50 | scriptor | well, neither does string.split I guess |
| 15:50 | firesofmay | scriptor, it returned me a clojure.lang.PersistentVector |
| 15:50 | S11001001 | ,(doc clojure.string/split) |
| 15:50 | clojurebot | "([s re] [s re limit]); Splits string on a regular expression. Optional argument limit is the maximum number of splits. Not lazy. Returns vector of the splits." |
| 15:53 | vishesh | Is there any function by which I can replace nth memeber of a collection with another? |
| 15:54 | gfredericks | vishesh: if you are using a vector you can do that with assoc |
| 15:55 | hfaafb | assoc? |
| 15:55 | clojurebot | then its perfect. but of course, there are a lot of other parts too that changes. so after I make assoc :show, is there a problem I make again (def data (assoc data :list ...) |
| 15:55 | gfredericks | ,(assoc [1 2 3 4 5] 3 :foo) |
| 15:55 | clojurebot | [1 2 3 :foo 5] |
| 15:59 | vishesh | gfredericks: Ok. For string work I can convert it to vector first and then use assoc, or is there any better way? |
| 16:00 | gfredericks | if you're doing random updates a lot and are worried about performance, then vectors are definitely the choice |
| 16:00 | gfredericks | strings would require full copies afaik |
| 16:02 | vishesh | Ok. I'm just learning Clojure, so no specific requirement as such right now. |
| 16:02 | vishesh | So would like to know any direct method I can apply on string too, for educational purposes at least |
| 16:05 | gfredericks | certainly all java methods are at your disposal |
| 16:06 | gfredericks | I don't see anything in the string class for updating a particular character, and wouldn't expect once since it's ineffecient |
| 16:06 | gfredericks | but you can do it by hand: |
| 16:06 | gfredericks | ,(let [s "foo and bar"] (str (subs s 0 4) "X" (subs s 5 (count s)))) |
| 16:06 | clojurebot | "foo Xnd bar" |
| 16:09 | vishesh | Ok. Thanks. I think if I really need performance benefits, I should use rather StringBuilder |
| 16:09 | gfredericks | yeah that sounds right |
| 16:15 | konr_trab | I can't "bind the qualified name e" when running (defmacro oops [code] `(try ~@code (catch Exception e "Oops"))) - isn't this valid code? |
| 16:15 | amalloy | e# |
| 16:15 | konr_trab | oh, that's it! |
| 16:15 | konr_trab | thanks! |
| 16:16 | amalloy | &(let [code '(blah)] `(try ~@code (catch Exception e "Oops"))) |
| 16:16 | lazybot | java.lang.SecurityException: You tripped the alarm! catch is bad! |
| 16:16 | amalloy | ,(let [code '(blah)] `(try ~@code (catch Exception e "Oops"))) |
| 16:16 | clojurebot | amalloy: Gabh mo leithsc?al? |
| 16:16 | amalloy | i hate you guys |
| 16:17 | hiredman | ~hate |
| 16:17 | clojurebot | Pardon? |
| 16:19 | cemerick | whew, the reader fails on tagged literals within commented regions |
| 16:19 | gfredericks | cemerick: commented with #_ ? |
| 16:19 | hiredman | commented how? |
| 16:20 | cemerick | ,*clojure-version* |
| 16:20 | clojurebot | {:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"} |
| 16:20 | cemerick | ,#_ #foo/bar 5 |
| 16:20 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: No reader function for tag foo/bar> |
| 16:20 | hiredman | well, yeah |
| 16:20 | xeqi | ,(comment #foo/bar) |
| 16:20 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )> |
| 16:20 | hiredman | the forms following #_ still have to be readable |
| 16:21 | gfredericks | hiredman: it could read both pieces and then not call the data-reader fn |
| 16:21 | cemerick | hrmph; it shouldn't go looking up the reader fn |
| 16:21 | gfredericks | I can't think of any downside to that |
| 16:21 | rplevy | trying to figure out if I am unnecessarily reinventing a wheel for a simple lein plugin. similar to s3-wagon, but just for simply pushing application uberjars to s3 without any need for maven. you specify bucket in project.clj, and it puts the jar in a directory like bucket/app/branch/*.jar |
| 16:21 | hiredman | *shrug* |
| 16:21 | amalloy | ,'#(f %1 #_%2) ;; another entertaining side effect of #_, if anyone hasn't seen it |
| 16:21 | clojurebot | (fn* [p1__99# p2__100#] (f p1__99#)) |
| 16:22 | mindbender1 | please Brenton, have a second look at CLJS1. It's simply the best! |
| 16:23 | cemerick | amalloy: that's cute |
| 16:23 | hiredman | rplevy: we have a a bin/ci that the ci server runs, that runs tests and pushes artifacts to s3 using s3cmd |
| 16:24 | rplevy | hiredman: that's a good idea |
| 16:28 | mindbender1 | I wonder how people keep building things that don't take arguments |
| 16:28 | hfaafb | easy [] |
| 16:29 | mindbender1 | Yes, evil is easy. The hard part? |
| 16:29 | hfaafb | sleeping at night |
| 16:29 | mindbender1 | boo! |
| 16:33 | technomancy | rplevy: I don't know if that's been done, but it's a good idea |
| 16:37 | rplevy | cool, I will go ahead with the idea then. Good idea to have a ci server call such lein command... |
| 16:37 | firesofmay | I am getting this error even though faker-en file is created : Exception in thread "main" java.io.FileNotFoundException: Could not locate ios_testing/faker_en__init.class or ios_testing/faker_en.clj on classpath: |
| 16:38 | technomancy | rplevy: yeah, keeping as little as possible in the jenkins config is definitely the way to go |
| 16:38 | firesofmay | Any ideas what could be wrong? |
| 16:38 | technomancy | bin/ci lets you avoid a lot of hassles keeping job config in line with various branching |
| 16:43 | thorbjornDX | is there a better-defined way of doing this?: (def updated-stuff (for [d small-seq q big-map] (assoc q :small-seq d))) |
| 16:43 | thorbjornDX | (sorry about the symbol names) |
| 16:44 | gfredericks | if big-map is a map I don't think that can possibly work |
| 16:44 | gfredericks | so it's not clear what you want exactly |
| 16:45 | gfredericks | you just want to take a map and add a key :small-seq? |
| 16:45 | gfredericks | you might want let instead of for |
| 16:45 | thorbjornDX | gfredericks: er, sorry. big-map should be seq-of-big-maps |
| 16:46 | thorbjornDX | gfredericks: hence the 'for' |
| 16:46 | amalloy | thorbjornDX: better-defined? seems perfectly well-defined |
| 16:46 | thorbjornDX | amalloy: okay, so if I want to do this multiple times, I should go ahead and define a macro? |
| 16:46 | gfredericks | woah man no macros |
| 16:47 | thorbjornDX | gfredericks: oh, okay :(... why not? |
| 16:47 | gfredericks | so what you have there will give you a cartesian product |
| 16:47 | gfredericks | is that what you want? every big map paired with every element of small-seq? |
| 16:48 | thorbjornDX | gfredericks: ah, no I don't. I'd like a 1:1 pairing |
| 16:48 | gfredericks | try (for [[d q] (map vector small-seq big-map)] (assoc ...)) |
| 16:48 | amalloy | fehhhhh. (map (fn [d q] (assoc ...)) small-seq big-map-seq) |
| 16:50 | thorbjornDX | amalloy: oh, I think that makes perfect sense |
| 16:50 | gfredericks | amalloy: yays |
| 16:50 | thorbjornDX | gfredericks: thanks for the tip about the cartesian product, I think I have some broken code to fix :P |
| 16:51 | gfredericks | I hadn't realized that map can be simpler for some anon-fn cases |
| 17:07 | naeg | casion: ping |
| 17:10 | mindbender1 | I can't believe some people in Clojure still recommends SICP to budding programmers |
| 17:11 | Sweden_jack | mindbender1: it depends a lot on the student |
| 17:11 | naeg | would appreciate feedback on myblog post about different checking algorithms for a connect four board: http://programmablelife.blogspot.co.at/2012/09/clojure-connect-four-1-checking-winner.html |
| 17:12 | rplevy | it's a good book / online lectures, why not? |
| 17:12 | mindbender1 | Sweden_jack: No matter what.. it's evil in my opinion |
| 17:12 | emezeske | mindbender1: What do you have against SICP? |
| 17:12 | Sweden_jack | then that's a silly opinion, in my opinion |
| 17:12 | mindbender1 | emezeske: Imperative |
| 17:12 | mindbender1 | swapping |
| 17:12 | mindbender1 | statefulness |
| 17:12 | mindbender1 | all the goobledygook |
| 17:13 | Sweden_jack | Which would rule out 99.9% of all programming books? |
| 17:13 | rplevy | well Lisp pre-clojure is more multi-paradigm |
| 17:13 | rplevy | there's a reason we use Clojure |
| 17:13 | scriptor | they can still take all the other lessons from SICP |
| 17:13 | mindbender1 | which brings me to an opinion I have. Almost all books needs revisiting |
| 17:14 | mindbender1 | including some early ones in clojure |
| 17:14 | rplevy | have you looked at "how to design programs" (I haven't) |
| 17:14 | mindbender1 | I have it |
| 17:14 | mindbender1 | same thing |
| 17:14 | rplevy | ok |
| 17:18 | dnolen | mindbender1: SICP is grand, imperative techniques won't being going out of style anytime soon - and for good reason. The problem w/ SICP w/ respect to Clojure is that ... it's about *Scheme* |
| 17:19 | dnolen | well ... framed in terms of Scheme. |
| 17:20 | Sweden_jack | dnolen: didn't you hear? C is worthless as well because it's stateful and imperative |
| 17:20 | Sweden_jack | tsk |
| 17:20 | rplevy | there are plenty of cases where it makes sense to be imperative even in Clojure |
| 17:21 | mindbender1 | dnolen: it probably won't even go out of style at all |
| 17:22 | dnolen | mindbender1: good call |
| 17:22 | mindbender1 | there's always a camp..take a position |
| 17:22 | emezeske | mindbender1: Not all programming is functional |
| 17:22 | amalloy | "almost all books need revisiting"? come back when you're done rewriting every book, i guess |
| 17:23 | rplevy | mindbender1: what about performance optimizations for isolated parts of otherwise beautifully functional code |
| 17:23 | naeg | is there a way to submit an article to planet clojure without syndicating your whole blog? |
| 17:24 | amalloy | naeg: i don't think so, but you can probably ask alex |
| 17:25 | hfaafb | string/replace takes 2 arguments but my repl is throwing number of argument errors... am I incorrect? |
| 17:25 | naeg | amalloy: alex? |
| 17:25 | amalloy | alex ott, who runs planet clojure |
| 17:25 | xeqi | (doc clojure.string/replace) |
| 17:25 | clojurebot | "([s match replacement]); Replaces all instance of match with replacement in s. match/replacement can be: string / string char / char pattern / (string or function of match). See also replace-first." |
| 17:26 | xeqi | hfaafb: looks like 3 arguments |
| 17:26 | hfaafb | oh, wait, I want to use the core replace... |
| 17:28 | hfaafb | IDE bug |
| 17:28 | hfaafb | :> |
| 17:37 | seneth | Why can˙t you define functions like this (defn test1 [x] #(* % %)) |
| 17:38 | seneth | it doesnt complain, but i cant use it like (test1 2). Returns <user$test1$fn__1449 user$test1$fn__1449@1444986> |
| 17:38 | seneth | its adress or something |
| 17:38 | gfredericks | you can define them, it's just not doing what you want |
| 17:39 | seneth | what is it actually doing? |
| 17:39 | gfredericks | you can (defn test1 [%] (* % %)) if you have some thing for percent signs |
| 17:39 | gfredericks | you're making a function that returns another function |
| 17:39 | gfredericks | you can also (def test1 #(* % %)) if you like |
| 17:39 | gfredericks | maybe that's the sort of thing you were hoping for |
| 17:39 | S11001001 | %1 %1 |
| 17:40 | amalloy | ((test1 'sdfaslkjfsadf) 4) ;; returns 16 as desired, har har |
| 17:40 | gfredericks | S11001001: eh? |
| 17:40 | S11001001 | ,'#(* % %) ; gfredericks |
| 17:40 | clojurebot | (fn* [p1__27#] (* p1__27# p1__27#)) |
| 17:40 | S11001001 | what |
| 17:40 | amalloy | S11001001: why wouldn't that work? |
| 17:40 | S11001001 | amalloy: it would |
| 17:40 | S11001001 | for some reason |
| 17:41 | amalloy | it's a perfectly normal thing to do |
| 17:41 | S11001001 | I was under the impression that % was like <> in srfi 26 |
| 17:41 | gfredericks | % ===== %1 |
| 17:41 | seneth | "you can also (def test1 #(* % %)) if you like", thats what I was looking for.Thanks |
| 17:41 | S11001001 | except positionable at any depth |
| 17:41 | amalloy | i don't know srfi, but i guess you mean that % % was %1 %2? |
| 17:41 | gfredericks | seneth: cool |
| 17:41 | S11001001 | seneth: that has other disadvantages so maybe don't do it? |
| 17:42 | gfredericks | dammit I hate disadvantages |
| 17:42 | amalloy | gfredericks: an extra-cautious ex-programmer of js or php or something? the fourth and fifth =s just for style points? |
| 17:43 | gfredericks | amalloy: ===== is legal somewhere? |
| 17:43 | gfredericks | sign me up for this language |
| 17:43 | S11001001 | seneth: e.g. it will lack :arglists metadata for your editor to help you with |
| 17:44 | rplevy | S11001001: or swiss-arrows Clojure lib, which was inspired by a util we wrote at Akamai, which was inspired by srfi 26 |
| 17:44 | S11001001 | rplevy: indeed |
| 17:44 | seneth | I wont be using that notation for defining fns.I am just exploring the language |
| 17:48 | amalloy | gfredericks: ##(let [===== =] (===== 1 1)) ;; welcome home |
| 17:48 | lazybot | ⇒ true |
| 17:49 | S11001001 | I think cute from srfi26 would be handy in some situations |
| 17:50 | rplevy | cut? |
| 17:50 | clojurebot | executable jar is a sample executable jar build using ant : http://github.com/cark/clj-exe-jar/tree/master |
| 17:50 | S11001001 | cute |
| 17:51 | rplevy | I see: http://srfi.schemers.org/srfi-26/cut.scm |
| 17:52 | S11001001 | with recursion: (cute + (a) (* (b) % (c)) (d)) |> (let [a# (a) b# (b) c# (c) d# (d)] #(+ a# (* b# % c#) d#)) |
| 17:52 | S11001001 | well with + and * evalled also |
| 17:57 | vishesh | quit |
| 18:00 | seneth | Why #(2) can be defined, but cannot be invoked (#(2))? Maybe because its lazily eveluated? |
| 18:00 | S11001001 | ,'#(2) |
| 18:00 | clojurebot | (fn* [] (2)) |
| 18:01 | S11001001 | ,'#(do 2) |
| 18:01 | clojurebot | (fn* [] (do 2)) |
| 18:01 | seneth | If you invoke it (#(2)) you get an error |
| 18:01 | S11001001 | yeah, 2 isn't a function |
| 18:02 | seneth | But then why didnt complain when I defined it |
| 18:02 | raek | Clojure is not a statically typed language |
| 18:02 | scriptor | ,(#(2)) |
| 18:02 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 18:03 | nDuff | seneth: ...you defined a function that tries to call 2 as a function. That's a valid thing to define, it's just not a valid thing to run. :) |
| 18:03 | Raynes | &(read-string "(fn* [] (2))") |
| 18:03 | lazybot | ⇒ (fn* [] (2)) |
| 18:03 | seneth | can i redefine 2 to point to a function? |
| 18:03 | scriptor | seneth: it doesn't create an error when you define for for the same reason it wouldn't work in a lambda |
| 18:03 | scriptor | ,(fn [] (2)) |
| 18:03 | clojurebot | #<sandbox$eval107$fn__108 sandbox$eval107$fn__108@48661a83> |
| 18:03 | gfredericks | seneth: no |
| 18:04 | seneth | then when I defined it, it should have known since i cant redefine numbers? |
| 18:04 | gfredericks | seneth: technically the compiler could catch that, yes |
| 18:04 | seneth | ok thanks |
| 18:04 | raek | seneth: if you want a function that returns to, you could either write (fn [] 2) or (constantly 2) |
| 18:04 | scriptor | but it wouldn't be very consistent |
| 18:04 | scriptor | (fn [n] (n)) is perfectly valid code |
| 18:04 | raek | *two |
| 18:05 | scriptor | but it'll break if you pass it a number, or anything else that can't be called as a function |
| 18:05 | scriptor | seneth: if you need to create a function that always returns one value look up constantly |
| 18:05 | scriptor | ,(doc constantly) |
| 18:05 | clojurebot | "([x]); Returns a function that takes any number of arguments and returns x." |
| 18:16 | gstamp | in marmalade nrepl-ritz seems to depend on nrepl 0.1.4 which isn't in marmalade yet. How annoying. |
| 18:18 | thorbjornDX | this is my first macro: (defmacro tack [m item] (assoc m (keyword item) item)), is it terrible? |
| 18:19 | hugod | gstamp: sorry about that - I messed up there - it does work if nrepl.el is installed from melpa |
| 18:21 | gstamp | no worries. I was hoping to avoid adding melpa. I might just install it manually. |
| 18:21 | amalloy | thorbjornDX: i have a hard time imagining a scenario in which that is not horrible, but i suppose it could happen |
| 18:21 | thorbjornDX | amalloy: haha, I need a reality check once in a while :) |
| 18:22 | Raynes | &(map println [\a \b \c]) |
| 18:22 | lazybot | ⇒ (abcnil nil nil) |
| 18:35 | Mandar | hey guys |
| 18:35 | Mandar | i'm trying to learn about refs |
| 18:35 | Mandar | does dosync retry the transaction until it works? |
| 18:36 | metellus | yes |
| 18:36 | Mandar | thanks |
| 18:36 | Mandar | so i don't have to use a timeout or anything else |
| 18:37 | Mandar | it will just work |
| 18:37 | thorbjornDX | amalloy: in general, should I avoid modifying my data structures? I'm trying to change quite a few old habits. |
| 18:39 | technomancy | gstamp: M-x package-install-file makes it easy to work from git |
| 19:00 | konr_trab | Is there a way to reference any anonymous function from inside? like #(if (< % 0) (this-function (- %)) ... ) |
| 19:00 | konr_trab | an* |
| 19:02 | konr_trab | recur! |
| 19:08 | Mandar | second noob question: what's the use case for atoms? i don't get where compare-and-set! could be useful in an application? |
| 19:09 | Mandar | (if you have a link that explains it better than this page: http://clojure.org/atoms it's great too) |
| 19:14 | aperiodic | Mandar: whenever you want something to be able to change, but don't need to synchronize changes to that thing with changes to anything else. an example would be if you're building a todo-list application, you could keep all the current todo items in an atom that contains a set |
| 19:15 | aperiodic | Mandar: when the user adds a new item, you'd (swap! todo-items conj new-item), and when they remove an item, you'd (swap! todo-items disj new-item) |
| 19:15 | Tolstoy | That's how I kinda user it. Like a ConcurrentHashMap, sort of. |
| 19:16 | Mandar | this is a bit weird to me |
| 19:16 | Tolstoy | Or sometimes as a sentinal value. |
| 19:16 | aperiodic | Mandar: i've never needed to use compare-and-set!, and i don't think using it is at all common |
| 19:16 | Mandar | i get the example |
| 19:16 | ChongLi | Mandar: the beauty of it is that it's thread safe |
| 19:16 | Mandar | but in this case why couldn't we just call a function returning a function with the new value of the clojure? |
| 19:17 | Mandar | oh |
| 19:17 | Mandar | okay |
| 19:17 | Mandar | now i get it |
| 19:17 | ChongLi | the atom is accessible and |
| 19:17 | ChongLi | "mutable" from any thread |
| 19:17 | ChongLi | in a safe way |
| 19:17 | aperiodic | Mandar: values are immutable. try constructing such a function without using an atom in that function's closure |
| 19:18 | ChongLi | since only the reference itself is changed, the value it points to is immutable |
| 19:18 | ChongLi | so when another thread is working with that value, it won't be harmed |
| 19:19 | Mandar | okay |
| 19:19 | Tolstoy | I'm guessing compare-and-set reduces the locking for those cases where most of the time the value doesn't really need to change? |
| 19:19 | ChongLi | and of course, once the old value is no longer needed it'll simply be garbage-collected |
| 19:19 | aperiodic | if you want to be pedantic, the value of the reference (the atom) never changes (you can use it as the value of a final field in a java class), only the value you get when you dereference the reference changes |
| 19:20 | Mandar | aperiodic, i'll try that, i come from erlang where such thing is easy because each process has its own immutable variables |
| 19:20 | Mandar | ("immutable variable" is a weird combination) |
| 19:20 | ChongLi | well, mutable variable is actually the weird one |
| 19:20 | ChongLi | variables were immutable for centuries before programmers came along |
| 19:22 | ChongLi | I like rich hickey's description of "places" |
| 19:22 | ChongLi | a mutable "variable" being a place in memory |
| 19:22 | ChongLi | not a value |
| 19:23 | aperiodic | Tolstoy: you get that for free using swap!, since swap! internally does the compare-and-set! |
| 19:24 | Tolstoy | Excellent. ;) |
| 19:27 | Mandar | aperiodic, you were right, i cannot write such a function because i cannot store the closure containing my data in a place where other functions have access to it |
| 19:28 | Mandar | so basically, an atom is a thread-safe shared var |
| 19:28 | Mandar | right? |
| 19:28 | clojurebot | flatten |is| rarely the right answer. What if your "base type" is a list |
| 19:29 | aperiodic | Mandar: basically, yup |
| 19:29 | Mandar | thanks guys, much clearer now |
| 19:32 | madsy | What's actually happening here? A def gets evaluated at compile time? http://squirrel.pl/blog/2012/09/13/careful-with-def-in-clojure/ |
| 19:35 | aperiodic | &(doc def) |
| 19:35 | lazybot | java.lang.SecurityException: You tripped the alarm! def is bad! |
| 19:36 | aperiodic | :-( |
| 19:37 | aperiodic | madsy: if you'll look at the docstring for def, you'll notice that if an initial value is supplied, it's evaluated, and the var is set to that value |
| 19:38 | amalloy | compiling a clojure program is just evaluating each top-level form, and saving any classes that get generated as a result |
| 19:38 | hiredman | http://clojure-log.n01se.net/date/2008-11-12.html#16:07 |
| 19:38 | madsy | aperiodic: Yeah, I never bothered because I thought def was a nobrainer. Thanks. |
| 19:38 | casion | wouldn't he want something like (def my-def #(get-my-value)) |
| 19:40 | madsy | casion: No need to wrap it. Just don't call it. |
| 19:40 | casion | yeah |
| 19:48 | akhudek | do people have a good go to library for parsing UserAgents in clojure? |
| 20:18 | konr_trab | 12 hours of work today :( - but it's all good because it is in - CLOJURE! |
| 20:18 | konr_trab | good night! |
| 21:57 | cjfrisz | Hmm...trying to use 'nil' as a function gives a NullPointerException |
| 21:57 | cjfrisz | I guess that makes sense...not sure if it's what I was expecting |
| 21:59 | jweiss | lein run is suddenly giving me "ClassNotFoundException" on my :main namespace. tried cleaning, re-self-installing, notthing fixes it. was working earlier today. |
| 22:02 | cjfrisz | Man...just not on it right now |
| 22:03 | akhudek | jweiss: bracket type in your main class maybe? |
| 22:04 | akhudek | or perhaps gen-class somehow got dropped? |
| 22:04 | akhudek | type=typo |
| 22:04 | jweiss | akhudek: i never had :gen-class. |
| 22:04 | jweiss | why would I need that? |
| 22:04 | jweiss | i'm not compiling into an uberjar or anything |
| 22:05 | jweiss | i've been using the same version of lein and everything else and it suddenly stopped working today, it's got to be something in my main namespace |
| 22:05 | jweiss | but it compiles fine at the repl |
| 22:06 | xeqi | jweiss: whats the value for :main ? |
| 22:06 | jweiss | :main ^{:skip-aot true} katello.tests.suite |
| 22:07 | xeqi | do you have a -main function? |
| 22:07 | jweiss | i think i see the problem. starting a fresh repl, i have a compile error in my main namespace (really in a dep). |
| 22:07 | jweiss | that's a shitty error to give. classnotfound. that is not the real error |
| 22:11 | Hodapp | http://pastebin.com/NHx5bfyZ - someone want to tell me what obvious thing I'm missing here that this should be a NullPointerException? |
| 22:11 | amalloy | too many parens |
| 22:13 | Hodapp | where? |
| 22:13 | clojurebot | where is log |
| 22:15 | xeqi | Hodapp: ((println ..) ...) |
| 22:15 | xeqi | |
| 22:15 | Hodapp | is there some other way to express that the 'then' portion should execute multiple things? |
| 22:15 | xeqi | (doc do) |
| 22:15 | clojurebot | excusez-moi |
| 22:15 | xeqi | ,(do (print "hi") (+ 1 2)) |
| 22:15 | clojurebot | hi |
| 22:15 | clojurebot | 3 |
| 22:16 | Hodapp | ugggggh |
| 22:20 | Hodapp | is there some way to convey, when attempting to work with lein-tarsier, that I want to work with this code without exceuting it? The REPL is not very useful when it's stuck inside of something... |
| 22:21 | Hodapp | part of it is probably this quil weirdness with 'defsketch' executing things |
| 22:21 | xeqi | "work with this code"? |
| 22:21 | aperiodic | Hodapp: that is exactly it. put your defsketch in your -main |
| 22:22 | xeqi | ah |
| 22:22 | Hodapp | aperiodic: if I put it in my -main, will it not execute when I run 'lein vimclojure' so I can use vim with it? |
| 22:22 | aperiodic | Hodapp: yes, because it's not top-level, so won't be evaluated when your namespace is compiled |
| 22:23 | Hodapp | now what do you even mean by -main? |
| 22:24 | Hodapp | nevermind, think I see |
| 22:32 | Hodapp | alright, now just have to figure out how to actually execute said main from witihn that nailgun session... |
| 22:33 | aperiodic | once you load the namespace, you should just be able to evaluate `(-main)` |
| 22:54 | axle_512 | Hmm, I am stuck trying to implement authentication with cemerick/friend… |
| 22:54 | axle_512 | trying to use form based authentication. |
| 22:54 | cemerick | axle_512: what's the problem? |
| 22:54 | axle_512 | cemerick: just using: (friend/authenticate {:credential-fn (partial creds/bcrypt-credential-fn users) |
| 22:54 | axle_512 | :workflows [(workflows/interactive-form)]}) |
| 22:55 | axle_512 | my form is posting to action="/login" method="POST" |
| 22:55 | axle_512 | and the form has two text inputs, one with id="username" and one with id="password" |
| 22:56 | cemerick | axle_512: you haven't specified the form-based workflow. |
| 22:57 | axle_512 | cemerick: ah, ok. I thought interactive-form was how I specify that. |
| 22:57 | cemerick | and form fields need e.g. name="username" attributes |
| 22:58 | cemerick | axle_512: nm, didn't see the second line of your paste |
| 22:58 | axle_512 | cemerick: ahh, name instead of id. doh! |
| 22:58 | axle_512 | cemerick: thanks, let me correct that. |
| 23:17 | muhoo | cemerick: have you any interest in exposing the Ax attributes portion of the openid workflow so that someone using the library can pick which attributes they want, instead of "carpet bombing"? |
| 23:18 | cemerick | muhoo: I personally don't. Patches welcome, of course. :-) |
| 23:19 | cemerick | Once some oauth2 basics are in place, I'll definitely get the openid workflow out of the main project so that it can be forked separately, etc. |
| 23:19 | muhoo | if i can find a way to do it without a breaking change to the api, i'll do that |
| 23:19 | cemerick | You can go bash out the vars that contain the attr maps, assuming you don't need to customize the attrs requested per account/provider/etc |
| 23:20 | muhoo | bash out? |
| 23:20 | cemerick | alter-var-root, etc |
| 23:20 | muhoo | oh, cool. |
| 23:20 | muhoo | that feels kind of icky though. |
| 23:21 | cemerick | oh, definitely a hack :-) |
| 23:21 | cemerick | what do you mean by "carpet bombing", BTW? |
| 23:22 | cemerick | just not being selective in the requested attrs? |
| 23:23 | muhoo | https://github.com/cemerick/friend/blob/master/src/cemerick/friend/openid.clj#L33 |
| 23:23 | muhoo | "might as well carpet-bomb for attributes" |
| 23:23 | cemerick | haha |
| 23:23 | cemerick | I don't see any reason not to *shrug* |
| 23:24 | muhoo | IIRC, the user gets a scary screen in google asking them to approve granting access to all this information |
| 23:24 | muhoo | when all i want is their email, first/last |
| 23:24 | cemerick | Of course, providers can define custom attrs, so being able to adapt to that is important for certain contexts. |
| 23:24 | cemerick | oh, I see |
| 23:24 | cemerick | So, sure, alter-var-root, and you'll be rid of that. |
| 23:25 | muhoo | perfect, that'll work, thanks. |
| 23:25 | axle_512 | cemerick: hmm, still no luck. I confirmed I now see [:params {:password user_password, :username jane}] in the request map. But still getting a redirect with an empty username= |
| 23:25 | cemerick | FWIW, it'd be a crazy simple patch to parameterize the map of attrs requested, so feel free to give it a shot. |
| 23:26 | cemerick | axle_512: can you paste your code and your html page somewhere? |
| 23:26 | axle_512 | cemerick: sure, one sec |
| 23:26 | muhoo | funny, i ran into exactly this problem in may: http://nelsonmorris.net/2012/09/13/solving-version-conflicts.html |
| 23:27 | cemerick | muhoo: see his new post about lein-pedantic |
| 23:28 | xeqi | I helped solve it like 3 times in a week, and I'd been fighting with cemerick that soft version ranges were better for like a month, so I had to go write something to fix their problems |
| 23:28 | cemerick | muhoo: BTW, could you file an issue for the attrs thing? |
| 23:28 | muhoo | xeqi: hahaha |
| 23:28 | xeqi | * soft versions were better then ranges |
| 23:28 | muhoo | thanks for writing it, i'm sure i'll run into that again. |
| 23:29 | muhoo | yeah, i don't think technomancy will go for ranges |
| 23:29 | muhoo | cemerick: will do |
| 23:31 | cemerick | xeqi: The topic contains multitudes, but you've gained a ton of ground. ;-) |
| 23:31 | cemerick | muhoo: thanks! |
| 23:31 | axle_512 | cemerick: https://gist.github.com/3719615 |
| 23:31 | axle_512 | cemerick: and my html is here: https://gist.github.com/3719619 |
| 23:33 | cemerick | axle_512: handler/site needs to be applied after friend/authenticate |
| 23:33 | xeqi | (inc cemerick) |
| 23:33 | lazybot | ⇒ 10 |
| 23:34 | axle_512 | cemerick: thank you. sorry to bug you. I will try that. |
| 23:34 | cemerick | It's a bummer that there's no metadata on middlewares indicating dependencies like that. :-( |
| 23:34 | cemerick | axle_512: no worries, ping back if problems come up again :-) |
| 23:35 | axle_512 | cemerick: in my project.clj, do I specify my ring handler as app? or secured-app? |
| 23:35 | cemerick | axle_512: whichever one you want to run/test. Should probably be the secured-app. |
| 23:36 | axle_512 | cemerick: ok, thank you! |
| 23:42 | axle_512 | cemerick: success! |
| 23:42 | cemerick | salut! |