2012-09-23
| 00:36 | djanatyn | whoever wrote or contributed anything to hiccup, I *love* you |
| 00:36 | djanatyn | hiccup has made my life so much easier. |
| 00:36 | djanatyn | I have to work through a very large portion of a java textbook, and I used clojure to write a program that creates a small static website with my Java code indexed by chapters, and the answers I gave indexed by chapter |
| 00:37 | akhudek | weavejester has done a lot for the community, including hiccup :-) |
| 00:37 | djanatyn | I have all the answers in a huge map, in it's own file. I've been writing little helper functions to make putting stuff in easier |
| 00:37 | djanatyn | I'll have to write him a thank you note and see if there's any bugs I could try to fix |
| 00:38 | akhudek | https://github.com/weavejester/hiccup/issues |
| 00:55 | duck1123 | has anyone had an issue recently where nrepl.el doesn't give you the repl? All I get is a blank buffer |
| 00:55 | casion | are you using autocomplete? |
| 00:56 | duck1123 | yes, I was trying to |
| 00:56 | casion | that happened to me as well |
| 00:56 | casion | are you jacking in to a project or not? |
| 00:56 | duck1123 | I start a nrepl connection when my server starts |
| 00:57 | duck1123 | then I connect to that |
| 00:57 | casion | that should work fine... |
| 00:57 | casion | there's an issue with your ac-nrepl and/or autocomplete config |
| 00:58 | Sgeo | I should figure out the autocomplete stuff too |
| 00:58 | casion | autocomplete is a pain until lein prev 1 comes out :| |
| 00:58 | Sgeo | Hmm? |
| 00:58 | casion | lein 2.0 prev 1 |
| 00:58 | casion | because it has an old clojure-complete dependency for headless repls |
| 00:58 | Sgeo | I thought there were 10 previews already |
| 00:59 | casion | RC1 |
| 00:59 | casion | it's late :\ |
| 00:59 | duck1123 | The thing is, I tried using a clean .emacs.d (actually, I used starter kit) and I still had the issue |
| 01:00 | duck1123 | should I remove complete-core from my deps? |
| 01:00 | casion | no |
| 01:00 | casion | did you use package.el for installing ac-nrepl and auto-complete? |
| 01:00 | duck1123 | yes |
| 01:00 | eggsby | hmm, I have autocomplete and nrepl, but I had to install nrepl from git, not from marmalade |
| 01:01 | casion | do you have (package-intialize) in your .emacs? |
| 01:01 | duck1123 | I believe so |
| 01:01 | duck1123 | ssh giving me issues, one sec |
| 01:01 | casion | ok |
| 01:03 | duck1123 | I do have package-initialize |
| 01:03 | casion | can you paste the relevant portion of your .emacs? |
| 01:03 | casion | the ac-nrepl had bad docs recently, but it was fixed iirc |
| 01:04 | casion | maybe you somehow picked up that elisp though? |
| 01:04 | duck1123 | which relevant portion? |
| 01:04 | casion | ac-nrepl and auto-complete config |
| 01:06 | duck1123 | well, it's not working even with none of auto-complete set up |
| 01:07 | casion | you remove all of auto-complete config and it still chokes? |
| 01:07 | duck1123 | yes |
| 01:08 | casion | if you clone and clear your emacs.d? |
| 01:08 | casion | and I assume lein repl works fine? |
| 01:09 | casion | and or connecting to lein repl :headless |
| 01:11 | duck1123 | Ok, I just wiped my config, added marmalade, installed clojure-mode and nrepl and it's still doing it |
| 01:12 | casion | lein repl works ok? |
| 01:12 | duck1123 | it says it started the server |
| 01:12 | duck1123 | trying to connect |
| 01:13 | duck1123 | Wrong type argument: integer-or-marker-p, nil |
| 01:14 | casion | are you using emacs 23? |
| 01:14 | duck1123 | GNU Emacs 24.1.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10) of 2012-07-17 on lawrencium, modified by Debian |
| 01:15 | duck1123 | this worked earlier today |
| 01:16 | clj_newb_2345_ | argh |
| 01:16 | casion | only thing I can think of is increasing the timeout or retry limit |
| 01:16 | clj_newb_2345_ | has anyoe in the world gotten lein + swt + osx ot work together? |
| 01:16 | casion | but I don't recall exactly now to do that in lein |
| 01:16 | casion | yes clj_newb_2345, and it's a pain |
| 01:16 | clj_newb_2345_ | I've already passed it -XstartOnFirstThread |
| 01:16 | clj_newb_2345_ | has a jvm-opts |
| 01:16 | clj_newb_2345_ | yet it still bitches about not on main thread |
| 01:16 | duck1123 | but wouldn't that only apply if I was using jack-in? |
| 01:17 | clj_newb_2345_ | casion: do ou have a working project.clj I can copy? |
| 01:17 | casion | duck1123: I don't think so |
| 01:17 | casion | clj_newb_2345: I do not currently |
| 01:17 | clj_newb_2345 | this thing basically looks imposisble |
| 01:17 | casion | that project is currently in a fubar state |
| 01:17 | clj_newb_2345 | i don't even know how to check if a given thread is the main thread |
| 01:17 | casion | and I started to learn seesaw instead |
| 01:18 | clj_newb_2345 | what project |
| 01:18 | clj_newb_2345 | ? |
| 01:18 | clj_newb_2345 | i manually insatlled swt.jar via maven |
| 01:18 | duck1123 | clj_newb_2345: check out seesaw, I beleive he's solved all the annoying bits |
| 01:19 | clj_newb_2345 | i neet swt |
| 01:19 | clj_newb_2345 | in order to embed a webview |
| 01:19 | duck1123 | oh well, I'll fix nrepl later, the wife hasn't seen the new doctor who yet |
| 01:19 | duck1123 | seesaw is a wrapper |
| 01:20 | casion | https://github.com/CMPITG/clojure-swt-examples |
| 01:20 | casion | that is what I followed/worked with getting swt working |
| 01:21 | clj_newb_2345 | that is linux only |
| 01:21 | casion | you have to find the osx swt dependency yourself and make a local repository to pull from |
| 01:21 | casion | at least that's what I did |
| 01:21 | casion | (and it subsequently broke…) |
| 01:26 | clj_newb_2345 | i've done all that |
| 01:26 | clj_newb_2345 | I don't think you've heard me clearly |
| 01:27 | clj_newb_2345 | i've installed swt.jar manually, I've included "-XstartOnFirstThread in jvm-opts, but it still bitches that it's not on mthe main thread |
| 01:32 | clj_newb_2345 | alright; I got swt + clojure working |
| 01:32 | clj_newb_2345 | unfortunately, just not with lein |
| 01:33 | casion | what did you do? |
| 01:37 | McFritzen | clj_newb_2345, do you believe that Flash is the best SC2 player? |
| 01:38 | clj_newb_2345 | ? |
| 01:38 | clj_newb_2345 | I think you have me confused with someone else. |
| 01:38 | clj_newb_2345 | so I currently have swt + clojure working, but I can't use it via lein. |
| 01:38 | clj_newb_2345 | java -cp clojure.jar clojure.main <-- starts a repl. Is there a way to have clojure.jar start out by loading another file instead? |
| 01:39 | clj_newb_2345 | i.e. something like java -cp clojure.jar my-main.clj |
| 01:39 | McFritzen | clj_newb_2345, not at all, I have no idea who you are namely. |
| 01:41 | rlb | clj_newb_2345: java -cp ... clojure.main foo.clj |
| 01:43 | clj_newb_2345 | rlb: I need "-i foo.clj" |
| 01:44 | clj_newb_2345 | http://clojure.org/repl_and_main |
| 01:44 | clj_newb_2345 | now, I need to do one last thing: somehow tell clojure.main to search for class 'foo" in src/foo |
| 01:44 | clj_newb_2345 | rather than "./foo" |
| 01:44 | clj_newb_2345 | what is the option that tells clojure where to search for *.clj files? |
| 01:45 | Sgeo | Do the suggested keybindings for org-mode conflict with nrepl.el or slime? |
| 01:50 | shachaf | Sgeo: Fancy seeing you here! |
| 01:50 | Sgeo | shachaf, I guess you're new to my language hopping and obsession. |
| 01:52 | scottj | Sgeo: Are you planning on doing org-babel? |
| 01:52 | Sgeo | scottj, I don't know what that is |
| 01:54 | clj_newb_2345 | *compile-path* = "classes" |
| 01:54 | clj_newb_2345 | how do I tell clojure hwere to search for *.clj files |
| 01:55 | scottj | Sgeo: I don't think the global org-mode bindings conflict. |
| 01:58 | samrat | the clj-oauth docs seems to be outdated, how do I use it with clj-http instead of clj-apache-http? |
| 02:16 | wei_ | is this the proper place for clojurescript questions? how would I translate "OAuth.SignatureMethod.sign(message, accessor);" to clojurescript? |
| 02:19 | Sgeo | C-u M-x nrepl-jack-in, after I attempt to type the project root, and I press enter, just puts a newline into the minibuffe |
| 02:19 | Sgeo | minibuffer |
| 02:27 | unlink | Why isn't it unspeakably bad practice to use other people's namespaces for their own projects? |
| 02:38 | scottj | Sgeo: you tried opening project.clj and starting it from there and it doesn't work? |
| 02:39 | Sgeo | scottj, hadn't tried that |
| 02:40 | amalloy | unlink: huh? |
| 02:41 | Sgeo | scottj, is that the typical usage? |
| 02:41 | Sgeo | Rather than C-u M-x nrepl-jack-in? |
| 02:41 | Sgeo | Doesn't seem to have worked |
| 02:42 | scottj | Sgeo: idk, I don't use nrepl, was just a guess I thought slime-jack-in behaved that way |
| 02:44 | scottj | Sgeo: I guess start nrepl with lein from terminal and then M-x nrepl to connect |
| 02:45 | scottj | that's what I do (except lein swank and M-x slime-connect) |
| 02:46 | Sgeo | It might actually be easier |
| 02:47 | scottj | I think ritz with slime is very good, but you may run into your own problems there and there are far fewer users to help. but doesn't take long to try. |
| 02:47 | scottj | Sgeo: are you coming from Haskell? what editor did you use there? |
| 02:48 | Sgeo | Mostly gedit (I was on Ubuntu) |
| 02:48 | Sgeo | And sometimes JEdit when I was on Windows |
| 02:48 | Sgeo | (at school) |
| 02:49 | Sgeo | I do want some of the functionality that ritz claims to offer |
| 02:49 | Sgeo | Especially project.clj reloading. And is it offering to allow resuming from an exception? |
| 02:50 | SegFaultAX | Does anyone know anything about high frequency trading? |
| 02:50 | Sgeo | Also, will l the version of SLIME it uses conflict with recommended versions of SLIME if I want to try Common Lisp again? |
| 02:51 | djanatyn | ,(let [seconds 72010, hours (mod seconds 3600), minutes (mod (- seconds (* hours 3600)) 60)] (- seconds (+ (* hours 3600) (* minutes 60)))) |
| 02:51 | clojurebot | 35410 |
| 02:51 | djanatyn | :| I don't understand what I'm doing wrong here |
| 02:51 | scottj | SegFaultAX: anything is pretty broad :) |
| 02:52 | djanatyn | ,(let [seconds 72010, hours (mod seconds 3600), minutes (mod (- seconds (* hours 3600)) 60)] {:hours hours :minutes minutes :seconds (- seconds (+ (* hours 3600) (* minutes 60)))) |
| 02:52 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )> |
| 02:52 | djanatyn | ,(let [seconds 72010, hours (mod seconds 3600), minutes (mod (- seconds (* hours 3600)) 60)] {:hours hours :minutes minutes :seconds (- seconds (+ (* hours 3600) (* minutes 60)))}) |
| 02:52 | clojurebot | {:hours 10, :minutes 10, :seconds 35410} |
| 02:52 | djanatyn | the hours and minutes are right, but I don't know what I'm doing wrong with the seconds |
| 02:52 | SegFaultAX | scottj: I'm cursious if it's possible for a person to get into it, or if it's reserved for large institutions. |
| 02:53 | scottj | Sgeo: ritz uses a specific version of slime that is incompatible with swank-clojure but works with common lisp so long as you use the same version of swank as ritz, I think (which is pretty old) |
| 02:53 | scottj | SegFaultAX: I think it's very hard for an individual to do. |
| 02:54 | scottj | SegFaultAX: because you have to rent servers at the exchanges, and those aren't cheap, and the feed level that you have to get is also very expensive. |
| 02:54 | SegFaultAX | What if I just wanted to do "pretty-fast frequency trading?" |
| 02:54 | scottj | SegFaultAX: btw I've never worked in HFT, so this is all just my impression |
| 02:55 | scottj | SegFaultAX: well you can do day trading, but I think the strats used by HFT require very fast responses (<1ms maybe) |
| 02:56 | SegFaultAX | scottj: Maybe day trading is what I mean. |
| 02:57 | SegFaultAX | scottj: Mostly just algorithmic trading. HFT is probably the wrong word, then. |
| 02:58 | amalloy | djanatyn: i think the hours are only right by coincidence |
| 02:58 | amalloy | (mod seconds |
| 02:58 | amalloy | 3600) doesn't divide by 3600, it gives the remainder |
| 02:58 | scottj | SegFaultAX: it's definitely possible for an individual to make money in that game, but realize that it's super competitive and you're going up against thousands of very experienced opponents in a zero sum game) |
| 02:58 | djanatyn | doh. thanks! |
| 02:59 | amalloy | you want rem, or div; i don't think there's a difference for positive numbers |
| 02:59 | SegFaultAX | scottj: Well, I'm thinking it might be a fun hobby application of FP. |
| 03:00 | SegFaultAX | scottj: A couple thousand is a reasonable margin for me. I'm not looking to make this my day job. |
| 03:01 | SegFaultAX | scottj: I'm working up some prototypes of using core.logic for this sort of thing. |
| 03:02 | scottj | SegFaultAX: interactivebrokers.com is what the small day dtraders use I believe, it has a java api iirc |
| 03:02 | scottj | and a simulation mode |
| 03:04 | scottj | SegFaultAX: there's a wrapper on clojars, not sure how complete it is (probably not very, it's 0.0.1) |
| 03:05 | SegFaultAX | It costs $10k just to open an account?! |
| 03:06 | SegFaultAX | Pft, maybe I should think of a different hobby. |
| 03:07 | SegFaultAX | Oh, $3k for ages 26 or younger. Sweet. |
| 03:17 | scottj | SegFaultAX: out of curiousity, what instruments are you thinking about trading? |
| 03:18 | SegFaultAX | scottj: Umm, pianos, trumpets and clarinets. |
| 03:18 | SegFaultAX | I don't know what you're asking. :) |
| 03:18 | SegFaultAX | Stocks? |
| 03:20 | scottj | yeah that was basically the question |
| 03:20 | SegFaultAX | Well then, stocks. |
| 03:21 | SegFaultAX | scottj: When I was much younger, my dad and I played around with futures. I don't remember much, though. |
| 03:25 | SegFaultAX | Is Scala worth learning? |
| 03:25 | SegFaultAX | It just looks so... ugly. |
| 03:47 | amalloy | SegFaultAX: depends what you've already learned, i suppose. ugly is a terrible reason either way; lots of people think clojure is ugly |
| 03:47 | Sgeo | Can nREPL servers be secured with passwords, or otherwise made safely Internet-accessible? |
| 03:53 | luxbock | http://www.4clojure.com/problem/166 |
| 03:53 | luxbock | could someone help me out with this one? |
| 03:53 | luxbock | "Write a function that takes three arguments, a less than operator for the data and two items to compare." |
| 03:54 | luxbock | I'm confused if the function I |
| 03:55 | luxbock | I'm writing is supposed to use the less than operator for all cases, and ignore the function supplied in the examples, eg. (fn [x y] (< (count x) (count y))) in the second case |
| 03:56 | SegFaultAX | luxbock: But the problem gives you the less-than function to use. |
| 03:58 | amalloy | is it clearer if i switch it to: "three arguments: ..."? |
| 03:59 | luxbock | hmm, not sure if I follow |
| 03:59 | SegFaultAX | luxbock: Do you understand the problem statement? |
| 04:00 | luxbock | not really |
| 04:00 | SegFaultAX | luxbock: Well, we know we're going to receive 3 arguments to our function |
| 04:00 | mpstyler | . |
| 04:00 | SegFaultAX | The first will be a comparator function, and the second/third will be the operands. |
| 04:01 | luxbock | right, so in the first example the first argument is "<", in the second it is "(fn [x y] (< (count x) (count y)))" and so on? |
| 04:01 | SegFaultAX | luxbock: So what might out function signature look like? |
| 04:01 | SegFaultAX | (fn [f a b] ...) perhaps? |
| 04:02 | SegFaultAX | Or (fn [lt a b] ...) if it makes it clearer that it's a less-than function |
| 04:02 | luxbock | yes, I tried fn [f a b] (cond (f a b) :gt approach at first, but that failed for the second example |
| 04:03 | SegFaultAX | What was your full solution? |
| 04:04 | luxbock | hmm, I was doing it yesterday and don't have it typed up anymore |
| 04:04 | luxbock | but I realize it wasn't a working solution |
| 04:04 | SegFaultAX | Well, what are the 3 possible conditions? |
| 04:05 | SegFaultAX | a > b, a < b, a == b |
| 04:05 | luxbock | right |
| 04:05 | SegFaultAX | But we only have the 1 operator |
| 04:05 | SegFaultAX | So how can we derive the other 2? |
| 04:07 | luxbock | oh, is the description saying that I'm not allowed to use > or ==? |
| 04:07 | SegFaultAX | luxbock: They aren't given. |
| 04:07 | luxbock | ah I see |
| 04:07 | SegFaultAX | luxbock: You just have the one, but you need to be able to figure out the other two from that one. |
| 04:08 | luxbock | ok got it, I should be able to do that with cond |
| 04:08 | luxbock | or do I need some other trickery_ |
| 04:08 | SegFaultAX | luxbock: Try it. |
| 04:09 | luxbock | alright |
| 04:14 | SegFaultAX | luxbock: Any luck? |
| 04:15 | luxbock | not quite, this problem is making me feel stupid |
| 04:16 | SegFaultAX | luxbock: Can you solve just the first one? |
| 04:20 | luxbock | well for that one I can just use fn [f a b] (cond (< b a) :gt) and it passes the first example but obviously none of the others |
| 04:20 | SegFaultAX | Why don't you use f if you know it's your less-than function? |
| 04:21 | luxbock | oh right |
| 04:22 | mpan | is there a built-in for "shelling out"? i.e. I want to execute some string in the shell and get back all its output as a string |
| 04:22 | mpan | would prefer not to introduce a heavier dependency |
| 04:23 | luxbock | SegFaultAX, got it now |
| 04:23 | luxbock | thanks |
| 04:25 | luxbock | looks like most people solved it by using "if" rather than "cond", but I think "cond" makes for more readable code |
| 04:25 | luxbock | I guess it's pretty much the same thing |
| 04:25 | mpan | oh, dunno how I missed it, but there's almost the exact name |
| 04:25 | SegFaultAX | luxbock: I like cond better there too. |
| 04:28 | mpan | in case anyone was wondering how to do the same: http://richhickey.github.com/clojure/clojure.java.shell-api.html , dunno how I missed it the first time |
| 04:28 | lazybot | Nooooo, that's so out of date! Please see instead http://clojure.github.com/clojure/clojure.java.shell-api.html and try to stop linking to rich's repo. |
| 04:28 | mpan | even better |
| 04:29 | mpan | wow that bot's good |
| 04:29 | mpan | (inc lazybot) |
| 04:29 | lazybot | ⇒ 7 |
| 05:04 | wunki | anyone have a clue why I get the following stacktrace when I try to jump to definition in Emacs (nrepl): https://gist.github.com/ce48e26f08d9c9a7806f ? |
| 05:29 | piranha | Hi all. Does anybody have some insight into how well ClojureScript will perform? Especially given that I have an idea to store all data my application needs in a single atom (which means I could have quite a lot of update-in/assoc-in going deep for few levels). |
| 05:38 | mpan | can anyone explain at a high level how "going up the tree" works in zippers? |
| 05:42 | Sgeo | The zipper stores not just what's below you, but also what's above you... kind of |
| 05:42 | Sgeo | The entire structure is stored in a zipper, the only difference between a zipper and a regular structure, conceptually, is that with a zipper, it's more efficient to access the "location" |
| 05:43 | mpan | like a "how I got here"? |
| 05:43 | Sgeo | Pretty much. (Please note that I may be mistaken in parts of my explanation) |
| 05:43 | mpan | because the underlying structure I'm expecting to feed in has an innate concept of "down" but not "up" |
| 05:43 | Sgeo | Try actually displaying a zipper at the REPL |
| 05:44 | ludston | ? Wouldn't Zippers just be doubly linked lists? |
| 05:45 | Sgeo | Well, with a zipper, you need "where you are" to be the most efficient thing to access. |
| 05:45 | Sgeo | There's no mutability involved |
| 05:45 | Sgeo | hmm, what to do |
| 05:46 | Sgeo | It's more like gluing together two lists, than a doubly-linked lists |
| 05:46 | ludston | You mean like an iterator on a node of a doubly linked list? |
| 05:46 | Sgeo | Two singly-linked lists |
| 05:46 | Sgeo | (But that analogy doesn't do well with trees, just what zippers are like on lists) |
| 05:46 | Sgeo | &(require '[clojure.zip :as zip]) |
| 05:46 | lazybot | ⇒ nil |
| 05:47 | Sgeo | &(zip/vector-zip [:a :b :c :d :e]) |
| 05:47 | lazybot | ⇒ [[:a :b :c :d :e] nil] |
| 05:47 | mpan | huh? the bot lets you mess with its namespaces? |
| 05:47 | Sgeo | &(-> (zip/vector-zip [:a :b :c :d :e])) zip/down |
| 05:47 | lazybot | ⇒ [[:a :b :c :d :e] nil] |
| 05:47 | Sgeo | &(-> (zip/vector-zip [:a :b :c :d :e]) zip/down) |
| 05:47 | lazybot | ⇒ [:a {:l [], :pnodes [[:a :b :c :d :e]], :ppath nil, :r (:b :c :d :e)}] |
| 05:48 | Sgeo | Uh... ok, so the first element is the value where we are. The next is a map, telling us what's to the left, what's to the right, and ...I guess what's above us? |
| 05:49 | Sgeo | &(-> (zip/vector-zip [:a :b :c :d :e]) zip/down zip/right) |
| 05:49 | lazybot | ⇒ [:b {:l [:a], :pnodes [[:a :b :c :d :e]], :ppath nil, :r (:c :d :e)}] |
| 05:49 | mpan | huh? |
| 05:49 | mpan | where's "up"? |
| 05:49 | Sgeo | You can see that now that we moved right, the first element is b, and in the second element, keys :l and :r give us what's to our left and right |
| 05:49 | Sgeo | mpan, I guess that's in the :pnodes key |
| 05:49 | ludston | Okay, so it's a tree where nodes have pointers to their root. |
| 05:50 | ludston | Why's it called a zipper? |
| 05:50 | mpan | is this like, the tree that has :a through :e as direct children of the root? |
| 05:51 | Sgeo | It contains sufficient information to easily access the current element, almost as easily the nearby elements, and ultimately, enough information to move around in any direction |
| 05:52 | Sgeo | &(-> (zip/vector-zip [[:a :b :c] [:d :e :f]]) zip/down zip/down) |
| 05:52 | lazybot | ⇒ [:a {:l [], :pnodes [[[:a :b :c] [:d :e :f]] [:a :b :c]], :ppath {:l [], :pnodes [[[:a :b :c] [:d :e :f]]], :ppath nil, :r ([:d :e :f])}, :r (:b :c)}] |
| 05:52 | mpan | kind of the illusion of imperative moving? |
| 05:52 | mpan | that's pretty cool |
| 05:52 | Sgeo | mpan, yeah, that's a good way to put it, I ... think |
| 05:53 | Sgeo | Each direction movement can be done in O(1) time (I think) |
| 05:54 | Sgeo | &(-> (zip/vector-zip [:a :b :c :d :e]) zip/down zip/right zip/path) |
| 05:54 | lazybot | ⇒ [[:a :b :c :d :e]] |
| 05:54 | Sgeo | &(-> (zip/vector-zip [[:a :b :c] [:d :e :f]]) zip/down zip/down zip/path) |
| 05:54 | lazybot | ⇒ [[[:a :b :c] [:d :e :f]] [:a :b :c]] |
| 05:54 | Sgeo | ...I have no idea about the internal structure of this thing |
| 05:54 | Sgeo | There may be some good Haskell guides to this stuff, but they're in terms of Haskell |
| 05:59 | Raynes | Sgeo: Do you sleep? |
| 06:24 | Sgeo | Raynes, not at sane times. |
| 06:24 | Raynes | Sgeo: Word. |
| 06:24 | Sgeo | It is currently 6:20 AM |
| 06:25 | Sgeo | My time |
| 06:27 | mpan | is there a way to pass to map the current fn I'm in [analogous to recur]? |
| 06:28 | mpan | it's for a function that recursively converts a tree-like structure to a string by some domain logic |
| 06:34 | Raynes | mpan: Just pass it in? |
| 06:35 | Raynes | I don't understand your problem. |
| 06:35 | mpan | I would like to pass it in a way that doesn't consume stack |
| 06:35 | mpan | although, now I'm beginning to wonder if that's an actual concern here |
| 06:43 | luxbock | can anonymous functions call themselves? |
| 06:44 | Raynes | Yes. |
| 06:44 | luxbock | how? |
| 06:44 | clojurebot | with style and grace |
| 06:44 | luxbock | heh |
| 06:44 | Raynes | &(fn foo [x] (foo x)) |
| 06:44 | lazybot | ⇒ (serializable.fn/fn foo [x] (foo x)) |
| 06:44 | Raynes | lol |
| 06:44 | Raynes | I wonder who require'd serializable-fn. |
| 06:45 | Raynes | $login |
| 06:45 | lazybot | You've been logged in. |
| 06:45 | Raynes | $reload |
| 06:45 | lazybot | Reloaded successfully. |
| 06:45 | Raynes | &(fn foo [x] (foo x)) |
| 06:45 | lazybot | ⇒ #<sandbox103110$eval106402$foo__106403 sandbox103110$eval106402$foo__106403@3950bb> |
| 06:46 | Sgeo | luxbock, even without that bit of syntax, there's a thing called the Y-combinator |
| 06:46 | Sgeo | Which would allow for it |
| 06:46 | mpan | I keep thinking I need something trampoline-like /outside/ the map |
| 06:46 | luxbock | yeah I read about Y-combinator once and it sounded really complicated |
| 06:46 | Sgeo | And even if that didn't exist, which it does, there's also some possible macrology |
| 06:47 | mpan | since F kind of depends on mapping F onto its inputs |
| 06:47 | luxbock | but yeah I forgot I could name the anonymous function, which in itself sounds weird, because wouldn't that make the function not anynymous, since now it has a name? |
| 06:47 | luxbock | or is that just a matter of semantics |
| 06:47 | mpan | but the name only exists inside? |
| 06:48 | Raynes | It's anonymous to the outside world. |
| 06:48 | luxbock | I see |
| 07:01 | Sgeo | https://github.com/pallet/ritz/tree/develop/swank |
| 07:01 | Sgeo | I don't understand the jack-in thing. |
| 07:02 | Sgeo | It says SLIME cannot be installed. But what use is SWANK without a UI like SLIME? What does jacking-in do, exaclly, without SLIME? |
| 07:12 | Sgeo | :( M-x pacakge-install-file apparently requires tar? |
| 08:06 | mpenet | yup |
| 08:07 | Sgeo | Am I going to end up bouncing between cursing at emacs and cursing at Eclipse? |
| 08:08 | mpenet | well you can continue to bounce between editors and curse after 5 min everytime, or do it properly and be done with it |
| 08:08 | mpenet | I don't think installing tar on windows is so hard |
| 08:41 | samrat | how do I sign API requests with clj-http? could someone provide any examples(I'm using clj-oauth) |
| 08:46 | broquaint | Sgeo: There's always Gow (Gnu on Windows) for tar et al - https://github.com/bmatzelle/gow/downloads |
| 08:46 | mpenet | reduce-kv doesn't work on java HashMaps (or even Maps I think) :( any good reason for that? |
| 08:51 | broquaint | mpenet: Because they're not native clojure types so won't have the necessary interface, wouldn't take much to get it working though I imagine. |
| 08:51 | Sgeo | broquaint, I found a tar, that worked, but the install had some problems |
| 08:53 | mpenet | yup figured that much, I was wondering if that would justify an issue or not, if this was by design |
| 08:55 | broquaint | It's just the nature of interop I suppose. |
| 08:56 | broquaint | Sgeo: FWIW I installed Gow + Emacs and found stuff Just Worked. |
| 09:44 | green_transistor | well this place is quiet |
| 09:46 | ludston | green_transistor: If you ask a question, I'll say hi. |
| 09:47 | green_transistor | whats up with reducers in clojure? :) |
| 09:47 | ludston | green_transistor: hi |
| 09:47 | green_transistor | indeed :) |
| 09:48 | ludston | green_transistor: What's a reducer? |
| 09:49 | green_transistor | There was a talk by hickey on how reducers speed up some list operations. http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html |
| 09:49 | green_transistor | so he says map will be implemented using reduce.. i pretty much lost him there |
| 09:51 | ludston | green_transistor: We have a cruel god. |
| 09:52 | green_transistor | haah in what context? |
| 09:53 | ludston | green_transistor: I mean the guy that writes Clojure, using his smarts to bend our minds. |
| 09:53 | green_transistor | ah subtle. his stuff is pretty radical :) |
| 09:56 | green_transistor | And why does *inferior-lisp-mode* suck so bad on emacs? |
| 09:58 | ludston | green_transistor: That's the common lisp mode isn't it? Nothing to do with clojure... |
| 10:06 | green_transistor | well it sucks for elisp :) no auto-complete |
| 10:19 | megamind | wat do you think of clojure ? |
| 10:21 | ivan | megamind: #clojure might be a little biased. in the right way. |
| 10:22 | Scriptor | are you conidering learning it, megamind? |
| 10:22 | megamind | it's my intend to ask for positive things here |
| 11:01 | duck1123 | oh well, it looks like I'm back to swank for the time being |
| 11:57 | technomancy | it's good |
| 12:01 | SrPx | Hey guys trying to install clojure again. This time I got leiningen 2.0. What is again that script you told me to download to integrate clojure with vim ? clojure leph or something |
| 12:02 | technomancy | SrPx: probably lein-tarsier? |
| 12:02 | SrPx | technomancy: yes eh, far from leph heh. Thanks |
| 12:03 | gfredericks | all new languages are at best an inspiration for a new clojure library: discuss |
| 12:03 | technomancy | well I don't actually know anything about vim, so don't thank me till it works |
| 12:05 | hiredman | gfredericks: the presentation coming up is another lisp |
| 12:07 | gfredericks | hiredman: oh crap |
| 12:10 | SrPx | new-host-8:bundle srpx$ lein vimclojure Couldn't find project.clj, which is needed for vimclojure |
| 12:10 | SrPx | any idea ? |
| 12:11 | SrPx | Oh I guess I should cd to the folder I want my project in, create it with lein new and start lein vimclojure from there? Is that it? |
| 12:11 | SrPx | let me see |
| 12:13 | ToxicFrog | Yeah, that message is telling you that you actually need a lein project before you can use lein vimclojure |
| 12:13 | ToxicFrog | So, exactly as you said |
| 12:22 | SrPx | Thanks |
| 12:22 | SrPx | I'm almost there, getting just this error when I open a project: |
| 12:23 | SrPx | http://o7.no/O2LRzD telling ng is misconfigured, I'm not sure what I have done, just created a project on -/Clojure/my-stuff |
| 12:27 | hiredman | I call "meh" on Plan |
| 12:27 | redline6561 | +1 |
| 12:28 | SrPx | worked, thanks ! (= |
| 12:28 | swarmer | what's Plan? |
| 12:28 | gfredericks | a friend of mine in there says something similar: optional parens + confusing type system |
| 12:28 | gfredericks | swarmer language that was discussed at EML |
| 12:28 | redline6561 | wow |
| 12:28 | gfredericks | EMC |
| 12:28 | gfredericks | ELC |
| 12:28 | gfredericks | emerging languages camp |
| 12:30 | gfredericks | I'm trying to make a serious effort to learn haskell while I'm here |
| 12:45 | samrat | having some Noir trouble: https://www.refheap.com/paste/5249, the session seems to somehow get cleared up. how do I prevent that? |
| 13:25 | Hodapp | apparently, if you enter something like (iterate (fn [x] (+ x 1)) 1) in the REPL in CCW, it tries to make the entire list un-lazy to show it to you |
| 13:26 | Hodapp | ,(iterate (fn [x] (+ x 1)) 1) |
| 13:26 | clojurebot | (1 2 3 4 5 ...) |
| 13:26 | Hodapp | hrmph |
| 13:30 | Hodapp | does Emacs handle lazy sequences okay? |
| 13:30 | casion | I thought lazy sequences were always forced in the repl |
| 13:30 | casion | unless you have some specific wrapping |
| 13:31 | mpenet | Hodapp: same with emacs/slime |
| 13:31 | Hodapp | mpenet: same as in same as CCW, or same as clojurebot? |
| 13:32 | casion | clojurebot forces the lazy seq too |
| 13:32 | mpenet | Hodapp: same as CCW |
| 13:32 | Hodapp | casion: but right here it's only bothered with 5 elements |
| 13:33 | mpenet | probably the clojail doing its magic |
| 13:33 | Hodapp | ahh, hmm |
| 13:33 | casion | I believe so |
| 13:33 | Hodapp | I think it was maybe just SBCL or CMUCL or something that showed lazy sequences un-forced in its REPL |
| 13:33 | mpenet | I wouldn't know |
| 13:34 | jkkramer | Hodapp: (set! *print-length* 103) |
| 13:34 | Hodapp | oooh |
| 13:34 | jkkramer | also, *print-level* |
| 13:35 | Hodapp | thanks, good to know |
| 13:42 | rich_ | Hi I'm pretty new to Clojure but I'm thinking of using it for a project in college. I'm wondering is there any tools for designing applications like class diagrams for OO or is stuff like that considered redundant? |
| 13:56 | firesofmay | xeqi, hey, is there a way to turn off lein-pedantic for a given project? |
| 13:57 | Hodapp | hmm... wondering if I should actually try to make a lazy object such that (tree child) equals tree, or just not to bother |
| 14:05 | Hodapp | since I've also emerged with some annoying mutually recursive cases |
| 14:05 | Hodapp | where I might just have to store a reference to something rather than trying to use it directly, bleah |
| 14:08 | Hodapp | this is a case where statefulness almost makes things easier 9_9 |
| 14:50 | xeqi | firesofmay: you could comment it out of your profiles.clj; or setting :pedantic :warn in your project.clj will make it warn only |
| 14:50 | firesofmay | xeqi, yeah I commented it out for now. thanks :) |
| 14:51 | xeqi | thats what I do, just comment/uncomment as needed |
| 14:51 | jro__ | I've a function "rebuild-index". I want to run this in background, and only print the result of the evaluation to the log when it finishes, what is the correct way to do this. Not creating a thread, I suppose. |
| 14:51 | technomancy | `lein with-profile pedantic some-task` |
| 14:52 | Hodapp | Here is a clue-by-four. Please hit me with it for thinking that a good first project with Clojure would be a context-free graphics language that requires mutual recursion. |
| 14:52 | xeqi | technomancy, firesofmay: haha, or that |
| 14:53 | xeqi | jro__: (future (logger/log (rebuild-index))) ? |
| 14:53 | firesofmay | technomancy, interesing. thanks |
| 14:53 | firesofmay | interesting* |
| 14:53 | technomancy | firesofmay: not that it exists, but if you move it from the :user profile to the :pedantic profile it would work |
| 14:54 | technomancy | plus you could add :aliases {"pedantically" ["with-profile" "pedantic"]} |
| 14:54 | jro__ | xeqi: thanks. Future dispatch that to a threadpool, which does not interfere with existing threads that are serving http threads? |
| 14:54 | firesofmay | technomancy, okay. |
| 14:57 | jro__ | Programming Clojure / Emerick index points to me that "future" is something related to "ClojureScript", "ClojureCLR", "Heroku", "Overtone"... :-) |
| 14:58 | cemerick | jro__: Take a look at the entry for DSL :-P |
| 14:58 | cemerick | The index was one place that we didn't have a hand in. |
| 14:58 | xeqi | jro__: it dispatches to the agent send-off pool, so I don't expect it to interfere with other threads |
| 15:00 | jro__ | cemerick: lol DSL -> (Digital Subscriber Line) versus Korma, 500 |
| 15:01 | jro__ | but the content of the book is good! Thanks, if you were involved with it. |
| 15:02 | cemerick | jro__: I'm the 'Emerick' part. :-P |
| 16:02 | cheburaksha | I'm trying to install Leiningen 2 on windows, so far not so good |
| 16:02 | cheburaksha | Exception in thread "main" java.io.FileNotFoundException: Could not locate leiningen/core__init.class or leiningen/core.clj on classpath: |
| 16:03 | technomancy | cheburaksha: some code is expecting lein1 |
| 16:07 | cheburaksha | technomancy: how did you determine that? inside the leiningen-2.0.0-preview10-standalone.jar there is a leiningen/core.clj |
| 16:09 | RonnieDk | cheburaksha: I installed Leiningen on Windows a few days back without any issues |
| 16:10 | technomancy | cheburaksha: where did you get that jar? core.clj hasn't existed since 1.x. |
| 16:14 | cheburaksha | technomancy: actually you're right! there is no core.clj in that folder. what i did was replace the version in the lein.bat file from from 1.5 to 2.0.0-preview10, and ran the bat file |
| 16:16 | technomancy | yeah, that's definitely not going to work |
| 16:20 | cheburaksha | RonnieDk: did you install it using cygwin or cmd? |
| 16:20 | cheburaksha | im doing it the cmd way, not a lot of info on the web for installing leiningen2 that way |
| 16:20 | RonnieDk | cheburaksha: The cmd |
| 16:20 | RonnieDk | cheburaksha: you're using the self-installer, right? |
| 16:23 | RonnieDk | cheburaksha: basically downloading wget manually and putting it in the current path, and they running the self-installer, if I remember correctly |
| 16:23 | cheburaksha | i think so. unpack v1.5, add to PATH, modify lein.bat for 2.0.0, run "lein self-install", it downloads, run "lein", get the error |
| 16:23 | RonnieDk | cheburaksha: modify lein? Why not download from github? |
| 16:23 | technomancy | ...? |
| 16:24 | RonnieDk | cheburaksha: you should get the latests from here: https://raw.github.com/technomancy/leiningen/preview/bin/lein |
| 16:26 | technomancy | are there programs where you can do stuff like that and it would actually work? |
| 16:32 | RonnieDk | cheburaksha: Oops, wrong link. That's not the DOS cmd file. Add .bat at the end |
| 16:34 | cheburaksha | RonnieDk: great! the one in the 1.5.2 distro was the latest i could find. is there a special way to navigate to the link you posted? |
| 16:35 | RonnieDk | wget the link |
| 16:37 | RonnieDk | technomancy: How come you don't link to the bat file on the github page? |
| 16:38 | cheburaksha | that's what im asking, it's like an underground link, hidden from unsuspecting noobs |
| 16:38 | hiredman | technomancy: is away from his computer, but I imagine it is because he wants to stay as far as possible from supporting lein on windows |
| 16:40 | cheburaksha | and if you go to the directory above, it doesn't exist. weird |
| 16:40 | RonnieDk | c |
| 16:41 | RonnieDk | cheburaksha: If you navigate to the folder where lein (the bash version) is you discover that bat file. That's how I found it |
| 16:43 | RonnieDk | cheburaksha: https://github.com/technomancy/leiningen/tree/master/bin |
| 16:45 | cheburaksha | oh, i c. cool, thanks :) |
| 16:45 | technomancy | RonnieDk: it is linked from the readme |
| 16:45 | RonnieDk | cheburaksha: So if you go with the bat file and setup emacs with marmelade, I haven't had any issues using Windows |
| 16:47 | RonnieDk | technomancy: Ah, yes. Sorry |
| 16:52 | aib | what's the syntax for referring to a static function? (let [trunc #((if (< % 0) Math/ceil Math/floor) %)] (trunc -1.5)) |
| 16:54 | broquaint | Yes? http://clojure.org/java_interop |
| 16:54 | mpan | is there another name to use for passing + as a fn that doesn't confuse ccw+eclipse? |
| 16:55 | aib | broquaint: => Math/floor ;CompilerException java.lang.RuntimeException: Unable to find static field: floor in class java.lang.Math, compiling:(NO_SOURCE_PATH:1) |
| 16:58 | mpan | is there a way to partially apply a macro? |
| 16:58 | mpan | (that sounds so strange to ask) |
| 16:58 | technomancy | unfortunately no; macros aren't really first-class |
| 16:58 | mpan | what's the closest work-around? |
| 16:59 | mpan | this is what I would have liked to write: (def soln-count (partial tree-reduce (constantly 1) +)) |
| 16:59 | mpan | where tree-reduce is a macro I need to fix |
| 17:01 | mpan | would apply help? |
| 17:02 | aib | mpan: maybe another macro? |
| 17:02 | mpan | aib: hm? |
| 17:02 | technomancy | it's best to implement the bulk of your macro in a function, then make the macro a trivial wrapper around the function |
| 17:02 | AimHere | Another macro? That's one of those 'Now he has two problems' solutions? ;) |
| 17:03 | aib | yeah. I'd go for nth-order functions myself |
| 17:03 | mpan | currently, the macro substitutes 2 functions into place in an otherwise constant structure |
| 17:03 | mpan | this is what I currently have (by far not working): https://www.refheap.com/paste/5257 |
| 17:04 | mpan | what's the recommended way to do this? |
| 17:05 | hiredman | there is no reason for that to be a macro |
| 17:05 | hiredman | write it as a function |
| 17:06 | mpan | oh, good point |
| 17:06 | mpan | I'm confused about my train of thought that led here, then |
| 17:06 | mpan | at some point earlier, I did think to myself I couldn't get what I wanted from just higher order functions |
| 17:06 | mpan | thank you |
| 17:13 | mpan | how can I randomly select a node from a tree? the two properties I'd ideally like to have are: traverses tree only once, gives the location not just the value of the node (because I need to modify the subtree there) |
| 17:13 | jro__ | I've two macros: (defmacro json-response [data & [status]] `(try .. (catch Exception #e ...)) and (defmacro is-authenticated? [cookies action] `(try ... (catch Exception #e ...). The exception part is similar in both, but I cannot reduce to one (defmacro with-exceptions [action] `(try ~action ...) because varargs of action. |
| 17:14 | mpan | like, doing it recursively works, but every node at depth d gets hit d times |
| 17:14 | jro__ | I've tried (defmacro with-exceptions [action] `(try ~action (catch Exception e#)... but I end up to arity problems. |
| 17:15 | casion | mpan: are you using zippers? |
| 17:16 | mpan | not currently but considered the possibility I might end up needing them |
| 17:17 | mpan | I guess I should mention: the per-node pmf calculation is more expensive than traversing nodes, so that's the main thing I want to avoid |
| 17:18 | casion | how would you like the distrobution to occur? |
| 17:18 | mpan | uh, not sure, but the current plan is |
| 17:19 | mpan | pass in a probability mass generating function, and weighted according to the mass over total mass |
| 17:19 | mpan | or, perhaps, just uniform |
| 17:19 | broquaint | aib: Right, yeah, the field/method distinction is annoying, you'll probably need another layer of indirection :/ |
| 17:19 | casion | mpan: I assume you don't know the depth of the current node? |
| 17:20 | aib | I'll make do with #(Math/floor %) for now :/ |
| 17:20 | mpan | not unless I specifically make a note to know |
| 17:20 | mpan | as in, I'm always starting this computation at the root |
| 17:21 | casion | you could just create a collection of 'random' traversal functions |
| 17:21 | casion | but that does assume you know the depth to allow for a distribution towards the middle of the tree |
| 17:22 | mpan | the tree is likely to be terribly imbalanced |
| 17:22 | mpan | so local decision-making is risky |
| 17:23 | jro__ | I would like to have something generic: (defn wrapped-json-exceptions [& args] (with-exceptions (apply json-response args))) |
| 17:24 | strax | hey guys, how do you change a character at a certain index in a string? |
| 17:25 | casion | mpan: I think you have to simply traverse the tree with an arbitrary/random termination point |
| 17:26 | mpan | the question is how to get a uniform or per-node probability mass |
| 17:26 | mpan | in a way that doesn't hit every node at depth d a total of d times |
| 17:26 | casion | I can think of ways to do it if you have an implicitly 'flat' tree (like an array indexed tree in C) |
| 17:27 | mpan | I'm trying to think (from domain knowledge) the max reasonable depth |
| 17:28 | casion | if you have a way of a way of treating the tree, or a branch as flat then you can get uniform distribution |
| 17:28 | casion | maybe using zip/next to an arbitrary termination? |
| 17:29 | mpan | I mean, suppose I wish to explicitly flatten it |
| 17:29 | mpan | how would I preserve the ability to go back in and change the subtree? |
| 17:29 | jro__ | strax: catenating a string from beginning to CharAt, then charAt, and then appending |
| 17:30 | casion | mpan: with zippers you can store a loc, or do a depth first walk |
| 17:31 | casion | but the former doesn't really help if you've explicitly flattened it, and the latter removes the need to |
| 17:31 | mpan | the first part sounds like it |
| 17:31 | mpan | thank you |
| 17:49 | mpan | I'm at a breakpoint inside a function in eclipse-ccw; how do I see the args? |
| 17:50 | mpan | or the local bindings as I make them? or the intermediate values of subexprs? |
| 17:50 | mpan | I have no idea what I did but they started showing up o_o |
| 17:53 | Raynes | mpan: I was going to suggest you try praying.' |
| 17:54 | mpan | Raynes: it may have been I was at the edge of it and not actually IN the function |
| 17:58 | lpvb | Is there good autocomplete for clojure |
| 18:01 | technomancy | lpvb: sure; lein repl in 2.x has it |
| 18:02 | lpvb | I mean, autocomplete for vim |
| 18:02 | lpvb | sorry |
| 18:05 | black_joe | I'm getting an error relating to java.lang.String when I try to run a function called "getBetween". |
| 18:05 | black_joe | This is the offending line: (let [x (doto string (.substring 0 (+ 1 (.indexOf charBetween))))] |
| 18:06 | black_joe | It says there is no matching field named indexOf for class String. |
| 18:06 | black_joe | But there obviously is. |
| 18:07 | raek_ | black_joe: 'doto' won't add the "string" symbol to the .indexOf call |
| 18:07 | hiredman | are you should it said class String? |
| 18:07 | hiredman | and are you sure charBetween is a char? |
| 18:07 | raek_ | ,(macroexpand-1 '(doto string (.substring 0 (+ 1 (.indexOf charBetween)))) |
| 18:07 | metellus | "doto string" will insert string into consecutive forms, not nested ones |
| 18:07 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 18:07 | raek_ | ,(macroexpand-1 '(doto string (.substring 0 (+ 1 (.indexOf charBetween))))) |
| 18:07 | clojurebot | (clojure.core/let [G__54 string] (.substring G__54 0 (+ 1 (.indexOf charBetween))) G__54) |
| 18:08 | lpvb | which book is better for someone who knows a bit of haskell and java: joy of clojure or programming clojure? |
| 18:08 | black_joe | I am sure that it is String. Not that it is a char. |
| 18:08 | black_joe | Let me just make sure. |
| 18:09 | raek_ | black_joe: so in this case I would just write (let [x (.substring string 0 (inc (.indexOf string char-between)))] ...) |
| 18:09 | black_joe | It also fails with a character. |
| 18:09 | black_joe | Same reason. |
| 18:10 | metellus | black_joe: the problem is that that's not how doto works |
| 18:10 | raek_ | black_joe: doto only inserts "string" into the outermost call |
| 18:10 | raek_ | (.indexOf charBetween) remains the way it is |
| 18:11 | black_joe | Ah. I consulted the doto documentation and the wording was a bit confusing. That explains it. |
| 18:11 | antonaut | Hi! I just started with clojure in emacs, and I wonder how I can load a file into a repl so I can play with it? I think i've got everything setup correctly (with swank-clojure and slime), because after running 'M-x clojure-jack-in' I can type 'slime' to get a repl. Its really only the loading part that's bugging me... |
| 18:11 | raek_ | and you get an error because you try to call (.indexOf charBetween) instead of (.indexOf string charBetween) |
| 18:11 | black_joe | I thought it took and object and ran every other method on that object. |
| 18:13 | technomancy | antonaut: the swank-clojure readme has a good overview of the commands it provides |
| 18:14 | antonaut | technomancy: thank you! |
| 18:16 | technomancy | sure |
| 18:18 | raek_ | black_joe: it adds the object to each call in a sequence of calls, not to arbitrarily nested calls |
| 18:18 | raek_ | you usually use it for methods that have side-effects |
| 18:19 | raek_ | ,(doto (ArrayList.) (.add 1) (.add 2) (.add 3)) |
| 18:19 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: ArrayList, compiling:(NO_SOURCE_PATH:0)> |
| 18:19 | raek_ | black_joe: also, it returns the object and not the result of any of the method calls |
| 18:20 | black_joe | Well I think I'll just try to do this with sequences instead of strings then. |
| 18:20 | raek_ | the above example expands into (let [foo (ArrayList.)] (.add foo 1) (.add foo 2) (.add foo 3) foo) |
| 18:20 | raek_ | black_joe: there's no reason to abandon the String approach... |
| 18:21 | raek_ | but you don't need doto in order to make a simple method call |
| 18:21 | black_joe | Well, even with the code you supplied it still fails. So I am going for an alternative. |
| 18:22 | jhowarth | With korma, is it possible to order by the count of an association? |
| 18:23 | raek_ | ,(let [s "foo bar"] (.substring s 0 (inc (.indexOf s " "))) |
| 18:23 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 18:23 | raek_ | ,(let [s "foo bar"] (.substring s 0 (inc (.indexOf s " ")))) |
| 18:23 | clojurebot | "foo " |
| 18:23 | raek_ | black_joe: ^ |
| 18:23 | raek_ | black_joe: it's probably easier to use regexes here, though |
| 18:24 | black_joe | Regexes are on my list. I just haven't learned them well enough. |
| 18:26 | raek_ | but it depends on what you are trying to do |
| 18:27 | black_joe | In this context it is used to remove an internal comment from commands a bot reads from a file. |
| 18:28 | black_joe | The file itself uses a LOT of markup, so I will probably learn regex before the rewrite is through. |
| 18:30 | nybbles_ | hey how do i use clojurescript libraries with leiningen? I am trying to use jayq, but i get "goog.require could not find: jayq.core " errors :| |
| 18:32 | mpenet | nybbles_: are you using lein-cljsbuild ? |
| 18:33 | nybbles_ | yuppp |
| 18:34 | mpenet | and jayq is in the list of dependencies of course? |
| 18:35 | nybbles_ | yes in project.clj, under :dependencies |
| 18:35 | nybbles_ | although thats strange, its in there with all the clj deps too |
| 18:36 | mpenet | if you just added it and are using lein cljsbuild auto you might need to relaunch it, also try lein cljsbuild clean before |
| 18:36 | nybbles_ | ah okay |
| 18:36 | nybbles_ | will try the clean thing |
| 18:37 | nybbles_ | great, thanks :) |
| 18:37 | nybbles_ | clean/auto did it |
| 18:37 | mpenet | you're welcome |
| 18:52 | mpan | is there a way to unpack args, or should I go and use apply? |
| 18:54 | firesofmay | what is the correct way to add :dev-dependencies in lein2? I am getting error trying to add Marginalia to my project by doing :profiles {:dev {:dependencies [[midje "1.4.0"] |
| 18:54 | firesofmay | [lein-marginalia "0.7.1"]]}}) |
| 18:55 | firesofmay | :profiles {:dev {:dependencies [[midje "1.4.0"] |
| 18:55 | firesofmay | [lein-marginalia "0.7.1"]]}}) |
| 18:55 | technomancy | firesofmay: :plugins rather than dependencies |
| 18:56 | technomancy | for lein-marginalia anyway |
| 18:56 | firesofmay | technomancy, oh so I should add it to my user profiles? |
| 18:59 | firesofmay | technomancy, thanks. that worked. |
| 19:10 | firesofmay | Hi, when I do lein marg, I ge this : "WARNING: conj-dependencies is deprecated." What does it mean? |
| 19:11 | firesofmay | I get* this |
| 19:15 | djanatyn | can I add lazytest to my profiles.clj, so I can use it for every project without having to add it to the project.clj? |
| 19:20 | mpan | could someone look over https://www.refheap.com/paste/5259 please? tree-reduce isn't working properly; if I give a nested tree to soln-str, the leaves don't get passed to the function |
| 19:22 | mpan | it ends up str'ing it directly instead of passing it through the argument fn first |
| 19:27 | mpan | seems to me it's behaving differently with the same args depending of called directly or recursively, but that must be my imagination |
| 19:44 | lpvb | does the eclipse public license make all clojure projects EPL licensed? |
| 19:57 | pandeiro | anyone know how to deactivate special quote behavior with clojure.data.csv ? |
| 20:13 | tjohnson | ... |
| 20:23 | black_joe | I am having trouble making (or finding) a function that tests a string to see if it contains a character. |
| 20:24 | black_joe | (.contains) does not work on char's. And (str) turns the char into a lazy-sequence, so that doesn't work either. |
| 20:27 | Bronsa | ,(some #{\a} "asd") |
| 20:27 | clojurebot | \a |
| 20:27 | Bronsa | ,(.contains "asd" (str \a)) |
| 20:27 | clojurebot | true |
| 20:27 | Bronsa | you choose |
| 20:28 | black_joe | (str c) (where c is a character) returned a lazy sequence when I used it. I would have used that way. |
| 20:29 | Bronsa | that shouldn't be the case, try to check whether c is really a char |
| 20:31 | pandeiro | is there an easy way to use a destructuring vector _and_ get bind all args to one symbol? |
| 20:32 | pandeiro | ah nvm :as works fine |
| 20:32 | amalloy | black_joe: (str x) never returns a lazy sequence for any x |
| 20:33 | amalloy | (str some-lazy-seq) does return a string containing "LazySeq", but it's still a strong |
| 20:34 | black_joe | Bronsa and amalloy: It does indeed work. I think the problem was that let created a lazy sequence before it was turned into a string for some reason. |
| 20:34 | Bronsa | that'd be the case if you map'ed over the string |
| 20:35 | black_joe | The exact scenario used split-at. |
| 20:40 | tjohnson2059 | . |
| 20:46 | black_joe | Now this is either down to a logical error or just some facet of Clojure that I haven't been able to figure out. |
| 20:46 | black_joe | http://pastie.org/4788419 |
| 20:46 | black_joe | The function returns false even though both halves of the string contain the character. |
| 20:52 | black_joe | And it seems that in the above snippet (str) on (first x) is actually a lazy sequence. I got that wrong on the debug. |
| 20:52 | black_joe | But lazy-seq does not turn it into plain text. |
| 20:57 | metellus | ,(str '(1 2)) |
| 20:57 | clojurebot | "(1 2)" |
| 20:58 | black_joe | In the example above (lazy-seq (str (first x))) becomes (c l o j u r e . l a n g . L a z y S e q @ 2 0 a 6 e) |
| 20:58 | metellus | why are you calling lazy-seq on it? |
| 20:59 | black_joe | I thought that turned a lazy sequence into text? |
| 21:00 | metellus | I don't know the particulars of lazy-seq, but that's not what it does |
| 21:03 | metellus | black_joe: I think you'll be better off *only* functions on strings or *only* functions on seqs, rather than a mixture of them |
| 21:04 | metellus | so for example, you'd use .substring and then .contains |
| 21:05 | black_joe | Alright. I will use split here then. |
| 21:06 | black_joe | Instead of split-at. |
| 21:06 | black_joe | I read in "Clojure Programming" that since Strings are homoiconic with sequences it is good practice to make functions compatible with both. |
| 21:08 | metellus | the problem is that (str (first x)) and (str (first (rest x))) aren't doing what you want them to do |
| 21:09 | metellus | (and if your function uses .contains on a string it's not really going to be compatible with sequences) |
| 21:09 | metellus | I'm not really good enough to Clojure to offer a better suggestion, though |
| 21:10 | amalloy | well, seqs have a .contains method too |
| 21:10 | amalloy | but i agree this isn't a good way to do it |
| 21:10 | black_joe | Well, either way, you've been helpful. I'm too new to Clojure to fully understand sequences or lazy sequences. |
| 21:10 | metellus | (.contains (str x)) isn't going to do what you want for any x that isn't a string, though |
| 21:12 | black_joe | Well, then I may just embed a let form and assign the string there. |
| 21:12 | black_joe | I'll play with these suggestions tomorrow. |
| 21:12 | black_joe | Thanks for helping. |
| 21:12 | metellus | hmm, it actually looks like his function will work if he gets rid of the (str ..)s he has everywhere |
| 21:25 | mpan | how does slash for divide not conflict with namespacing? |
| 21:27 | SegFaultAX | mpan: What do you mean? |
| 21:28 | mpan | so I wanted keyword :/ but it wasn't allowed |
| 21:29 | ivan | see SLASH and CLOJURE_SLASH in LispReader.java |
| 21:29 | mpan | ah, so it's special cased earlier on? |
| 21:29 | ivan | yes |
| 21:29 | mpan | ah thanks |
| 21:29 | tomoj | is it normal for clojure-dev membership to remain pending for some time after one's CA is received? |
| 21:41 | mpan | say I have a tree from which I make a zipper |
| 21:41 | mpan | is there a way to get a flat seq of zippers representing each tree elem? |
| 21:42 | tomoj | mpan: if I understand what you mean, (->> z (iterate z/next) (take-while (complement z/end?))) |
| 21:43 | tomoj | which, imo, would be nice to have in clojure.zip (as "nexts"?) |
| 21:43 | mpan | could you please explain how that works? |
| 21:44 | mpan | as in, the tree has both terminal and nonterminal nodes, similar to |
| 21:44 | mpan | [a [b c d] [e [f g h] [i j k]]] |
| 21:45 | mpan | the actual tree is approx that layout, just with more metadata dumped into the leaves |
| 21:54 | mpan | tomoj: got it to work. awesome! thanks! |
| 21:55 | mpan | it's got some extras in it, though |
| 21:56 | mpan | oh! |
| 21:56 | mpan | it's because it's interpreting the structure to mean something else |
| 21:56 | mpan | (as in, the zipper was constructed to mean something else) |
| 21:58 | mpan | (as in, I was interpreting the tree differently than vector-zip does) |
| 21:59 | mpan | [a b c] being 1 node w/ 3 children rather than 1 node w/ 2 children |
| 22:41 | uvtc | pppaul, are you getting a lot of rain where you are? |
| 23:07 | mpan | is there an equivalent of iterate for something really expensive that you don't want evaluated more often than necessary? |
| 23:08 | mpan | I think last time I ended up writing the iteration fn directly or something, but that seemed redundant |
| 23:09 | shachaf | What's wrong with iterate for that? |
| 23:09 | mpan | the lazy seq got evaluated in chunks |
| 23:10 | mpan | and a chunk is actually pretty significantly expensive when we don't want the rest of it |
| 23:10 | shachaf | Oh, I don't know how Clojure lazy seqs work. |
| 23:10 | shachaf | I assumed it was like real lazy lists. :-( |
| 23:10 | mpan | I heard there was a way to get entirely lazy behavior |
| 23:10 | mpan | but didn't hear what it was |
| 23:10 | ChongLi | does this help: |
| 23:10 | ChongLi | http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/ |
| 23:10 | ChongLi | ? |
| 23:11 | Hodapp | probably oft-repeated question: how might I reliably achieve a Clojure REPL with functioning history? |
| 23:11 | Hodapp | short of tryclj.com |
| 23:11 | shachaf | rlwrap? |
| 23:11 | tomoj | shachaf: hey! |
| 23:11 | Hodapp | at some point all answers are probably going to converge on "learn emacs" |
| 23:12 | brehaut | Hodapp: my lein2 repl has it out of the box |
| 23:12 | tomoj | mpan: iterate is not chunked afaik |
| 23:12 | QUACKALPACATRON | shachaf, you are like that person that is everywhere |
| 23:12 | QUACKALPACATRON | what is her name again, emma or something like thast. |
| 23:12 | tomoj | &(do (first (map println (iterate inc 0))) nil) |
| 23:12 | lazybot | ⇒ 0 nil |
| 23:12 | Hodapp | brehaut: silly question, can I easily get to a lein2 repl outside of a project? |
| 23:12 | Hodapp | guess I could just make an empty one |
| 23:12 | brehaut | yes |
| 23:12 | mpan | oh awesome |
| 23:12 | brehaut | lein repl |
| 23:12 | mpan | what did that guy do last night with printing a whole chunk then? |
| 23:13 | shachaf | hi tomoj |
| 23:13 | Hodapp | huh, for some reason I was thinking that wouldn't work, but it is working |
| 23:13 | Hodapp | awesome |
| 23:13 | shachaf | hi QUACKALPACATRON |
| 23:13 | tomoj | dunno, was it my example? don't have a good sense of time |
| 23:13 | tomoj | &(do (first (map println (range))) nil) |
| 23:13 | lazybot | ⇒ 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 nil |
| 23:13 | mpan | ah, map is causing chunking? iterate doesn't? |
| 23:13 | mpan | thanks! |
| 23:13 | tomoj | no, (range) is chunked |
| 23:13 | Hodapp | gawd, I am about to stab Eclipse though. If I enter in an open-quote, the lag for input in the file approaches seconds |
| 23:14 | Hodapp | until I close that quote |
| 23:14 | tomoj | map inherits the chunkiness of its inputs |
| 23:14 | mpan | ooh |
| 23:14 | mpan | thanks |
| 23:21 | unlink | Does clojure.java.jdbc support simultaneously operating on two different database connections? |
| 23:27 | mpan | is there an analogue of -> that keeps allows a chain of assocs? |
| 23:27 | mpan | or should I just use -> with a bunch of partial applications? |
| 23:28 | mpan | oh wait, I can precompute all my stuff, so I can just use assoc |
| 23:29 | mpan | doesn't strictly need the chaining order |
| 23:38 | tomoj | hmm, chain of assocs? |
| 23:40 | tomoj | like assoc-in? |
| 23:41 | mpan | sorry, along the other dimension |
| 23:42 | mpan | like assoc with multiple pairs, except I had originally thought order mattered for me |
| 23:42 | mpan | like, I would need to calc stuff after each assoc |
| 23:43 | mpan | turns much more cleanly into a let and an assoc |
| 23:43 | mpan | if I drop that requirement |
| 23:50 | Hodapp | damn, I dread going to bed... when I wake up, I have to walk into a job where immutability isn't kosher. |
| 23:51 | shachaf | Hodapp: Watch out for those people trying to mutate 4 into 3. |
| 23:51 | tomoj | I never thought of it that way, but I guess I have the same problem |
| 23:52 | Hodapp | still working at 4clojure problems, but they are interesting for sure |
| 23:52 | Hodapp | just did the fibonacci one |
| 23:53 | Hodapp | ,((fn [n] ((fn fib [m sum1 sum2] (if (> m 0) (cons sum1 (fib (- m 1) sum2 (+ sum1 sum2))))) n 1 1)) 20) |
| 23:53 | clojurebot | (1 1 2 3 5 ...) |