#clojure logs

2014-09-14

00:20john2xcider doesn't automatically load all namespaces defined in a project? Unlike in `lein repl`, where all the project's namespaces are immediately available?
01:08amalloyjohn2x: uh, lein repl doesn't autoload all your namespaces either. it autoloads the namespace you mark as :main in project.clj, if you set a :main at all. that namespace often transitively loads other namespaces, but that's up to you
01:13john2xamalloy: ah I think I mean 'evals' the namespaces.. it seems in cider, I have to eval a file before I can require it?
01:13amalloyno you don't. you can require files whenever you want
01:15john2xah right. silly me. I was relying on company-mode to list all available namespaces..
05:57SagiCZ1is there a paredit command that swaps first expressions in sexps like this?
05:57SagiCZ1(foo1 (foo2 x)) --> (foo2 (foo1 x))
05:58SagiCZ1no amount of slurping or barfing does this
06:12amalloySagiCZ1: paredit-convolute-sexp
06:13amalloyif you put point between foo2 and x
06:57cflemingamalloy: What does convolute-sexp actually do? Just swap the two head symbols?
06:58cflemingamalloy: I've never found a good explanation of what it does.
07:03cflemingActually, I see - the smartparens doc has a better explanation: Move the expressions before point in the current list before the enclosing list.
08:30SagiCZ1cfleming: we dont have that paredit command in Cursive do we?
08:31cflemingSagiCZ1: No, but now I know how it should work I can implement it.
08:33SagiCZ1cfleming: alright, great.. not a major feature but it would be nice to have
08:37cflemingSagiCZ1: No doubt, I've wanted it from time to time (now that I know what it actually does)
08:42gaverhaeHi all! Has anyone got any experience with ClojureScript/React on Android?
09:56favetelinguisWhy am not my pre condition firering if i call (straights 1) http://lpaste.net/111034
09:59gaverhaefavetelinguis: What's the definition of "deck" ?
09:59favetelinguis[A 2 3 4 5 6 7 8 9 T J Q K]
10:00favetelinguisi want to only be able to call this function with values 2-5
10:01gaverhaefavetelinguis: I get: (straights 1) AssertionError Assert failed: (and (> num-cards 2) (< num-cards 6)) stra.core/straights (form-init7754222051149817257.clj:1)
10:01gaverhaefavetelinguis: What's your Clojure version? Any idea what JVM options you've passed? Did you disable assertions in your project.clj?
10:02favetelinguisrunning in lighttable insta repl
10:02gaverhaefavetelinguis: If clojure.core/*assert* is false when the defn form is compiled, pre/post condition code will not be generated
10:02favetelinguishmm how can i check that value?
10:04favetelinguislooks like it us true
10:12gaverhaefavetelinguis: You need to check its value at compile time, so something like putting (println *assert*) at the top level
10:14favetelinguisdoes the function overall make sense for you? im a clj nood and found cycle to be perfect to represent straights in poker
10:14favetelinguisthe let statement is just placeholder and does nothing
10:19gaverhaefavetelinguis: I don't know anything about poker; other than that it looks fine. I'd only note that < and > in Clojure cna take multiple arguments, so you could replace (and (> num-cards 2) (< num-cards 6)) with (< 2 num-cards 6)
10:19gaverhaefavetelinguis: Oh, and the local binding "cards" is unused, so you could remove it.
10:26favetelinguisok ty
11:22perplexahey
11:23perplexai'm trying to use midje with leiningen in only one specific project. i don't want to add it to my global profiles.clj but rather project.clj and i don't see the midje task in leiningenm.
11:24perplexai added the following to my project.clj: :dev {:dependencies [[lein-midje "3.1.3"]
11:24perplexa [cascalog/midje-cascalog "2.1.1"]]}}
11:24perplexaanything else i'm missing?
11:25clojerCan anyone explain how eval-ing forms in a core.cljs file works when using a Weasel browser repl? Nothing I eval in this file makes any difference to the connected browser (Chrome).
11:25perplexaregarding my question, i found out, it has to be in :plugins :P
11:25clojerI'm using Emacs (Live) 24/Cider 0.7
11:31perplexa /wg 24
11:41guest889اي عرب مهتمين بكلوجر؟
11:55ethan_ /msg NickServ IDENTIFY cjs-emacs
12:50johnwalkeranyone doing clojurecup? i am looking for a team
12:55ro_stis using future and future-cancel the correct way to start and stop threads in Clojure?
12:56justin_smithro_st: future is good when the thread should run until it calculates some result, and you want to easily access that result
12:56ro_sti want to have a sleep loop run in its own thread but be able to kill that thread
12:56ro_stso that i can wrap it up in a reloaded Component
12:56justin_smithro_st: future-cancel only works if the future hasn't started yet, or it checks if its thread is interrupted and acts on that
12:56ro_sti thought maybe to use agents but there's no way to stop one
12:57ro_stshould i just interop with java?
12:57justin_smithno
12:57ro_stwhat should i use?
12:57justin_smithif you don't need a derefable result, you can pass an fn of no args to (Thread. f)
12:57dbaschro_st: have a shared flag, and have the thread check the flag and exit if set
12:57justin_smithif you want it to be cancellable, you need to make it check for cancellation
12:58ro_stahhh
12:58ro_sti'll try this. thank you
13:12ro_stwhat do i use to exit the thread?
13:12ro_stjust return?
13:13justin_smithro_st: put an if or when around your recur
13:13justin_smithif you are looping via recur (as you should)
13:13justin_smithor, do (while (not (.isInterrupted (Thread/currentThread))) ...)
13:13justin_smiththere should really be a shortcut for that
13:17ro_stgot it. thanks guys
13:23irctchi, do you know how to filter all true results form a list such as (a b true c true d e f true) -> (a b c d e f)?
13:23justin_smithirctc: filter
13:23irctcyes but I don't know what function to filter with
13:23justin_smith,(filter #(= true %) '(a b true c true d e f true))
13:23clojurebot(true true true)
13:23justin_smith,(remove #(= true %) '(a b true c true d e f true))
13:23clojurebot(a b c d e ...)
13:24irctcooh i see
13:24justin_smithsorry, first version was a serious thinko :)
13:24justin_smithshort for thinkographical error, of course
13:25irctccan you link me to a reference for the % symbol? I come from clisp and it's something foreign for me
13:25justin_smith,(macroexpand '#(= true %))
13:25clojurebot(fn* [p1__79#] (= true p1__79#))
13:25justin_smithit's a shorthand for "first argument" inside the #() convenience macro
13:26justin_smith(fn [x] (= true x)) would be the same, it's just less friendly to read and write
13:27irctcthanks
13:27justin_smiththe one gotcha with #(frob % %2 %3 %&) is that you can't nest more #() forms inside
13:27justin_smithbecause % would be ambiguous at that point
13:27justin_smith,(#(reverse %&) 1 2 3 4 5)
13:27clojurebot(5 4 3 2 1)
13:28justin_smithjust for completeness' sake :)
13:30irctcoh I see
13:34justin_smith,(remove #{true} '(a b true c true d e f true))
13:34clojurebot(a b c d e ...)
13:34justin_smithsets can be used as predicates, this can be useful if you have some set of values to check
13:35justin_smiththis fails of course if false and nil are values that should be matched
14:10caternare there any decent videos of Meta-Ex?
14:13justin_smithcatern: have you seen what's linked from the official site? http://meta-ex.com/
14:14caternthose are either sound-only recordings or just interviews
14:14caterni want to see them livecoding
14:14caternin fact, they should do a livestream
14:15justin_smithcatern: first video, skip to the 15 minute mark
14:15catern(or the equivalent ofc)
14:16caternshould I email them and request/suggest that they do a livestream? they've surely already thought of it...
14:19caternor perhaps not... little actually happens in the buffer, it seems
14:20caternor i guess the horrible cameraperson might just not be capturing it
14:22caternwould be nice if instead of dirctly linking the hardware and supercollider or whatever, they linked hardware -> emacs buffer (-> overtone -> supercollider)
14:22justin_smithcatern: that would be terrible
14:23justin_smithemacs does not to multithreading at all
14:23justin_smithadjusting two knobs at the same time would suck
14:23caternjustin_smith: well, then it would be nice if they could do that
14:24justin_smithyes, I guess it would be nice if emacs was threaded. Don't hold your breath.
14:24caternwell, even for the pretty-much-single-threaded things
14:24justin_smithsorry, I only get this grumpy because I wish emacs was usable for such things.
14:24caterninstead of directly linking hardware -> supercollider, have the hardware modify the code
14:24justin_smithand I tried it extensively, and it only led to pain
14:25justin_smitha clojure process in the jvm can easily be connected to MIDI though
14:25justin_smithand you could use something like cider to update midi state in an emacs view I guess
14:26justin_smithor, better, update the state of the things MIDI is controlling in an emacs view
14:56irctchi
14:56irctcI have this (incomplete) function
14:56irctchttp://pastecode.org/index.php/view/64873765
14:57irctcand I want to keep doing the same, but calling ciclo once more in each extra line
14:57irctchowever, the number of times I want to do that can't be known beforehand
14:58irctchow can I automate it?
14:59justin_smithwhat is the logic for when (ciclo x) becomes (ciclo (ciclo x))
15:00irctc(1 2 3 4) -> (4 1 2 3) -> (3 4 1 2)
15:00irctcI want to call it n-1 times
15:00irctcwhere n is the size of x
15:00justin_smithOK, but the first two elements call just ciclo
15:04irctcoh well I soul've added (take-nth 2 (emparejar equipos (ciclo(ciclo equipos)))
15:05irctcIbut the issue still remains
15:05justin_smithoh, so you alternate calling with n+1 ciclo calls, and then take the rest
15:06irctcyes, (take-nth 2 (rest ... is just a way to take even-placed elements in the list
15:06irctcwithout the rest it takes odd ones
15:07justin_smith,((fn [els] (take (count els) (iterate (fn [l] (cons (last l) (butlast l))) els))) [0 1 2 3 4])
15:07clojurebot([0 1 2 3 4] (4 0 1 2 3) (3 4 0 1 2) (2 3 4 0 1) (1 2 3 4 0))
15:07justin_smithis that the result you expect?
15:08corecode_hi
15:09corecode_does the reader somehow retain location information, where a (sub)sexpr was read from? (file/line)
15:10justin_smithcorecode_: it adds the file / line data to the metadata of vars
15:10justin_smith((juxt :file :line) (meta #'map))
15:10justin_smith,((juxt :file :line) (meta #'map))
15:10clojurebot["clojure/core.clj" 2586]
15:11justin_smithcd
15:11justin_smithsilly mouse to focus
15:18corecode_justin_smith: thanks!
16:58Solokehwhat is this room?
17:02gfredericks~clojure
17:02clojurebotclojure is the bestest programming language available.
17:02gfredericks$google clojure
17:02andyf~gfredericks
17:02clojurebotgfredericks is a DSL for seeding clojurebot with high-concept talk ideas
17:03andyfThat last one is a joke. gfredericks appears fully human in person.
18:27ggarciajrhi all. I'm starting with clojure and I was wondering if anyone can help me with an issue I'm having.
18:28danielcomptonggarciajr: fire away. For future reference you don't need to ask to ask
18:31augustlhyPiRion: random slightly off topic question: how difficult would it be to have a custom memory allocator for c-rrb? I.e. my own GC, a ref counter, whatever.
18:34hyPiRionaugustl: I started out with that, but it was too much overhead for the time period of my thesis. It's possible, but you'll have to locate all positions where the refcount increases and decreases (obviously).
18:35augustlhyPiRion: I see, tnx :)
18:35hyPiRionaugustl: If it makes the library more suitable for whatever you need it for, file an issue and I'll have a look at it this week
18:36augustlhyPiRion: trying to find an AOT compiled environment with persistent data structures ;) Rust + c-rrb seems like a good option.
18:36ggarciajrWhy this works -> (println (str "Tweets downloaded: " (count (map #(extract-tweet-data %) (:statuses (:body downloaded-data))))))
18:36ggarciajrAnd this doesn't? -> (let [downloaded-data (search-twitter query count since) tweets (map #(extract-tweet-data %) (:statuses (:body downloaded-data))) tweets-downloaded (count tweets)] (println tweets-downloaded))
18:36augustlapparently, the clojure community is the only one that can't live without persistent data structures?
18:36hyPiRionah :)
18:36hyPiRionyeah, I'm pretty frustrated by the limited amount of persistent data structures in other languages
18:37augustlGo seems to say NOPE use message passing
18:37ggarciajrI get this error when trying to execute the second version -> actual: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
18:38augustlapparently 4-16 core machines with shared RAM are going away very soon? ;)
18:38hyPiRionGo says no to generics :p
18:38hyPiRionOtherwise it'd be doable
18:39augustlggarciajr: where does downloaded-data come from in the example that works?
18:39augustlggarciajr: perhaps the values are different for downloaded-data in your two snippets
18:39ggarciajrit is downloaded from twitter using twitter-api
18:40augustlhyPiRion: if I can get c+rrb working in Rust, there's also https://github.com/michaelwoerister/rs-persistent-datastructures, and then I have everything i need :)
18:40augustlc-rrb*
18:40ggarciajraugust1, they are comming from the same function. the data it just a map
18:42ggarciajrbtw, tweets type is clojure.lang.LazySeq
18:46raspasovggarciajr: how does extract-tweet-data look?
18:47raspasovcan you put all your code in a github gist or something like that?
18:49augustloh hey, https://github.com/BartoszMilewski/Okasaki
18:49augustlis there anything C++ doesn't have
18:49brehautreason? clarity? determinism?
18:49ggarciajr(defn extract-tweet-data [tweet] {:id (:id tweet) :text (:text tweet) :user (extrat-screen-name (:user tweet))})
18:49ggarciajr(defn extrat-screen-name [user] (:screen_name user))
18:50augustlseems like C++ has no underlying concepts, just All The Features
18:52raspasovalmost everything is possible in any language, it's really what the language makes idiomatic that counts
18:53augustlwell, custom memory allocation is not possible in Clojure :)
18:54raspasovyes, almost :D
19:00ggarciajrfound the problem. variable shadowing. count was being shadowed :(
19:00raspasovhaha ok :) it happens
19:01ggarciajrthanks guys
19:01raspasovanytime you have a question you should post your whole namespace at least, someone with more experience would have spotted that right away
19:02ggarciajrthanks for the tip
19:02raspasovnp :)
19:13edipofederleJOIN rubyonrails
19:16locksoops
19:16edipofederlehi
19:23edipofederleexit
19:23edipofederle\EXIT
19:23edipofederleQUIT
19:23edipofederle\QUIT
20:36fUDHelloo
21:29johnwalkercampeterson: ping
22:08normanrichardshey
22:09gfredericks,'hi
22:09clojurebothi
23:00dee5Is there any way to namespace qualify a symbol that was created/input to a macro?
23:26clojurenoobiehello!!
23:27clojurenoobiehow goes the chat channel?
23:29clojurenoobieI am trying to write a function that given a string, will detect the indexes of a substring of vectors... Having some issues.
23:30clojurenoobie(map (detect-insubstring-function string-to-check-inside %)["item1" "item2" "item"]
23:30clojurenoobieI mean this seems like it would be really straightforward, but I keep keep getting errors...
23:31clojurenoobieI think python has made me a bit overreliant on string parsing magic...
23:31clojurenoobieany ideas?
23:31falafelclojurenoobie: I don't get your example, do you have some real world example of input *and* output
23:37xeqi,(map #(re-find #"\d" %) ["item1" "item2" "item3"])
23:37clojurebot("1" "2" "3")
23:37xeqiclojurenoobie: ^ ?
23:38clojurenoobieYay, thanks
23:38clojurenoobieone other question, is there an elegant clojurish way to splite a string given a vector of indices?
23:39clojurenoobieI've got a function that works ok right now, but it's kind of ugly
23:44justin_smithclojurenoobie: what is a vector of indexes?
23:58justin_smith,((fn [s indexes] (map #(apply subs s %) (partition 2 1 (concat indexes [(.length s)])))) "chasefourdiamonds" [0 5 9])
23:58clojurebot("chase" "four" "diamonds")
23:58justin_smiththat is at least a start