#clojure logs

2012-01-16

00:13sritchieamalloy: I finally snuck a macro-writing-macro into my code
00:13sritchiehttps://github.com/sritchie/midje-cascalog/blob/develop/src/midje/cascalog.clj#L98
00:32amalloyheh. why directed at me specifically, sritchie?
00:33sritchieamalloy: you gave me the smackdown months ago on that crazy pallet threading macro I kept fighting with
00:33amalloyhaha oh yeah
00:34devnsimplest way to drop a map whose key's value is the lowest of all the maps in the set?
00:34devnsince my set is sorted i am currently using difference
00:35devnagainst #{(last @set)}
00:35amalloydisj?
00:36devnthanks amalloy
02:43raekdevn: you can also use (first (rseq the-set)) to get the last element in constant time
02:44raek&(let [s (into (sorted-set) "abcde")] (disj s (first (rseq s))))
02:44lazybot⇒ #{\a \b \c \d}
02:48mindbenderI'm having trouble with my clojurescript repl. I'm able to (do (def env (brwoser/repl-env) (repl/repl env)) and get a clojurescript prompt. I type an expression say (+ 1 1) then I connect with the browser but no evaluation happens. Firefox crashes after sometimes and still no evaluation. And I have no source of log for the connection so I can't really figure out what might be wrong. How do I debug this?
03:24amalloyraek: well, log2(n) time, anyway
03:31Licensermorning
03:31raekyeah. sorry. you're right. of course it should be log2(n).
03:54Blktgood morning everyone
05:22clj_newbis it just me, or do others also find clojure code easier to read when all arguments are prepended with a keyword?
05:28bsteuberclj_newb: depends I guess - the longer the argument list, the more appealing keywords are
05:40clj_newbbsteuber: experience so far: a little annoying to write, but I thikn much easier to read
05:40clj_newbI like it; the context it provides.
05:54clj_newbin clojure, is it bad practice to have Animal/Cat.clj Animal/Dog.clj Animal.clj ?
05:54clj_newbwhere Animal.clj does various imports from Cat/Dog and then exports parts of them?
05:54ambrosebsthere's no need to, namespace != class
05:55ambrosebsI would have animals.clj
05:55ambrosebs(defprotocol Animal ...) (deftype Cat ...) (deftype Dog)
05:55ambrosebsall in one ns
05:55clj_newbI'm sorry, I screwd up the above example; I currently have something like: animal/cat.clj animal/dog.clj animal.clj
05:56clj_newbwhat is concerning me is that I have both x.clj and x as a directory
05:56clj_newbis this fear irrational and mispalced?
05:56ambrosebsthat's perfectly valid
05:56kral'morning
05:57clj_newblastly, is there a way to tell clojure: namespace animal is defined in animal/main.clj ?
05:58ambrosebswhy not just put everything in animal.clj?
05:58clj_newbI like shorter files; easier for me to read
06:00ambrosebswhy do you want to do something like that with namespaces?
06:01ambrosebs(your original question)
06:02ambrosebsthere's probably a better way to do what you want
06:03clj_newbso I want a single :use line
06:03clj_newbthat imports all the functions I care about relating to animals
06:03clj_newbthis includes things in animals/cat.clj animals/dog.clj animals/camel.clj, etc ...; but I dont' want to import all of them (since those files also contains helper functions I don't wnat)
06:04clj_newbso basically, there's a subset of animals/*.clj that I commonly use; I want to list them all in an animal.clj, and then just :use animal all over the place
06:04clj_newbWhat is the right pattern that I should be using?
06:04ambrosebsyou could make the helper functions ^:private
06:04Chousukeclj_newb: there's a way to migrate stuff from one namespace to another but it's a hack
06:04Chousukeand generally frowned upon
06:05ambrosebsgenerally it's "bad practice" to use an unqualified :use
06:05clj_newbChousuke: oh; I'm just generally using wrappers
06:05babilenclj_newb: Look at defn- and ^:private
06:05clj_newbChousuke , ambrosebs , babilen : noted; thanks
06:06ambrosebssee (:use animal :only [make-Cat make-Dog])
06:06Chousukehonestly though it sounds a lot like you're going for some sort of OOP-ish design :P might be fine in your case though
06:06ambrosebsand (:require [animal :as a])
06:07clj_newbChousuke: given my proficiency of clojure; you should tkae whatever you are assuming, choose something a few orders of magnitude worse, and that's probably what I'm doing :-)
06:07Chousukeit shouldn't really matter whether your things are cats or dogs or whatnot. You should think more in terms of functions and data.
06:07clj_newbit's only recently that i've gotten used to the purity (compared to scheme) of clojure; I feel like I'm still fighting it's namespace tooth and nail
07:56fulletsIs there a better way to stop slime submitting incomplete expressions that start with { than hacking slime-input-complete-p?
08:37methodsclojure wiki says to run `mvn package` on clojure-contrib checkout but it seems to fail complaining about missing artifacts
08:41ambrosebsmethods: contrib is deprecated
08:41ambrosebshttp://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
08:42methodsoh i was following this http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started
08:43ambrosebsthat looks pretty old, but I don't have a better resource handy
08:43ambrosebsyou should start by installing leiningen
08:44ambrosebsif you find yourself doing "java -jar clojure.jar", then you should be using leiningen
08:45ambrosebsIMO
08:45methodsidk i just built from source
08:45ambrosebssure, that works
08:46methodsthen i went through that wiki and installed rlwrap and stuff
08:47clgvmethod: rlwrap ftw. but now its probably time for leiningen. even more if you want to setup projects
08:47ambrosebs"lein repl" brings up a repl with rlwrap
08:47clgvmethods: leiningen uses rlwrap if installed
08:47methodsftw ?
08:47clgvftw=for the win ;)
08:58RazWelles_Question: This year I want to learn a lisp, and I want to use it for AI. I'll be using a neural network approach, and I'll probably be crunching a great deal of neurons. Speed-wise, would Clojure-CLR be up to this task, or should I employ SBCL?
09:01RazWelles_I ask CLR because the main library I'll need to interface to is .NET
09:01RazWelles_other than that, I don't need any other libraries
09:17clgvRazWelles_: the answer depends which part will be implemented with clojure? the neuron evaluation and updates?
09:18RazWelles_clgv, yes, neuron eval and updates, the .Net just passes the data to it
09:20clgvRazWelles_: thats almost only multiplication and addition of values. I guess even in .Net one would consider an attempt to use unsafe code for maximum speedup
09:21clgvRazWelles_: the interesting question is, how would your project benefit from lisp/clojure?
09:23RazWelles_clgv, well I've wanted to cut my teeth on lisp for a while, so I'm using this project as an excuse. As I'm not going to be purely connectionist, I may take other approaches where I feel the code would be easier to read and still do the job-- but mostly, I wanted to learn a lisp, and drop to C when I need to
09:24clgvRazWelles_: Clojure 1.3 improves a lot on 1.2 by introducing a better handling of primitive values like doubles which you'll need
09:25RazWelles_clgv, oh that'll be nice. Is it possible to use unsafe code from clojure-clr?
09:25clgvRazWelles_: for representing your neurons the immutable data structures would be a speed killer, so you cant benefit from using them for this aspect.
09:25RazWelles_I see
09:27clgvafair you can call any C# method from Clojure CLR similar to the JVM implementation
09:27clgvlets rephrase that to CLI method ;)
09:28RazWelles_So perhaps I should look into SBCL and P/Invoke again?
09:28Kototamahi, how can I deploy a compojure web app to allow the one who deploy the webapp to edit the css files?
09:29clgvRazWelles_: you should try to get a comparison between both languages related to the characteristics you are interested in and decide then
09:30RazWelles_clgv, understood, thank you for your help :)
09:31clgvRazWelles_: afair you can integrate Clojure CLR seamlessly with other .Net libs the same as clojure with the java libs
09:31clgvso that would be one advantage on your list.
09:32RazWelles_clgv, yeah, that's was the main reason I wanted to use Clojure, it had ready-to-use .Net access. With SBCL I would have to resort to interfacing myself, wihch is sort of daunting if you're still learning
09:32RazWelles_*which
09:34clgvRazWelles_: maybe you should set up a benchmark to see if clojure 1.3 using primitives is fast enough for you
09:34RazWelles_clgv, I guess that means I'll start by learning clojure- I was going to pick up "The Joy of Clojure" today
09:35babilenGood choice
09:35clgvgood book. you have some previous knowledge about lisp?
09:36RazWelles_Only a little, I was trying to work through SICP but classes got in the way, I now finally have some time to dedicate to learning a new programming language
09:37RazWelles_Well, sicp is scheme but.. close? lol
09:51clgvRazWelles_: I dont know. I had a lecture on CLOS and am using clojure since almost 1.5 years now
10:31jonasenIs there a function to turn a keyword into a namespace qualified keyword? e.g., :bar -> :foo/bar
10:31noidi_::bar
10:32noidi_,::foo
10:32clojurebot:sandbox/foo
10:33jonasennoidi_: Yeah, but I need a function. e.g., (ns-qualify 'sandbox :foo) -> :sandbox/foo
10:33raekjonasen: you could do something like (symbol "the-namespace" (name some-symbol))
10:33raeksorry, replace symbol with keyword... :-)
10:34raekjonasen: (defn ns-qualify [ns-name-symbol kw] (keyword (name ns-name-symbol) (name kw)))
10:35jonasen,(keyword "foo" "bar")
10:35clojurebot:foo/bar
10:35jonasenraek: Thanks!
10:35raekbut to answer the original question: no, there isn't a function that does exactly that in clojure.core.
10:39clgvis there an update-in! for transient maps?
10:40clgv&(apropos "update-")
10:40clgvhumm no lazybot :/
10:40Scriptor,(apropros "update-")
10:40clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: apropros in this context, compiling:(NO_SOURCE_PATH:0)>
10:40Scriptor,(apropos "update-")
10:40clojurebot(update-in update-proxy)
10:41clgvguess not
11:17cch1Looking for help extending midje to segregate facts into unit and integration facts... anybody got an idea of how to structure such an effort?
12:10TimMcclgv: The problem with update-in! is that it wouldn't know whether the contained collections were transient or persistent, and would have to ask each one.
12:14benares_98is there a difference between the functions mod and div?
12:15TimMcbenares_98: You've read their docs, yes?
12:16benares_98TimMc: I did but didn't understand the 'truncates towards negative infinity'
12:17tmciverWhat's div? According to clojuredocs, it's an incanter function . . .
12:17benares_98sorry I meant Mod and rem
12:17TimMc&((juxt unchecked-divide-int mod quot rem /) 20 -6)
12:17TimMcOops, lazybot is down.
12:17TimMc,((juxt unchecked-divide-int mod quot rem /) 20 -6)
12:17clojurebot[-3 -4 -3 2 -10/3]
12:19TimMcOops, bad example.
12:19TimMc,((juxt unchecked-divide-int mod quot rem /) -20 6)
12:19clojurebot[-3 4 -3 -2 -10/3]
12:20TimMcbenares_98: quot and rem are the same as / and % from Java -- integer division operators providing quotient and remainder.
12:20benares_98thanks
12:21TimMcbenares_98: mod, however, always gives the positive modulo for a positive modulus. (and vice versa)
12:21benares_98It didn't dawn on me until I started testing with negative numbers
12:21tmciver,(mod 20 -6)
12:21clojurebot-4
12:23tmciverTimMc: hmm, I thought I understood mod, but I guess I don't
12:24tmciver,(mod -20 6)
12:24clojurebot4
12:24tmciverI expected those last two to both be -4
12:24TimMc,(map (juxt #(mod (- %1) (- %2)) #(- (mod %1 %2))) [20 20 -20 -20] [6 -6 -6 6])
12:24clojurebot([-2 -2] [4 4] [2 2] [-4 -4])
12:25TimMc^ That's a bit confusing, but what it says is, if you negate both arguments to mod, it is the same as negating the output. (mod distributes -)
12:26TimMctmciver: With (mod -20 6), you start with -20 and keep adding 6 until you reach a non-negative number.
12:27tmciverTimMc: Really? Now I'm really confused. I've always thought that mod was 'remainder after division' so
12:27tmciver,(mod 20 6)
12:27clojurebot2
12:27tmcivermake sense to me
12:28tmciverbut I guess I haven't used mod with negative numbers before.
12:28jamiltronrem = quot - floor (quot / number) * num
12:28TimMctmciver: It can have various definitions, but this one is "The smallest non-negative number reachable by adding a multiple of the modulus to the... modulend?"
12:29clgvis there something with the capabilities of 'for and the sideeffect semantic of 'doseq? e.g. dofor? ;)
12:31TimMctmciver: In other words, the residue of the mod operation with n will always be from [0,n) -- that range is backwards for negative n, of course.
12:34tmciverTimMc: so you've got -20 and you keep adding 6 (4 times) to get +4.
12:34TimMcyup
12:35tmciverTimMc: In (mod 20 -6) you start with 20 and subtract 6 (4 times) to get -4.
12:35TimMcright
12:35rplevyis clojurescript one intended to be used as a library, or is lib-ish stuff going to be broken into its own project?
12:35tmciverVery enlightening.
12:36TimMctmciver: and in -20 -6, -6 is subtracted 3 times to get down (up) to -2.
12:37tmciver,(mod -20 -6)
12:37clojurebot-2
12:38tmciverTimMc: Hmm, why -2? I would have naively expected -6 to be subracted 4 times (to get above zero?).
12:39TimMctmciver: mod (or at least this one) will always preserve the sign of the modulus. quot/rem preserve information about the magnitude of the modulus and modulend (?).
12:40tmciverTimMc: In (mod 20 -6) the modulul is -6, yes?
12:40TimMcright
12:40TimMcso the result will be between -6 and 0.
12:40tmcivers/modulul/modulus
12:41tmciverTimMc: this is good stuff to know. This definitely would have been a future bug for me (and might still be!)
12:41TimMctmciver: Just watch out in other languages... mod has different meanings. >_<
12:42tmciver>_< indeed
12:43TimMcI don't think Java even *has* a modulo in its stdlib.
12:43joegalloclgv: what do you want from for that is missing on doseq?
12:44tmciverTimMc: isn't it just %?
12:44clgvjoegallo: is iterating over multiple seq possible? maybe I should recheck the docs...
12:44rplevyI just noticed my question earlier is kind of unclear, I'm asking about ClojureScriptOne
12:44TimMctmciver: That's rem.
12:44joegalloclgv: pretty sure the answer is yes
12:44clgv;(doc doseq)
12:45clgv,(doc doseq)
12:45clojurebot"([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
12:45tmciverTimMc: yes, I was going to say that rem is probably what I'm going to want, generally.
12:45clgvoh. like 'for - I always saw doseq only similar to (doseq [item seq] ...)
12:45tmciverTimMc: Thanks. You're a fountain of wisdom as usual.
12:48TimMcyay
12:49joegalloclgv: what i miss sometimes is the doseq version of map, but it's not like typing doall is that hard ;)
12:49clgvjoegallo: well doall has some performance disadvantages in that case. but a domap can be easily implemented
12:50joegalloi guess i meant dorun, you're right
12:50clgvjoegallo: if I remember correctly it was about 1/4 in my application specific context
13:38AWizzArd$seen fogus
13:44TimMcAWizzArd: That's not his nick.
13:45TimMcalso, lazybot is down
13:47AWizzArdOh okay, what is his nick?
13:48TimMc`fogus, I think.
13:54bobhopeIs there an easy way to compute with complex numbers in clojure?
14:00jsabeaudryIs aleph still the best bet for asynchronous http?
14:00AWizzArdjsabeaudry: client or server?
14:00jsabeaudryAWizzArd: Both
14:01jsabeaudryAWizzArd: Mainly server in the short term
14:01AWizzArdI think there is not yet a comfortable layer over Jetty, so yes, Aleph then.
14:03jsabeaudryAWizzArd: Altighty, thanks for the info! Aleph it is
14:23AWizzArd,*clojure-version*
14:23clojurebot{:major 1, :minor 3, :incremental 0, :qualifier nil}
14:23AWizzArd,(instance? Long/TYPE 4)
14:23clojurebotfalse
14:23AWizzArdwhy is this false?
14:24joegallo,(instance java.lang.Long 4)
14:24clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: instance in this context, compiling:(NO_SOURCE_PATH:0)>
14:24joegallo,(instance? java.lang.Long 4)
14:24clojurebottrue
14:24joegalloLong != long
14:24AWizzArdYes, it is a Long, but shouldn’t it be a long?
14:24joegalloLong/Type == long
14:24AWizzArdIn 1.3
14:25AWizzArdI tried this with (long 4), or I had a (defn foo [^long x] (instance? Long/TYPE x)), but they all return 'false'.
14:26joegalloShot in the dark, but hiredman remains my authoritative source on such things: your long is getting upcasted to Long when you ask what its type is, because you can't ask what type a primitive is, only Objects. So your primitive becomes an object, and happily tells you it is a Long.
14:27hiredman,(doc instance?)
14:27clojurebot"([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"
14:27hiredmanprimitives are not an instance of any class
14:28AWizzArdI thought in 1.2 one could use `instance?` to check for primitive types.
14:28hiredman,(instance? Long 4)
14:28clojurebottrue
14:28AWizzArdBut probably 1.3 ensures that when I do (defn foo [^long n] …) that n indeed will be a long.
14:29hiredmanAWizzArd: most likely instance? was not getting inlined, so you were checking the boxed type
14:30hiredmanit is possible you might get different behaviour evaled code vs. compiled code because of some interaction of boxing + inlining
14:30hiredman,((fn [^long x] (instance Long x)) 4)
14:30clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: instance in this context, compiling:(NO_SOURCE_PATH:0)>
14:31hiredman,((fn [^long x] (instance? Long x)) 4)
14:31clojurebottrue
14:31hiredman,(metadata #'clojure.core/instance?)
14:31clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: metadata in this context, compiling:(NO_SOURCE_PATH:0)>
14:31hiredman,(meta #'clojure.core/instance?)
14:31clojurebot{:ns #<Namespace clojure.core>, :name instance?, :arglists ([c x]), :added "1.0", :doc "Evaluates x and tests if it is an instance of the class\n c. Returns true or false", ...}
14:31hiredman,(keys (meta #'clojure.core/instance?))
14:31clojurebot(:ns :name :arglists :added :doc ...)
14:31hiredmanclojurebot: jerk
14:31clojurebotyou cut me deep, man.
14:33k9quaint-wkdoes anyone have a suggestion for a framework for user roles written in clojure that can run on GAE?
14:45RazWellesSomeone in here mentioned earlier clojure has immutable lists- does that mean it can't self-modify?
14:46amalloyRazWelles: self-modifying code (at runtime) is not a thing you really want in any language. it's a thing where you say "OMG if I could do this then I could solve all problems instantly", but if you actually try it you just wind up sad and confused
14:47RazWellesamalloy, so... that's a no? :P
14:47technomancy"It takes twice as much brainpower to debug something as to initially write it. Therefore if you write code that is as clever as you can, by definition you are not smart enough to debug it."
14:48joegalloi'm going to replace "self-modify" in your question with "be modified" and then answer that yes, it means that they can't be modified
14:49joegallolike strings in java, or the simple wrapper objects (Boolean, Long, etc.)
14:49technomancyIt's possible to write a function that compiles a replacement for itself.
14:50technomancyit could be fun as an experiment, but if you did that in code that had to be maintained it would be grounds for a severe flogging.
14:51RazWellesWell, I'm looking into learning lisp for ai research, I thought clojure might be a good option
14:51RazWellesbut I'm also weighing in SBCL
14:51amalloytechnomancy: "possible". more like trivial, right? (def modifying-fn eval). BAM, pass it a different list
14:51technomancyamalloy: ssshhh
14:52RazWellesI'm at the beginning here so I'm just looking for the right road to dedicate my initial time to
14:52joegalloRazWelles: i bet we're probably a little biased toward Clojure in this channel
14:53amalloyRazWelles: seriously, code that modifies itself at runtime is a disaster for SBCL and AI as well. try asking in #lisp, they'll tell you not to try that either. focus on other criteria for choosing a language
15:14semperossomething simple is eluding me; I have this namespace declaration: https://gist.github.com/1622752
15:14semperosand it throw a compilation error; anyone care to look?
15:14semperos(it's extremely simple)
15:15amalloysemperos: your problem is elsewhere
15:15semperosthought I was losing it...
15:15amalloypresumably in attempting to compile the code you're including
15:15joegallocheck red.models.document
15:15semperosunderstood
15:15semperosand I see my error now, thx amalloy joegallo
15:26k9quaint-wkdoes anyone have a suggestion for a framework for user roles written in clojure that can run on GAE?
15:27k9quaint-wkappengine's roles are, shall we say, a bit limited in scope
15:44peregrine81is there a reason a simple ORM or HRM doesn't exist for closure?
15:45peregrine81like I define a model for a hash and perhaps relationships and I can do things like
15:45peregrine81(filter filterFunc Model) => Vector of Hashs of the model
15:46peregrine81the filter is really just creates the select statement for me
15:46peregrine81filter func may just be a vector of keys and values
15:47peregrine81or does this exist and Im blind
15:52joegallolike this? http://sqlkorma.com/
16:28peregrine81yes thank you!
16:56ABShi all, I spent quite some time reading congomongo's source and I couldn't find any support for mongo's $or in the :where conditions. can someone confirm it's not supported or I'm just blind? :-)
17:01ABS_sorry, lost connection
17:06gunsls
17:12TimMc$seen `fogus
17:12lazybot`fogus was last seen quitting 2 days and 20 hours ago.
17:12TimMcYay, lazybot is back!
17:28argvuhi =)
17:28DevlolHello. Just a little question, if reify is used many times, can it causes permgen space oom exceptions ?
17:28jsabeaudryI'm completely puzzled. I'm playing with aleph and if I put my data ByteBuffer in little-endian the http response fails to get decompressed by gzip. Anyone has a clue what could be the problem? http://pastebin.com/uuSRNdRm
17:28TimMcDevlol: A (reify ...) statement only creates the class once -- on compile (whether AOT or JIT).
17:29hiredmanjsabeaudry: fails how?
17:29jsabeaudryhiredman: Wireshark fails to decompress it and firefox says it cannot read the response
17:30hiredmanmaybe your content type header should say the content is gzipped?
17:30jsabeaudry(which is probably the same error but firefox is less explicit I would guess)
17:30argvui'm new with clojure and i'm trying to code a sudoku solver with backtracking, right now this code http://pastebin.com/MF0RBWvC is able to solve grids but it's really slow (take lots a secs to solve just one hard grid), it's probably really wrong but i cannot figure out where is the mistake. someone can help me ? =)
17:31TimMcargvu: "lots of seconds" -- how many?
17:31argvuit depends, from 7/8 to 20
17:31dnolenargvu: also slow compared tow hat?
17:32dnolento what, I mean
17:32argvucompared to .. for example http://attractivechaos.github.com/plb/kudoku.html
17:33ztellmanjsabeaudry: the response headers say it's gripped?
17:33DevlolTimMc: ok thanks for the clarification, because it looks like http://bit.ly/wu3y9g causes me some problems
17:33ztellmangzipped*
17:33dnolenargvu: did you port the code?
17:34argvuno, i haven't
17:34jsabeaudryztellman: Wireshark says they do
17:35ztellmanjsabeaudry: that's probably netty assuming the byte buffer is big-endian, then
17:36ztellmansince that's the standard java and network traffic ordering
17:39argvul
17:43TimMcargvu: You could try profiling it.
17:43TimMcI don't think I'm going to spend a half-hour understanding your undocumented code. :-/
17:44argvui understand =)
17:44argvuwhat do you mean with profiling ? how exactly ?
17:44jsabeaudryztellman: That is a pity, not being able to transfer bytes in the order I please. I'll try to find a hack around it I guess
17:45jsabeaudryztellman, hiredman: Thanks for your help
17:45dnolenargvu: what are you comparing against then? it's hard to improve the performance without knowing that.
17:45ztellmanjsabeaudry: keep in mind that's just a guess on my part, but there's nothing in aleph proper that touches the contents of the body
17:47argvudnolen: againt any of these https://github.com/attractivechaos/plb/tree/master/sudoku
17:47isak_how can i convert a bunch of vectors to sets? I'm trying (apply set [1 2 3] [4 5]), but i get an ArityException
17:47dnolenargvu: but did you port one of those?
17:47argvudnolen: no i didn't
17:48raekisak_: you want to get (#{1 2 3} #{4 5}) as the output?
17:48dnolenargvu: so it's going to difficult to say, no? since it may be your approach.
17:49isak_yeah raek
17:49raekisak_: then 'map' is the function you are looking for: ##(map set [[1 2 3] [4 5]])
17:49lazybot⇒ (#{1 2 3} #{4 5})
17:50tolstoyAnyone using core.cache? Is it not meant to be mutable in any way?
17:50tolstoyI'd like a simple-cache where you put values in and they fade out after TTL.
17:50argvudnolen: it's my approach for sure, because i understand that it' woule be to long to try to understand my code and fix it, i'll ask another question ... what's the best way to do backtrakcing in clojure ? =)
17:50isak_thanks raek. so do you know why apply gives an arityexception?
17:51ztellmanisak_ (set …) only takes a single argument
17:51isak_i see
17:52raekisak_: (apply set [1 2 3] [4 5]) doesn't make sense if you want it to get (#{1 2 3} #{4 5})
17:52dnolenargvu: there's no best way, probably many of the appraoches in that repo will work
17:53raekfirst, (apply f a b c [d e f]) is a shortcut for (apply f [a b c [d e f]])
17:53raekwhich means (f a b c [d e f])
17:53amalloyraek: whoa, that is not true
17:53TimMcyeah
17:54argvudnolen: the issue here is that i'm so stupid that i cannot even understand it ... however i was talking about backtracking in general
17:54TimMc(apply a b c [d e f]) is (f a b c d e f)
17:54amalloyshorthand for (apply f [a b c d e f]), which is the same as (f a b c d e f)
17:54raekamalloy: er. yeah.
17:54raeksorry folks... :-)
17:54argvudnolen: *understand the approach in that repo
17:54amalloyyou meant: (apply f [a b c] [d e]) is (f [a b c] d e)
17:54TimMcand mine is wrong by one important letter
17:54jsabeaudryztellman: Found a way around it, I enqueue (.array buf) instead of buf and it goes through perfectly.
17:54raekso
17:55tolstoyAh, maybe core.memoize is what I want (on top of core.cache).
17:55raek(apply set [1 2 3] [4 5]) is the same as (apply set [[1 2 3] 4 5]) and (set [1 2 3] 4 5)
17:55ztellmanjsabeaudry, yeah, because that will wrap the array in a big-endian buffer again
17:55ztellmanif you reverse the order after the encode-to-buffer, does that work too?
17:56isak_ok i get it, so apply is only for when you dont know the arguments at compile time
17:57jsabeaudryztellman: surprisingly it does not :S
17:58ztellmanjsabeaudry: remember that (.order buf …) returns a new byte-buffer, it's not a side-effect
17:59ztellmanor wait, according to the javadoc it is, never mind
17:59ztellmanno idea, then
17:59jsabeaudryztellman: Ah nevermind it does work to rereverse it. I had forgotten the .rewind
18:00ztellmanjsabeaudry: cool, that's at least a little sane, then
18:00ztellmanI'll make a note to look if it's always right to reverse it before handing it over to netty
18:01jsabeaudryztellman: Might be related to this bug https://issues.jboss.org/browse/NETTY-158
18:01ztellmanjsabeaudry: shouldn't effect the encoder, I'd expect
18:01MenTaLguYhmm
18:02MenTaLguYdoes clojure have an equivalent of bit-shift-right that doesn't do sign extension?
18:02MenTaLguYi.e. Java's >>> ?
18:05amalloy,(require 'clojure.repl)
18:05clojurebotnil
18:05amalloy,(repl/apropos "shift")
18:05clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: repl, compiling:(NO_SOURCE_PATH:0)>
18:05amalloy,(clojure.repl/apropos "shift")
18:05clojurebot(bit-shift-left bit-shift-right)
18:06MenTaLguYso that's a no?
18:06TimMcNothing obvious.
18:07TimMcChecking logs...
18:09TimMcclojure.lang.Numbers doesn't have anything
18:11TimMc06:08 < mikera> Is now: (defn >>> [v bits] (bit-shift-right (bit-and 0xFFFFFFFF v) bits))
18:11TimMc*shrug*
18:11amalloyat least twice i've seen someone implement this and desire to add it to lang or core
18:11MenTaLguYI guess I'll just drop down into Java for this code
18:12amalloynever seems to take off
18:12MenTaLguYit probably really should be there
18:13TimMcamalloy: Open a ticket... -.-
18:13hiredmanhttp://dev.clojure.org/jira/browse/CLJ-827
18:15hiredmanhttp://dev.clojure.org/jira/browse/CLJ-899 this is so bad
18:15hiredmanjesus, fogus upvoted it?
18:16TimMcpretty terrible
18:16technomancy~guards
18:16clojurebotSEIZE HIM!
18:18amalloyhiredman: how can you tell who voted?
18:18alexbaranoskycan you downvote on Jira?
18:18hiredmanamalloy: if you click on the number next to vote
18:18amalloymaybe you have more privs, but for me there's nothing clickable, and nothing happens if i try anyway
18:19hiredmanit says Vote (2)
18:19hiredmanif you click on the 2
18:19alexbaranoskythe number isn't clickable, but the thumbs-up is clickable
18:19amalloyyep, i recognize what "click on the number" means. i'm saying it doesn't do anything
18:19hiredmanwhatever you do, don't click on the thumbs up
18:19alexbaranoskyI'm afraid that I might accidentally upvote it ...
18:20hiredmandunno
18:20alexbaranoskyI guess I don't have downvote priveleges.
18:20amalloyalexbaranosky: i don't think there is a downvote
18:20hiredmanI don't think you can downvote
18:20hiredmanwhich is too bad
18:20amalloyyou can rescind an upvote, though, iirc
18:20alexbaranoskywonder if I can alter the http params
18:21amalloyalexbaranosky: yeah, if you accidentally upvote you can just take it back
18:21alexbaranoskyamalloy: good to know
18:22hiredman"Stuart Halloway created CLJ-899 - Allow colon as whitespace in map literals"
18:22hiredmanugh
18:23alexbaranoskyI don't get how this is even in discussion
18:23hiredmanright
18:24hammer_Hi, I'm Dan, first time on here. I am trying to convert a logistic classifier from Python to Clojure, and it's running *very* slow - much slower than the Python version. Here's the gist: https://gist.github.com/1623542 Any help would be greatly appreciated.
18:24alexbaranoskynext we'll have an alternate syntax that looks like this: `f(g(x))`
18:24amalloyalexbaranosky: "Guys wouldn't it be cool if". "Oh man that'd be awesome, make an issue"
18:24alexbaranoskythat you can use interchangeably with (f (g x))
18:25alexbaranoskyuse them together like this: `(f g(x))`
18:25amalloyit doesn't look like a discussion so much as a (bad) idea stu had and threw up on jira to remember/survey on
18:26hammer_This is the function call I use: (logistic-beta-vector (label-vec 100000) (feature-vec 100000) 0.00000001) https://gist.github.com/1623542
18:26technomancyamalloy: the best part is IIRC it happened right after stu shut some other issue down for "you need a concrete problem statement"
18:27amalloysee, he was careful not to say "one needs..."
18:27hiredmanI don't know that clojure.math.numeric-tower is performant at all
18:28hammer_hiredman: sorry, I don't even use that library -- I'll remove it
18:28hiredmanalthough, it actually doesn't look like you are using it
18:29hiredmanmath operations like + and * are faster if you treat them as binary
18:29hiredman(two arguments)
18:30hiredmanI think apply + is actually faster than reduce +
18:30hammer_also, one iteration takes about 800 seconds
18:30hammer_hiredman: thanks, I'm profiling the change
18:30amalloyhiredman: really? i think apply is just calling reduce, isn't it?
18:30hiredmanI would check out visualvm if you haven't yet
18:31amalloyor rather, the many-arg clause of + calls reduce
18:31technomancyamalloy: normally it would; + is kind of special in this case
18:31hiredmanamalloy: yes, but I seem to recall it being faster that way
18:32hiredmanactually, I could have it reversed, reduce may be faster
18:32hiredman,(time (apply + (range 1e6)))
18:32clojurebot"Elapsed time: 729.371 msecs"
18:32clojurebot499999500000
18:32hiredman,(time (reduce + (range 1e6)))
18:32clojurebot"Elapsed time: 623.267 msecs"
18:32clojurebot499999500000
18:33sritchieI'm working with hammer_ on this one in person, actually
18:33hiredmanhammer_: if the python code infact just calls a c extension it may be hard to beat
18:33sritchieit's bizarre, the clojure code's something like 2 orders of magnitude slower than python
18:33sritchieI had thought it was fast because it was cheating and taking some view on the data
18:34sritchiehiredman: but it actually runs everything each time
18:34amalloy,(time (loop [acc 0, coll (range 1e6)] (if-let [[x & xs] (seq coll)] (recur (+ acc x) xs) acc)))
18:34clojurebot"Elapsed time: 1497.646 msecs"
18:34clojurebot499999500000
18:34hiredmansritchie: what do you mean?
18:35sritchiehiredman: in numpy, if you run some operation on a matrix and look at one corner, I think the operation acts lazily and only applies itself to the piece you're looking at
18:35sritchieI wonder if it's worth shelling out to python
18:36hiredmanis it a fairly direct port of the python? I doubt it, since it is using map and filter
18:36sritchiehammer_: can you post the python?
18:36hammer_sure one second
18:37hiredmanit also looks like maybe you are missing a set of parens in your code
18:37hiredmanline 87
18:37robinkraftsritchie: I'm pretty sure Numpy calculations generally aren't lazy
18:38hiredmanis this clojure 1.2 or 1.3?
18:38sritchie1.3
18:40hammer_Here is the Python gist: https://gist.github.com/1623646
18:41hammer_I fixed the parens problem; but that would just screw up the actual values, not the amount of time. rerunning now.
18:42TimMcHow do I call the int version of a Java method that is overloaded for both int and long? (Working on a better patch for bit-shift-right-logical)
18:43amalloyTimMc: you can certainly do it by (.foo obj (Integer. x)). you might also get away with hinting it somewhere instead
18:44TimMcHmm, OK -- that's what I tried.
18:44TimMcI'll have to check the bytecode to confirm this is the right call...
18:47AWizzArdDoes ^:const only work for primitives?
18:48hiredmanAWizzArd: they are not evaled
18:48hiredmanso effectively it only works for readable things
18:48TimMcamalloy: Oops, no -- the method is overloaded for int, long, and Object!
18:51_carlos_hi!
18:51TimMc...and that's wrong too, never mind.
18:52_carlos_is it idiomatic in any case to use mutually recursive functions? I was always taught that wanting to do it implied a bad design. clojure enables it with a forward declaration and a special function call
18:54clj_newbis there a shorter way of writing: (map (fn [data env] (my_eval :data data :env env)) lst) ?
18:55clj_newbi wnat to shorten the (fn [data env] (my_eval :data data :env env)) part
18:55hiredman-
18:55technomancyclj_newb: any map call with a nontrivial literal fn is probably better off as for
18:55clj_newbthe fn is trivial
18:55clj_newbit's just it takes named arguments
18:55technomancythat won't even work for arity reasons
18:56clj_newbyou're ab oslutely right
18:58oakwise_carlos_: check out the trampoline function
18:58_carlos_oakwise: I know, I just wondering why such a feature
18:59_carlos_technomancy: what does it mean nontrivial literal fn?
18:59clj_newbunrelated question: is there a way in clojure to auto-require an entire directory tree? i.e. I want to auto-require ~/my-clojure-helper-functions/**/*.clj
18:59clj_newb(it seems like this is possible since all of java.* appears to be auto required)
19:00technomancy_carlos_: any (fn []) call more than 10-15 chars I guess?
19:00technomancyclj_newb: import != require
19:00TimMcclj_newb: Just java.lang.*
19:00clj_newbI'm looking for :require, not :use
19:00oakwise_carlos_: clojure doesn't have full tail call optimization, so if two functions keep calling each other recursively, they'll keep building up the call stack unnecessarily
19:01clj_newbI just wantt o be refer to sthigns like my_util.****/foo w/o having to add :requires all over the place
19:01technomancyclj_newb: there's no built-in way to do that, but there is nstools.
19:02_carlos_oakwise: I know. my question is "why should one even consider to build mutually recursive functions"
19:02TimMcMenTaLguY: I've submitted a patch for bit-shift-right-logical, but who knows.
19:04emezeske_carlos_: mutual recursion can be used in place of complex state machines sometimes
19:05emezeske_carlos_: without a central dispatch loop thing
19:05emezeske_carlos_: it can be cleaner to just call another function than to set some new state value and recur
19:05TimMctechnomancy: You haven't mentioned slamhound to clj_newb yet?
19:06oakwise_carlos_: Ah I see. State machines are the classic case I think.
19:06technomancyoh yeah, there's that too
19:06technomancyTimMc: a small ns form can be better than an autogenerated large one though
19:06clj_newbslamhound/README.md is very informative
19:07MenTaLguYwith state machines, you can potentially model the state machine as a lazy stream over its inputs
19:07MenTaLguYwhich solves your stack depth problem
19:07MenTaLguYwhile still allowing a mutually-recursive style
19:11_carlos_I see. thank you emezeske, oakwise, MenTaLguY .
19:11MenTaLguYlaziness ftw
19:36clj_newbis there a shorter way to write (list 'a (list 'b 'c) 'd) ? Writing '(a (b c) d) causes the a/b/c/d to be namespace-quantified, which I donm't want
19:37TimMcclj_newb: '(a (b c) d)
19:37TimMcnot `(a (b c) d)
19:38clj_newbcrap, I actuallly need `
19:38clj_newbsince I use ~ elsewhere
19:39amalloythen consider using keywords instead of symbols to represent your data items. if they're not supposed to be recognizable vars, symbols are often just confusing
19:41clj_newbamalloy: so this almost works; except all of my functions also use keywords since I pass arguments by name
19:41clj_newbas a result, it becomes iffy figuring out which keywords should be looked up in the environment, and which should not
19:42clj_newbokay, using ` with ~' appears to make it work
19:42TimMc"which keywords should be looked up in the environment" means you're using keywords wrong.
19:43clj_newbi'm using code is data / datat is code as a way to represent nested GUIs as lists
19:43clj_newbthen to build them, I "eval" the list, by looking at the first element, to know what gui element to construct
19:43clj_newbright now, this is a symbol; but if I use a keyword instead; then I need to "oookup the keyword in the environment"
19:48clj_newbwtf
19:48clj_newbwhy is (type `(1 2)) = Cons ? rather than PersistentList ?
19:49hiredmanwhat made you think it would be PersistentList?
19:49technomancyclj_newb: because the classes aren't what matters
19:50clj_newbwhen writing a metacicular evaluator
19:50clj_newbhow do you test if somethign is listy ?
19:50clj_newbseq?
19:50clojurebotseq is what
19:50technomancyyeah, it's seq?
19:50technomancydon't trust the list? predicate; it is 95% useless.
19:51clj_newbwoot
19:51clj_newbit works now
19:51clj_newbthanks
19:51hiredmanwell, if you want to check for an IPersistentList it works great
19:51clj_newbI feel like my IQ has risen 10 points back to 80/100
19:51hiredmanwhich is exactly what the doc string says it does
20:03clj_newbis there a way to tell clojure: when a named param is not passed, don't assume value of nil; complain! ?
20:04technomancyyou can use preconditions for that
20:14TimMctechnomancy: The surprise is really that syntax-quote returns seqs, not lists.
20:17amalloyTimMc: you don't really want it to return lists anyway, right? it wouldn't be as versatile
20:18TimMcI guess with seqs it can be streaming.
20:18amalloy`(~start ~@middle ~end)
20:19amalloythis doesn't have to be part of a macro - it's way more descriptive than (concat [start] middle [end])
20:19amalloyand allows for the possibility that middle is infinite, or or just way longer than you need (the streaming point you made)
20:20amalloyi suspect it also saves the time of walking over the whole things twice - once to build a list, then again later when you want to use it
20:20sritchiehiredman: really odd about that clojure function --
20:21sritchiefrom hammer_ before
20:21sritchieI found that it was extremely fast for 100,000
20:21sritchierun over and over
20:21sritchiebut when I tried to run this particular code with 1,000,000 iterations, the first four or so were very fast, then the whole computation started to bog down, until by 7 or so it was interminable
20:21sritchiethen running 100,000 again took 17 seconds
20:22amalloyon an unrelated note: i find i never want to write (with-meta expr meta). i always end up writing (-> expr (with-meta meta)), to make it easier to separate/parse mentally. am i the only one?
20:22sritchiedo you guys know which memory setting I need to jack up to deal with issues like this?
20:23technomancyamalloy: I always forget the argument order too
20:24joegalloyup, every time
20:24amalloytechnomancy: i actually remember it, these days. maybe using -> helped me with that
20:24technomancyamalloy: with-meta is the only with-* call in clojure.core that doesn't introduce dynamic scope
20:24amalloyyeah, i remember chouser's riddle
20:24technomancymaking it a certifiable odd duck
20:27amalloyit's a little arguable whether with-open actually introduces dynamic scope
20:27sritchiemore concisely -- does anyone know how to deal with a case of bogged-down garbage collector?
20:27amalloylike, the values are lexically scoped. but they don't *work* outside of the apparent dynamic scope
20:27technomancyamalloy: never thought of it that way
20:27amalloydepends what's bogging it down, really, sritchie
20:28sritchieI do have a concise example, I believe
20:36sritchieboom, examplified: https://gist.github.com/1624010
20:37sritchieamalloy: I'm running this log-likelihood function a bunch of times -- I had thought that dorun would prevent clojure from holding on to the head of a sequence
20:37sritchieI'm guessing that I'm just getting slammed with garbage collection issues here?
20:37sritchie(profiling at the bottom)
20:43amalloysritchie: have you tried profiling and watching the heap size over time? this kinda looks like some of your objects are piling up on the heap and becoming uncollectable
20:44sritchieI'm off to download yourkit now
20:45amalloyi don't see anything in the code that looks like it should behave that way, unless there's an error in locals-clearing and labels/features aren't being cleared when you start your loop
20:45hiredmanI suggested visualvm above
20:45hiredmancomes with the jdk
20:45sritchieah, got it
20:47amalloywe had symptoms like this once, and what was happening was each iteration of the algorithm generated X amount of trash, and Y amount of stuff that couldn't be GCed because it wound up in a memoization cache. eventually, there was only X + epsilon amount of space left in the heap, and every couple allocations triggered another GC run, barely cleaning up anything
20:50sritchiethat sounds like a pretty fine description of what's going on here
20:50sritchieI'll try out visualvm and see if I can target what's generating the garbage
20:53sritchiehmm, I think I fixed it
20:53sritchiehttps://gist.github.com/1624059
20:53sritchieI started by taking off of a stream this time
20:53sritchieoh
20:54sritchieit was this:
20:54sritchie(def X-rand (feature-vec 10000000))
20:54sritchie(def y-rand (label-vec 10000000))
20:54sritchieX-rand and y-rand were holding on to the heads of those lazy sequences
20:54sritchieand as the code walked toward 1,000,000, more was getting realized
20:58amalloyah, right
21:00devthif i have a symbol "println" - how do i resolve that to the function in clojure core? my syntax-quote-fu is weak.
21:03devthoh. it's just (resolve 'println)
21:16bitopshi all, I'm getting confused trying to require in my ns.
21:16bitopscode: (ns foo.core (:require [clojure.string :as str]))
21:16bitopsbut I get an error message about periods?
21:16bitopsin the repl my require works fine.
21:19bitopssorry, the error message is "Don't know how to create ISeq from: clojure.lang.SymbolDon't know how to create ISeq from: clojure.lang.Symbol"
21:24bitopsah, my apologies. the actual error message that confounds me is: lib names inside prefix lists must not contain periods
21:32TimMc$findfn 'println println
21:32TimMcArgh, lazybot is deadbot.
21:34TimMcbitops: That looks fine... did you copy that code verbatim, or retype it?
21:35bitopsTimMc: that is a verbatim copy and paste from my code
21:35bitopsI am quite perplexed.
21:37TimMcbitops: Check for outside problems like wrong version of Clojure, not having saved file to disk, etc.
21:37TimMcsanity checks
21:38bitopsTimMc: checking...
21:39TimMcWorks here.
21:40TimMcI once got some weird-ass errors when I accidentally nabbed an unstable clojure.core. (Tip: Version ranges in dependencies are not very reliable.)
21:40bitopsTimMc: I'm re-starting my swank server, project.clj looks good.
21:41bitopsTimMc: hrm. Still explodes.
21:41bitopsDon't know how to create ISeq from: clojure.lang.Symbol
21:44bitopsTimMc: I may just try to re-create my project. I had just gotten off the ground. Maybe I'm missing something that will become obvious when I re-init.
21:45TimMcWhat happens when you lein run it?
21:47bitopsTimMc: I hadn't tried that, let me see.
21:47bitopsno :main namespace specified in project.clj
21:47bitopsI'm building a test webapp
21:47bitopsfor heroku deployment
21:48bitopsbut maybe I'm missing something?
21:49bitopsTimMc: it's all good actually. I'm about to head home, so no biggie.
21:49bitopsthank you for the help!
21:49TimMcAh, lein run wouldn't help then!
21:49adiabaticstupid question of the week: can't noir use clojure 1.3? I did the `lein plugin install lein-noir 1.2.1` dance, and it pulled clojure 1.2.1
21:50seancorfieldthat's just for the lein plugin i think
21:50seancorfieldonce you create a noir project with the plugin, i think you'll find it uses clojure 1.3.0
21:50seancorfield(all lein plugins have to use clojure 1.2.1 to run)
21:52adiabaticwhy? that bit of lein hasn't been updated yet?
21:52seancorfieldlots of plugins out there aren't compatible with 1.3.0 yet i suspect
21:52seancorfieldso leiningen can't run plugins in 1.3.0 because many will break
21:52benares_98can anyone explain how the for function is used? I don't understand what [seq-expr body-expr] in the doc means.
21:52adiabaticbenares_98: are you familar with list comprehensions in other languages?
21:53seancorfield(for [i (range 10) j (range 10)] (* i j)) ;; does that help?
21:53benares_98adiabatic: This is my first venture in lisp dialect
21:53adiabaticbenares_98: I'm familar with 'em from Python, so…
21:54seancorfield,(for [i (range 3) j (range 3) :when (not= i j)] [i j (* i j)])
21:54clojurebot([0 1 0] [0 2 0] [1 0 0] [1 2 2] [2 0 0] ...)
21:55seancorfieldi can't remember what other qualifiers you can specify in there but it's pretty flexible / powerful
21:55amalloy:while, :let
21:55adiabatic(doc for) doesn't even mention :let
21:55clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test. (
21:55benares_98I see examples of for with :when and :while in brackets but where do theses fit in the [seq-expr body-expr] of the doc?
21:55amalloyadiabatic: guess again
21:56rlbIn 1.2 I was reading a 64-bit unsigned int like this: (bit-and (.readLong data-stream) 0xFFFFFFFFFFFFFFFF). What's the best way in 1.3?
21:56seancorfieldadiabatic: "Supported modifiers are: :let ..."
21:56adiabaticright. my bad.
21:56amalloybenares_98: (for (comment THIS IS THE seq-expr) [x (range) :when (even? x)] (comment THIS IS THE body-expr) (/ x 2))
21:57seancorfieldbenares_98: see the examples i posted? do those help
21:58benares_98seancorfield: so :when, :while, :let are support modifiers for the 'for' function?
21:58benares_98seancorfield: they do I'll look at them again.
21:58seancorfieldthey control how the sequences are iterated over
21:59seancorfield,(for [i (range 1 10) :let [s (* i i)]] (str i " squared is " s))
21:59clojurebot("1 squared is 1" "2 squared is 4" "3 squared is 9" "4 squared is 16" "5 squared is 25" ...)
22:00rlb(I know I can use (.and (BigInteger/valueOf ...) ...), just wanted to see if there was anything more appropriate.)
22:00seancorfield,(clojure-version)
22:00clojurebot"1.3.0"
22:00seancorfield,0xFFFFFFFFFFFFFFFF
22:00clojurebot18446744073709551615N
22:01amalloy,(for [c (range 100) :let [c2 (* c c)], b (range c) :let [b2 (* b b)], a (range b) :when (= c2 (+ b2 (* a a)))] [a b c])
22:01clojurebot([3 4 5] [6 8 10] [5 12 13] [9 12 15] [8 15 17] ...)
22:01benares_98thanks, I believe I understand it now.
22:01adiabatic(for [cake cakes] [(put-cherry-on-top cake)])
22:02amalloybenares_98: a somewhat more involved example to compute pythagorean triples
22:02devnSo, I'm doing a fresh installation of OSX on this machine and I'm looking to set up a modern clojure environment. My old config uses slime-connect, paredit fixes for the slime buffer, and on and on. What is the modern guide for having a sane clojure environment in emacs? Anyone here use el-get?
22:03seancorfielddevn: I went with Emacs 24.0.90, the init.el mods to add marmalade, clojure-mode, lein swank-clojure and clojure-jack-in - seemed to be the easiest setup i could find documented...
22:04rlbseancorfield: ?
22:04seancorfieldbut i haven't done much customization... what's the "paredit fixes for the slime buffer"? sounds like i could use those :)
22:04rlb,(bit-and 4 0xFFFFFFFFFFFFFFFF)
22:04clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: bit operation not supported for: class clojure.lang.BigInt>
22:04adiabaticbenares_98: also: :when keeps evaluating every single thing that it can in the seq-exprs — :while, on the other hand, stops the for on first failure
22:04devnseancorfield: matching {}'s, highlighting, etc.
22:04adiabaticIIRC
22:05devnseancorfield: honestly my emacs.d is such a mess that I'm sort of amazed any of it works.
22:05seancorfieldrlb: ah, i wasn't sure why your existing code wasn't sufficient... now i get it
22:05devnseancorfield: but I do have a really nice clojure environment from what I've seen
22:06seancorfielddevn: sounds like nice fixes... where do i get those? :)
22:06devnseancorfield: I can show you what I have -- hopefully it helps -- give me a moment and I'll gist it.
22:06benares_98why is :when, :let, :while not in the (doc for)? Is there another doc that is more concise?
22:06rlbHmm, and the obvious thing won't work because the reader makes 0xFF... into a bigint, so you can't use valueOf.
22:07adiabaticbenares_98: look again
22:07rlbIs there a way to turn a bigint into a BigInteger?
22:07adiabaticit's all in there, but the difference between :when and :while is underdocumented
22:07adiabatic(I need to file a bug report if not a patch against that…)
22:08seancorfield,(doc for)
22:08clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], ...
22:09seancorfieldbenares_98: I see :let there
22:09benares_98rlb: you're right, it's in the doc but it has no explanation on how the modifiers are used.
22:09seancorfield(doc for)
22:09clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test. (
22:09rlbAhh -- (.toBigInteger ...)
22:09seancorfieldand there is :while and :when
22:09devnseancorfield: https://gist.github.com/1624324
22:10seancorfieldthanx devn
22:10adiabaticseancorfield: right, but I had to ask in here what the difference between :while and :when was
22:10devnseancorfield: hopefully it can be of some use -- I honestly don't remember where half of that stuff came from, it's just been snowballing
22:10benares_98thanks for the help everyone!
22:10adiabatic(ok, you're probably answering two different questions, but…)
22:10rlbNot, the prettiest, but...
22:10rlb (.and (BigInteger/valueOf (.readLong data-stream))
22:10rlb (.toBigInteger 0xFFFFFFFFFFFFFFFF)))
22:10rlb
22:10benares_98I'll play with the modifiers to understand furhter
22:10rlbworks
22:11rlbOf course, I should probably cache the .toBigInteger conversion...
22:11rlb(I'm assuming that the compiler won't do that for me.)
22:12seancorfielddevn: some of that's pretty scary looking stuff! :)
22:13seancorfieldadiabatic: i guess i thought :while was intuitive... and :when too based on the (when cond expr)
22:13seancorfieldbut you're right it's underdocumented
22:14adiabaticif you're familiar with [keep|drop]while, sure. If you're not…
22:17devnseancorfield: agreed. this is why I'm asking for suggestions. I've built a cathedral
22:49amalloyseancorfield: you might be surprised about :while. i learned a bit about it from stackoverflow recently
22:50seancorfoh? do tell... now i'm curious! :)
22:50alexbaranoskyis it the spiritual cousin of take-while, but in for expressions?
22:53amalloyseancorf: http://stackoverflow.com/q/8816464/625403 - looking back at the docs it should be clear it behaves this way, but i had sorta imagined :while as magically guessing whether i mean "end the current iteration of this inner-most variable" vs "end the result of the for expression"
22:56alexbaranoskyamalloy, nice. I've yet to use :while - but good to learn more about it for future reference
22:57amalloyyeah, it's applicable a lot less often than when/let
22:58adiabatichunh, weir
22:58adiabaticd
23:31seancorfield`if i missed anything, blame comcast :(
23:40amalloyseancorfield`: not much, if anything: http://lazybot.org/logs/#clojure/2012-01-16
23:40TimMclazybot *dot org*?
23:40TimMcSince when did bots get domains?
23:41amalloyyou didn't get yours? check your mailbox again
23:41TimMchaha
23:42seancorfield`appreciated amalloy - i really didn't miss much, eh? :)
23:42seancorfield`interesting about :while... i hadn't thought about it in that much detail...