#clojure logs

2012-02-18

00:00TimMccemerick: It makes it annoying to use APIs that have arglists like [a b & {:keys [c d]}]
00:00cemerickAPMap should only accept entries/pairs in its cons method. Can't sleep some nights because of it.
00:01cemericka flexible mapply fn would be easy enough.
00:01TimMcSure, I've written mapply several times.
00:02TimMcIt would be easy enough to make one that does both.
00:02cemerickright, that's what I meant by flexible
00:02TimMc...but I never don't know which I want statically.
00:02cemerickNot really worth the hassle IMO.
00:02TimMcWhat's the best way to turn a map into interleaved keys and vals? interleave keys vals?
00:03amalloyapply concat
00:03TimMcHah, nice.
00:03amalloy&(for [e '{a 1 b 2 c 3}, x e] x)
00:03lazybot⇒ (a 1 b 2 c 3)
00:04amalloyis another approach
00:04cemerickPeople yell at me for using mapcat identity for that.
00:04amalloyjustifiably so, i suppose. not that my 'for is any better
00:05cemerickThese things become habitual.
00:13hiredman~flatten
00:13clojurebotflatten 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.
00:13TimMcI 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.
00:14hiredmancrashed the jvm that time, buckets of fun
00:14TimMcClearly, everyone else was watching the same movie.
00:21amalloyfriday night just wouldn't be the same without watching a movie over TimMc's shoulder
01:01TimMcWait, remind me again why UUIDs need to have reader syntax?
01:01TimMcI'm not asking to be convinced, I just don't see any point.
01:04technomancyheh
01:06amalloyi think it's supposed to be for data transfer/serialization
01:09emezeskeTimMc: Is this UUID reader syntax business a real thing being considered?
01:11technomancy=\
01:11emezeskeThat's a very curious feature
02:04cemerickemezeske: Very. It's in 1.4
03:52spoon16best way to filter null values from a map? https://gist.github.com/1858320
04:22tomojis clojurescript one's bootstrap/git-deps the easiest current way to get clojurescript library deps?
05:49aidyIs there a Scheme for-each equivalent in clojure, without sequence bindings? e.g. (for-each fn seq)
06:00morphlingaidy: no, doseq is what you should use but (doall (map fn seq)) will probably work, too
06:01aidyokay, thanks :)
07:55tdrgabiI've been trying for an hour to (:require [clojure.java.jbdc :as sql])
07:55tdrgabiand I keep getting Could not locate clojure/java/jbdc__init.class or clojure/java/jbdc.clj on classpath:
07:55tdrgabiI have it in the project file
07:56tdrgabi:dependencies [
07:56tdrgabi [org.clojure/clojure "1.2.1"]
07:56tdrgabi [org.clojure/data.json "0.1.2"]
07:56tdrgabi [org.clojure/java.jdbc "0.1.1"]
07:56tdrgabi [enlive "1.0.0-SNAPSHOT"]])
07:56tdrgabiand the jar is present when I do lein swank
07:56tdrgabiany ideas what I do wrong?
07:56raektdrgabi: did you write that (:require ...) line in the repl or in the ns form?
07:56tdrgabiyes, this is my ns
07:56tdrgabi(ns cooking_assistant.core
07:56tdrgabi (:require [clojure.java.io :as io])
07:56tdrgabi (:require [clojure.java.jbdc :as sql])
07:56tdrgabi (:require [net.cgrand.enlive-html :as html])
07:56tdrgabi (:import (java.sql DriverManager)))
07:57tdrgabiand it fails at jdbc require
07:57raekhave you run lein deps and restarted the repl after you added it to the project.clj file?
07:57tdrgabiyes. multiple times :)
07:57tdrgabithere's a clojure.java dir in the clojure.jar I have in deps
07:58raektdrgabi: ah, you have a typo: "jdbc", not "jbdc"
07:58tdrgabimaybe it's looking there instead of the java.jdbc.jar
07:58tdrgabithis is embarasing
07:58tdrgabithanks :)
07:59tdrgabihow do you guys use the new slime/swank in emacs?
07:59tdrgabiC-c C-c does a compile now instead of eval - buffer
07:59raekI have been using C-c C-k
08:00raekbut I thought "compile" and "load" did the same in swank-clojure
08:00tdrgabiI think it was recently changed, but I'm new at this so don't take my word for it
08:35tdrgabiafter including [sqlitejdbc "0.5.6"] to lein and running lein deps
08:35tdrgabilein swank crashes with Exception in thread "main" java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (macroexpand.clj:1)
08:35tdrgabi at clojure.lang.Compiler.eval(Compiler.java:5440)
08:36tdrgabiif I remove it, it works
08:36tdrgabiCaused by: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V
08:36tdrgabi at clojure.contrib.def$defmacro___509.<init>(def.clj:39)
08:36tdrgabiis it possible that it wants the older clojure.contrib?
08:46tdrgabidid any of you used clojure with sqlite?
09:32jjcomerDoes anyone have a clever way to randomly interleave two lists?
09:38kephale,(interleave (shuffle (range 10)) (shuffle (range 100 110)))
09:38clojurebot(5 108 8 107 4 ...)
09:39kephaleis that clever enough?
09:40jjcomerkephale: 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
09:40TimMcjjcomer: Define "randomly interleaved".
09:41kephaleyou just want a permutation of the list of the strings
09:41kephale?
09:41jjcomerSo "orange" and "apple" could generate "aporangplee"
09:41kephaleah
09:42TimMcjjcomer: You'll want to define a probability distribution for the size of a contiguous segment.
09:42kephalethat strikes me as being a parametrized function
09:42kephaleyeah
09:42kephaleparameterized*
09:43kephalewell, or a parameter specifying a distribution of chunk sizes
09:46TimMc&(let [chunker (partial partition-by (fn [x] (rand-int 3)))] (interleave (chunker "abcdefghijk") (chunker (range 10)))) ;; except you'd want an interleave-all
09:46lazybot⇒ ((\a \b \c) (0) (\d) (1) (\e) (2) (\f) (3 4) (\g \h) (5 6) (\i) (7 8 9))
09:48TimMcjjcomer: ^ partition-by rand-int might be good enough for you, but it doesn't give you much control over chunk size
09:49TimMc&(let [chunker (partial partition-by (fn [x] (rand-int 2)))] (interleave (chunker "abcdefghijk") (chunker (range 10))))
09:49lazybot⇒ ((\a) (0 1 2) (\b) (3) (\c) (4 5) (\d) (6) (\e) (7 8 9))
09:49TimMc&(let [chunker (partial partition-by (fn [x] (rand-int 2)))] (interleave (chunker "abcdefghijk") (chunker (range 10))))
09:49lazybot⇒ ((\a) (0 1) (\b \c) (2 3 4 5 6) (\d \e) (7 8) (\f \g) (9))
09:49tomojhow does that compare to this https://gist.github.com/74eb36db2e78d49291a9 (ugly loop implementation aside...)
09:50tomoji.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
09:50TimMcI'm not actually sure.
09:51TimMcI suspect that jjcomer's needs are not algorithmically precise, though.
09:51jjcomertomoj: That's what I have now, not sure if there is a more clojure way to do it :)
09:51jjcomer:TimMc: this is just to generate test data
09:54tomojinterleave will drop chunks
09:55tomojoh, interleave-all?
09:56TimMcI don't think it exists.
09:57TimMcjjcomer: Use tomoj's solution.
09:58jjcomerTimMc: agreed thanks guys, thanks tomoj
10:02tomoj:/
10:07TimMctomoj: Wouldn't be hard to modify your gist to *be* interleave-all.
10:31sgarrettHello #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:36gfrederickssgarrett: are you interested in performance at all, or just writing idiomatic clojure?
10:48sgarrettgredericks: idiomatic clojure
10:49sgarrettgfredericks: actually that and performance :P
10:52sgarrettgfredericks: 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:56gfrederickssgarrett: welp
10:56gfredericksthere are a few things that could be shortened up with some knowledge of more core functions
10:57gfredericks(partial + 1) <=> inc
10:57gfredericks(iterate (partial + 1) 2) <=> (drop 2 (range))
10:57gfredericksalthough there is a difference with chunking between those two
10:58kijHi, what is an better way to clean up my repl (namespace and lagg) than closing and starting clojure-jack-in ?
10:58gfrederickssgarrett: (not (zero? x)) => (pos? x) ; at least in this context
10:59gfredericks$findfn pos? [-3 -2 0 6 -4 8] 6
10:59lazybot[]
11:00gfredericksI guess the filter/first thing is pretty typical. I've always wished there were a core function for it.
11:00sgarrettgfredericks: 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:00gfrederickssgarrett: performance-wise, since you brought up Sieve's I should point out that the sieve of eratosthenes is a division-free algorithm
11:01gfredericksI think that's what distinguishes it from the sort of thing you're doing
11:01sgarrettAhhh duh. You're right.
11:01sgarrettSo it takes out multiples 2i, 3i, 4i.
11:02gfredericksit's a lot more straightforward to do not-lazy with arrays of booleans and that sort of thing; but that's no fun
11:02sgarrettOkay.
11:03gfredericksso 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:03gfredericksI 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:04sgarrettYeah. I was hoping that it would be lazy in the sense that they wouldn't be evaluated until they have to be used.
11:04gfrederickssgarrett: 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:05gfredericksthat's a more general concern with lazy sequences
11:05sgarrettRight. 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:06gfrederickswell 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:06gfrederickswhich will get you a lot farther
11:06sgarrettAhhh I see. Okay.
11:06gfredericksI did a lazy version that takes that into account here: http://gfredericks.com/gfrlog/posts/90
11:07sgarrettAwesome. Thank you.
11:07gfredericksno problem
11:09sgarrettgfredericks: 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:09jcromartieso this is neat but a little sparse http://functionaljobs.com/
11:10jcromartieI'm sure it's a great way for employers to get qualified applicants though
11:14gfrederickssgarrett: it doesn't generally, but your algorithm does.
11:14gfredericksI think it's an implicit kind of thing
11:15gfredericksyour 'nums' sequence is an increasingly nested pile of filters
11:15gfrederickseach one holding a prime
11:16sgarrettI 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:17gfredericksthat'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:17gfredericksso when you're computing the 10000th prime, all of the previous filters you've piled on are doing their checks
11:18sgarrettThat's probably my main performance issue then. Okay. Thanks again. I have some work to do. :P
11:19gfredericksI should maybe correct myself and say that not _all_ the filters are in action at each point
11:19gfredericksthe divisible-by-three filter never sees the even numbers, for example
11:19gfredericksso it's not totally awful
11:20gfredericksokay, wandering off; good luck
11:20sgarrettBut say division by 5 filter, will that see multiples of 3 or no?
11:24xeqisgarrett: no, the 3 filter will take care of those
11:40sgarrettThanks again. Appreciate the help.
12:11dbushenkohow to set a base url for a noir web app?
12:13_philhey what is a good way to filter out the *last* elements of a sequence that all have the same value?
12:15pipelinereverse it and keep peeking until you have the right subsequence maybe
12:15_philthere is (butlast (partition-by ...)), (reverse (reduce (reverse ...))) but there must be a better way
12:16_philand then reverse it back?
12:19pipeline_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_phili just ended up with (reverse (drop-while (reverse ...)))
12:32_philthe collection doesnt contain that many elements so that performance isnt gonna be a problem
13:30humasecthmm... how to access lein project attributes from clojure? say, :resources-path
13:30TimMchumasect: Are you writing a plugin or hook?
13:31humasectneither ^_^
13:32TimMchumasect: Are you just trying to load a resource?
13:40humasectyeah, TimMc ^_^ clojure.java.io/resource only works on existing files, so i must use /file
13:45TimMchumasect: You're trying to load non-existent files? >_>
13:45ClusterCatHi, a newbie question: Is there a way to clone all contrib modules in one go? (git clone --recursive doesn't seem to work)
13:46humasectTimMc: no, just to get the path name ^_^ to create the files in resources/ =)
13:46TimMcClusterCat: All the 1.3 contrib things like clojure.tools.logging?
13:46ClusterCatYes, TimMc.
13:48TimMcThat actually sounds pretty useful. Where did you see a listing?
13:51TimMcHmm, I see http://dev.clojure.org/display/doc/Clojure+Contrib
16:38jellenbogenhi
16:49fliebelI'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:56fliebelyay, works... just some stupid classpath fiddling of course.
17:18hey_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:47noobmeHello, can anyone help me with a simple Clojure question?
17:48mdeboardnoobme: Just ask
17:49noobmeSay 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:49noobme(defn f [& xs]
17:49noobme (if (empty? xs)
17:49noobme true
17:49noobme (or (first xs) (f (rest xs)))))
17:52mdeboardWhat do you want your return value to be?
17:53noobmefor the example, true: (f true false false true)
17:53Chousukenoobme: you need to apply f to the rest xs
17:54noobmebecause of the way or works?
17:54Chousukebecause of the way f works :P
17:54noobmeelaborate
17:54Chousukeit uses rest arguments, so if you give it a seq, your xs in the recursion will be ((foo ...))
17:55noobmeI don't follow that
17:55Chousukethink about what you pass to f when you call it, and in the recursive call
17:56noobmeI assumed the tail of the sequence
17:56Chousuke(f true false true ...) as opposed to (f '(false true ...))
17:56noobmeoh I see
17:56noobmethat's a weird interaction between lists and the &
17:57Chousukewell, & just puts the "rest of" the arguments in a list
17:57Chousukeand in the recursive case, that rest is a list, so it gets put in a list
17:57noobmeyes I hadn't thought about that
17:57Chousukeif you use plain recur though the destructuring doesn't happen again.
17:58mdeboardnoobme: 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:58Chousukeso if you made a tail recursive version you could use (recur (rest xs))
17:59noobmeusing apply seems unaesthetic to me in this case
17:59Chousukethat's something to keep in mind when you use rest args and recur, since it differs from plain recursion
17:59ChousukeI'm pretty sure there's a function for this somewhere anyway
17:59noobmeyes
18:00noobmein fact or does what f purportedly does
18:00noobmebut I needed to get this down before trying to solve the problem
18:00Chousukeor does, yeah, but it's not a function
18:00noobmeSo, is there a way around using apply?
18:00Chousukejust (or (first xs) (apply f (rest xs)))
18:01noobmethat uses apply though
18:01Chousukeoh right, misunderstood the question :P
18:01Chousukeyou could use an explicit loop I think
18:01Chousukeand make it tail recursive so you can recur
18:01noobmeyeah
18:02noobmeor use an internal implementation
18:02noobmethat takes the & xs
18:02noobmeand only operates on lists
18:03noobmei.e. (defn f [& xs]
18:03noobme((fn … ) xs)
18:04noobmeokay, I understand now. Thanks mdeboard and Chousuke!
18:04mdeboardnoobme: Out of curiosity, why does `apply` seem unaesthetic?
18:04noobmeToo heavy handed for what ought to be a simple function
18:05mdeboardheavy handed in what way?
18:05mdeboardI don't agree or disagree, just curious.
18:05noobmehmm...
18:05mdeboardI'm a bigger noob than you
18:05noobmeoh I doubt that ;)
18:06noobmeapply to me seems like something you use to evaluate data as code…
18:06noobmeat least from my experience with other languages
18:06noobmeit just seems out of place in this case
18:07amalloygood news: that's not at all what apply is
18:07mdeboardnoobme: Evaluating data as code and vice versa is lisp
18:08mdeboardnoobme: apply seems more like `map` than `exec` or `read`
18:08noobmeamalloy: what do you mean?
18:08amalloyit has nothing to do with evaluating data as code
18:09noobmeapply just seems way too powerful for ORing things. I was going for something more basic.
18:09amalloyyou only need it because you want to take &args, as you discovered
18:10amalloyif 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:11noobmeyes, but I specifically need it to have variable arity
18:11noobmefor the purposes of this exercise
18:11noobmehttp://www.4clojure.com/problem/83
18:12amalloyso? 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:12amalloyheh. that's a cute problem; you'll probably laugh at the shortest answer
18:12noobmeokay I see
18:41mdeboardbool-seq is weird
18:44amalloybool-seq?
18:45mdeboardYeah, I'm using clojure-jack-in repl, bool-seq came up on the auto-complete for bool
18:45mdeboardclojure 1.3.0
18:45amalloy,bool-seq
18:45clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: bool-seq in this context, compiling:(NO_SOURCE_PATH:0)>
18:45amalloywhat package is it in?
18:46mdeboard(bool-seq true true false) returns 'false', (bool-seq true true true) returns nil
18:46mdeboardI dunno
18:46amalloymdeboard: you can find out with: #'bool-seq
18:46AimHereMight it be part of the code you're working with/
18:46mdeboardoic
18:46mdeboardto both
18:46mdeboard#'user/bool-seq
18:46mdeboardwas result of that
18:46amalloyso...you defined it yourself
18:47AimHereYou define a function, then tell us all how weird it is?
18:47AimHereI say that's attention-seeking behaviour, or amnesia, or you've been coding in your sleep.
18:53mdeboardDid I --
18:53mdeboardHoly fuck
18:53mdeboardWelp.
18:53mdeboardWow.
18:53mdeboardSorry.
18:53mdeboardliterally like 5 minutes--
18:54mdeboardAimHere: The last two, I guess.
19:00TimMcSleep-coding for sure.
19:03gfredericks(defn bool-seq [& args] ({[true true false] false} args))
19:03ibdknoxlol
19:04amalloyhaha i was only kinda looking at the chat, and i thought that was mdeboard confessing he'd discovered how he defined the function
19:04TimMcvary-meta to the rescue?
19:04amalloyalter-meta!
19:04TimMcah, yes
19:04gfredericksyou guys always get me out of my binds
19:06mdeboardI am not a smart man
19:07ibdknoxwe all have our moments :)
19:08TimMcReminds 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:08TimMcThe next day I couldn't figure out how it worked. >_<
19:08chewbrancaanyone have a more elegant odd number lazy sequence than (iterate #(+ % 2) 1) ?
19:09TimMcchewbranca: (range 1 Double/POSITIVE_INFINITY 2) I think
19:09TimMcThe Double is a bit ugly.
19:09TimMc&(take 7 (range 1 Double/POSITIVE_INFINITY 2))
19:09lazybot⇒ (1 3 5 7 9 11 13)
19:10chewbrancayeah that iterate function works fine, just doesn't seem overly elegant to have to use a lambda
19:10gfredericks(iterate dinc 1)
19:10TimMcchewbranca: If that offends you, there's always partial
19:11amalloy"have to use" a lambda! lambdas are a privilege, not an obligation
19:11chewbrancanot offended, was just curious to do better
19:12gfredericksnew challenge: what clojure code is more fun to read out loud than (def dinc (comp inc inc))
19:12amalloyi'd use your iterate, unless i badly needed performance, and then i would consider TimMc's range
19:13RaynesI'd probably not use either.
19:13chewbrancalambdas are definitely a privilege, and shouldn't be abused ;-)
19:13Raynes&(take 10 (filter odd? (range)))
19:13lazybot⇒ (1 3 5 7 9 11 13 15 17 19)
19:13TimMc(def ∞ Double/POSITIVE_INFINITY)
19:13Raynesamalloy: Mines best, really.
19:13RaynesBecause it is the one that would confuse people the most.
19:13TimMc(range 1 ∞ 2)
19:13TimMcRaynes: Yours is the most declarative. I like it.
19:14gfredericksRaynes: yours is the one that uses the most arithmetic
19:14amalloyyes, Raynes, yours is pretty good tbh, despite you apparently hating it
19:14RaynesWhat makes you think I hate it?
19:14RaynesSeriously, that's the one I'd write in my own code. It'd be the first thing to pop in my mind.
19:14TimMcRaynes: How is it confusing?
19:14amalloyBecause it is the one that would confuse people the most.
19:15RaynesI just meant that the laziness is more likely to confuse people.
19:15chewbrancaRaynes: I thought about doing that, but not as much of a fan of generating everything and then filtering rather than generating directly
19:15ibdknoxit's pretty inefficient though
19:15RaynesIt's pretty insignificant.
19:15amalloyit may be more efficient than the iterate version
19:16amalloybecause of chunking
19:16TimMchmmf
19:16amalloy&(time (-> (filter odd? (range)) (nth 1e6)))
19:16lazybot⇒ "Elapsed time: 626.096694 msecs" 2000001
19:16Rayneschewbranca: The line between "generating everything and then filtering" and "generating it in the first place" is much thinner with lazy seq.
19:16Raynesseqs*
19:16amalloy&(time (-> (iterate #(+ 2 %) 1) (nth 1e6)))
19:16lazybot⇒ "Elapsed time: 218.161028 msecs" 2000001
19:17AimHere&(time (range 1 1e6 2))
19:17lazybot⇒ "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:17RaynesBang
19:17amalloyRaynes: you didn't time anything
19:17Raynes:p
19:17amalloy&(time (-> (range 1 Double/POSITIVE_INFINITY 2)) (nth 1e6)))
19:17lazybotclojure.lang.ArityException: Wrong number of args (2) passed to: core$time
19:18amalloy&(time (-> (range 1 Double/POSITIVE_INFINITY 2) (nth 1e6)))
19:18lazybot⇒ "Elapsed time: 202.197132 msecs" 2000001
19:20broquaintPossibly daft question but why might up & down not navigate history in the slime repl?
19:20amalloybecause it's a text editor
19:20RaynesBecause you couldn't move around in the buffer otherwise.
19:20amalloyM-p/M-n
19:20RaynesYou can na...
19:20broquaintAnd C-up / C-down only result in 5A/5B respectively.
19:20Raynesamalloy: Man.
19:20Raynesamalloy: Type slower or something.
19:20chewbrancaalright, so the lambda with + 2 seems fine for speed, although not quite as descriptive as filter odd?
19:21broquaintSuper, M-[pn] works perfectly, thanks! :)
19:21chewbrancaalways fun to see different options, thanks guys
19:21amalloy(you could still move around in the buffer with C-p/C-n, Raynes)
19:21RaynesI hate you.
19:21amalloydespite your baffling distaste for those options
19:21_philis there a more idiomatic way for this? https://gist.github.com/1861404
19:22_philbasically group-by but with additional transformation of the values
19:22amalloyyessss
19:22amalloy(reduce #(update-in % (fnil conj []) %2) {} ...), i think
19:23amalloyoh, i see, you're doing totally different stuff. stull, use fnil
19:23RaynesYou should always stull use fnil.
19:23_philamalloy: cool, thx
19:30ibdknox,(doc fnil)
19:30clojurebot"([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:31ibdknoxhuh, wish I had known about that one
19:31teI 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:31amalloyibdknox: now you do!
19:32ibdknoxindeed :)
19:33ck_,(doc nil?)
19:33clojurebot"([x]); Returns true if x is nil, false otherwise."
19:34AimHerete > what do you mean by 'two args constantly in the same position'? You mean two constant values?
19:34amalloyhe wants (map #(f % a b) vals)
19:35teyeah, sorry, figured that out immediately after i asked
20:00mdeboardamalloy: I don't know whether to laugh or groan at the shortest solution to #83
20:09logaanhey guys
20:10logaani've got a file "src/debate_paper/models/document.clj" and i would like to access the functions defined there from the repl
20:10logaani'm using lein
20:10nappingIt's not part of lein project, is it?
20:10logaanit's not referenced in project.clj
20:11logaanbut it is inside the lein project structure
20:11logaanthis is a noir app
20:11nappingif that's src for the project, you should be able to do something like lein repl then (use 'debate_paper.models.document)
20:12logaanit's giving me: Exception lib names inside prefix lists must not contain periods clojure.core/load-lib (core.clj:5223)
20:13logaani'm using debate-paper in the ns declaration inside document.clj
20:14logaaneven though the path to the file is debate_paper
20:14logaanis that an issue?
20:15nappingI forgot about the - _ translation
20:16logaan(use 'debate-paper.models.document) gives me the same error
20:20logaanany ideas?
20:21logaanaah turns it out was an error inside my file
21:00teCan anyone point in the right direction when it comes to building and using overtone on the edge?
21:01teThe releases I see on clojars.org are 0.7.0-SNAPSHOT, but master is 0.1.5.
21:02tebah, nevermind
21:02tei had accidentally pulled rosejn's
21:30muhooi 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:31muhooit seems... not idiomatic to me
21:38amalloynot really. all that mapping, removing, and taking could be part of the doseq
21:41amalloysomething 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:43muhooah cool, doseq is like for. i didn't know that
21:44muhoowhat's with the c bound in the beginning of the doseq, then also rebound in the :let?
21:45amalloy*shrug* i didn't want to invent any more names
21:45muhoooh ok
21:46muhooum, so which c is the one defined in the let then?
21:46muhoothe one in (print c), or in the while/whens, or none of the above?
21:49muhooah, apparenttly the one in print
21:49muhoonm
21:52muhooit's neat that i was able to test it by replacing (let [in ... with (with-open [in (make-reader "file:///foo.txt")] ...
22:21muhoohmm, how many hours do you suppose it'd take to become somewhat proficient in clojure?
22:21muhooi'm at 76 hours so far, and i still feel like a useless idiot.
22:22muhoo160 pages into "joy of clojure" too. maybe if i just stay focussed on getting through that, it'll be more productive
22:22tmcivermuhoo: 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:29alexbaranoskymuhoo, as usual... it depends
22:34muhooi'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:36muhooeverhthing i've gotten really good at, probably has taken me ridiculous numbers of hours
22:36muhoobut at the time i was young and didn't care. now, i care.
22:38Scriptormuhoo: it probably takes a major project or two as well
22:39Scriptorbeyond just hours
22:39muhoogood point. writing factorial and 4clojure stuff just doesn't cut it.
22:40muhoomost of what i've learned has been through deep, wailing-and-gnashing-of-teeth pain and suffering.
22:41muhoolike "i have no idea what i'm doing, but i'll take on this major, highly-visible project with a tight deadline!"
22:41muhoo no more. i do not want to die of a heart attack.
22:42Scriptorheh, exactly, it forces you to internalize all the little things that the smaller problems focus on
22:44muhooi 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:45muhooit's not like "gawd, this language is so fucking stupid", it's like "gawd, I'M so fucking stupid..."
22:49alexbaranoskymuhoo, you shifted the bottle neck ;)
22:53Scriptorgetting pissed off at the language/tools is just one step to mastery
22:54muhooalexbaranosky: exactly. i'm the weak link, not the language. in this case, the llanguage is smarter than i am.
22:55muhooScriptor: 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:55muhoothen again, i do get annoyed at java... a lot... one oof the main reasons i want to learn clojure in the first place.
22:56Scriptormuhoo: 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:56Scriptoron the other hand, at least small code snippets translate pretty well
22:57Scriptorright now I'm just getting annoyed at emacs...why can't it find 'package
22:58Scriptorah, goddamn v22.1
22:58ScriptorI could've sworn I had 24
22:59muhoowow, that's old
22:59muhoorunning debian lenny, are you?
22:59Scriptorer, windows :p
23:12Scriptoroh man, I've missed the fuzzy autocomplete that the starter kit gets you
23:26mdeboardWhy does (take-nth) start with the 0th element in a seq?
23:26mdeboard,(take-nth 3 [1 2 3 4 5 6])
23:26clojurebot(1 4)
23:26mdeboardthat's weird.
23:36amalloywell if it didn't there'd be no way to get the 0th element
23:36amalloywhereas you can easily drop some of them yourself if you don't want to start at the beginning
23:38mdeboardyar