#clojure log - Mar 09 2013

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

1:02 RazWelles: what's the fastest way to add to a list/set/vector every 60msec?

1:02 (meaning this list would get big over time)

1:03 cons?

1:03 clojurebot: (def ^:const x 42) will cause any compiled reference to x to be as if you wrote 42 instead

1:12 alexbaranosky1: RazWelles: not quite sure what you're asking. But 'conj' is the fastest way to add things to collections

1:13 RazWelles: alexbaranosky1, ahh ok, I just thought every operation in clojure was by value, so as the list got bigger and bigger.. like say in the gig range, it would grind the computer to a halt if it was copying values and generating a new sequence each time

1:13 seq/list/vector

1:14 x.x still new to this

1:15 alexbaranosky1: persistent data structures don't copy

1:16 RazWelles: ahh ok

1:16 alexbaranosky1, what if I need to append to the end of the list?

1:28 tomoj: you don't do that

1:28 vectors conj at the end, maybe you want that

1:39 arrdem: who on here was working on a "sane defaults" ring template project?

1:43 `lein new compojure foo` I can do that..

1:52 Frozenlock: Can I use `count' to check how big is a result AND estimate the time taken? IE will realize any lazystuff?

1:55 Raynes: ivaraase1: So what is so great about my accent?

2:24 amalloy: Raynes: could you rephrase the question as an mp3?

2:24 Raynes: lol

2:25 Frozenlock: Yesssss! 100 fold speed increase in mongodb =D

2:25 arrdem: w00t

2:25 incanter vs compojure?

2:26 andyfingerhut: Wow. Do databases use Java reflection? :-)

2:26 arrdem: s/compojure/hiccup

2:26 aaand they do different jobs

2:27 Frozenlock: I just changed how I store my data: in a less horrible way.

2:38 herve-s: \part

3:35 Raynes: hyPiRion: http://logs.lazybot.org/irc.freenode.net/%23clojure

3:37 $latest compojure

3:37 lazybot: [compojure "1.1.5"] -- https://clojars.org/compojure

3:37 Raynes: $latest ring/ring-jetty-adapter

3:37 lazybot: [ring/ring-jetty-adapter "1.2.0-beta1"] -- https://clojars.org/ring/ring-jetty-adapter

3:38 Raynes: Hehe.

3:38 lazybot's Compojure is *amazingly* old.

3:38 Like 0.6.x

3:39 hyPiRion: Raynes: :D

4:06 Gonzih: $latest clodiuno

4:06 lazybot: [clodiuno "0.0.4-SNAPSHOT"] -- https://clojars.org/clodiuno

5:38 Ember-: any way to do something like this?

5:38 (walk/postwalk-replace {[:foo string?] nil} nested-structure)

5:38 works fine if string? is replaced with an absolute string

5:38 but I want to remove ALL entries hierarchically where key is :foo

5:43 I tried to use regexps too but doesn't work :(

5:43 borkdude: anyone using workgroups.el here?

5:44 ~anyone

5:44 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

5:44 borkdude: yehyeh

5:47 I'm a bit confused about workgroups.el: what is the exact difference between save and update?

5:47 my understanding: update saves the new window configuration, but what does save do?

5:54 Ember-: I'm guessing no one knows answer to my question :(

5:54 *sadface*

6:01 hyPiRion: Ember-: It's not exactly afternoon in the US of A right now

6:01 Ember-: it's 13:03 here :)

6:02 hyPiRion: and 12 here :)

6:03 Ember-: but I'm guessing I might be able to do what I want with plain ol' walk function

6:03 hyPiRion: But NY -> 0600 and San Fran is 0300

6:04 Ember-: and I guess you don't know the answer to my question? :)

6:04 since you're awake

6:05 hyPiRion: Ember-: That's true. I'm not good at clojure.walk nor immutable tree manipulations

6:06 Ember-: aww

6:07 somehow it would feel logical that if smap contains a predicate walk api would pass the value to that predicate

6:08 but now, my train arrives at the station

6:08 have a nice day everyone :) ->

6:10 hyPiRion: have a nice day :)

6:10 arrdem: hyPiRion: mother of god why are you still up...

6:14 hyPiRion: arrdem: huh? I'm Norwegian, it's like 12:15 here

6:30 borkdude: argh, orgmode.org is down

6:47 OscarZ: newb here experimenting with Ring.. I made a new file controller.clj in addition to handler.clj that was provided by default... for some reason getting classnotfoundexception for (:use [ring.velocity.core :only [render]])

6:47 the same line works in handler.clj

6:49 the same lib should be visible in controller too ?

6:49 hyPiRion: OscarZ: yes, assuming both are in the same project

6:49 are you using (:use [ring.velocity.core :only [render]]) as an argument to ns?

6:50 OscarZ: ok thanks.. yes they are.. i need to recheck everything, its probably something stupid :)

6:51 ah crap.. that was it :) i had (ns compojure-test.controller) as the first line ..

6:51 hyPiRion: :)

6:51 Just so you know, if you want to use `use` instead sometime, you have to quote the values you send in

6:52 so in your case, you may end up with (use '[ring.velocity.core :only [render]])

6:52 (Though `use` is mostly used for repl-testing)

6:53 OscarZ: oh.. in the default handler.clj, there is no quote.. it seems to work

6:54 hyPiRion: OscarZ: yeah, that works fine because it's inside the (ns .. ) part

6:55 if you want to get a library without using ns, use (use ..)

6:56 OscarZ: oh, right.. i think i need to read up on namespaces, use and require :)

6:58 using 'use' without ns, you can get more "local" import for some library (import as in java) ?

7:01 hyPiRion: Well, the thing is that you rarely want to specify the namespace when running in a repl for instance

7:01 So like

7:01 ,(require '[clojure.string :as string])

7:01 clojurebot: nil

7:02 hyPiRion: won't make a new namespace just to get new namespaces you'd like to experiment on

7:02 OscarZ: oh right.. makes sense

7:03 hyPiRion: ,(string/join ", " [1 2 3])

7:03 clojurebot: "1, 2, 3"

7:06 OscarZ: if i want to read some parameters coming from html form, save them in the database and then render the page again by reading stuff on the database.. whats the pattern to implement this in ring ?

7:16 borkdude: OscarZ you might want to look at the luminus examples

7:17 http://www.luminusweb.net/

7:18 OscarZ: thanks borkdude, ill check it out

7:31 supersym: emacs/org-mode is fun :

7:32 :)

7:32 i'm a believer now

7:32 borkdude: supersym what are you using it for

7:33 supersym: well, I kinda ended up with a desire to program in lisp, so I got about half-way learning clojure now... but figured I might as well learn some elisp, so I am hooking up socket.io, swank and emacs

7:34 and i more or less got starterkit running although I'm not sure what/if I need to configure but got as far as a ~/.emacs.d/hostname.el file with some stuff to try out settings etc

7:35 Im mostly interested in literate programming though :)

8:11 OscarZ: luminous seems nice... what is the relation between ring and luminous ?

8:11 luminus sorry

8:25 supersym: well luminus is a framework

8:25 aka a set of libraries to work with

8:25 ring is middleware

8:26 anyway more than that i wont be able to tell, havent worked with either one before,...

8:27 OscarZ: what exactly the ring part does in a web application? im :using compojure.core and ring.velocity.core in my test app

8:28 is that only the abstraction... a bit like MVC pattern ?

8:28 supersym: ring would be not one, but multiple different components each providing a service to be in between server and client usually

8:29 but server, as in HTTP server, is also something offered by ring.. as is routing which depends on who you ask if its considered true "middleware"

8:29 yeah compojure would be what does routing to different urls

8:30 noir got deprecated in favor of it

8:30 OscarZ: know node.js? middleware = connect

8:30 Bodil: Ring isn't middleware, it's more of a protocol, but it comes with a lot of useful middleware, as well as adapters for various web servers.

8:30 supersym: ok there see... my bad :P

8:32 OscarZ: is luminus implementation of the same ring protocol, or is it independent thing?

8:33 Bodil: Luminus aims to provide a pre-wired framework built in Ring, as I understand it.

8:33 If you're curious about what Ring is exactly, the spec document is very enlightening: https://github.com/ring-clojure/ring/blob/master/SPEC

8:34 I didn't really get how ridiculously elegant the idea of Ring is until I read that. :)

8:37 OscarZ: seems cool.. i dont know much yet but some of the example ring/clojure code i've seen looks nice.. not much clutter in there :) i like minimalism

8:40 supersym: *nods*

8:49 sun.net.util.IPAddressUtil is Sun proprietary API and may be removed in a future release

8:49 god i hate oracle

8:49 and java btw... shame they had to build clojure on it

8:50 bad service, crappy servers, worse products and documentation

8:50 </rant>

8:51 OscarZ: you need something like: http://commons.apache.org/proper/commons-net//javadocs/api-3.2/org/apache/commons/net/util/SubnetUtils.html ?

8:51 supersym: not really... tbh i dont care about their libs much.. what I do care about, is greedy no-good software giants messing up fine products

8:52 OscarZ: sorry, please rant on :)

8:53 supersym: nah.. my i'm trying to get hadoop working.. but map-reduce wont build, and i have protobuf

8:53 beats me but I know Arch makepkg are also not considering it a dependency so everything fails

8:53 OscarZ: there seems to have been a lot of security issues lately.. im not sure whether they were introduced by Oracle or if they were existing already when they took over..

8:54 supersym: Java was already heavily targeted I think

8:54 but Oracle doesnt make it better, I dare say: worse probably

8:59 corecode: hi

8:59 what would i use to run an infinite lazy loop of a function, say rand-int?

9:02 supersym: wtf

9:03 well ring-server needs

9:03 'something' to run

9:03 but what

9:03 corecode: aha!

9:03 repeatedly

9:03 supersym: perhaps luminus might have everything working already

9:04 :)

9:11 clojure-new: Hello, i know this is crazy question but still: http://cljbin.com/paste/513b436de4b0c9b87f44cfbd

9:12 Why it works just fine, but when i uncomment loop it beaks internal of my app?

9:12 Is there some magic side effects of loop?

9:13 Function returns same results with and without loop in it.

10:14 ChongLi: hi

10:14 anyone here use write clojure in vim and use ctags?

10:46 clojure-newb: Hi Raynes I have a laser question if you are around ?

11:17 Mark___: hi. i'm trying to integrate eclipse rap with ring. rap its own servlet so i'm just trying to forward the httpservletrequest and response objects to it from a ring handler. is there some convenient way to get those from

11:20 ah, nm. i just found ring-servlet tests which seems to give me a starting point

11:23 jonasen: Bronsa: tools.reader question: Is it possible to disable java constructor literals? So the reader would throw on #java.io.FileWriter[...] forms?

11:25 Bronsa: jonasen: the edn reader has them disabled, the clojure reader can disable them by binding clojure.tools.reader/*read-eval* to false

11:25 jonasen: Bronsa: or even better, do the same thing as with reader literals. I.e., "call this function when you encounter a constructor literal"

11:25 Bronsa: this will disable both java ctors, #= and record ctors though

11:26 jonasen: does *read-eval* disable constructor literals? I did not know that. Thanks

11:26 Bronsa: I will update the README and add a note about that

11:26 jonasen: does the clojure reader work that way too?

11:27 Bronsa: since clojure 1.5, yes

11:27 jonasen: so *read-eval* false is safe in 1.5?

11:28 Bronsa: yes, AFAIK

11:28 Foxboron: So, i was thinking. Currently Sublime Text only have SublimeREPL for REPL integration. Any Python hackers using Sublime Text wanna try get a nREPL for Sublime running?

11:38 xeqi: jonasen: reading with *read-eval* false can still cause class loading, which might run some static initializers, but I havne't found any that would do something bad in the java stdlib or clojure

11:47 dog_cat11: ,(appy str (\a \space \\ \b))

11:47 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: appy in this context, compiling:(NO_SOURCE_PATH:0:0)>

11:47 dog_cat11: ,(apply str (\a \space \\ \b))

11:47 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn>

11:47 dog_cat11: ,(apply str '(\a \space \\ \b))

11:47 clojurebot: "a \\b"

11:47 dog_cat11: how do I create a string with only one "\"? ie "a \b" ?

11:49 jeremyheiler: ,(println (str \a \space \\ \b))

11:49 clojurebot: a \b\n

11:49 jeremyheiler: It's escaping the \ for you. That's why it's showing twice.

12:02 OscarZ: so def creates a global variable.. what happens if I have that in a function and it gets called multiple times?

12:03 i guess its always preferable to use "let" if possible ?

12:03 andyfingerhut: jonasen: I don't think it would be wise to rely on *read-eval* being safe in Clojure 1.5, even if it happens to be right now. That way lies future security holes.

12:04 jonasen: i.e. relying on *read-eval* false making read & read-string safe from side effects.

12:07 clojure-newb: hey guys how do I convert ["some-id"] into (pre/post= "some-id") (pre2/post2 (do-something "some-id")) ?

12:09 borkdude: is a function made with partial per definition a clojure?

12:09 closure

12:11 I would say yes

12:13 andyfingerhut: Isn't every function in Clojure (and Common Lisp, and probably a few other languages) a closure? Some of them might not "close over" anything in their environment, but some do.

12:14 jeremyheiler: borkdude, I agree. The function returned from partial is closing over the arguments to partial.

12:16 jonasen: andyfingerhut: I want to read clojure code and not edn data. What's missing from edn (for my use case) is that it can't read forms like #(foo 1 2 3).

12:18 dog_cat11: @jeremyheiler, i got it to work, thanks

12:18 andyfingerhut: jonasen: OK. I was just concerned when I saw your earlier comments that you might be drawing the conclusion that using clojure.core/read with *read-eval* false was safe for reading untrusted data. While it might happen to be that way in Clojure 1.5 (I'm not sure it is), there is no promise of that going forward.

12:18 jonasen: andyfingerhut: I'll keep that in mind, thanks!

12:20 andyfingerhut: jonasen: When you say forms like #(foo 1 2 3), do you mean Clojure's shorthand for creating functions, which usually has %1 %2 etc. in it to refer to arguments?

12:20 hyPiRion: Isn't like, "#java.io.FileWriter[\"file-here\"]" unsafe?

12:21 trptcolin: is Charles Norton in here?

12:22 andyfingerhut: hyPiRion: Definitely yes in Clojure 1.3 and 1.4. Clojure 1.5 doesn't allow it if *read-eval* is false, which is a change in 1.5, but even then everything I've heard is that you shouldn't read untrusted data with clojure.core/read or read-string. Even if they happen to be safe in 1.5, the developers don't want to make that promise.

12:25 jonasen: andyfingerhut: yes, #(inc %) is what I meant

12:26 hyPiRion: Ah, okay.

12:30 OscarZ: speaking of closures.. I'm playing with Datomic and I have a set of objects and need to apply a function to each object ... the function takes however two parameters: (entity db eid)

12:31 i tried something like: (map #(d/entity (db conn)) results))

13:07 clojure-newb: guys, I'm having trouble understanding how to do something… I want to apply n transformations to the same data structure with each transformation operating on the result of the previous transformation…. I can't use thread macro as far as I know because the number of transformations is dynamic.. how do I do this ?

13:08 xeqi: sounds like a reduce

13:08 mpenet: ,(doc comp)

13:08 clojurebot: "([] [f] [f g] [f g h] [f1 f2 f3 & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."

13:09 mpenet: depends if by dynamic you mean if it depends on the intermediary results

13:09 clojure-newb: in my case I have a fragment of html and I'm using laser to select and transform on n element/id combinations

13:09 and I do need to care about what the id specifically is so first I get a list via regexp of the id's I care about

13:09 then for each one call in with a select/transform pairing

13:10 I am having trouble visualising how to do this any way in clojure, whether mutable or reduce or otherwise

13:10 each time I call my function it needs to use the results of the last call

13:11 dog_cat11: ,(nth (nth ( nth [[[:value]]] 0) 0) 0)

13:11 clojurebot: :value

13:11 dog_cat11: is there a more idiomatic way to do this?

13:11 kawas44: Hi

13:12 xeqi: &(get-in [[[:value]]] [0 0 0])

13:12 lazybot: ⇒ :value

13:12 dog_cat11: thanks

13:12 xeqi: clojurebot: I use (apply laser/fragment ....) for something similar

13:12 clojurebot: Something weird that I noticed: & (use '[clojure.contrib.json :as json]) & &| (json/pprint-json nil) |&

13:12 xeqi: blah, clojure-newb ^

13:12 clojure-newb: xeqi: sounds interesting, any more info ?

13:13 xeqi: clojure-newb: https://www.refheap.com/paste/12343

13:14 ugly code from an upcoming billing page I'm building

13:14 maybe you can gleen something from it

13:15 clojure-newb: xeqi: looking now, its going to take me some time to get it :-) ors apply mean it will use the result of the last function call in the current function call ?

13:15 *does

13:16 xeqi: (apply fn [1 2 3]) => (fn 1 2 3)

13:18 clojure-newb: xeqi: hmm, I am probably not understanding

13:18 suppose I am more used to imperative loops and mutable state

13:20 wondering if reduce would do it as there is the concept of accumulator

13:20 ?

13:21 or if laser can help me out by understanding what the id is at the point I am transforming ?

13:22 xeqi: clojure-newb: do you have a paste you can share?

13:22 clojure-newb: kinda like : (l/re-id #"some-id") (l/content (something *current-id*)) ?

13:23 would I be able to get the actual value of *current-id* in the transformation form ?

13:23 that would save me a load of trouble :-)

13:27 xeqi: I'm trying to put something together that makes sense

13:28 WormJuice: clojure-newb, hi

13:28 clojure-newb: WormJuice: hi

13:28 WormJuice: I am the finest programmer on the planet second only to the Microsoft Chief Software Architect

13:29 clojure-newb: WormJuice: what is your name all about ?

13:29 dog_cat11: what's the optimal way to return an array with a modified inner value?

13:29 WormJuice: clojure-newb, one assumes a drink made of annelids

13:30 dog_cat11: example fn([[[1 2[ 3 [4]]]) -> [[[1 2[ 3 [4]]]

13:30 example fn([[[1 2[ 3 [4]]]) -> [[[1 2[ 3 [5]]

13:30 example fn([[[1 2[ 3 [4]]]) -> [[[1 2[ 3 [5]]]

13:30 sorry

13:33 clojure-newb: WormJuice: I'm confused :-)

13:34 WormJuice: clojure-newb, you take a worm, say an earthworm

13:34 put it in the citrus juicer or whatever

13:34 and drink it

13:36 dog_cat11: I think assoc-in will let me return a vector with a modified inner value

13:37 clojure-newb: xeqi: here is something which might explain what I am trying to do better : https://www.refheap.com/paste/12346

13:45 xeqi: clojure-newb: I have a feeling you might be wanting to do something like https://github.com/Raynes/laser/blob/master/docs/guide.md#seqs-of-nodes

13:49 clojure-newb: xeqi: yes it seems close, but we would need to dynamically specify the selector

13:56 dog_cat11: For a hash in the form {:key int-val, ...} i'm trying to return a vector of keys where the value equals the maximum of all values

13:56 is this an idiomatic way of doing it?

13:57 ,(let [a {:a 1 :b 0 :c 1}](mapv first (filter #(= (apply max (vals a)) (second %)) a)))

13:57 clojurebot: [:a :c]

14:02 hyPiRion: perhaps

14:02 ,(let [a {:a 1, :b 0, :c 1}] (let [m (reduce max (vals a))] (for [[k v] a :when (= v m)] k)))

14:02 clojurebot: (:a :c)

14:03 hyPiRion: it's a bit more evident, and doesn't compute the max value more than once.

14:21 supersym: Now I keep failing google protocol buffers for java... hadoop wont build without them but I downloaded, installed and tried to hand compile make && install ...

14:21 [ERROR] symbol : class Parser

14:21 [ERROR] location: package com.google.protobuf

14:21 anyone ever seen that before.... Java n00b here so that must be it

14:22 cannot find symbol, class I guess

14:23 dog_cat11: hiPyRion, thanks

14:23 i usually figure out the max key and bind it in a let statement

14:23 but for this i just left it in there

14:23 i found this way:

14:24 ,(let [a {:a 1 :b 0 :c 1}] (filterv #(= (a %) (apply max (vals a))) (keys a)))

14:24 clojurebot: [:a :c]

14:28 RazWelles: If I have a list of function symbols, is there a way to invoke them in order without resorting to eval?

14:28 dog_cat11: what's wrong with eval?

14:29 RazWelles: nothing, but every time I search up eval it says "don't do it"-- so I assumed maybe there was a better/faster way

14:29 dog_cat11: lol, sounds like you need macros

14:30 RazWelles: I need it at runtime

14:31 In python it would be: [x() for x in [fun1, fun2, fun3, fun4]

14:31 *]

14:31 TimMc: RazWelles: Those are function instances, not funciton names.

14:32 pendlepants: if I've got a function w/ a signature like (fn [& {:keys [a b c]} :as opts] ...), is there a way I can pass it a map like (fn-name {:a 1 :b 2})? I'm trying to read its arguments from an outside config.

14:32 TimMc: ,(class conj)

14:32 clojurebot: clojure.core$conj

14:32 TimMc: ,(class 'conj)

14:32 clojurebot: clojure.lang.Symbol

14:32 RazWelles: TimMc, sorry I'm not too good with all the terminology yet, but in C it would essentially be a list of function pointers that get invoked sequentially

14:32 TimMc: ~mapply

14:32 clojurebot: You could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))

14:33 TimMc: pendlepants: ^

14:33 pendlepants: thanks TimMc.

14:33 TimMc: pendlepants: It's very annoying to call those functions. :-/

14:33 pendlepants: what should I be calling them?

14:34 xeqi: &(for [f [#(println "hi") #(println "huh?") #(println "something")] (f))

14:34 lazybot: java.lang.RuntimeException: Unmatched delimiter: )

14:34 TimMc: RazWelles: Right, so eval (or ns-resolve or something) would be used to get from names to functions, but you already have the functions.

14:34 xeqi: &(for [f [#(println "hi") #(println "huh?") #(println "something")]] (f))

14:34 lazybot: ⇒ (hihuh?somethingnil nil nil)

14:34 TimMc: RazWelles: Do you want the results from the functions?

14:35 xeqi: well, maybe doseq would be better there

14:36 RazWelles: TimMc, yes- I still haven't quite wrapped my head around the idea of self modifying code

14:36 dog_cat11: don't worry, no one fully understands

14:37 RazWelles: ahaha, at least I'm not alone

14:37 dog_cat11: a good book is let over lambda, even though its common lisp

14:38 RazWelles: dog_cat11, I'll take a look at it thanks, looks like a good portion of the text is available to read on the site

14:38 dog_cat11: yeah

14:38 on lisp is also good

14:39 paul graham has it available on his website

14:39 IMO, the best lisps books are not for clojure, but you can apply the lessons anyway

14:40 RazWelles: Yeah- I was actually starting with Clozure CL but the library I wanted to play with was specifically .Net, so I picked up Clojure-CLR

14:42 TimMc: RazWelles: If you have functions [a b c], then (doall (for [f [a b c]] (f)))

14:42 RazWelles: TimMc, ah! That sounds like what I want, thanks :)

14:43 TimMc: The doall is there because for is lazy. If your functions have side-effects or need to execute in a certain dynamic scope, forcing the seq is important.

14:43 RazWelles: xeqi was giving an example above.

14:43 RazWelles: Ohh I didn't see it

14:44 Thanks xeqi I'll at that to my notes

14:45 TimMc: (doseq would be better if you didn't want the return values.)

14:48 RazWelles: ahh, thanks TimMc, xeqi! :)

14:57 dark4eg: people plase help me install latest version clojure and lein on ubuntu

14:58 Foxboron: dark4eg: sure :)

14:58 dark4eg: tried apt-get install leiningen?

14:58 Frozenlock: dark4eg: https://github.com/technomancy/leiningen --> the installation process for ubuntu is quite straightforward.

15:01 dark4eg: thx

15:01 supersym: common what is it with instructions and people not giving them anymore... sigh.. just my day

15:02 dark4eg: I needed reboot :)

15:02 supersym: everyone thinks its a good idea to tuck install docs and instructions like 20 pages deep ><

15:04 thank god for leiningen :P

15:04 now I get the "without setting your hair on fire"

15:04 Frozenlock: I wouldn't have started with clojure if it wasn't for leiningen.

15:05 dark4eg: сука ну почему я такой дебил не знаю английского...

15:05 Frozenlock: So next time you think "wth is this fool doing here?", blame technomancy. :)

15:08 semisight: for records and types, is there any way to overload the +/- core operators?

15:08 jeremyheiler: semisight, They are not operatores. They are just functions.

15:08 semisight: ex: I have a Point2D class, can I make it so that (+ p1 p2) works?

15:09 jeremyheiler: I know, what I'm asking is if I can override them for my own classes only?

15:09 devn: semisight: (let [+ (fn [p1 p2] (...math...))] (+ a b))

15:10 supersym: :)

15:10 jjido: yes. Clojure checks the type of the opera des

15:10 semisight: devn: that's the only way? that's only local :/

15:10 jjido: operands

15:10 austinh: dnolen: Do you have any ideas about debugging core.logic programs? I was wondering if I could annotate goals and/or solution streams to keep track of position within the search.

15:11 jeremyheiler: semisight, You can probably create method on the type, but that will probably not allow you to use clojure.core/+ in that namespace unless you prefix it.

15:11 semisight: jeremyheiler: that's what I just tried, and you're right. not too elegant unfortunately

15:11 how is + implemented?

15:12 jeremyheiler: ,(source +)

15:12 clojurebot: Source not found\n

15:12 jeremyheiler: boo

15:12 amalloy: ~def +

15:12 semisight: found it

15:12 jeremyheiler: It calls add() on the Number class.

15:13 semisight: eh

15:13 ah well

15:13 thanks for your help!

15:19 jeremyheiler: It's actually not that bad https://www.refheap.com/paste/12348

15:19 ohpauleez, you signed off.

15:19 Mandus, the autocomplete is stupid in xchat... (sorry ohpauleez)

15:19 asdfasdf

15:29 ohpauleez: haha

15:30 jeremyheiler: ohpauleez, I think I fixed it. I've bugged ahihi enough trying to say "Ah, ".

15:34 ahihi: it's okay, it makes me feel popular

15:35 Raynes: ugh

15:35 jeremyheiler: ahihi, Glad to be of service :-)

15:35 Raynes: Guy called 'clojure-newb' was in here earlier asking laser questions but I was sleeping.

15:36 If he had just used an actual name I could very likely have hunted him down on Github and helped him.

15:36 Now I just feel like an ass.

15:37 Bodil: Raynes: You feel like an ass for sleeping? You might be just a bit too hard on yourself this morning. :)

15:38 Raynes: Yeah, I just realized how self deprecating that was.

15:40 hyPiRion: Raynes: Yeah, I hate it when you don't reply because you're doing something else.

15:41 You should have full attention on me, and only me, damnit.

15:42 TimMc: Raynes: They're around periodically. If only we had a bot that could leave messages for people...

15:43 Raynes: hyPiRion: Did you actually test your lazybot changes last night?

15:43 I find it hard to believe you managed to get it running and configured in less than 20 minutes.

15:44 amalloy: he has a repl, man. he went around the boring functions and just called the interesting ones with faked-up inputs

15:45 Raynes: amalloy: And I find it hard to believe you're going to get to my place in less than 14 minutes.

15:45 amalloy: tough luck, dude

15:45 Raynes: I haven't even put pants on.

15:45 And I'm eating poptarts.

15:45 fbernier: is there another way to write 1 + 2 - 5 + 8 + 2 other than (+ (+ (- (+ 1 2) 5) 8) 2)

15:45 ?

15:45 Raynes: Well, you could use Haskell.

15:46 devn: Raynes: im using conch to basically to do the same pygmentize stuff you're doing in refheap, but mine seems a lot slower, any ideas?

15:46 jjido: fbernier: use let

15:46 Raynes: http://www.epicgifs.net/images/show/EKRIFMQ6

15:46 amalloy: fbernier: (-> 1 (+ 2) (- 5) (+ 8) (+ 2))?

15:46 hyPiRion: Raynes: I had a repl and a brain. That ought to be enough, right?

15:46 Raynes: devn: Are you sure that it is slower?

15:46 devn: Raynes: No. :)

15:47 Raynes: devn: Are you sure that it is pygmentize that is taking the time?

15:47 fbernier: thanks for the suggestions amalloy and jjido I'll look into that.

15:47 devn: Raynes: reasonably certain.

15:47 Raynes: devn: What are you doing with pygmentize?

15:47 devn: Raynes: https://github.com/devn/getclojure/blob/master/src/getclojure/views/helpers.clj

15:48 Raynes: devn: How many times are you calling this function?

15:48 TimMc: Raynes: Go put your pants on.

15:48 Raynes: Like, are you just doing it once every now and then or are you calling it a bazillion times for something?

15:48 devn: i think roughly twice as many times as you are on the recent pastes page

15:49 Raynes: TimMc: I better, looks like he just left and is on his way. Wouldn't look right me getting into his car in my boxers and disheveled hair.

15:49 devn: Nope.

15:49 I never call pygmentize at all on that page.

15:49 devn: Raynes: er wait, you're just saving the full paste arent you?

15:49 err the pygmentized html

15:49 Raynes: When a paste is created I call pygmentize on the whole paste and 4 lines of the paste.

15:49 The 4 lines is the summary that you see.

15:49 (maybe 5 lines)

15:49 devn: welp, i guess I need to add a database now :)

15:49 ive been just using elasticsearch, but there are limits to freedom

15:50 Raynes: That would be what I suggest. It isn't conch that is slow, it's just that shelling out and starting Python and stuff is slower than if it were just using Python.

15:50 Your other option is to rewrite your code in Python.

15:50 :P

15:50 devn: yeah totally, wasn't calling conch slow, and the code is really nice btw

15:50 Drinkable

15:51 Raynes: Hahah

15:51 I swear I wasn't drunk that day, I just couldn''t pick names.

15:51 devn: haha, no I think it's actually a great name

15:51 that's why i mentioned it

15:52 it made me pause for a second, but then i was like, oh, right, that makes good sense

15:52 Raynes: lol

15:53 * devn goes to fix his 7 second load times

15:53 devn: Raynes: btw, im stealing liberally from refheap, hope you don't mind

15:53 Raynes: Of course not.

15:54 devn: Another thing.

15:54 devn: yo?

15:54 TimMc: Raynes: Pants! Now.

15:54 Foxboron: hmm, anyone know how i could possibly do this in a more simple manner? https://github.com/Foxboron/Parjer/blob/master/src/parjer/quote.clj#L6

15:55 Raynes: devn: refheap has an API call to get the raw highlighted HTML of a paste. Unless you'd be pasting like thousands of things, you could potentially piggyback on refheap's pygmentize. Not sure if innuendo (the Clojure API client) supports it though. Also might not be an option for what you're doing, since if you're highlighting a bazillion things we obviously don't want to pound refheap with that.

15:55 TimMc: Pants on.

15:55 TimMc: Good.

15:56 Foxboron: https://github.com/hiredman/clojurebot/blob/master/src/clojurebot/epigrams.clj

15:56 devn: Raynes: yeah, there's a lot of stuff being highlighted

15:56 Raynes: I need to add a DB anyway to get users and allow them to rate things

15:57 Foxboron: TimMc: well, i did look at that source when writing mine. But wanted to try write it on my own ^^

15:57 or my own version*

15:59 TimMc: Foxboron: Can't say I approve of the use of flatten.

15:59 Foxboron: I know D: Thats why i am asking :/

16:00 Raynes: TimMc: Alan just sent me a text that said "Hmm, road closures, expect further delays :-P"

16:01 TimMc: Sounds like another pop-tart is called for.

16:01 Raynes: TimMc: Found a few legitimate uses of flatten in laser.

16:02 TimMc: It's basically so that people can do things like (fragment html selector1 transformer1 (when what [selector2 transformer3]))

16:02 I didn't add this particular feature, but I was happy that someone did.

16:03 I was real mean though and refused to use clojure.core/flatten. Instead I moved clojail's flatten-all function to useful and used that. :P

16:03 Because it works on maps which is totally pointless here, but felt right.

16:04 TimMc: Another fun thing is that the guy also made a commit later that used the regular flatten and its ignore-maps limitation was entirely necessary for his code to work! That was the first time I'd ever seen code where flatten's map limitations was a good thing.

16:04 True story.

16:13 devn: Raynes: Useful could be even moreso if we put up API docs for it

16:13 TimMc: Foxboron: [].slice.call(document.getElementsByTagName('p')).map(function(el){return el.textContent.trim()}).filter(function(s){return s.length;}) :-P

16:14 devn: Raynes: The main reason I don't use useful more is that I don't have a fast way to check if what I want is there or not, yknow?

16:14 Foxboron: D:

16:15 TimMc: Foxboron: (->> (h/select page [:p]) (map (comp clojure.string/trim first :content)) (filter not-empty))

16:16 Foxboron: For bonus points, use h/unwrap instead of :content.

16:16 sturner: Anyone here tinkered with the latest LightTable 0.3.x?

16:18 TimMc: Foxboron: Better: (->> (h/select page [:p]) (map (comp clojure.string/trim first :content)) (filter not-empty))

16:19 Foxboron: TimMc: yeah

16:19 look MUCHMUCH cleaner

16:21 TimMc: (Whoops, h/unwrap fell out of that one.)

16:21 (No, I flubbed the entire paste.)

16:22 Foxboron: explains the lack of a closing paran

16:22 TimMc: (->> (h/select page [:p]) (map (comp #(.replace % "\n" " ") clojure.string/trim first h/unwrap)) (filter not-empty))

16:25 Foxboron: TimMc: works perfectly :)

16:25 much cleaner

16:25 rahcola: are the types (as in type system) of clojure's basic data structures listed somewhere?

16:27 I would like to implement a protocol for vectors etc.

16:32 TimMc: rahcola: There is no spec, per se.

16:33 mmitchell: anyone know if it's possible to do a batch insert/update using the jdbc adapter in clojure?

16:53 TimMc: mmitchell: insert-values or whatever doesn't do what you need?

17:45 devn: Raynes: would you guys take a definition of inclusive-range in useful, or is that out of scope?

18:01 hclarke: hey guys. what's the recommended windows setup these days?

18:02 lein + emacs? or something else?

18:03 arrdem: hclarke: that'd be the recommendation under Unix..

18:03 not sure how well it'll roll under Windows tho

18:04 hclarke: i'm just hoping it's not "lein + emacs + vmware" :p

18:04 arrdem: heh for me it's lein + emacs + dual-boot Arch

18:05 ivan: lein and emacs and nrepl.el work on Windows

18:06 arrdem: ivan: share this magic, I wasn't able to find a way to run emacs on Windows when I looked last

18:06 ivan: arrdem: did the official builds not work?

18:07 Foxboron: arrdem: well

18:07 ivan: http://ftp.gnu.org/gnu/emacs/windows/

18:07 Foxboron: i dont think lein repl worked on windows a few months back

18:07 but i do believe its fixed now.

18:24 devn: it should be working

18:26 hclarke: lein repl is working for me (as of 30 seconds ago, first try). now to get emacs working.

18:48 devn: Does anyone know how to kill nrepl in emacs? I updated project.clj and ran lein deps. In swank-clojure I would always just clojure-jack-in and slime would prompt me to kill the old session. With nrepl I find myself restarting emacs because I can't seem to find a way to properly destroy the nrepl session.

18:51 jcrossley3-away: devn: killing the *nrepl-connection* buffer does it for me

18:53 alandipert: devn: you can also do nrepl-restart

18:56 danneu: how come the tail recursive argument to `conj` acts like a list in this noob code (5 lines) https://gist.github.com/danneu/d51fca630561ce7605cc

18:57 tomoj: danneu: it's nil

18:57 &(conj nil 1)

18:57 lazybot: ⇒ (1)

18:58 tomoj: in the base case your 'when' form evaluates to nil

18:59 danneu: thanks. that hurts my brain so lemme stare at it for a while

19:00 tomoj: try changing it to (if (> x 0) ... [])

19:04 danneu: tomoj: ah (conj (conj (conj nil 1) 2) ...)

19:06 guess i tried too soon to roll with the big dogs by using `when`

19:10 dealing with mutation soup in my ruby dayjob has gotten me to start exploring clojure

19:11 i saw a line recently in some clojure literature. went something like 'mutable state is the new spaghetti code' and i thought that was right on even though ive only been programming for a few years

19:23 dabd: could someone help me set format to display floats with decimal separator dot instead of comma? On my system (format "%.1f" 0.5) return 0,5

19:24 if I evaluate (java.util.Locale/getDefault)

19:24 I get #<Locale en_US>

19:24 why is it printing commas?

19:30 also (java.lang.String/format "%.1f" (to-array [0.5])) returns "0,5"

19:30 but(java.lang.String/format ( java.util.Locale/getDefault) "%.1f" (to-array [0.5])) returns "0.5"

19:30 shouldn't both return the same?

19:35 supersym: well its not like it can be state can it?

19:35 but sure looks like locale to me too

19:37 alandipert: dabd: that's wild - feels like a jvm/system config issue

19:37 &(String/format java.util.Locale/US "%.1f" (to-array [0.5]))

19:38 lazybot: ⇒ "0.5"

19:38 alandipert: dabd: ^ workaround

19:41 dabd: it used to work fine but suddenly format started printing numbers with commas

19:41 where is that jvm setting?

19:45 dnolen: hrm, I always forget, is there a permutations fn anywhere?

19:47 Bronsa: math.combinatorics

19:47 dnolen: Bronsa: thanks

20:10 pandeiro: will the default

20:10 sorry

20:10 will the default lein new ... continue using 1.4.0 forever? can i change that?

20:13 hyPiRion: pandeiro: 2.1.0 will update to 1.5

20:13 And we're working on improving that issue for 2.2.0

20:13 *fixing

20:13 pandeiro: hyPiRion: ok, so it's hard-coded in?

20:14 hyPiRion: pandeiro: oh, I read lein repl. Well, you can make your own template

20:14 but yeah, it'll get bumped for 2.1.0.

20:15 pandeiro: sure, i need to create a custom lein new template anyway.. just wondered if the default template were accessible somewhere/how

20:15 hyPiRion: pandeiro: https://github.com/technomancy/leiningen/tree/master/resources/leiningen/new/default

20:17 pandeiro: huh, in my .m2 repo i only have leiningen 2.0.0-previewX and SNAPSHOT, but my lein version is 2.0.0

20:27 technomancy: pandeiro: lein's own jar is in ~/.lein, not m2

20:27 pandeiro: technomancy: i looked there but didn't see it

20:27 technomancy: in self-installs

20:27 pandeiro: of course :)

20:27 thanks

20:48 sclj: getting feet wet w/ clojure. can someone help me with lazyseq issue?

20:48 i'm trying to use peek on the result of a for operation

20:49 but it blows up saying that lazyseq can't convert to persistent stack.

20:51 hyPiRion: ,(doc peek) ; sclj: I suppose you'd like to use first instead.

20:51 clojurebot: "([coll]); For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collection is empty, returns nil."

20:51 hyPiRion: The main issue is that a lazyseq is neither a list, queue nor vector.

20:52 As such, you'd either have to convert it into one first, or just use first instead :)

20:52 sclj: right...so i tried wrapping my result in a (list) call, but that seemed to put an extra list around me result

20:52 hmm.

20:53 hyPiRion: ,(list* (for [a [1 2 3]] (* a 2)))

20:53 clojurebot: (2 4 6)

20:54 hyPiRion: Whoops, list* doesn't return a list.

20:59 sclj: so...i can't tell if i am confused or if the doc string is for peek.

20:59 oh, i see what you emant now.

21:00 hyPiRion: the gist of it is: Use first.

21:00 sclj: peek is the same as first for a list, but lazyseq is not a list.

21:00 hyPiRion: yep

21:01 sclj: sp i could use (peek (vec lazy)) or (first lazy)

21:01 hyPiRion: yeah

21:01 sclj: is there no way to convert from a lazy to a list?

21:01 hyPiRion: vec would realize the whole thing though

21:01 hm.

21:02 sclj: because i tried list and list* and neither worked

21:02 hyPiRion: ,(list? (into () (reverse [1 2 3])))

21:02 clojurebot: true

21:02 sclj: sorry, i'll just use first. just trying to understand why what i started with is wrong

21:03 hyPiRion: Not exactly idiomatic though, as you'd probably guess.

21:03 (no worries)

21:03 sclj: thanks

22:46 thm_prover: where is the complexity in writing a decent editor like emacs?

22:46 technomancy: there's nothing like emacs

Logging service provided by n01se.net