#clojure log - Feb 18 2012

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

0:00 TimMc: cemerick: It makes it annoying to use APIs that have arglists like [a b & {:keys [c d]}]

0:00 cemerick: APMap should only accept entries/pairs in its cons method. Can't sleep some nights because of it.

0:01 a flexible mapply fn would be easy enough.

0:01 TimMc: Sure, I've written mapply several times.

0:02 It would be easy enough to make one that does both.

0:02 cemerick: right, that's what I meant by flexible

0:02 TimMc: ...but I never don't know which I want statically.

0:02 cemerick: Not really worth the hassle IMO.

0:02 TimMc: What's the best way to turn a map into interleaved keys and vals? interleave keys vals?

0:03 amalloy: apply concat

0:03 TimMc: Hah, nice.

0:03 amalloy: &(for [e '{a 1 b 2 c 3}, x e] x)

0:03 lazybot: ⇒ (a 1 b 2 c 3)

0:04 amalloy: is another approach

0:04 cemerick: People yell at me for using mapcat identity for that.

0:04 amalloy: justifiably so, i suppose. not that my 'for is any better

0:05 cemerick: These things become habitual.

0:13 hiredman: ~flatten

0:13 clojurebot: flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.

0:13 TimMc: I like how there were only 5 new lines of text in the channel when I came back from watching a movie, and 2 of them were a bot.

0:14 hiredman: crashed the jvm that time, buckets of fun

0:14 TimMc: Clearly, everyone else was watching the same movie.

0:21 amalloy: friday night just wouldn't be the same without watching a movie over TimMc's shoulder

1:01 TimMc: Wait, remind me again why UUIDs need to have reader syntax?

1:01 I'm not asking to be convinced, I just don't see any point.

1:04 technomancy: heh

1:06 amalloy: i think it's supposed to be for data transfer/serialization

1:09 emezeske: TimMc: Is this UUID reader syntax business a real thing being considered?

1:11 technomancy: =\

1:11 emezeske: That's a very curious feature

2:04 cemerick: emezeske: Very. It's in 1.4

3:52 spoon16: best way to filter null values from a map? https://gist.github.com/1858320

4:22 tomoj: is clojurescript one's bootstrap/git-deps the easiest current way to get clojurescript library deps?

5:49 aidy: Is there a Scheme for-each equivalent in clojure, without sequence bindings? e.g. (for-each fn seq)

6:00 morphling: aidy: no, doseq is what you should use but (doall (map fn seq)) will probably work, too

6:01 aidy: okay, thanks :)

7:55 tdrgabi: I've been trying for an hour to (:require [clojure.java.jbdc :as sql])

7:55 and I keep getting Could not locate clojure/java/jbdc__init.class or clojure/java/jbdc.clj on classpath:

7:55 I have it in the project file

7:56 :dependencies [

7:56 [org.clojure/clojure "1.2.1"]

7:56 [org.clojure/data.json "0.1.2"]

7:56 [org.clojure/java.jdbc "0.1.1"]

7:56 [enlive "1.0.0-SNAPSHOT"]])

7:56 and the jar is present when I do lein swank

7:56 any ideas what I do wrong?

7:56 raek: tdrgabi: did you write that (:require ...) line in the repl or in the ns form?

7:56 tdrgabi: yes, this is my ns

7:56 (ns cooking_assistant.core

7:56 (:require [clojure.java.io :as io])

7:56 (:require [clojure.java.jbdc :as sql])

7:56 (:require [net.cgrand.enlive-html :as html])

7:56 (:import (java.sql DriverManager)))

7:57 and it fails at jdbc require

7:57 raek: have you run lein deps and restarted the repl after you added it to the project.clj file?

7:57 tdrgabi: yes. multiple times :)

7:57 there's a clojure.java dir in the clojure.jar I have in deps

7:58 raek: tdrgabi: ah, you have a typo: "jdbc", not "jbdc"

7:58 tdrgabi: maybe it's looking there instead of the java.jdbc.jar

7:58 this is embarasing

7:58 thanks :)

7:59 how do you guys use the new slime/swank in emacs?

7:59 C-c C-c does a compile now instead of eval - buffer

7:59 raek: I have been using C-c C-k

8:00 but I thought "compile" and "load" did the same in swank-clojure

8:00 tdrgabi: I think it was recently changed, but I'm new at this so don't take my word for it

8:35 after including [sqlitejdbc "0.5.6"] to lein and running lein deps

8:35 lein swank crashes with Exception in thread "main" java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (macroexpand.clj:1)

8:35 at clojure.lang.Compiler.eval(Compiler.java:5440)

8:36 if I remove it, it works

8:36 Caused by: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V

8:36 at clojure.contrib.def$defmacro___509.<init>(def.clj:39)

8:36 is it possible that it wants the older clojure.contrib?

8:46 did any of you used clojure with sqlite?

9:32 jjcomer: Does anyone have a clever way to randomly interleave two lists?

9:38 kephale: ,(interleave (shuffle (range 10)) (shuffle (range 100 110)))

9:38 clojurebot: (5 108 8 107 4 ...)

9:39 kephale: is that clever enough?

9:40 jjcomer: kephale: I am trying to generate random merges of two strings. So the catch is that I need the list's order to be preserved but randomly interleaved

9:40 TimMc: jjcomer: Define "randomly interleaved".

9:41 kephale: you just want a permutation of the list of the strings

9:41 ?

9:41 jjcomer: So "orange" and "apple" could generate "aporangplee"

9:41 kephale: ah

9:42 TimMc: jjcomer: You'll want to define a probability distribution for the size of a contiguous segment.

9:42 kephale: that strikes me as being a parametrized function

9:42 yeah

9:42 parameterized*

9:43 well, or a parameter specifying a distribution of chunk sizes

9:46 TimMc: &(let [chunker (partial partition-by (fn [x] (rand-int 3)))] (interleave (chunker "abcdefghijk") (chunker (range 10)))) ;; except you'd want an interleave-all

9:46 lazybot: ⇒ ((\a \b \c) (0) (\d) (1) (\e) (2) (\f) (3 4) (\g \h) (5 6) (\i) (7 8 9))

9:48 TimMc: jjcomer: ^ partition-by rand-int might be good enough for you, but it doesn't give you much control over chunk size

9:49 &(let [chunker (partial partition-by (fn [x] (rand-int 2)))] (interleave (chunker "abcdefghijk") (chunker (range 10))))

9:49 lazybot: ⇒ ((\a) (0 1 2) (\b) (3) (\c) (4 5) (\d) (6) (\e) (7 8 9))

9:49 TimMc: &(let [chunker (partial partition-by (fn [x] (rand-int 2)))] (interleave (chunker "abcdefghijk") (chunker (range 10))))

9:49 lazybot: ⇒ ((\a) (0 1) (\b \c) (2 3 4 5 6) (\d \e) (7 8) (\f \g) (9))

9:49 tomoj: how does that compare to this https://gist.github.com/74eb36db2e78d49291a9 (ugly loop implementation aside...)

9:50 i.e. picking each letter from one or the other word equally likely in sequence until the shorter word runs out, then take the rest of the other word

9:50 TimMc: I'm not actually sure.

9:51 I suspect that jjcomer's needs are not algorithmically precise, though.

9:51 jjcomer: tomoj: That's what I have now, not sure if there is a more clojure way to do it :)

9:51 :TimMc: this is just to generate test data

9:54 tomoj: interleave will drop chunks

9:55 oh, interleave-all?

9:56 TimMc: I don't think it exists.

9:57 jjcomer: Use tomoj's solution.

9:58 jjcomer: TimMc: agreed thanks guys, thanks tomoj

10:02 tomoj: :/

10:07 TimMc: tomoj: Wouldn't be hard to modify your gist to *be* interleave-all.

10:31 sgarrett: Hello #clojure. I made a lazy seq function for primes I was wondering if someone could look over the small snippet of code and tell me if what I'm doing is proper clojure code or maybe some areas that I could improve. Here is the gist: https://gist.github.com/1856559

10:36 gfredericks: sgarrett: are you interested in performance at all, or just writing idiomatic clojure?

10:48 sgarrett: gredericks: idiomatic clojure

10:49 gfredericks: actually that and performance :P

10:52 gfredericks: I was using the Sieve of Eratosthenes for my algorithm and I was trying to filter out the multiples of each prime every time the function gets called with the next prime.

10:56 gfredericks: sgarrett: welp

10:56 there are a few things that could be shortened up with some knowledge of more core functions

10:57 (partial + 1) <=> inc

10:57 (iterate (partial + 1) 2) <=> (drop 2 (range))

10:57 although there is a difference with chunking between those two

10:58 kij: Hi, what is an better way to clean up my repl (namespace and lagg) than closing and starting clojure-jack-in ?

10:58 gfredericks: sgarrett: (not (zero? x)) => (pos? x) ; at least in this context

10:59 $findfn pos? [-3 -2 0 6 -4 8] 6

10:59 lazybot: []

11:00 gfredericks: I guess the filter/first thing is pretty typical. I've always wished there were a core function for it.

11:00 sgarrett: gfredericks: Okay. Cool. I'm not surprised I missed those I guess. Just started with "Programming Clojure" a couple weeks ago. So just trying to make sure I'm on the right track and improve where I can.

11:00 gfredericks: sgarrett: performance-wise, since you brought up Sieve's I should point out that the sieve of eratosthenes is a division-free algorithm

11:01 I think that's what distinguishes it from the sort of thing you're doing

11:01 sgarrett: Ahhh duh. You're right.

11:01 So it takes out multiples 2i, 3i, 4i.

11:02 gfredericks: it's a lot more straightforward to do not-lazy with arrays of booleans and that sort of thing; but that's no fun

11:02 sgarrett: Okay.

11:03 gfredericks: so there are lazy ways to do it. I think there are pretty simple ways to do it too. One consideration though is whether your algorithm keeps all the primes less than p in memory when computing p

11:03 I don't think most people care that intensely about their hobby sieve algorithms, but for some reason that's the stuff I think about :)

11:04 sgarrett: Yeah. I was hoping that it would be lazy in the sense that they wouldn't be evaluated until they have to be used.

11:04 gfredericks: sgarrett: well that's one aspect, but the part I was talking about is that when you're asking your sazy sequence for the 10000th prime, it will still have the first 9999 in memory whether or not you're holding on to them

11:05 that's a more general concern with lazy sequences

11:05 sgarrett: Right. How would I go about changing mine to something that doesn't take up that memory? Or is there a good article somewhere about that?

11:06 gfredericks: well mathematically you do need a bit of information to compute p, but it's not all the primes less than p -- it's all the primes less than the sqrt(p)

11:06 which will get you a lot farther

11:06 sgarrett: Ahhh I see. Okay.

11:06 gfredericks: I did a lazy version that takes that into account here: http://gfredericks.com/gfrlog/posts/90

11:07 sgarrett: Awesome. Thank you.

11:07 gfredericks: no problem

11:09 sgarrett: gfredericks: So when calling (lazy-seq) from the book I got the idea that when that's called it's not keeping the values in memory. Is that true or did I misinterpret it?

11:09 jcromartie: so this is neat but a little sparse http://functionaljobs.com/

11:10 I'm sure it's a great way for employers to get qualified applicants though

11:14 gfredericks: sgarrett: it doesn't generally, but your algorithm does.

11:14 I think it's an implicit kind of thing

11:15 your 'nums' sequence is an increasingly nested pile of filters

11:15 each one holding a prime

11:16 sgarrett: I guess in my mind I was trying to do it that way but not keep the previous filter, so keep drilling down on the next set of numbers.

11:17 gfredericks: that's why I said 'implicit'; it's easy to imagine that the filtering work has already been done, but in reality you couldn't have actually removed _all_ multiples of three from the sequence

11:17 so when you're computing the 10000th prime, all of the previous filters you've piled on are doing their checks

11:18 sgarrett: That's probably my main performance issue then. Okay. Thanks again. I have some work to do. :P

11:19 gfredericks: I should maybe correct myself and say that not _all_ the filters are in action at each point

11:19 the divisible-by-three filter never sees the even numbers, for example

11:19 so it's not totally awful

11:20 okay, wandering off; good luck

11:20 sgarrett: But say division by 5 filter, will that see multiples of 3 or no?

11:24 xeqi: sgarrett: no, the 3 filter will take care of those

11:40 sgarrett: Thanks again. Appreciate the help.

11:54 * TimMc throws a doall after sgarrett, just in case

12:11 dbushenko: how to set a base url for a noir web app?

12:13 _phil: hey what is a good way to filter out the *last* elements of a sequence that all have the same value?

12:15 pipeline: reverse it and keep peeking until you have the right subsequence maybe

12:15 _phil: there is (butlast (partition-by ...)), (reverse (reduce (reverse ...))) but there must be a better way

12:16 and then reverse it back?

12:19 pipeline: _phil: just keep it reversed all the time... always add to the right side, read from the left (the left is then "the end")

12:31 _phil: i just ended up with (reverse (drop-while (reverse ...)))

12:32 the collection doesnt contain that many elements so that performance isnt gonna be a problem

13:30 humasect: hmm... how to access lein project attributes from clojure? say, :resources-path

13:30 TimMc: humasect: Are you writing a plugin or hook?

13:31 humasect: neither ^_^

13:32 TimMc: humasect: Are you just trying to load a resource?

13:40 humasect: yeah, TimMc ^_^ clojure.java.io/resource only works on existing files, so i must use /file

13:45 TimMc: humasect: You're trying to load non-existent files? >_>

13:45 ClusterCat: Hi, a newbie question: Is there a way to clone all contrib modules in one go? (git clone --recursive doesn't seem to work)

13:46 humasect: TimMc: no, just to get the path name ^_^ to create the files in resources/ =)

13:46 TimMc: ClusterCat: All the 1.3 contrib things like clojure.tools.logging?

13:46 ClusterCat: Yes, TimMc.

13:48 TimMc: That actually sounds pretty useful. Where did you see a listing?

13:51 Hmm, I see http://dev.clojure.org/display/doc/Clojure+Contrib

16:38 jellenbogen: hi

16:49 fliebel: I'm trying to load an image in Clojure. I used (javax.imageio.ImageIO/read (io/input-stream file)), but now I moved the image to my resource folder, but I'm unsure how to get to it. I found (clojure.java.io/resource "pirateboot.png"), which returns nil.

16:56 yay, works... just some stupid classpath fiddling of course.

17:18 hey_lu_: can you tell me what https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Keyword.java#L45 does? and why it does that?

17:47 noobme: Hello, can anyone help me with a simple Clojure question?

17:48 mdeboard: noobme: Just ask

17:49 noobme: Say I have a sequence of boolean values, e.g. [true false false true] and I want to OR them together. This is what I'm doing and it gives me very strange results:

17:49 (defn f [& xs]

17:49 (if (empty? xs)

17:49 true

17:49 (or (first xs) (f (rest xs)))))

17:52 mdeboard: What do you want your return value to be?

17:53 noobme: for the example, true: (f true false false true)

17:53 Chousuke: noobme: you need to apply f to the rest xs

17:54 noobme: because of the way or works?

17:54 Chousuke: because of the way f works :P

17:54 noobme: elaborate

17:54 Chousuke: it uses rest arguments, so if you give it a seq, your xs in the recursion will be ((foo ...))

17:55 noobme: I don't follow that

17:55 Chousuke: think about what you pass to f when you call it, and in the recursive call

17:56 noobme: I assumed the tail of the sequence

17:56 Chousuke: (f true false true ...) as opposed to (f '(false true ...))

17:56 noobme: oh I see

17:56 that's a weird interaction between lists and the &

17:57 Chousuke: well, & just puts the "rest of" the arguments in a list

17:57 and in the recursive case, that rest is a list, so it gets put in a list

17:57 noobme: yes I hadn't thought about that

17:57 Chousuke: if you use plain recur though the destructuring doesn't happen again.

17:58 mdeboard: noobme: I see where you made your cognitive error, I made the same trying to duplicate your function. The ampersand signals variable arity; using a seq with multiple elements != variable arity

17:58 Chousuke: so if you made a tail recursive version you could use (recur (rest xs))

17:59 noobme: using apply seems unaesthetic to me in this case

17:59 Chousuke: that's something to keep in mind when you use rest args and recur, since it differs from plain recursion

17:59 I'm pretty sure there's a function for this somewhere anyway

17:59 noobme: yes

18:00 in fact or does what f purportedly does

18:00 but I needed to get this down before trying to solve the problem

18:00 Chousuke: or does, yeah, but it's not a function

18:00 noobme: So, is there a way around using apply?

18:00 Chousuke: just (or (first xs) (apply f (rest xs)))

18:01 noobme: that uses apply though

18:01 Chousuke: oh right, misunderstood the question :P

18:01 you could use an explicit loop I think

18:01 and make it tail recursive so you can recur

18:01 noobme: yeah

18:02 or use an internal implementation

18:02 that takes the & xs

18:02 and only operates on lists

18:03 i.e. (defn f [& xs]

18:03 ((fn … ) xs)

18:04 okay, I understand now. Thanks mdeboard and Chousuke!

18:04 mdeboard: noobme: Out of curiosity, why does `apply` seem unaesthetic?

18:04 noobme: Too heavy handed for what ought to be a simple function

18:05 mdeboard: heavy handed in what way?

18:05 I don't agree or disagree, just curious.

18:05 noobme: hmm...

18:05 mdeboard: I'm a bigger noob than you

18:05 noobme: oh I doubt that ;)

18:06 apply to me seems like something you use to evaluate data as code…

18:06 at least from my experience with other languages

18:06 it just seems out of place in this case

18:07 amalloy: good news: that's not at all what apply is

18:07 mdeboard: noobme: Evaluating data as code and vice versa is lisp

18:08 noobme: apply seems more like `map` than `exec` or `read`

18:08 noobme: amalloy: what do you mean?

18:08 amalloy: it has nothing to do with evaluating data as code

18:09 noobme: apply just seems way too powerful for ORing things. I was going for something more basic.

18:09 amalloy: you only need it because you want to take &args, as you discovered

18:10 if you look at the implementation of every?, which is basically what you implemented, it just takes an actual list, and doesn't need apply

18:11 noobme: yes, but I specifically need it to have variable arity

18:11 for the purposes of this exercise

18:11 http://www.4clojure.com/problem/83

18:12 amalloy: so? then you need apply to call it recursively. apply is for constructing arguments to call functions with; if your function doesn't accept a list and you have a list, you'll need apply

18:12 heh. that's a cute problem; you'll probably laugh at the shortest answer

18:12 noobme: okay I see

18:41 mdeboard: bool-seq is weird

18:44 amalloy: bool-seq?

18:45 mdeboard: Yeah, I'm using clojure-jack-in repl, bool-seq came up on the auto-complete for bool

18:45 clojure 1.3.0

18:45 amalloy: ,bool-seq

18:45 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: bool-seq in this context, compiling:(NO_SOURCE_PATH:0)>

18:45 amalloy: what package is it in?

18:46 mdeboard: (bool-seq true true false) returns 'false', (bool-seq true true true) returns nil

18:46 I dunno

18:46 amalloy: mdeboard: you can find out with: #'bool-seq

18:46 AimHere: Might it be part of the code you're working with/

18:46 mdeboard: oic

18:46 to both

18:46 #'user/bool-seq

18:46 was result of that

18:46 amalloy: so...you defined it yourself

18:47 AimHere: You define a function, then tell us all how weird it is?

18:47 I say that's attention-seeking behaviour, or amnesia, or you've been coding in your sleep.

18:53 mdeboard: Did I --

18:53 Holy fuck

18:53 Welp.

18:53 Wow.

18:53 Sorry.

18:53 literally like 5 minutes--

18:54 AimHere: The last two, I guess.

19:00 TimMc: Sleep-coding for sure.

19:03 gfredericks: (defn bool-seq [& args] ({[true true false] false} args))

19:03 ibdknox: lol

19:03 * gfredericks forgot the "is weird" docstring

19:04 amalloy: haha i was only kinda looking at the chat, and i thought that was mdeboard confessing he'd discovered how he defined the function

19:04 TimMc: vary-meta to the rescue?

19:04 amalloy: alter-meta!

19:04 TimMc: ah, yes

19:04 gfredericks: you guys always get me out of my binds

19:05 * gfredericks tries to figure out if that was a pun

19:06 mdeboard: I am not a smart man

19:07 ibdknox: we all have our moments :)

19:08 TimMc: Reminds me of the time I first wrote some highly "concurrent" Javascript code (a state explosion in a timeout factory) while hopped up on dark chocolate.

19:08 The next day I couldn't figure out how it worked. >_<

19:08 chewbranca: anyone have a more elegant odd number lazy sequence than (iterate #(+ % 2) 1) ?

19:09 TimMc: chewbranca: (range 1 Double/POSITIVE_INFINITY 2) I think

19:09 The Double is a bit ugly.

19:09 &(take 7 (range 1 Double/POSITIVE_INFINITY 2))

19:09 lazybot: ⇒ (1 3 5 7 9 11 13)

19:10 chewbranca: yeah that iterate function works fine, just doesn't seem overly elegant to have to use a lambda

19:10 gfredericks: (iterate dinc 1)

19:10 TimMc: chewbranca: If that offends you, there's always partial

19:11 amalloy: "have to use" a lambda! lambdas are a privilege, not an obligation

19:11 chewbranca: not offended, was just curious to do better

19:12 gfredericks: new challenge: what clojure code is more fun to read out loud than (def dinc (comp inc inc))

19:12 amalloy: i'd use your iterate, unless i badly needed performance, and then i would consider TimMc's range

19:13 Raynes: I'd probably not use either.

19:13 chewbranca: lambdas are definitely a privilege, and shouldn't be abused ;-)

19:13 Raynes: &(take 10 (filter odd? (range)))

19:13 lazybot: ⇒ (1 3 5 7 9 11 13 15 17 19)

19:13 TimMc: (def ∞ Double/POSITIVE_INFINITY)

19:13 Raynes: amalloy: Mines best, really.

19:13 Because it is the one that would confuse people the most.

19:13 TimMc: (range 1 ∞ 2)

19:13 Raynes: Yours is the most declarative. I like it.

19:14 gfredericks: Raynes: yours is the one that uses the most arithmetic

19:14 amalloy: yes, Raynes, yours is pretty good tbh, despite you apparently hating it

19:14 Raynes: What makes you think I hate it?

19:14 Seriously, that's the one I'd write in my own code. It'd be the first thing to pop in my mind.

19:14 TimMc: Raynes: How is it confusing?

19:14 amalloy: Because it is the one that would confuse people the most.

19:15 Raynes: I just meant that the laziness is more likely to confuse people.

19:15 chewbranca: Raynes: I thought about doing that, but not as much of a fan of generating everything and then filtering rather than generating directly

19:15 ibdknox: it's pretty inefficient though

19:15 Raynes: It's pretty insignificant.

19:15 amalloy: it may be more efficient than the iterate version

19:16 because of chunking

19:16 TimMc: hmmf

19:16 amalloy: &(time (-> (filter odd? (range)) (nth 1e6)))

19:16 lazybot: ⇒ "Elapsed time: 626.096694 msecs" 2000001

19:16 Raynes: chewbranca: The line between "generating everything and then filtering" and "generating it in the first place" is much thinner with lazy seq.

19:16 seqs*

19:16 amalloy: &(time (-> (iterate #(+ 2 %) 1) (nth 1e6)))

19:16 lazybot: ⇒ "Elapsed time: 218.161028 msecs" 2000001

19:17 AimHere: &(time (range 1 1e6 2))

19:17 lazybot: ⇒ "Elapsed time: 0.58079 msecs" (1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 ...

19:17 Raynes: Bang

19:17 amalloy: Raynes: you didn't time anything

19:17 Raynes: :p

19:17 amalloy: &(time (-> (range 1 Double/POSITIVE_INFINITY 2)) (nth 1e6)))

19:17 lazybot: clojure.lang.ArityException: Wrong number of args (2) passed to: core$time

19:18 amalloy: &(time (-> (range 1 Double/POSITIVE_INFINITY 2) (nth 1e6)))

19:18 lazybot: ⇒ "Elapsed time: 202.197132 msecs" 2000001

19:20 broquaint: Possibly daft question but why might up & down not navigate history in the slime repl?

19:20 amalloy: because it's a text editor

19:20 Raynes: Because you couldn't move around in the buffer otherwise.

19:20 amalloy: M-p/M-n

19:20 Raynes: You can na...

19:20 broquaint: And C-up / C-down only result in 5A/5B respectively.

19:20 Raynes: amalloy: Man.

19:20 amalloy: Type slower or something.

19:20 chewbranca: alright, so the lambda with + 2 seems fine for speed, although not quite as descriptive as filter odd?

19:21 broquaint: Super, M-[pn] works perfectly, thanks! :)

19:21 chewbranca: always fun to see different options, thanks guys

19:21 amalloy: (you could still move around in the buffer with C-p/C-n, Raynes)

19:21 Raynes: I hate you.

19:21 amalloy: despite your baffling distaste for those options

19:21 _phil: is there a more idiomatic way for this? https://gist.github.com/1861404

19:22 basically group-by but with additional transformation of the values

19:22 amalloy: yessss

19:22 (reduce #(update-in % (fnil conj []) %2) {} ...), i think

19:23 oh, i see, you're doing totally different stuff. stull, use fnil

19:23 Raynes: You should always stull use fnil.

19:23 _phil: amalloy: cool, thx

19:30 ibdknox: ,(doc fnil)

19:30 clojurebot: "([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."

19:31 ibdknox: huh, wish I had known about that one

19:31 te: I want to map across a seq with two args constantly in the same position: (map some-fn-that-takes-a-seq-and-two-args '(seq of elements) positional-arg1 positional-arg2)

19:31 amalloy: ibdknox: now you do!

19:32 ibdknox: indeed :)

19:33 ck_: ,(doc nil?)

19:33 clojurebot: "([x]); Returns true if x is nil, false otherwise."

19:34 AimHere: te > what do you mean by 'two args constantly in the same position'? You mean two constant values?

19:34 amalloy: he wants (map #(f % a b) vals)

19:35 te: yeah, sorry, figured that out immediately after i asked

20:00 mdeboard: amalloy: I don't know whether to laugh or groan at the shortest solution to #83

20:09 logaan: hey guys

20:10 i've got a file "src/debate_paper/models/document.clj" and i would like to access the functions defined there from the repl

20:10 i'm using lein

20:10 napping: It's not part of lein project, is it?

20:10 logaan: it's not referenced in project.clj

20:11 but it is inside the lein project structure

20:11 this is a noir app

20:11 napping: if that's src for the project, you should be able to do something like lein repl then (use 'debate_paper.models.document)

20:12 logaan: it's giving me: Exception lib names inside prefix lists must not contain periods clojure.core/load-lib (core.clj:5223)

20:13 i'm using debate-paper in the ns declaration inside document.clj

20:14 even though the path to the file is debate_paper

20:14 is that an issue?

20:15 napping: I forgot about the - _ translation

20:16 logaan: (use 'debate-paper.models.document) gives me the same error

20:20 any ideas?

20:21 aah turns it out was an error inside my file

21:00 te: Can anyone point in the right direction when it comes to building and using overtone on the edge?

21:01 The releases I see on clojars.org are 0.7.0-SNAPSHOT, but master is 0.1.5.

21:02 bah, nevermind

21:02 i had accidentally pulled rosejn's

21:30 muhoo: i saw this on the list, and thought "wow, is that really the idiomaatic way to loop over a stream?" https://refheap.com/paste/777

21:31 it seems... not idiomatic to me

21:38 amalloy: not really. all that mapping, removing, and taking could be part of the doseq

21:41 something like (let [in (.getInputStream avendar)] (doseq [c (repeatedly #(.read in)) :while (not= c -1) :when (not= c \return) :let [c (char c)]] (print c)) captures the intent of the original reasonably well

21:43 muhoo: ah cool, doseq is like for. i didn't know that

21:44 what's with the c bound in the beginning of the doseq, then also rebound in the :let?

21:45 amalloy: *shrug* i didn't want to invent any more names

21:45 muhoo: oh ok

21:46 um, so which c is the one defined in the let then?

21:46 the one in (print c), or in the while/whens, or none of the above?

21:49 ah, apparenttly the one in print

21:49 nm

21:52 it's neat that i was able to test it by replacing (let [in ... with (with-open [in (make-reader "file:///foo.txt")] ...

22:21 hmm, how many hours do you suppose it'd take to become somewhat proficient in clojure?

22:21 i'm at 76 hours so far, and i still feel like a useless idiot.

22:22 160 pages into "joy of clojure" too. maybe if i just stay focussed on getting through that, it'll be more productive

22:22 tmciver: muhoo: I've been dabling in Clojure in my spare time for over a year and I'm just getting out of the 'useless idiot' stage.

22:29 alexbaranosky: muhoo, as usual... it depends

22:34 muhoo: i'm probably just underestimating how much time it takes to get good at anything. this is the first time i'm actually trying to keep track.

22:36 everhthing i've gotten really good at, probably has taken me ridiculous numbers of hours

22:36 but at the time i was young and didn't care. now, i care.

22:38 Scriptor: muhoo: it probably takes a major project or two as well

22:39 beyond just hours

22:39 muhoo: good point. writing factorial and 4clojure stuff just doesn't cut it.

22:40 most of what i've learned has been through deep, wailing-and-gnashing-of-teeth pain and suffering.

22:41 like "i have no idea what i'm doing, but i'll take on this major, highly-visible project with a tight deadline!"

22:41 no more. i do not want to die of a heart attack.

22:42 * muhoo swears off startups for good.

22:42 Scriptor: heh, exactly, it forces you to internalize all the little things that the smaller problems focus on

22:44 muhoo: i do really love this language though. in every other language, i've found myself pissed off at the language and/or tools, but now, with clojure i find i'm pissed off at myself instead.

22:45 it's not like "gawd, this language is so fucking stupid", it's like "gawd, I'M so fucking stupid..."

22:49 alexbaranosky: muhoo, you shifted the bottle neck ;)

22:53 Scriptor: getting pissed off at the language/tools is just one step to mastery

22:54 muhoo: alexbaranosky: exactly. i'm the weak link, not the language. in this case, the llanguage is smarter than i am.

22:55 Scriptor: that's what i was wondering. will there be a time where i get annoyed at clojure? maybe after i learn haskell or ml, i dunno.

22:55 then again, i do get annoyed at java... a lot... one oof the main reasons i want to learn clojure in the first place.

22:56 Scriptor: muhoo: eh, I only marginally know both clojure and haskell, but I've found them to be different enough to not compare them when using them

22:56 on the other hand, at least small code snippets translate pretty well

22:57 right now I'm just getting annoyed at emacs...why can't it find 'package

22:58 ah, goddamn v22.1

22:58 I could've sworn I had 24

22:59 muhoo: wow, that's old

22:59 running debian lenny, are you?

22:59 Scriptor: er, windows :p

23:12 oh man, I've missed the fuzzy autocomplete that the starter kit gets you

23:26 mdeboard: Why does (take-nth) start with the 0th element in a seq?

23:26 ,(take-nth 3 [1 2 3 4 5 6])

23:26 clojurebot: (1 4)

23:26 mdeboard: that's weird.

23:36 amalloy: well if it didn't there'd be no way to get the 0th element

23:36 whereas you can easily drop some of them yourself if you don't want to start at the beginning

23:38 mdeboard: yar

Logging service provided by n01se.net