#clojure logs

2013-03-09

01:02RazWelleswhat's the fastest way to add to a list/set/vector every 60msec?
01:02RazWelles(meaning this list would get big over time)
01:03RazWellescons?
01:03clojurebot(def ^:const x 42) will cause any compiled reference to x to be as if you wrote 42 instead
01:12alexbaranosky1RazWelles: not quite sure what you're asking. But 'conj' is the fastest way to add things to collections
01:13RazWellesalexbaranosky1, 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
01:13RazWellesseq/list/vector
01:14RazWellesx.x still new to this
01:15alexbaranosky1persistent data structures don't copy
01:16RazWellesahh ok
01:16RazWellesalexbaranosky1, what if I need to append to the end of the list?
01:28tomojyou don't do that
01:28tomojvectors conj at the end, maybe you want that
01:39arrdemwho on here was working on a "sane defaults" ring template project?
01:43arrdem`lein new compojure foo` I can do that..
01:52FrozenlockCan I use `count' to check how big is a result AND estimate the time taken? IE will realize any lazystuff?
01:55Raynesivaraase1: So what is so great about my accent?
02:24amalloyRaynes: could you rephrase the question as an mp3?
02:24Rayneslol
02:25FrozenlockYesssss! 100 fold speed increase in mongodb =D
02:25arrdemw00t
02:25arrdemincanter vs compojure?
02:26andyfingerhutWow. Do databases use Java reflection? :-)
02:26arrdems/compojure/hiccup
02:26arrdemaaand they do different jobs
02:27FrozenlockI just changed how I store my data: in a less horrible way.
02:38herve-s\part
03:35RayneshyPiRion: http://logs.lazybot.org/irc.freenode.net/%23clojure
03:37Raynes$latest compojure
03:37lazybot[compojure "1.1.5"] -- https://clojars.org/compojure
03:37Raynes$latest ring/ring-jetty-adapter
03:37lazybot[ring/ring-jetty-adapter "1.2.0-beta1"] -- https://clojars.org/ring/ring-jetty-adapter
03:38RaynesHehe.
03:38Rayneslazybot's Compojure is *amazingly* old.
03:38RaynesLike 0.6.x
03:39hyPiRionRaynes: :D
04:06Gonzih$latest clodiuno
04:06lazybot[clodiuno "0.0.4-SNAPSHOT"] -- https://clojars.org/clodiuno
05:38Ember-any way to do something like this?
05:38Ember-(walk/postwalk-replace {[:foo string?] nil} nested-structure)
05:38Ember-works fine if string? is replaced with an absolute string
05:38Ember-but I want to remove ALL entries hierarchically where key is :foo
05:43Ember-I tried to use regexps too but doesn't work :(
05:43borkdudeanyone using workgroups.el here?
05:44borkdude~anyone
05:44clojurebotJust 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 ..."
05:44borkdudeyehyeh
05:47borkdudeI'm a bit confused about workgroups.el: what is the exact difference between save and update?
05:47borkdudemy understanding: update saves the new window configuration, but what does save do?
05:54Ember-I'm guessing no one knows answer to my question :(
05:54Ember-*sadface*
06:01hyPiRionEmber-: It's not exactly afternoon in the US of A right now
06:01Ember-it's 13:03 here :)
06:02hyPiRionand 12 here :)
06:03Ember-but I'm guessing I might be able to do what I want with plain ol' walk function
06:03hyPiRionBut NY -> 0600 and San Fran is 0300
06:04Ember-and I guess you don't know the answer to my question? :)
06:04Ember-since you're awake
06:05hyPiRionEmber-: That's true. I'm not good at clojure.walk nor immutable tree manipulations
06:06Ember-aww
06:07Ember-somehow it would feel logical that if smap contains a predicate walk api would pass the value to that predicate
06:08Ember-but now, my train arrives at the station
06:08Ember-have a nice day everyone :) ->
06:10hyPiRionhave a nice day :)
06:10arrdemhyPiRion: mother of god why are you still up...
06:14hyPiRionarrdem: huh? I'm Norwegian, it's like 12:15 here
06:30borkdudeargh, orgmode.org is down
06:47OscarZnewb 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]])
06:47OscarZthe same line works in handler.clj
06:49OscarZthe same lib should be visible in controller too ?
06:49hyPiRionOscarZ: yes, assuming both are in the same project
06:49hyPiRionare you using (:use [ring.velocity.core :only [render]]) as an argument to ns?
06:50OscarZok thanks.. yes they are.. i need to recheck everything, its probably something stupid :)
06:51OscarZah crap.. that was it :) i had (ns compojure-test.controller) as the first line ..
06:51hyPiRion:)
06:51hyPiRionJust so you know, if you want to use `use` instead sometime, you have to quote the values you send in
06:52hyPiRionso in your case, you may end up with (use '[ring.velocity.core :only [render]])
06:52hyPiRion(Though `use` is mostly used for repl-testing)
06:53OscarZoh.. in the default handler.clj, there is no quote.. it seems to work
06:54hyPiRionOscarZ: yeah, that works fine because it's inside the (ns .. ) part
06:55hyPiRionif you want to get a library without using ns, use (use ..)
06:56OscarZoh, right.. i think i need to read up on namespaces, use and require :)
06:58OscarZusing 'use' without ns, you can get more "local" import for some library (import as in java) ?
07:01hyPiRionWell, the thing is that you rarely want to specify the namespace when running in a repl for instance
07:01hyPiRionSo like
07:01hyPiRion,(require '[clojure.string :as string])
07:01clojurebotnil
07:02hyPiRionwon't make a new namespace just to get new namespaces you'd like to experiment on
07:02OscarZoh right.. makes sense
07:03hyPiRion,(string/join ", " [1 2 3])
07:03clojurebot"1, 2, 3"
07:06OscarZif 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 ?
07:16borkdudeOscarZ you might want to look at the luminus examples
07:17borkdudehttp://www.luminusweb.net/
07:18OscarZthanks borkdude, ill check it out
07:31supersymemacs/org-mode is fun :
07:32supersym:)
07:32supersymi'm a believer now
07:32borkdudesupersym what are you using it for
07:33supersymwell, 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
07:34supersymand 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
07:35supersymIm mostly interested in literate programming though :)
08:11OscarZluminous seems nice... what is the relation between ring and luminous ?
08:11OscarZluminus sorry
08:25supersymwell luminus is a framework
08:25supersymaka a set of libraries to work with
08:25supersymring is middleware
08:26supersymanyway more than that i wont be able to tell, havent worked with either one before,...
08:27OscarZwhat exactly the ring part does in a web application? im :using compojure.core and ring.velocity.core in my test app
08:28OscarZis that only the abstraction... a bit like MVC pattern ?
08:28supersymring would be not one, but multiple different components each providing a service to be in between server and client usually
08:29supersymbut 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"
08:29supersymyeah compojure would be what does routing to different urls
08:30supersymnoir got deprecated in favor of it
08:30supersymOscarZ: know node.js? middleware = connect
08:30BodilRing 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.
08:30supersymok there see... my bad :P
08:32OscarZis luminus implementation of the same ring protocol, or is it independent thing?
08:33BodilLuminus aims to provide a pre-wired framework built in Ring, as I understand it.
08:33BodilIf you're curious about what Ring is exactly, the spec document is very enlightening: https://github.com/ring-clojure/ring/blob/master/SPEC
08:34BodilI didn't really get how ridiculously elegant the idea of Ring is until I read that. :)
08:37OscarZseems 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
08:40supersym*nods*
08:49supersymsun.net.util.IPAddressUtil is Sun proprietary API and may be removed in a future release
08:49supersymgod i hate oracle
08:49supersymand java btw... shame they had to build clojure on it
08:50supersymbad service, crappy servers, worse products and documentation
08:50supersym</rant>
08:51OscarZyou need something like: http://commons.apache.org/proper/commons-net//javadocs/api-3.2/org/apache/commons/net/util/SubnetUtils.html ?
08:51supersymnot really... tbh i dont care about their libs much.. what I do care about, is greedy no-good software giants messing up fine products
08:52OscarZsorry, please rant on :)
08:53supersymnah.. my i'm trying to get hadoop working.. but map-reduce wont build, and i have protobuf
08:53supersymbeats me but I know Arch makepkg are also not considering it a dependency so everything fails
08:53OscarZthere 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..
08:54supersymJava was already heavily targeted I think
08:54supersymbut Oracle doesnt make it better, I dare say: worse probably
08:59corecodehi
08:59corecodewhat would i use to run an infinite lazy loop of a function, say rand-int?
09:02supersymwtf
09:03supersymwell ring-server needs
09:03supersym'something' to run
09:03supersymbut what
09:03corecodeaha!
09:03corecoderepeatedly
09:03supersymperhaps luminus might have everything working already
09:04supersym:)
09:11clojure-newHello, i know this is crazy question but still: http://cljbin.com/paste/513b436de4b0c9b87f44cfbd
09:12clojure-newWhy it works just fine, but when i uncomment loop it beaks internal of my app?
09:12clojure-newIs there some magic side effects of loop?
09:13clojure-newFunction returns same results with and without loop in it.
10:14ChongLihi
10:14ChongLianyone here use write clojure in vim and use ctags?
10:46clojure-newbHi Raynes I have a laser question if you are around ?
11:17Mark___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:20Mark___ah, nm. i just found ring-servlet tests which seems to give me a starting point
11:23jonasenBronsa: tools.reader question: Is it possible to disable java constructor literals? So the reader would throw on #java.io.FileWriter[...] forms?
11:25Bronsajonasen: the edn reader has them disabled, the clojure reader can disable them by binding clojure.tools.reader/*read-eval* to false
11:25jonasenBronsa: or even better, do the same thing as with reader literals. I.e., "call this function when you encounter a constructor literal"
11:25Bronsathis will disable both java ctors, #= and record ctors though
11:26jonasendoes *read-eval* disable constructor literals? I did not know that. Thanks
11:26BronsaI will update the README and add a note about that
11:26jonasendoes the clojure reader work that way too?
11:27Bronsasince clojure 1.5, yes
11:27jonasenso *read-eval* false is safe in 1.5?
11:28Bronsayes, AFAIK
11:28FoxboronSo, 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:38xeqijonasen: 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:47dog_cat11,(appy str (\a \space \\ \b))
11:47clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: appy in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:47dog_cat11,(apply str (\a \space \\ \b))
11:47clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn>
11:47dog_cat11,(apply str '(\a \space \\ \b))
11:47clojurebot"a \\b"
11:47dog_cat11how do I create a string with only one "\"? ie "a \b" ?
11:49jeremyheiler,(println (str \a \space \\ \b))
11:49clojurebota \b\n
11:49jeremyheilerIt's escaping the \ for you. That's why it's showing twice.
12:02OscarZso def creates a global variable.. what happens if I have that in a function and it gets called multiple times?
12:03OscarZi guess its always preferable to use "let" if possible ?
12:03andyfingerhutjonasen: 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:04andyfingerhutjonasen: i.e. relying on *read-eval* false making read & read-string safe from side effects.
12:07clojure-newbhey guys how do I convert ["some-id"] into (pre/post= "some-id") (pre2/post2 (do-something "some-id")) ?
12:09borkdudeis a function made with partial per definition a clojure?
12:09borkdudeclosure
12:11borkdudeI would say yes
12:13andyfingerhutIsn'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:14jeremyheilerborkdude, I agree. The function returned from partial is closing over the arguments to partial.
12:16jonasenandyfingerhut: 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:18dog_cat11@jeremyheiler, i got it to work, thanks
12:18andyfingerhutjonasen: 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:18jonasenandyfingerhut: I'll keep that in mind, thanks!
12:20andyfingerhutjonasen: 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:20hyPiRionIsn't like, "#java.io.FileWriter[\"file-here\"]" unsafe?
12:21trptcolinis Charles Norton in here?
12:22andyfingerhuthyPiRion: 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:25jonasenandyfingerhut: yes, #(inc %) is what I meant
12:26hyPiRionAh, okay.
12:30OscarZspeaking 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:31OscarZi tried something like: (map #(d/entity (db conn)) results))
13:07clojure-newbguys, 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:08xeqisounds like a reduce
13:08mpenet,(doc comp)
13:08clojurebot"([] [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:09mpenetdepends if by dynamic you mean if it depends on the intermediary results
13:09clojure-newbin my case I have a fragment of html and I'm using laser to select and transform on n element/id combinations
13:09clojure-newband 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:09clojure-newbthen for each one call in with a select/transform pairing
13:10clojure-newbI am having trouble visualising how to do this any way in clojure, whether mutable or reduce or otherwise
13:10clojure-newbeach time I call my function it needs to use the results of the last call
13:11dog_cat11,(nth (nth ( nth [[[:value]]] 0) 0) 0)
13:11clojurebot:value
13:11dog_cat11is there a more idiomatic way to do this?
13:11kawas44Hi
13:12xeqi&(get-in [[[:value]]] [0 0 0])
13:12lazybot⇒ :value
13:12dog_cat11thanks
13:12xeqiclojurebot: I use (apply laser/fragment ....) for something similar
13:12clojurebotSomething weird that I noticed: & (use '[clojure.contrib.json :as json]) & &| (json/pprint-json nil) |&
13:12xeqiblah, clojure-newb ^
13:12clojure-newbxeqi: sounds interesting, any more info ?
13:13xeqiclojure-newb: https://www.refheap.com/paste/12343
13:14xeqiugly code from an upcoming billing page I'm building
13:14xeqimaybe you can gleen something from it
13:15clojure-newbxeqi: 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:15clojure-newb*does
13:16xeqi(apply fn [1 2 3]) => (fn 1 2 3)
13:18clojure-newbxeqi: hmm, I am probably not understanding
13:18clojure-newbsuppose I am more used to imperative loops and mutable state
13:20clojure-newbwondering if reduce would do it as there is the concept of accumulator
13:20clojure-newb?
13:21clojure-newbor if laser can help me out by understanding what the id is at the point I am transforming ?
13:22xeqiclojure-newb: do you have a paste you can share?
13:22clojure-newbkinda like : (l/re-id #"some-id") (l/content (something *current-id*)) ?
13:23clojure-newbwould I be able to get the actual value of *current-id* in the transformation form ?
13:23clojure-newbthat would save me a load of trouble :-)
13:27clojure-newbxeqi: I'm trying to put something together that makes sense
13:28WormJuiceclojure-newb, hi
13:28clojure-newbWormJuice: hi
13:28WormJuiceI am the finest programmer on the planet second only to the Microsoft Chief Software Architect
13:29clojure-newbWormJuice: what is your name all about ?
13:29dog_cat11what's the optimal way to return an array with a modified inner value?
13:29WormJuiceclojure-newb, one assumes a drink made of annelids
13:30dog_cat11example fn([[[1 2[ 3 [4]]]) -> [[[1 2[ 3 [4]]]
13:30dog_cat11example fn([[[1 2[ 3 [4]]]) -> [[[1 2[ 3 [5]]
13:30dog_cat11example fn([[[1 2[ 3 [4]]]) -> [[[1 2[ 3 [5]]]
13:30dog_cat11sorry
13:33clojure-newbWormJuice: I'm confused :-)
13:34WormJuiceclojure-newb, you take a worm, say an earthworm
13:34WormJuiceput it in the citrus juicer or whatever
13:34WormJuiceand drink it
13:36dog_cat11I think assoc-in will let me return a vector with a modified inner value
13:37clojure-newbxeqi: here is something which might explain what I am trying to do better : https://www.refheap.com/paste/12346
13:45xeqiclojure-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:49clojure-newbxeqi: yes it seems close, but we would need to dynamically specify the selector
13:56dog_cat11For 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:56dog_cat11is this an idiomatic way of doing it?
13:57dog_cat11,(let [a {:a 1 :b 0 :c 1}](mapv first (filter #(= (apply max (vals a)) (second %)) a)))
13:57clojurebot[:a :c]
14:02hyPiRionperhaps
14:02hyPiRion,(let [a {:a 1, :b 0, :c 1}] (let [m (reduce max (vals a))] (for [[k v] a :when (= v m)] k)))
14:02clojurebot(:a :c)
14:03hyPiRionit's a bit more evident, and doesn't compute the max value more than once.
14:21supersymNow 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:21supersym[ERROR] symbol : class Parser
14:21supersym[ERROR] location: package com.google.protobuf
14:21supersymanyone ever seen that before.... Java n00b here so that must be it
14:22supersymcannot find symbol, class I guess
14:23dog_cat11hiPyRion, thanks
14:23dog_cat11i usually figure out the max key and bind it in a let statement
14:23dog_cat11but for this i just left it in there
14:23dog_cat11i found this way:
14:24dog_cat11,(let [a {:a 1 :b 0 :c 1}] (filterv #(= (a %) (apply max (vals a))) (keys a)))
14:24clojurebot[:a :c]
14:28RazWellesIf I have a list of function symbols, is there a way to invoke them in order without resorting to eval?
14:28dog_cat11what's wrong with eval?
14:29RazWellesnothing, but every time I search up eval it says "don't do it"-- so I assumed maybe there was a better/faster way
14:29dog_cat11lol, sounds like you need macros
14:30RazWellesI need it at runtime
14:31RazWellesIn python it would be: [x() for x in [fun1, fun2, fun3, fun4]
14:31RazWelles*]
14:31TimMcRazWelles: Those are function instances, not funciton names.
14:32pendlepantsif 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:32TimMc,(class conj)
14:32clojurebotclojure.core$conj
14:32TimMc,(class 'conj)
14:32clojurebotclojure.lang.Symbol
14:32RazWellesTimMc, 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:32TimMc~mapply
14:32clojurebotYou could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))
14:33TimMcpendlepants: ^
14:33pendlepantsthanks TimMc.
14:33TimMcpendlepants: It's very annoying to call those functions. :-/
14:33pendlepantswhat should I be calling them?
14:34xeqi&(for [f [#(println "hi") #(println "huh?") #(println "something")] (f))
14:34lazybotjava.lang.RuntimeException: Unmatched delimiter: )
14:34TimMcRazWelles: Right, so eval (or ns-resolve or something) would be used to get from names to functions, but you already have the functions.
14:34xeqi&(for [f [#(println "hi") #(println "huh?") #(println "something")]] (f))
14:34lazybot⇒ (hihuh?somethingnil nil nil)
14:34TimMcRazWelles: Do you want the results from the functions?
14:35xeqiwell, maybe doseq would be better there
14:36RazWellesTimMc, yes- I still haven't quite wrapped my head around the idea of self modifying code
14:36dog_cat11don't worry, no one fully understands
14:37RazWellesahaha, at least I'm not alone
14:37dog_cat11a good book is let over lambda, even though its common lisp
14:38RazWellesdog_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:38dog_cat11yeah
14:38dog_cat11on lisp is also good
14:39dog_cat11paul graham has it available on his website
14:39dog_cat11IMO, the best lisps books are not for clojure, but you can apply the lessons anyway
14:40RazWellesYeah- 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:42TimMcRazWelles: If you have functions [a b c], then (doall (for [f [a b c]] (f)))
14:42RazWellesTimMc, ah! That sounds like what I want, thanks :)
14:43TimMcThe 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:43TimMcRazWelles: xeqi was giving an example above.
14:43RazWellesOhh I didn't see it
14:44RazWellesThanks xeqi I'll at that to my notes
14:45TimMc(doseq would be better if you didn't want the return values.)
14:48RazWellesahh, thanks TimMc, xeqi! :)
14:57dark4egpeople plase help me install latest version clojure and lein on ubuntu
14:58Foxborondark4eg: sure :)
14:58Foxborondark4eg: tried apt-get install leiningen?
14:58Frozenlockdark4eg: https://github.com/technomancy/leiningen --> the installation process for ubuntu is quite straightforward.
15:01dark4egthx
15:01supersymcommon what is it with instructions and people not giving them anymore... sigh.. just my day
15:02dark4egI needed reboot :)
15:02supersymeveryone thinks its a good idea to tuck install docs and instructions like 20 pages deep ><
15:04supersymthank god for leiningen :P
15:04supersymnow I get the "without setting your hair on fire"
15:04FrozenlockI wouldn't have started with clojure if it wasn't for leiningen.
15:05dark4egсука ну почему я такой дебил не знаю английского...
15:05FrozenlockSo next time you think "wth is this fool doing here?", blame technomancy. :)
15:08semisightfor records and types, is there any way to overload the +/- core operators?
15:08jeremyheilersemisight, They are not operatores. They are just functions.
15:08semisightex: I have a Point2D class, can I make it so that (+ p1 p2) works?
15:09semisightjeremyheiler: I know, what I'm asking is if I can override them for my own classes only?
15:09devnsemisight: (let [+ (fn [p1 p2] (...math...))] (+ a b))
15:10supersym:)
15:10jjidoyes. Clojure checks the type of the opera des
15:10semisightdevn: that's the only way? that's only local :/
15:10jjidooperands
15:10austinhdnolen: 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:11jeremyheilersemisight, 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:11semisightjeremyheiler: that's what I just tried, and you're right. not too elegant unfortunately
15:11semisighthow is + implemented?
15:12jeremyheiler,(source +)
15:12clojurebotSource not found\n
15:12jeremyheilerboo
15:12amalloy~def +
15:12semisightfound it
15:12jeremyheilerIt calls add() on the Number class.
15:13semisighteh
15:13semisightah well
15:13semisightthanks for your help!
15:19jeremyheilerIt's actually not that bad https://www.refheap.com/paste/12348
15:19jeremyheilerohpauleez, you signed off.
15:19jeremyheilerMandus, the autocomplete is stupid in xchat... (sorry ohpauleez)
15:19jeremyheilerasdfasdf
15:29ohpauleezhaha
15:30jeremyheilerohpauleez, I think I fixed it. I've bugged ahihi enough trying to say "Ah, ".
15:34ahihiit's okay, it makes me feel popular
15:35Raynesugh
15:35jeremyheilerahihi, Glad to be of service :-)
15:35RaynesGuy called 'clojure-newb' was in here earlier asking laser questions but I was sleeping.
15:36RaynesIf he had just used an actual name I could very likely have hunted him down on Github and helped him.
15:36RaynesNow I just feel like an ass.
15:37BodilRaynes: You feel like an ass for sleeping? You might be just a bit too hard on yourself this morning. :)
15:38RaynesYeah, I just realized how self deprecating that was.
15:40hyPiRionRaynes: Yeah, I hate it when you don't reply because you're doing something else.
15:41hyPiRionYou should have full attention on me, and only me, damnit.
15:42TimMcRaynes: They're around periodically. If only we had a bot that could leave messages for people...
15:43RayneshyPiRion: Did you actually test your lazybot changes last night?
15:43RaynesI find it hard to believe you managed to get it running and configured in less than 20 minutes.
15:44amalloyhe has a repl, man. he went around the boring functions and just called the interesting ones with faked-up inputs
15:45Raynesamalloy: And I find it hard to believe you're going to get to my place in less than 14 minutes.
15:45amalloytough luck, dude
15:45RaynesI haven't even put pants on.
15:45RaynesAnd I'm eating poptarts.
15:45fbernieris there another way to write 1 + 2 - 5 + 8 + 2 other than (+ (+ (- (+ 1 2) 5) 8) 2)
15:45fbernier?
15:45RaynesWell, you could use Haskell.
15:46devnRaynes: 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:46jjidofbernier: use let
15:46Rayneshttp://www.epicgifs.net/images/show/EKRIFMQ6
15:46amalloyfbernier: (-> 1 (+ 2) (- 5) (+ 8) (+ 2))?
15:46hyPiRionRaynes: I had a repl and a brain. That ought to be enough, right?
15:46Raynesdevn: Are you sure that it is slower?
15:46devnRaynes: No. :)
15:47Raynesdevn: Are you sure that it is pygmentize that is taking the time?
15:47fbernierthanks for the suggestions amalloy and jjido I'll look into that.
15:47devnRaynes: reasonably certain.
15:47Raynesdevn: What are you doing with pygmentize?
15:47devnRaynes: https://github.com/devn/getclojure/blob/master/src/getclojure/views/helpers.clj
15:48Raynesdevn: How many times are you calling this function?
15:48TimMcRaynes: Go put your pants on.
15:48RaynesLike, are you just doing it once every now and then or are you calling it a bazillion times for something?
15:48devni think roughly twice as many times as you are on the recent pastes page
15:49RaynesTimMc: 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:49Raynesdevn: Nope.
15:49RaynesI never call pygmentize at all on that page.
15:49devnRaynes: er wait, you're just saving the full paste arent you?
15:49devnerr the pygmentized html
15:49RaynesWhen a paste is created I call pygmentize on the whole paste and 4 lines of the paste.
15:49RaynesThe 4 lines is the summary that you see.
15:49Raynes(maybe 5 lines)
15:49devnwelp, i guess I need to add a database now :)
15:49devnive been just using elasticsearch, but there are limits to freedom
15:50RaynesThat 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:50RaynesYour other option is to rewrite your code in Python.
15:50Raynes:P
15:50devnyeah totally, wasn't calling conch slow, and the code is really nice btw
15:50devnDrinkable
15:51RaynesHahah
15:51RaynesI swear I wasn't drunk that day, I just couldn''t pick names.
15:51devnhaha, no I think it's actually a great name
15:51devnthat's why i mentioned it
15:52devnit made me pause for a second, but then i was like, oh, right, that makes good sense
15:52Rayneslol
15:53devnRaynes: btw, im stealing liberally from refheap, hope you don't mind
15:53RaynesOf course not.
15:54Raynesdevn: Another thing.
15:54devnyo?
15:54TimMcRaynes: Pants! Now.
15:54Foxboronhmm, 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:55Raynesdevn: 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:55RaynesTimMc: Pants on.
15:55TimMcGood.
15:56TimMcFoxboron: https://github.com/hiredman/clojurebot/blob/master/src/clojurebot/epigrams.clj
15:56devnRaynes: yeah, there's a lot of stuff being highlighted
15:56devnRaynes: I need to add a DB anyway to get users and allow them to rate things
15:57FoxboronTimMc: well, i did look at that source when writing mine. But wanted to try write it on my own ^^
15:57Foxboronor my own version*
15:59TimMcFoxboron: Can't say I approve of the use of flatten.
15:59FoxboronI know D: Thats why i am asking :/
16:00RaynesTimMc: Alan just sent me a text that said "Hmm, road closures, expect further delays :-P"
16:01TimMcSounds like another pop-tart is called for.
16:01RaynesTimMc: Found a few legitimate uses of flatten in laser.
16:02RaynesTimMc: It's basically so that people can do things like (fragment html selector1 transformer1 (when what [selector2 transformer3]))
16:02RaynesI didn't add this particular feature, but I was happy that someone did.
16:03RaynesI 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:03RaynesBecause it works on maps which is totally pointless here, but felt right.
16:04RaynesTimMc: 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:04RaynesTrue story.
16:13devnRaynes: Useful could be even moreso if we put up API docs for it
16:13TimMcFoxboron: [].slice.call(document.getElementsByTagName('p')).map(function(el){return el.textContent.trim()}).filter(function(s){return s.length;}) :-P
16:14devnRaynes: 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:14FoxboronD:
16:15TimMcFoxboron: (->> (h/select page [:p]) (map (comp clojure.string/trim first :content)) (filter not-empty))
16:16TimMcFoxboron: For bonus points, use h/unwrap instead of :content.
16:16sturnerAnyone here tinkered with the latest LightTable 0.3.x?
16:18TimMcFoxboron: Better: (->> (h/select page [:p]) (map (comp clojure.string/trim first :content)) (filter not-empty))
16:19FoxboronTimMc: yeah
16:19Foxboronlook MUCHMUCH cleaner
16:21TimMc(Whoops, h/unwrap fell out of that one.)
16:21TimMc(No, I flubbed the entire paste.)
16:22Foxboronexplains the lack of a closing paran
16:22TimMc(->> (h/select page [:p]) (map (comp #(.replace % "\n" " ") clojure.string/trim first h/unwrap)) (filter not-empty))
16:25FoxboronTimMc: works perfectly :)
16:25Foxboronmuch cleaner
16:25rahcolaare the types (as in type system) of clojure's basic data structures listed somewhere?
16:27rahcolaI would like to implement a protocol for vectors etc.
16:32TimMcrahcola: There is no spec, per se.
16:33mmitchellanyone know if it's possible to do a batch insert/update using the jdbc adapter in clojure?
16:53TimMcmmitchell: insert-values or whatever doesn't do what you need?
17:45devnRaynes: would you guys take a definition of inclusive-range in useful, or is that out of scope?
18:01hclarkehey guys. what's the recommended windows setup these days?
18:02hclarkelein + emacs? or something else?
18:03arrdemhclarke: that'd be the recommendation under Unix..
18:03arrdemnot sure how well it'll roll under Windows tho
18:04hclarkei'm just hoping it's not "lein + emacs + vmware" :p
18:04arrdemheh for me it's lein + emacs + dual-boot Arch
18:05ivanlein and emacs and nrepl.el work on Windows
18:06arrdemivan: share this magic, I wasn't able to find a way to run emacs on Windows when I looked last
18:06ivanarrdem: did the official builds not work?
18:07Foxboronarrdem: well
18:07ivanhttp://ftp.gnu.org/gnu/emacs/windows/
18:07Foxboroni dont think lein repl worked on windows a few months back
18:07Foxboronbut i do believe its fixed now.
18:24devnit should be working
18:26hclarkelein repl is working for me (as of 30 seconds ago, first try). now to get emacs working.
18:48devnDoes 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:51jcrossley3-awaydevn: killing the *nrepl-connection* buffer does it for me
18:53alandipertdevn: you can also do nrepl-restart
18:56danneuhow come the tail recursive argument to `conj` acts like a list in this noob code (5 lines) https://gist.github.com/danneu/d51fca630561ce7605cc
18:57tomojdanneu: it's nil
18:57tomoj&(conj nil 1)
18:57lazybot⇒ (1)
18:58tomojin the base case your 'when' form evaluates to nil
18:59danneuthanks. that hurts my brain so lemme stare at it for a while
19:00tomojtry changing it to (if (> x 0) ... [])
19:04danneutomoj: ah (conj (conj (conj nil 1) 2) ...)
19:06danneuguess i tried too soon to roll with the big dogs by using `when`
19:10danneudealing with mutation soup in my ruby dayjob has gotten me to start exploring clojure
19:11danneui 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:23dabdcould 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:24dabdif I evaluate (java.util.Locale/getDefault)
19:24dabdI get #<Locale en_US>
19:24dabdwhy is it printing commas?
19:30dabdalso (java.lang.String/format "%.1f" (to-array [0.5])) returns "0,5"
19:30dabdbut(java.lang.String/format ( java.util.Locale/getDefault) "%.1f" (to-array [0.5])) returns "0.5"
19:30dabdshouldn't both return the same?
19:35supersymwell its not like it can be state can it?
19:35supersymbut sure looks like locale to me too
19:37alandipertdabd: that's wild - feels like a jvm/system config issue
19:37alandipert&(String/format java.util.Locale/US "%.1f" (to-array [0.5]))
19:38lazybot⇒ "0.5"
19:38alandipertdabd: ^ workaround
19:41dabdit used to work fine but suddenly format started printing numbers with commas
19:41dabdwhere is that jvm setting?
19:45dnolenhrm, I always forget, is there a permutations fn anywhere?
19:47Bronsamath.combinatorics
19:47dnolenBronsa: thanks
20:10pandeirowill the default
20:10pandeirosorry
20:10pandeirowill the default lein new ... continue using 1.4.0 forever? can i change that?
20:13hyPiRionpandeiro: 2.1.0 will update to 1.5
20:13hyPiRionAnd we're working on improving that issue for 2.2.0
20:13hyPiRion*fixing
20:13pandeirohyPiRion: ok, so it's hard-coded in?
20:14hyPiRionpandeiro: oh, I read lein repl. Well, you can make your own template
20:14hyPiRionbut yeah, it'll get bumped for 2.1.0.
20:15pandeirosure, i need to create a custom lein new template anyway.. just wondered if the default template were accessible somewhere/how
20:15hyPiRionpandeiro: https://github.com/technomancy/leiningen/tree/master/resources/leiningen/new/default
20:17pandeirohuh, in my .m2 repo i only have leiningen 2.0.0-previewX and SNAPSHOT, but my lein version is 2.0.0
20:27technomancypandeiro: lein's own jar is in ~/.lein, not m2
20:27pandeirotechnomancy: i looked there but didn't see it
20:27technomancyin self-installs
20:27pandeiroof course :)
20:27pandeirothanks
20:48scljgetting feet wet w/ clojure. can someone help me with lazyseq issue?
20:48sclji'm trying to use peek on the result of a for operation
20:49scljbut it blows up saying that lazyseq can't convert to persistent stack.
20:51hyPiRion,(doc peek) ; sclj: I suppose you'd like to use first instead.
20:51clojurebot"([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:51hyPiRionThe main issue is that a lazyseq is neither a list, queue nor vector.
20:52hyPiRionAs such, you'd either have to convert it into one first, or just use first instead :)
20:52scljright...so i tried wrapping my result in a (list) call, but that seemed to put an extra list around me result
20:52scljhmm.
20:53hyPiRion,(list* (for [a [1 2 3]] (* a 2)))
20:53clojurebot(2 4 6)
20:54hyPiRionWhoops, list* doesn't return a list.
20:59scljso...i can't tell if i am confused or if the doc string is for peek.
20:59scljoh, i see what you emant now.
21:00hyPiRionthe gist of it is: Use first.
21:00scljpeek is the same as first for a list, but lazyseq is not a list.
21:00hyPiRionyep
21:01scljsp i could use (peek (vec lazy)) or (first lazy)
21:01hyPiRionyeah
21:01scljis there no way to convert from a lazy to a list?
21:01hyPiRionvec would realize the whole thing though
21:01hyPiRionhm.
21:02scljbecause i tried list and list* and neither worked
21:02hyPiRion,(list? (into () (reverse [1 2 3])))
21:02clojurebottrue
21:02scljsorry, i'll just use first. just trying to understand why what i started with is wrong
21:03hyPiRionNot exactly idiomatic though, as you'd probably guess.
21:03hyPiRion(no worries)
21:03scljthanks
22:46thm_proverwhere is the complexity in writing a decent editor like emacs?
22:46technomancythere's nothing like emacs