#clojure log - Sep 14 2014

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:20 john2x: cider doesn't automatically load all namespaces defined in a project? Unlike in `lein repl`, where all the project's namespaces are immediately available?

1:08 amalloy: john2x: 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

1:13 john2x: amalloy: ah I think I mean 'evals' the namespaces.. it seems in cider, I have to eval a file before I can require it?

1:13 amalloy: no you don't. you can require files whenever you want

1:15 john2x: ah right. silly me. I was relying on company-mode to list all available namespaces..

5:57 SagiCZ1: is there a paredit command that swaps first expressions in sexps like this?

5:57 (foo1 (foo2 x)) --> (foo2 (foo1 x))

5:58 no amount of slurping or barfing does this

6:12 amalloy: SagiCZ1: paredit-convolute-sexp

6:13 if you put point between foo2 and x

6:57 cfleming: amalloy: What does convolute-sexp actually do? Just swap the two head symbols?

6:58 amalloy: I've never found a good explanation of what it does.

7:03 Actually, I see - the smartparens doc has a better explanation: Move the expressions before point in the current list before the enclosing list.

8:30 SagiCZ1: cfleming: we dont have that paredit command in Cursive do we?

8:31 cfleming: SagiCZ1: No, but now I know how it should work I can implement it.

8:33 SagiCZ1: cfleming: alright, great.. not a major feature but it would be nice to have

8:37 cfleming: SagiCZ1: No doubt, I've wanted it from time to time (now that I know what it actually does)

8:42 gaverhae: Hi all! Has anyone got any experience with ClojureScript/React on Android?

9:56 favetelinguis: Why am not my pre condition firering if i call (straights 1) http://lpaste.net/111034

9:59 gaverhae: favetelinguis: What's the definition of "deck" ?

9:59 favetelinguis: [A 2 3 4 5 6 7 8 9 T J Q K]

10:00 i want to only be able to call this function with values 2-5

10:01 gaverhae: favetelinguis: I get: (straights 1) AssertionError Assert failed: (and (> num-cards 2) (< num-cards 6)) stra.core/straights (form-init7754222051149817257.clj:1)

10:01 favetelinguis: What's your Clojure version? Any idea what JVM options you've passed? Did you disable assertions in your project.clj?

10:02 favetelinguis: running in lighttable insta repl

10:02 gaverhae: favetelinguis: If clojure.core/*assert* is false when the defn form is compiled, pre/post condition code will not be generated

10:02 favetelinguis: hmm how can i check that value?

10:04 looks like it us true

10:12 gaverhae: favetelinguis: You need to check its value at compile time, so something like putting (println *assert*) at the top level

10:14 favetelinguis: does the function overall make sense for you? im a clj nood and found cycle to be perfect to represent straights in poker

10:14 the let statement is just placeholder and does nothing

10:19 gaverhae: favetelinguis: 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:19 favetelinguis: Oh, and the local binding "cards" is unused, so you could remove it.

10:26 favetelinguis: ok ty

11:22 perplexa: hey

11:23 i'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:24 i added the following to my project.clj: :dev {:dependencies [[lein-midje "3.1.3"]

11:24 [cascalog/midje-cascalog "2.1.1"]]}}

11:24 anything else i'm missing?

11:25 clojer: Can 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:25 perplexa: regarding my question, i found out, it has to be in :plugins :P

11:25 clojer: I'm using Emacs (Live) 24/Cider 0.7

11:31 perplexa: /wg 24

11:41 guest889: اي عرب مهتمين بكلوجر؟

11:55 ethan_: /msg NickServ IDENTIFY cjs-emacs

12:50 johnwalker: anyone doing clojurecup? i am looking for a team

12:55 ro_st: is using future and future-cancel the correct way to start and stop threads in Clojure?

12:56 justin_smith: ro_st: future is good when the thread should run until it calculates some result, and you want to easily access that result

12:56 ro_st: i want to have a sleep loop run in its own thread but be able to kill that thread

12:56 so that i can wrap it up in a reloaded Component

12:56 justin_smith: ro_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:56 ro_st: i thought maybe to use agents but there's no way to stop one

12:57 should i just interop with java?

12:57 justin_smith: no

12:57 ro_st: what should i use?

12:57 justin_smith: if you don't need a derefable result, you can pass an fn of no args to (Thread. f)

12:57 dbasch: ro_st: have a shared flag, and have the thread check the flag and exit if set

12:57 justin_smith: if you want it to be cancellable, you need to make it check for cancellation

12:58 ro_st: ahhh

12:58 i'll try this. thank you

13:12 what do i use to exit the thread?

13:12 just return?

13:13 justin_smith: ro_st: put an if or when around your recur

13:13 if you are looping via recur (as you should)

13:13 or, do (while (not (.isInterrupted (Thread/currentThread))) ...)

13:13 there should really be a shortcut for that

13:17 ro_st: got it. thanks guys

13:23 irctc: hi, 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:23 justin_smith: irctc: filter

13:23 irctc: yes but I don't know what function to filter with

13:23 justin_smith: ,(filter #(= true %) '(a b true c true d e f true))

13:23 clojurebot: (true true true)

13:23 justin_smith: ,(remove #(= true %) '(a b true c true d e f true))

13:23 clojurebot: (a b c d e ...)

13:24 irctc: ooh i see

13:24 justin_smith: sorry, first version was a serious thinko :)

13:24 short for thinkographical error, of course

13:25 irctc: can you link me to a reference for the % symbol? I come from clisp and it's something foreign for me

13:25 justin_smith: ,(macroexpand '#(= true %))

13:25 clojurebot: (fn* [p1__79#] (= true p1__79#))

13:25 justin_smith: it's a shorthand for "first argument" inside the #() convenience macro

13:26 (fn [x] (= true x)) would be the same, it's just less friendly to read and write

13:27 irctc: thanks

13:27 justin_smith: the one gotcha with #(frob % %2 %3 %&) is that you can't nest more #() forms inside

13:27 because % would be ambiguous at that point

13:27 ,(#(reverse %&) 1 2 3 4 5)

13:27 clojurebot: (5 4 3 2 1)

13:28 justin_smith: just for completeness' sake :)

13:30 irctc: oh I see

13:34 justin_smith: ,(remove #{true} '(a b true c true d e f true))

13:34 clojurebot: (a b c d e ...)

13:34 justin_smith: sets can be used as predicates, this can be useful if you have some set of values to check

13:35 this fails of course if false and nil are values that should be matched

14:10 catern: are there any decent videos of Meta-Ex?

14:13 justin_smith: catern: have you seen what's linked from the official site? http://meta-ex.com/

14:14 catern: those are either sound-only recordings or just interviews

14:14 i want to see them livecoding

14:14 in fact, they should do a livestream

14:15 justin_smith: catern: first video, skip to the 15 minute mark

14:15 catern: (or the equivalent ofc)

14:16 should I email them and request/suggest that they do a livestream? they've surely already thought of it...

14:19 or perhaps not... little actually happens in the buffer, it seems

14:20 or i guess the horrible cameraperson might just not be capturing it

14:22 would be nice if instead of dirctly linking the hardware and supercollider or whatever, they linked hardware -> emacs buffer (-> overtone -> supercollider)

14:22 justin_smith: catern: that would be terrible

14:23 emacs does not to multithreading at all

14:23 adjusting two knobs at the same time would suck

14:23 catern: justin_smith: well, then it would be nice if they could do that

14:24 justin_smith: yes, I guess it would be nice if emacs was threaded. Don't hold your breath.

14:24 catern: well, even for the pretty-much-single-threaded things

14:24 justin_smith: sorry, I only get this grumpy because I wish emacs was usable for such things.

14:24 catern: instead of directly linking hardware -> supercollider, have the hardware modify the code

14:24 justin_smith: and I tried it extensively, and it only led to pain

14:25 a clojure process in the jvm can easily be connected to MIDI though

14:25 and you could use something like cider to update midi state in an emacs view I guess

14:26 or, better, update the state of the things MIDI is controlling in an emacs view

14:56 irctc: hi

14:56 I have this (incomplete) function

14:56 http://pastecode.org/index.php/view/64873765

14:57 and I want to keep doing the same, but calling ciclo once more in each extra line

14:57 however, the number of times I want to do that can't be known beforehand

14:58 how can I automate it?

14:59 justin_smith: what is the logic for when (ciclo x) becomes (ciclo (ciclo x))

15:00 irctc: (1 2 3 4) -> (4 1 2 3) -> (3 4 1 2)

15:00 I want to call it n-1 times

15:00 where n is the size of x

15:00 justin_smith: OK, but the first two elements call just ciclo

15:04 irctc: oh well I soul've added (take-nth 2 (emparejar equipos (ciclo(ciclo equipos)))

15:05 Ibut the issue still remains

15:05 justin_smith: oh, so you alternate calling with n+1 ciclo calls, and then take the rest

15:06 irctc: yes, (take-nth 2 (rest ... is just a way to take even-placed elements in the list

15:06 without the rest it takes odd ones

15:07 justin_smith: ,((fn [els] (take (count els) (iterate (fn [l] (cons (last l) (butlast l))) els))) [0 1 2 3 4])

15:07 clojurebot: ([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:07 justin_smith: is that the result you expect?

15:08 corecode_: hi

15:09 does the reader somehow retain location information, where a (sub)sexpr was read from? (file/line)

15:10 justin_smith: corecode_: it adds the file / line data to the metadata of vars

15:10 ((juxt :file :line) (meta #'map))

15:10 ,((juxt :file :line) (meta #'map))

15:10 clojurebot: ["clojure/core.clj" 2586]

15:11 justin_smith: cd

15:11 silly mouse to focus

15:18 corecode_: justin_smith: thanks!

16:58 Solokeh: what is this room?

17:02 gfredericks: ~clojure

17:02 clojurebot: clojure is the bestest programming language available.

17:02 gfredericks: $google clojure

17:02 andyf: ~gfredericks

17:02 clojurebot: gfredericks is a DSL for seeding clojurebot with high-concept talk ideas

17:03 andyf: That last one is a joke. gfredericks appears fully human in person.

18:27 ggarciajr: hi all. I'm starting with clojure and I was wondering if anyone can help me with an issue I'm having.

18:28 danielcompton: ggarciajr: fire away. For future reference you don't need to ask to ask

18:31 augustl: hyPiRion: 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:34 hyPiRion: augustl: 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:35 augustl: hyPiRion: I see, tnx :)

18:35 hyPiRion: augustl: 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:36 augustl: hyPiRion: trying to find an AOT compiled environment with persistent data structures ;) Rust + c-rrb seems like a good option.

18:36 ggarciajr: Why this works -> (println (str "Tweets downloaded: " (count (map #(extract-tweet-data %) (:statuses (:body downloaded-data))))))

18:36 And 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:36 augustl: apparently, the clojure community is the only one that can't live without persistent data structures?

18:36 hyPiRion: ah :)

18:36 yeah, I'm pretty frustrated by the limited amount of persistent data structures in other languages

18:37 augustl: Go seems to say NOPE use message passing

18:37 ggarciajr: I 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:38 augustl: apparently 4-16 core machines with shared RAM are going away very soon? ;)

18:38 hyPiRion: Go says no to generics :p

18:38 Otherwise it'd be doable

18:39 augustl: ggarciajr: where does downloaded-data come from in the example that works?

18:39 ggarciajr: perhaps the values are different for downloaded-data in your two snippets

18:39 ggarciajr: it is downloaded from twitter using twitter-api

18:40 augustl: hyPiRion: 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:40 c-rrb*

18:40 ggarciajr: august1, they are comming from the same function. the data it just a map

18:42 btw, tweets type is clojure.lang.LazySeq

18:46 raspasov: ggarciajr: how does extract-tweet-data look?

18:47 can you put all your code in a github gist or something like that?

18:49 augustl: oh hey, https://github.com/BartoszMilewski/Okasaki

18:49 is there anything C++ doesn't have

18:49 brehaut: reason? clarity? determinism?

18:49 ggarciajr: (defn extract-tweet-data [tweet] {:id (:id tweet) :text (:text tweet) :user (extrat-screen-name (:user tweet))})

18:49 (defn extrat-screen-name [user] (:screen_name user))

18:50 augustl: seems like C++ has no underlying concepts, just All The Features

18:52 raspasov: almost everything is possible in any language, it's really what the language makes idiomatic that counts

18:53 augustl: well, custom memory allocation is not possible in Clojure :)

18:54 raspasov: yes, almost :D

19:00 ggarciajr: found the problem. variable shadowing. count was being shadowed :(

19:00 raspasov: haha ok :) it happens

19:01 ggarciajr: thanks guys

19:01 raspasov: anytime you have a question you should post your whole namespace at least, someone with more experience would have spotted that right away

19:02 ggarciajr: thanks for the tip

19:02 raspasov: np :)

19:13 edipofederle: JOIN rubyonrails

19:16 locks: oops

19:16 edipofederle: hi

19:23 exit

19:23 \EXIT

19:23 QUIT

19:23 \QUIT

20:36 fUD: Helloo

21:29 johnwalker: campeterson: ping

22:08 normanrichards: hey

22:09 gfredericks: ,'hi

22:09 clojurebot: hi

23:00 dee5: Is there any way to namespace qualify a symbol that was created/input to a macro?

23:26 clojurenoobie: hello!!

23:27 how goes the chat channel?

23:29 I am trying to write a function that given a string, will detect the indexes of a substring of vectors... Having some issues.

23:30 (map (detect-insubstring-function string-to-check-inside %)["item1" "item2" "item"]

23:30 I mean this seems like it would be really straightforward, but I keep keep getting errors...

23:31 I think python has made me a bit overreliant on string parsing magic...

23:31 any ideas?

23:31 falafel: clojurenoobie: I don't get your example, do you have some real world example of input *and* output

23:37 xeqi: ,(map #(re-find #"\d" %) ["item1" "item2" "item3"])

23:37 clojurebot: ("1" "2" "3")

23:37 xeqi: clojurenoobie: ^ ?

23:38 clojurenoobie: Yay, thanks

23:38 one other question, is there an elegant clojurish way to splite a string given a vector of indices?

23:39 I've got a function that works ok right now, but it's kind of ugly

23:44 justin_smith: clojurenoobie: what is a vector of indexes?

23:58 ,((fn [s indexes] (map #(apply subs s %) (partition 2 1 (concat indexes [(.length s)])))) "chasefourdiamonds" [0 5 9])

23:58 clojurebot: ("chase" "four" "diamonds")

23:58 justin_smith: that is at least a start

Logging service provided by n01se.net