#clojure logs

2011-04-16

00:00justinlillyjars are just zip files + metadata.
00:00chewbran1adoesn't seem to work for me, $ zgrep couch lib/clojure-couchdb-0.4.7.jar returns nothing
00:03justinlillydisappointing :-/
00:30amalloyjustinlilly, chewbran1a: zgrep passes its options straight along to gunzip, whish probably assumes gzip encoding unless you pass it a zip option
00:30justinlillyinteresting. man page says "passes its options along to grep" or somesuch, iirc.
00:31justinlillyfrom manpage: All options specified are passed directly to grep.
00:31amalloyoh sorry. guess i misread
00:31amalloybut it definitely supports zip encoding
00:31justinlillybest I could come up with was grep -a (which assumes its text format, not binary)
00:31justinlillydoesn't work very well though.
00:31amalloyif you find the right option
00:32justinlillybrief googling turned up unarchive, grep, rearchive :-P
00:32amalloyewwww what
00:33amalloybut i guess the zip format is pretty crippled. maybe that makes sense
00:40Apage43man
00:40Apage43zip
00:41Apage43i hope if i create one of the most widely used file formats in existence that i don't die alone in a hotel room of alcohol poisoning.
01:13amalloyApage43: that's probably a good thing to hope for whether or not you create any file formats at all
01:14Apage43it's not likely, at any rate. I'm not really into alcohol much.
01:16Apage43file formats though I might dabble in too much sometimes.
01:16carllercheis there a function that wraps a value in a seq unless it already is in one?
01:25amalloy$findfn 1 [1]
01:25sexpbot[clojure.core/xml-seq clojure.core/vector clojure.core/list]
01:25amalloylooks like no built-ins
01:26carllerchehow does findfn work?
01:26amalloycarllerche: how is it implemented, or how do you use it?
01:26carllerchewell, both I guess... is there a local version?
01:26carllerchei'm still finding the API docs a bit hard to manage
01:27amalloyno, joshua__ and i wrote it for sexpbot. mec cloned sexpbot and pulled it out into something local, but i haven't looked into it
01:27carllerchesince I still barely know the landscape
01:27amalloythe syntax is $findfn arg1 arg2... result
01:28amalloyhe tries (f arg1 arg2...) on every function he knows about and sees which ones end up giving you the result you want
01:28amalloy$findfn inc [1 2 3] [2 3 4]
01:28sexpbot[clojure.core/map clojure.core/keep]
01:28carllerchesomething like: (defn wrap [x] (if (coll? x) x [x]))
01:30amalloycarllerche: and feel free to /msg sexpbot anything you want to try out
01:31carllerchenice
01:32amalloyof course findfn is pretty primitive: it can't figure out inc from $findfn map [1 2 3] [2 3 4], because you need to pass inc as an argument, not call it. but for simple stuff it helps you find your way around, and discover occasional gems
01:33amalloy$findfn [1 2 3] [3 2 1] ; cause i forget what rseq is called
01:33sexpbot[clojure.core/rseq clojure.core/reverse]
01:33carllercheheh, that's cool
01:34amalloyhm?
01:34clojurebothmm, maybe my repl is out of wack
01:34amalloyclojurebot: forget hm
01:34clojurebothmm, maybe my repl is out of wack
01:34amalloybah
01:34technomancyclojurebot: forget hmm, maybe my repl |is| out of wack
01:34clojurebotI forgot that hmm, maybe my repl is out of wack
01:34amalloyah
01:34technomancy(since it allows arbitrary verbs)
01:35amalloyclojurebot: hm?
01:35clojurebotPardon?
01:35amalloyhooray
02:31joshua__technomancy, what |is| that hmm thing you guys were just messing with?
02:42chewbran1aanyone have a recommendation for parsing a large xml file? running xml-seq on a 1gb file and hitting MemoryError: GC overhead limit exceeded
02:45mreynoldschewbran1a: Are you doing something like this : http://www.chrisumbel.com/article/clojure_xml_parsing_xml-seq ?
02:48chewbran1amreynolds: basically doing: http://stackoverflow.com/questions/1194044/clojure-xml-parsing/1195568#1195568
02:50mreynoldschewbran1a: Unfortunately I'm struggling with a similar problem and am no expert. I can say that what I've read would indicate that you might be holding on to a portion of the sequence. Also, that question was answered in 09 and might be a bit dated versus the new sequence code. Do you know what objects are being held on to?
02:51chewbran1amreynolds: just stumbled upon this: https://groups.google.com/forum/#!topic/clojure/Nlynqq-NVbc
02:51chewbran1alooks like xml parse loads the whole doc
02:52mreynoldsouch
02:53chewbran1athat last link points to a library: https://github.com/marktriggs/xml-picker-seq that is apparently designed for processing large xml files
02:54mreynoldschewbran1a: makes sense with the 'seq' on the end
02:54mreynoldschewbran1a: good luck :) Let me know if it works
02:54chewbran1amreynolds: will do
03:11mreynoldsIs there a way to shorten the printing of a.b.c.d/keyword (used as ::keyword) to just ::keyword?
03:17amalloymreynolds: i don't think you'd really want that. the printed value would stop being correct if you changed namespaces
03:18mreynoldsamalloy: Not sure what you mean. I'm not trying to get rid of the namespace in the code, just on console when I print it out? I understand that just using :keyword vs ::keyword looses the namespace, and thus the comparison capabilities.
03:18mreynoldsamalloy: Right now I have a ton of records with "a.b.c.d" in them and it's filling my screen. Just want to trim it down a bit.
03:20amalloymeh. i'm probably being too dogmatic, but i like that when clojure prints a value V to string S, it can be read back in as the same V, and will compare equal to other objects that print as S
03:21mreynoldsamalloy: Oh, I agree if I was using it in a programmatic fashion. At the moment this is just for debugging.
03:22amalloyanyway, i don't think there really is. if there were, there would be some global variable you could set! to make keywords change their behavior
03:22mreynoldslooks like it might be this : http://clojuredocs.org/clojure_core/1.2.0/clojure.pprint/*print-suppress-namespaces*
03:23mreynolds... but I just realized the reason I was printing that thing was because of forcing the evaluation, so lemme fix that bug first
03:37mreynoldsAlright, I'm stuck on the classic "when I print it, it works; when I don't print it, it doesn't work" bug. Is there a doc I can read to help explain this better? I've been futzing around with (do) for far too long with no results.
03:37mreynolds(bug here is in my code, in case I didn't state that clearly)
03:58hiredman,(doc condp)
03:58clojurebot"([pred expr & clauses]); Takes a binary predicate, an expression, and a set of clauses. Each clause can take the form of either: test-expr result-expr test-expr :>> result-fn Note :>> is an ordinary keyword. For each clause, (pred test-expr expr) is evaluated. If it returns logical true, the clause is a match. If a binary clause matches, the result-expr is returned, if a ternary clause matches, i...
04:15amalloymreynolds: do is not really much help laziness-wise. you probably want to look at dorun, doall, or doseq
04:33mreynoldsamalloy_: Yeah, thanks. As it turns out, I re-read through my code and realized I was using (do...) correctly, but in the wrong place. Adding a doseq in place of a for loop appears to have fixed the problem.
04:34mreynoldsI'm actually pretty stoked at being able to convert my "for loop" style code to a lazy sequence. It's very elegant to be able to do that.
05:03chewbran1aawesome!! got buffered xml parsing working with xml-picker-seq and xom.. good times
05:04mreynoldsWhat ended up working?
05:04chewbran1amreynolds: just had to port over to using the xom wrapper with a buffered reader
05:04mreynoldschewbran1a: nice :)
05:10chewbran1ahttp://paste.lisp.org/display/121545
05:10chewbran1aif anyone is around is bored, I would be happy to hear suggestions or comments on that code
05:10mreynoldschewbran1a: Does it perform the same without the type hint?
05:12fliebelchewbran1a: Does duck-streams offer any advantage over clojure.java.io/reader?
05:12chewbran1ayeah I imagine the type hit isn't necessary, it only creates the reader once, although I honestly have no idea, this is the most complicated piece of clojure I've written yet, so still very new to things
05:13fliebelchewbran1a: I think you could clean up that nested bit a lot with ->>
05:13chewbran1afliebel: its a clojure contrib library that just facilitates giving you streams to work with
05:13chewbran1afliebel: http://richhickey.github.com/clojure-contrib/duck-streams-api.html
05:13fliebelchewbran1a: So does clojure.java.io
05:14ejacksonmorning, morning.
05:14fliebelejackson: mornng
05:14fliebelhttp://clojure.github.com/clojure/clojure.java.io-api.html
05:14chewbran1afliebel: I'm not familiar with ->> and I'll have to take a peek at clojure.java.io
05:14tomojdoes duck-streams even exist anymore?
05:15tomojoh, yep
05:15chewbran1aits used in the lib: https://github.com/marktriggs/xml-picker-seq that is the wrapper around xom I'm using, so I just went with duck-stream
05:15chewbran1amain issue was processing a gig of xml without overflowing GC/memory
05:16tomojthere's also clojure.contrib.io
05:16tomojconfusing...
05:16fliebelchewbran1a: ##(->> (range 10) (map (partial * 2)) (apply str) reverse println)
05:16sexpbot⟹ (8 1 6 1 4 1 2 1 0 1 8 6 4 2 0) nil
05:16chewbran1awhich this is churning along on now with utilization, much better than before
05:17chewbran1afliebel: oh niiiiice
05:17chewbran1ayeah that would have helped a lot
05:17chewbran1awhen was that introduced?
05:17fliebelchewbran1a: -> threds at the first argument ->> threads at the last one.
05:18tomoj&(:added (meta #'->>))
05:18sexpbot⟹ "1.1"
05:18fliebel&(:added (meta '->>))
05:18sexpbot⟹ nil
05:18clojurebot⟹ "Returns the metadata of obj, returns nil if there is no metadata."
05:18fliebellol
05:19chewbran1afliebel: very cool, I'll port over to that and clean up the code a bit
06:20fliebelI don't know what to think of this… Is it just that Clojure infected my brain, or is it silly to use a class for containing mouse buttons? https://github.com/pepijndevos/pyMouse/pull/8/files
06:25midslacking symbols (I think), this seems like a fair way to do an enumeration in .py
06:28midsalternative might be using string literals (which are interned by default)
07:58peteriserinsis it possible to prevent stack overflow for this function while preserving the same style? (def memo-fib (memoize #(if (< % 2) 1 (+ (memo-fib (dec %)) (memo-fib (- % 2))))))
07:59fliebel$mail stuartsierra It just occurred to me the you can't observe a certain type of events in cljque like you can in Swing. Useful?
07:59sexpbotMessage saved.
08:01fliebelpeteriserins: Same style? I don't think so. The way to avoid stackoverflow is to use looping, or looping that looks like TCO.
08:02hiredman'interative' vs. 'recursive'
08:02peteriserinsfliebel: but why does the stack overflow appear for a memoized function?
08:02peteriserinsfliebel: oh I see, maybe I should precompute the first few values in sequence
08:03fliebelpeteriserins: How does memoizing help here?
08:03peteriserinsfliebel: yep, it worked
08:05peteriserinsfliebel: I'll pastebin in a moment
08:05fliebelpeteriserins: As I see it, the result would only be memoized after the recurring, because before that, no function returns.
08:06peteriserinsyep, http://pastebin.com/MAEsKSjM
08:09fliebelpeteriserins: Run it with 2000, you just postponed the problem.
08:09peteriserinsfliebel: works for me; are you setting the first 1000 to 2000 as well?
08:10fliebelpeteriserins: Ah, I see what you're aiming at. Yes, if you do it that way, it works.
08:12fliebelYou could increase step a whole lot. (range 1 1000 100)
08:13peteriserinsfliebel: oh right, step could pretty much be the stack overflow treshold
08:14peteriserinsfliebel: but one might have to do those values in pairs of adjacent numbers
08:14fliebelpeteriserins: Why?
08:15peteriserinsfliebel: so that it can have enough memoized values without going from 1000 to 1
08:16fliebelpeteriserins: Also, why would you want to store every fib number from 0 to the highest computed so far? Just the last 2 would do, right?
08:16peteriserinsfliebel: as long as I need only successively higher ones
08:16peteriserinsfliebel: but say I want some sparse set, I have to keep intermediates
08:17fliebelokay...
08:19peteriserinsthen again if I wanted random big numbers, I'd probably just do matrix exp
08:19fliebelpeteriserins: Why do you want fib numbers anyway? Some Euler problem?
08:20peteriserinsfliebel: yes Euler problem, but I actually want the totient function, I was just experimenting with fibs
08:20raekpeteriserins: another way to implement a sequence of numbers like this is to represent them as a lazy sequence. this solves the problem of recursive calls, but does not "preserve the style".
08:21peteriserinsraek: for the totient function, I'd need to refer to arbitrary indices not just a few previous
08:21peteriserinsbut this approach seems to take up a lot of space, so I don't think it'll work
08:23peteriserinsI was basically hoping to find a more clojuresque way of doing dynamic programming than making a mutable array a la C
09:29BorkdudeI am using a wrap-reload handler in compojure
09:29BorkdudeI am expecting that it only reloads when the source file changes, but it reloads with every request even when nothing changed
10:24Borkdude`Trying lein ring now
10:24Borkdude`and I keep getting this exception:
10:24Borkdude`Exception in thread "main" java.lang.NoSuchMethodError: clojure.lang.RestFn.<ini
10:24Borkdude`t>(I)V (war.clj:1)
10:26Borkdude`Project.clj here: http://pastie.org/1800713
10:33dnolenBorkdude`: that usually means you have some compiled lib that doesn't match the Clojure version.
11:52Borkdude`Ah it was probably a conflict between lein-run and lein-ring
11:58TimMcHuh, I thought I would get Double/POSITIVE_INFINITY if I did (/ 0.0)
12:23SergioTapiaHi Clojure community.
12:23SergioTapiaI'm mainly a .NET/Ruby developer and I'd like to start branching out a bit and learn about functional programming. What book would you recommend for someone that knows how to program, but wants to learn about Clojure and what it's used for?
12:24Borkdude`The Joy of Clojure
12:24Borkdude`also see this (my) thread on SO: http://stackoverflow.com/questions/2578837/comparing-clojure-books
12:25SergioTapiaThanks, let me get some coffee and take a look. I tried Raynes try-clojure website and the syntax for the language is kind of freaky! in a good way.
12:25SergioTapia(+ 2 2) Hehe :) I like how you can nest different anonymous methods and works with the resutls.
12:25clojurebot4
12:25RaynesSergioTapia: The Joy of Clojure is a fantastic book, but you probably want to start with Practical Clojure and /then/ read The Joy of Clojure.
12:26SergioTapiaRaynes! LOL you're here?!
12:26SergioTapiaYou're raynes from DIC right?
12:26RaynesYes, and I'm always here. :)
12:27SergioTapiaHahaha, great. Expect me to ask a LOT of questions about the language. :D By the way, great site: try-clojure
12:27Raynes<3
12:28tufflaxSergioTapia I recommend you read the docs on clojure.org, I read 2 books and the docs, and I think I learned the most from reading the docs
12:28SergioTapiaNah - I despise reading docs from top to bottom. :x I prefer a book with a more linear learning path.
12:28SergioTapiaFrom there I can branch out to topics that interest me.
12:28tufflaxOk :)
12:28RaynesRight, the docs are fantastic, but aren't organized in a linear for-beginners way.
12:28Borkdude`SergioTapia: if you need to search the docs, clojuredocs.org is a great site
12:29SergioTapiaAlso: I'm going to be using Eclipse with the CounterClockwise plugin. *ducks*
12:29SergioTapiaRead about it here: http://learn-clojure.com/get_clojure.html
12:29RaynesSergioTapia: Nothing to duck for. Plenty of people use that.
12:30RaynesMost Clojurians use Emacs and Vim is a close second, but those aren't the only valid options. :>
12:30SergioTapiaI WISH I could use Emacs, but I need the autocomplete at first. to get a feel for the language.
12:31RaynesSLIME does autocomplete, methinks. Not sure exactly how it works. I don't think I've ever used autocomplete in any language.
12:31BorkdudeSergioTapia: you can do it, but it will just be a matter of time before you start using emacs for irc ánd clojure programming.. *ducks*
12:31rcgRaynes: when you say vim.. whats the setup of choice for developping clojure with vim.. already found some tutorials out there but just want another opinion
12:31Raynesrcg: VimClojure. http://dev.clojure.org/display/doc/Getting+Started There is a page for it here.
12:32SergioTapiaRaynes: So how do you know what class offers what? Or how do you see a method signature? Do you just commit them to memory?
12:32rcgRaynes: ah sweet, thanks..
12:32SergioTapiaComing from .NET/Ruby, the main benefit of having autocomplete for me, was seeing what fit where when working on larger projects.
12:33BorkdudeRaynes: class? aaah, it buuurns ;-P
12:33RaynesWell, Clojure has neat tools for finding documentation and such.
12:33Raynes&(doc println)
12:33sexpbot⟹ "([& more]); Same as print followed by (newline)"
12:33Raynes&(find-doc "print")
12:33sexpbot⟹ ------------------------- clojure.contrib.pprint/*code-dispatch* [[object]] The pretty print dispatch function for pretty printing Clojure code. ------------------------- clojure.contrib.pprint/*print-base* nil The base to use for printing integers and rationa... failed to gist: Connection reset
12:33RaynesWell, you see the point.
12:33Raynes(notes that it failed because the gist was too large.
12:34Raynes) ; closes his parentheses.
12:34tufflax:)
12:34SergioTapiaOk, so you have that. I guess I'll have to see it in action
12:35RaynesYou'll find that things are easier to remember in Clojure because of the lack of complexity.
12:35RaynesThings tend to be simple.
12:36SergioTapiaFrom the very small lines of code I've seen I really like the way you can pipeline statements. It feels very similar to Linq in how you can chain results with new actions.
12:36SergioTapiaFeels very very slick.
12:36tufflax"statements", what is that?
12:37Raynestufflax: Be gentle. He has yet to learn our terminology. ;)
12:38SergioTapiaWhat do you call statements in clojure? This is a statement in C#/Ruby: x = 1 + 2;
12:38TimMcSergioTapia: I assume you are referring to how functions can be composed? e.g. ##(first (drop-while (partial < 5) (range 10)))
12:38sexpbot⟹ 0
12:38tufflaxSergioTapia: In clojure there are special operators, macros and functions
12:39TimMcerr, ##(first (drop-while (partial > 5) (range 10)))
12:39sexpbot⟹ 5
12:39SergioTapiaSo statement = function?
12:39SergioTapia"Everything is a first class function" I read somewhere.
12:39tufflaxlet in a s.o., while is a macro, and + is a function
12:39TimMcSergioTapia: A statement changes state. :-)
12:39tufflaxSergioTapia well, there are also special operators and macros, so that's not quite true
12:39BorkdudeSergioTapia: often in C# statements are actually expressions of which you ignore their results
12:40TimMcClojure avoids that in most of the code.
12:40SergioTapiaThere's a lot of wooshing going on in my room right now. I'll read the book and come back to ask any questions I might have. :)
12:40BorkdudeSergioTapia: in Clojure everything is an expression, like (+ 1 2 3) is the expression which evaluates to 6
12:41Borkdude(+ 1 2 3)
12:41clojurebot*suffusion of yellow*
12:41Borkdude#(+ 1 2 3)
12:41Borkdudehow does this work nowadays?
12:41Borkdude&(+ 1 2 3)
12:41sexpbot⟹ 6
12:41tufflax, or &
12:41clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/or
12:42Borkdudethen what is ## for? I saw it used somewhere
12:42tufflaxdunno
12:42Borkdudecan you ask clojurebot for help?
12:42Borkdudeor sexpbot?
12:42mrBlissYou can use ##(+ 1 1) for evaluating expressions in the middle of a sentence.
12:42sexpbot⟹ 2
12:42tufflaxprobably, don't know exactly
12:43tufflaxhow
12:43Borkdudesexpbot help
12:43Borkdude,(help)
12:43clojurebotjava.lang.Exception: Unable to resolve symbol: help in this context
12:43Borkdude;-)
12:48RaynesBorkdude: ##(println "is for embedded code. Unfortunately, you can't ask him for help on this.")
12:48sexpbot⟹ is for embedded code. Unfortunately, you can't ask him for help on this. nil
12:52SergioTapiaSo I find a guide on how to install the CounterClockwise addon and it's pretty awesome. Guess who wrote it?
12:53SergioTapiahttp://dev.clojure.org/display/doc/Getting+Started+with+Eclipse+and+Counterclockwise
12:53SergioTapia:D
12:54RaynesSergioTapia: I didn't write that.
12:54RaynesSergioTapia: Clojure's wiki used to be on Assembla. When they moved to confluence, I moved all of those pages to there, so it has my name on it.
12:55SergioTapiaBummer. Still, I found it. ;)
12:55SergioTapia&(+ 1 2 3)
12:55sexpbot⟹ 6
12:56SergioTapia&(println ("I'm actually built with Java."))
12:56sexpbotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
12:56SergioTapiaNOOOOOOOOOOooooooo
12:56SergioTapiaStill learning. :)
12:56markomanwhat does this mean: clojure.lang.IFn?
12:57SergioTapiaI think a IFn is an anonymous function.
12:57Raynesmarkoman: Something that is an IFn. A Clojure function. He wrapped a string in parentheses, so it tried to call the string, but the string isn't a function, so boom.
12:57markomanim getting that error every while and then
12:58SergioTapiaTesting...
12:58SergioTapia&(println "I'm actually built with Java.")
12:58sexpbot⟹ I'm actually built with Java. nil
12:58SergioTapiaWhy did it add nil?
12:59markoman,(println "I'm actually built with Java.")
12:59clojurebotI'm actually built with Java.
12:59RaynesSergioTapia: Because everything in Clojure has to return something. Even if it's only nil. Since println does side-effects and has no meaningful value to return, it returns nil.
12:59RaynesThe text is what println prints and nil is what it returns.
13:00Raynesclojurebot apparently throws away the return value. Not sure why.
13:01SergioTapiaI see.
13:01SergioTapiaOK, I'm out. Be back later on tonight for some Clojure coding and reading. This is really different to anything I've ever used before.
13:01RaynesYour mind. It'll be blown.
13:01RaynesHave fun.
13:01markoman:)
13:02SergioTapiaAlso, worth throwing it out there out of interest. Have any of you guys tried F#? Have you noticed any shortcomings with the language compared to other FP langs such as Clojure and Erlang?
13:02RaynesI played with F# when it first came out. No real opinion on it or OCaml.
13:12BorkdudeI tried F#
13:28ataggartwith the advent of non-dynamically-rebindable vars, are there any naming conventions for them?
13:29TimMcataggart: I would think that the naming conventions are more necessary for rebindable vars.
13:30TimMci.e., vars are assumed to be static most of the time anyway
13:30ataggartTimMc: yes, but we already have those, namely earmuffs, thigns without earmuffs are generally functions. Just wondering if there was a community standard for non-function vars that cannot be rebound
13:30ataggartI'd almost call them constants
13:31ataggartoh well, I'll just omit the earmuffs
13:31pdk`did people really rebind vars that often before anyway
13:31pdk`cause that's just ugly
13:33ataggart*out* gets rebound all the time
13:34seancorfield*db* iin c.c.sql too I believe?
13:35SergioTapiaGuys, do you use Linux? I have a question not really related to Clojure maybe you could help.
13:35SergioTapiaI have a .rar I need to unrar, and I install 7Zip via the software center in Ubuntu 10. However, there is no 7zip context menu when I right click on the file. :S
13:36Vinzenti think you should install unrar
13:36seancorfieldyup, just confirmed *db* for c.c.sql (had to go look in internal.clj)
13:36TimMcSergioTapia: You coudl use Open With, or maybe launch 7zip separately and use File-> OPen.
13:37SergioTapiaHm... Open With > Doesn't show me 7zip anywhere.
13:37SergioTapiaAnd I can't find 7zip in the Applications bar up top.
13:37SergioTapiaAny other suggestions?
13:37seancorfieldsudo locate 7zip
13:37Vinzentataggart, there is +constant+ convention in CL, but cI've never seen it in clojure code
13:37seancorfieldthat should tell you where it's hiding
13:38seancorfield(def +answer+ 42) ;; not sure i like that :(
13:38SergioTapia[sudo] password for papuccino1:
13:38SergioTapia/usr/share/app-install/desktop/7zip.desktop
13:38SergioTapia/usr/share/icons/Humanity/mimes/16/application-7zip.svg
13:38SergioTapia/usr/share/icons/Humanity/mimes/22/application-7zip.svg
13:38SergioTapia/usr/share/icons/Humanity/mimes/24/application-7zip.svg
13:38SergioTapia/usr/share/icons/Humanity/mimes/32/application-7zip.svg
13:38SergioTapia/usr/share/icons/Humanity/mimes/48/application-7zip.svg
13:38SergioTapiapapuccino1@ubuntu:~$
13:38ataggartI'd wait for clojure to have an actual deconst
13:38SergioTapiaWow... it seems to have only located the icons.
13:40SergioTapiaSolved it, thanks. :)
13:42BorkdudeSergioTapia: if you come from .NET, what are you doing in linux? Just wondering.
13:43SergioTapiaI wanted to learn new things, things got kind of stale.
13:43SergioTapiaPlus, Ruby works better in Linux than in Windows.
13:43SergioTapiaSince I like Ruby, I always have an Ubuntu VM on standby.
13:44BorkdudeJust know that you don't have to be in Ubuntu for Clojure, although I installed it once just for Clojure... ;-)
13:44BorkdudeDid you do F# yourself
13:44SergioTapiaYeah I imagine I can use any Linux distro. But Ubuntu is my favorite, second to Linux Mint.
13:44Borkdude?
13:45SergioTapiaYeah I used it for about a month. Nothing I would get payed for though.
13:45TimMcLinux tends to be friendlier for development, in my mind.
13:45SergioTapiaFibonacci numbers and other useless stuff like that.
13:45BorkdudeSergioTapia: I mean, I get by in Windows using emacs now just as good as in linux
13:45SergioTapia@TimMc: Depends on your language.
13:45Borkdudefor clojure
13:45TimMcSergioTapia: Specifically, Windows has *terrible* shell scripting support.
13:46TimMc(Mac = Linux for the purposes of my comments here.)
13:46BorkdudeTimMc: I agree, .bat-file hell ;-)
13:46TimMcAlso, I hate backslashes in paths. :-P
13:47Borkdudeand I needed to download something that did what touch in linux does in Windows, those things make me crazy sometimes
13:47SergioTapia@TimMc: I couldn't agree or not. I've never done shell scripting.
13:47BorkdudeTimMc: windows got powershell nowadays, it makes things a lot better
13:47SergioTapiaI've used Powershell with Active Directory. Fantastic tbqh.
13:47TimMcSergioTapia: It's really important once you get into complicated projects, where you want to do automated deployment testing and the like.
13:48TimMcOh yeah, powershell... forgot about that.
13:48TimMcBorkdude: echo >> foo.txt doesn't work as touch?
13:50SergioTapiaI'm reading Programming Clojure. Pretty sweet book so far.
13:50SergioTapia(defstruct person :first-name :last-name)
13:50SergioTapia Hm... I like succinct code. :D
13:50TimMcSergioTapia: Just watch out for some of the older syntax.
13:50BorkdudeTimMc: when I do that, a foo.txt file gets created with the following content:
13:50BorkdudeTimMc: ECHO is on (aan).
13:51TimMcBorkdude: Ah, weird. Try echo -n "" >> foo.txt
13:51BorkdudeI actually just needed to modify the "modified date" of certain file
13:51Borkdudes
13:51TimMcErr, maybe echo "" /n or whatever.
13:51TimMcBorkdude: >> is append, so that should work.
13:52BorkdudeTimMc: it appends ECHO is on (aan). everytime :)
13:54BorkdudeTimMc: and that would totally mess up my files
13:54BorkdudeTimMc: but I solved it, someone made a touch.exe which does what touch in linux dus
13:54Borkdudedoes
14:00mefesto`Raynes: ping?
14:03amalloymefesto: as it happens i'm poking at tryclojure right now. i might be good enough if he's not around?
14:04mefestoamalloy: oh, i was just going to mention to him that i received a github issue email and wanted to know if it was something i should fix
14:04amalloymefesto: in fact that's what i'm about to push a fix for
14:04mefestoamalloy: ok cool. just adding the css class to the code elements, right?
14:05amalloyright
14:05clojurebotHuh?
14:05mefesto<code class="expr">...</code>
14:05BorkdudeI keep mistyping json as clojure maps...
14:06amalloymefesto: https://github.com/Raynes/tryclojure/pull/16
14:08mefestoamalloy: cool, i can continue with my mindless web surfing then :)
14:08amalloyat least until Raynes pulls and discovers this didn't work
14:18SergioTapiaWhat's the difference between a Map and a Set?
14:19SergioTapiaCan a Set be considered sort of like a C# enum?
14:19SergioTapiaAs in a list of values
14:19amalloyno
14:19amalloynot of C# enums are anything like java enums, anyway
14:19amalloys/of/if
14:19sexpbot<amalloy> not if C# enums are anything like java enums, anyway
14:20hiredmanwell, I mean, the proper why to do enums is sets of keywords
14:20hiredmanbut you don't actually have sets of the keywords
14:21hiredmanjust, this function returns one of these 4 keywords (would could said as "this functions returns one of this set of keywords")
14:21SergioTapiaAre you referring to Clojure: "but you don't actually have sets of the keywords"
14:21amalloySergioTapia: sets are just...sets, from math. a collection of unique values. you can do any collection operations on them, more or less, and they preserve uniqueness
14:22raeka set is a collection that contains values unordered and without duplicates
14:22raek,#{:a :b :c}
14:22clojurebot#{:a :c :b}
14:22SergioTapiaSo it IS like a C# enum. Thanks! :) Just trying to fit things together.
14:22raek,(conj #{:a :b :c} :d)
14:22clojurebot#{:a :c :b :d}
14:22raek,(conj #{:a :b :c} :a)
14:22clojurebot#{:a :c :b}
14:22hiredmanhttp://www.codeproject.com/KB/recipes/sets.aspx
14:22hiredmanpoor guys
14:23SergioTapia> 28 Mar 2004
14:23hsbot Not in scope: data constructor `Mar'
14:23SergioTapia.net 3.5 now has the HashSet class fyi. ;)
14:24hiredmanwell, there you go, that is what a set is
14:24SergioTapiak
14:24hiredmanwho let in hsbot?
14:25raekSergioTapia: I think you are confusing types and values
14:26SergioTapiaAre you familiar with C#? If you're not you probably aren't understand my comparison.
14:27amalloySergioTapia: so stop making comparisons to C#, and instead say something about what a set is
14:27SergioTapiaI asked so I could make some association to something I'm familiar with.
14:28amalloyindeed, and that's great
14:29amalloybut if you ask "is this like a framble" and someone says "i don't know what a framble is, but it behaves like so", your response of "aha, so it's a lot like a framble" leaves us all wondering whether you've missed something
14:30SergioTapiaI don't see where you could get confused. If someone says it does X, and I say, as so it behaves just like Foo. You can safely assume that X indeed behaves like Foo.
14:31amalloywhatever, if you're satisfied
14:31SergioTapiaof course
14:39thorwilso C# hashsets are like frambles, cool.
14:40amalloythorwil: that's explicitly spelled out in the doxygen :)
14:59SergioTapiaHehe. I'm stuck trying to get a working Fibonacci sequencer.
15:00SergioTapiaI was always TERRIBLE with math problems.
15:02midswhat is a framble?
15:05SergioTapiaIt's like a set
15:05amalloyit's a metasyntactic variable :P
15:05hiredmanclojurebot: framble is a macguffin
15:05clojurebotIn Ordnung
15:05hiredmanframble?
15:05clojurebotframble is a macguffin
15:07TimMcSergioTapia: "You can safely assume that X indeed behaves like Foo." <-- I have no idea who you are.... so no, I can't assume that.
15:07SergioTapiaLate to the party
15:07SergioTapia-10 points.
15:08TimMcSergioTapia: Anyway, here's all you need to know: http://clojure.org/data_structures#Data%20Structures-Sets
15:08SergioTapiaAny help? http://stackoverflow.com/questions/5688822/how-can-i-generate-the-fibonacci-sequence-using-clojure
15:08TimMcSergioTapia: Chiding someone for reading the backlog and answering your ill-formed questions: -30 points from Hufflepuff.
15:08amalloy$google fibonacci clojure rosetta
15:08sexpbotFirst out of 46 results is: Fibonacci sequence - Rosetta Code
15:08sexpbothttp://rosettacode.org/wiki/Fibonacci_sequence
15:09amalloySergioTapia: ^ is badass
15:09SergioTapiaClojure 1.2.0
15:09SergioTapiajava.lang.IllegalArgumentException: Wrong number of args (4) passed to: helloworld$fibonacci (helloworld.clj:0)
15:09SergioTapia1:1 user=> #<Namespace src.helloworld>
15:09SergioTapia1:2 src.helloworld=>
15:09SergioTapiaThanks, let me check that out.
15:09amalloySergioTapia: i think you passed the wrong number of arguments
15:10SergioTapiaBut I count two, let me draw some ASCII. :D
15:10SergioTapia(defn fibonacci[a b] (println a b (fibonacci (+ b 1) a + b)))
15:10amalloy*cough* a + b
15:10SergioTapia |----------| |----------|
15:11SergioTapiaugh. Fail. Didn't draw correctly. Anyways, Are you saying a +b does not eval to a single value?
15:11amalloyum no. notice you wrote (+ b 1)?
15:11SergioTapiaYeah, that's 1 parameter, and the 'a+b' should be the second, no?
15:12amalloywhy didn't you write b+1?
15:12SergioTapiaI'm new and Try-Clojure showed me that's how you do it.
15:12SergioTapiaSo this would be the same:
15:12SergioTapia(fibonacci (b + 1) (a + b))
15:12SergioTapia?
15:12amalloyno, it would not be the same, it would actually work
15:12amalloyer
15:12amalloyman
15:13amalloysorry didn't read very well
15:13amalloy&(+ 1 2)
15:13sexpbot⟹ 3
15:13amalloy&(1 + 2)
15:13sexpbotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
15:13amalloyyou see the difference there?
15:14SergioTapiaYes, I see it. What's strange now is that I'm not getting your exception... I'm getting this:
15:14SergioTapiaEOF while reading (helloworld.clj:5)
15:14amalloyunbalanced parens
15:14ssiderisSergioTapia: check your parentheses
15:14SergioTapiaAh NOW I'm getting that correct exception. :)
15:14amalloyssideris: better: use an editor that does that for you :)
15:14SergioTapiaI'm using eclipse, strange that it missed that single parens.
15:15TimMcSergioTapia: I believe you mentioned familiarity with emacs -- I highly recommend paredit mode.
15:15ssiderisamalloy: check your parentheses by using the latest hi-tech parentheses balancing mechanisms :-D
15:16SergioTapiaSold Seperately (tm
15:16SergioTapia*see what I did there?*
15:16ssiderisoh since we're talking about emacs: is there a command that tells it "balance the open statement by adding any parens necessary"?
15:17TimMcssideris: paredit
15:17TimMcand the command is "(" :-P
15:17ssiderisTimMc: I'd rather have emacs do it _afterwards_
15:18amalloyTimMc: that doesn't seem accurate to me. paredit doesn't let you get into that state
15:18SergioTapiaBy the way, what does this line do?
15:18SergioTapia(ns src.helloworld)
15:18ssiderisamalloy: exactly
15:18SergioTapiaIt was added automatically to my clojure project on Eclipse.
15:18TimMcSergioTapia: That declares a namespace for your vars to live in.
15:18amalloyssideris: you can't easily, because once there's a dangling ( it's hard for it to know where the closing ) should go
15:18SergioTapia'ns' meaning Namespace?
15:19TimMcSergioTapia: Exactly.
15:19amalloybut if you don't have paredit on, you can just pound ) yourself until it says "mismatched parenthesis"
15:19hiredmanamalloy: can have issues with [ and {
15:19TimMcSergioTapia: CHeck out the top of this file I'm working on for an example: https://github.com/timmc/CS4300-hw6/blob/master/src/hw6/tracer.clj
15:19amalloysure, it's not perfet
15:20TimMcSergioTapia: http://clojuredocs.org/clojure_core/clojure.core/ns
15:21TimMcamalloy: I discovered last week that typing "]" in paredit will get me to the close of the current statement regardless of whether it is a paren, square, or curly. Pretty convenient, since square bracket doesn't require shift on my keyboard.
15:21amalloyyep
15:21TimMc s/statement/expression/ >_<
15:23SergioTapiaWhat language?
15:23amalloyc#, of course
15:23TimMcimperative
15:24SergioTapia@amalloy: C# is a most EXCELLENT language, as is Ruby. Why don't you like it?
15:24amalloySergioTapia: did i say that? i didn't say that
15:24SergioTapiaImplied it
15:24amalloyi filled in the blanks for TimMc
15:24TimMcincorrectly!
15:24amalloyhaha sorry
15:24amalloythat was the language SergioTapia mentioned though
15:24SergioTapiaLOL, did you mean Ruby then? :P
15:24TimMcSergioTapia: I was referring to the vocabulary of imperative programming.
15:25SergioTapiaoh hahaha.
15:26TimMcOrdering values around and such... it's just not a very nice way to treat them.
15:27SergioTapiaOk, time for some tinkering. Is there a library that allows me to work with JSON in a clojure application?
15:27amalloyclojure.contrib.json, but please consider not using it if your code only needs to work with other clojure code
15:28hiredmanclojurebot: json?
15:28clojurebotTitim gan éirí ort.
15:28hiredmanclojurebot: json is <reply>http://dakrone.github.com/cheshire/
15:28clojurebotIn Ordnung
15:28devn:)
15:29SergioTapiaSince I've used CouchDB in the past and it works with JSON (meaning any language with JSON support can work with it), I wanted to build a small lib that allows clojure apps to easily interact with CouchDB.
15:30amalloyclojure-couchdb exists, though i don't know how good it is
15:30hiredmanSergioTapia: please don't
15:30amalloylol
15:30hiredmanthere are at least 3 such libraries already
15:30devnheh
15:31devnThe Lisp Curse
15:31hiredmanand one of them already has 6th level forks
15:31hiredmana fork of a fork of a fork …
15:31devnso many tines
15:31SergioTapia@hiredman: Why?
15:31devnSergioTapia: because if libraries already exist, improve upon them
15:32amalloyoh my god http://stackoverflow.com/questions/279619/whats-your-favorite-implementation-of-producing-the-fibonacci-sequence/3286056#3286056 is the worst fibonacci implementation ever
15:32hiredmanSergioTapia: because watching you do it will ignore me to great end as you ask for help in the channel and I will end up putting you on /ignore
15:32devnamalloy: on stackoverflow!? surely you jest!
15:32DeranderSergioTapia: lisp programmers are famous for reimplementing functionality over and over, every time solving 80% of the problem
15:32DeranderSergioTapia: you end up with 100 libraries all solving a different 80%
15:32amalloydevn: there's good stuff on SO. and bad stuff too, of course. this is worse than usual
15:33devnamalloy: the lisp curse should be required reading for any new lisp community
15:33TimMcamalloy: THat's amazing.
15:33devnhttp://www.winestockwebdesign.com/Essays/Lisp_Curse.html
15:34amalloyregarding the solution after it, i must say duff's device always makes me want to puke
15:34SergioTapia@hiredman: Well aren't you condescending. What the hell.
15:34devnSergioTapia: see the link i posted above
15:35devnSergioTapia: hiredman has a...way with people...so to speak, but it's hard to disagree with what he's suggesting in this case -- those libraries exist already. improve upon them.
15:35amalloy(inc devn)
15:35sexpbot⟹ 1
15:36devnSergioTapia: if you want to make this community better, that's the RightThingToDo(tm)
15:36Deranderdevn: ™
15:36devn(thank you Derander) :)
15:36Derander;-)
15:37devnSergioTapia: alternatively you might write that library as an exercise and then never put it on github. that would be acceptable, but less helpful.
15:39devnSergioTapia: tl;dr on the link i posted above: Lisp is so powerful everyone is a lone wolf and writes the same library but never /finishes/ them. what happens? people new to the language go poking around for a couchdb library and find 15 of them. they are all half finished. they write their own. the problem continues.
15:39devnthis is /bad/.
15:40TimMcdevn: So, should I not be pushing my ray tracer homework to github?
15:41devnTimMc: please excuse my hyperbole
15:42TimMcI *should* link to cray from my README, though.
15:42devn^^great idea
15:42devn(inc TimMc)
15:42sexpbot⟹ 2
15:43devn(inc amalloy) ;; because he's consistently awesome.
15:43devn(inc amalloy)
15:43Derandertoo bad
15:43sexpbot⟹ 8
15:43tufflax(inc amalloy)
15:43sexpbot⟹ 9
15:43tufflax:P
15:43tufflaxwhere's the highscore? :P
15:43devn(karma amallow)
15:43devn(karma amalloy)
15:43devnhmm
15:44amalloy$karma amalloy
15:44amalloymeh
15:44TimMc&karma amalloy
15:44sexpbotjava.lang.Exception: Unable to resolve symbol: karma in this context
15:44amalloyi think it's broken but i forget why
15:44devnso what's everyone hacking on today?
15:44tufflaxA kompiler for java in java :S
15:44TimMcdevn: http://i.imgur.com/ktXQ7.png <_ ray tracer, duh :-)
15:44tufflaxcompiler*
15:44devntufflax: so you can write java in your java?
15:44tufflaxyes exactly... its homework :P
15:45devn:)
15:45tufflaxbut when im done im gonna have like 12-week break :D
15:45devnworked on this a bit yesterday: https://github.com/levand/clj-soy
15:46devnsee: http://code.google.com/closure/templates/
15:46amalloyi'm looking around on the internet for People who are Wrong, and fixing it
15:46hiredmanwell irc is the place for that
15:46amalloyhiredman: SO is even more so
15:47amalloyso much wrong
15:47devnhello STOP someone on the internet is wrong STOP commenting on how wrong they are STOP
15:48hiredmanSO has collapsed under the weight of People who are Wrong in to a sort of blackhole which just attracts People who are Wrong and unfortunately the cosmic censorship hypothesis doesn't apply
15:49devnHanlon's Razor.
15:49devnNever attribute to malice that which is adequately explained by stupidity.
15:55Vinzentcan you explain me why (reduce entity (fn [e [k v]] (update-in e [k] inc)) entity), where entity is a map, returns last pair but not the map?
15:56amalloyargument order is wrong
15:56amalloyi think
15:56amalloy&(doc reduce)
15:56sexpbot⟹ "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well... http://gist.github.com/923430
15:57amalloythough it's simpler to use into/for than reduce, really: ##(into {} (for [[k v] {:a 1 :b 2]] [k (inc v)]))
15:58amalloy&(into {} (for [[k v] {:a 1 :b 2}] [k (inc v)]))
15:58sexpbot⟹ {:a 2, :b 3}
15:59devnamalloy: if you want to coordinate on tidying up after the People who are Wrong, ping me links and I'll hit them
16:00devnas in, go to the link and correct the error, not physically hit the person
16:00amalloydevn: just let me know when you perfect the cross-internet electrotherapy device
16:00Vinzentamalloy, OMG. Thank you, it's args order. You know, i was sitting about a half hour and can't understand what's wrong with my code %) Working at night is a bad idea
16:00devnamalloy: if you use twitter at all, the PlanetClojure bot records clojure questions
16:00devn(from SO)
16:00amalloydevn: i know
16:00amalloyi just subscribe to the clojure rss feed though
16:00devnk just thought i'd mention it :)
16:02VinzentYes, variant with for is better, thanks again
16:08VinzentOne more question: is it more idiomatic to use scheme-like ->string instead of to-string?
16:09amalloymeh
16:09amalloyi see the latter more often, but i don't know that anyone feels strongly about it
16:11LauJensenamalloy: In the first CQL we use the -> notation, which ended up being a harder read than to/from
16:12LauJensenused*
16:12amalloythere you go, LauJensen feels strongly about it. and he's best in class :)
16:12LauJensenWhat the hell?
16:13Vinzent:) btw, -> notation used in the new record things, isnt it?
16:31amalloyVinzent: i don't think the syntax for that is solidified yet, is it?
16:32LauJensenamalloy: Not sure. I would ask Rich but Im afraid such a demonstration of entitlement would provoke him to cut corporate support for Clojure as well :)
17:00TimMcIt looks like when futures throw exceptions, they don't get printed on the console. Interesting.
17:06raekTimMc: if the task throws an exception, it will be stored in the future object and thrown if it is rereferenced
17:07raekso either you can add a (try ... (catch Throwable e (.printStackTrace e))) or use a "raw" Thread
17:07raekit depends on how/if you want to treat errors automatically in your application
17:08raek*dereferenced
17:11TimMcAha... so if I never deref the future, I never see the exception.
17:11TimMcI really should be using a raw Thread, then.
17:11TimMc(I don't care about the return value.)
17:12markomani have interesting problem with getting data from map
17:13markomani made a paste about it if someone wants to look at it: http://pastebin.com/ahDUgCXc
17:14markomanin practice im not sure how to keep count of previous, current and next values (page ids) and return them when match is found
17:15raekmarkoman: what do you wish the (page-next-prev "page2" pages) call to return?
17:16markoman{:prev pageid :next pageid} where page ids are from args
17:17raekso for the case where page-id is "page2", what would those be? "page1" and "page3"?
17:18raekor "page1" and "section1"?
17:18markomanyes and what if prev next not available, then just nil is good
17:18markomansection or any other unmentioned are not counted at al but passed. im interested only about page type
17:19raekfirst, you can filter out all non-pages (since they are irrelevant here): (filter #(= (:dtype %) :page) coll)
17:20markomanpossible returns would be {:prev nil :next "page2"} {:prev "page1" :next "page3"} {:prev "page2" :next nil}
17:21raekthen you can add a dummy page at each and make a sequence of triples: (partition 3 1 (concat [{}] filtered-coll [{}]))
17:21markomanand maybe {nil nil} if no original page-id found. ok, filter is nice
17:23raekand then choose the first triple where the middle one has the correct id: (first (filter (fn [[_ p _]] (= (get-in p [:args :id]) page-id)) partitioned-coll))
17:24raekand then (let [[prev current next] the-triple] {:prev (get-in prev [:args :id]), :next (get-in next [:args :id])})
17:25raekbut it might be easier to walk through all these triples once an construct a map from ids to ids of previous page and a map from ids to next ids
17:26raekthe format you declare your data in does not have to be the same as the program uses to do its work
17:27markomanhmh... good ideas. sounds rather complicated. i was thinking if I could make a recursive calls and passing values...
17:29markomanyeah, other data has no meaning, just page type and id in agrs
17:29markomanlet me test some
17:33markomanpartition thing is nice too, but not easy to understand apart from result it creates is clear
17:33amalloyraek: fwiw, i like (comp #{page} :dtype) better than #(= (:dtype %) :page)
17:34raekamalloy: agreed :)
17:36markomanwhat is the difference there?
17:40ataggartthe former returns :page or nil, the latter returns true or false
17:44markomanwith keyword corrected it return same map: (comp #{:page} :dtype) so...
17:49markomanupdated paste with current version, that gives right output: http://pastebin.com/g51z9vsx thanks guys, this gives a lot to chew
18:05trmswEvening all :) I need to use ActiveX objects from a clojure application. This is horrid but entirely possible, my problem is that the ActiveX objects involved are reasonably expensive to initialise, are single-threaded, and need to be used on and off throughout the life of my app.
18:06trmswI'd like to have one thread per object and keep the thread going until my application quits, passing requests / messages to it
18:06trmswhow can I do this in Clojure?
18:07amalloywrap them up in agents? you won't get a single thread per object, but i don't htink that's really your goal anyway
18:08trmswyou mean the agent holds a reference to the object and requests are done on the agent?
18:08amalloyyes, something like that
18:09trmswthing is, I really do need to keep the same thread alive
18:09trmswi think. Based on my reading of this: http://danadler.com/jacob/JacobThreading.html
18:13trmswon the other hand this kind of problem is completely against the clojure grain...
18:23amalloytrmsw: well, i'm not inclined to read that whole mess to figure out if you actually need this. but if you do, you should be able to create a future object that loops checking a blocking queue
18:23amalloyand passes the messages along to the activex object it wraps
18:26trmswamalloy: reluctant to wade through the details of obsolete technology? That's very inconsiderate! Thanks, I will look into blocking queues.
18:26amalloy*laugh*
18:31trmswnonetheless I have a soft spot for ActiveX and being able to script office applications, since I have to use them.
18:31trmswOk so that's perhaps a confession too many. Night
18:43markomanhow do you use logical operator in clojure, and or namely?
18:44markoman(= 0 a & b) (= 0 a | b)
18:44raekmarkoman: bit operators?
18:45markomanno, just normal
18:45raek(if (and a b) ...) (if (or a b) ...)
18:46raekbut from the example it looks like you are looking for (= 0 (bit-and a b)) (= 0 (bit-or a b))
18:46raek(doing bitwise logic operations, rather than logic operations on single booleans)
18:47markoman(= 0 (and a b)) (= 0 (or a b)) works too?
18:47markomanseems to work :) thanks
18:47raekbooeans are not integers, so those will always return false
18:48raek(well, assuming that a and b are booleans)
18:49raek,(macroexpand-1 '(and a b))
18:49clojurebot(clojure.core/let [and__3468__auto__ a] (if and__3468__auto__ (clojure.core/and b) and__3468__auto__))
18:49markoman,(= 0 (or 1 0))
18:49clojurebotfalse
18:49raek'and' and 'or' are just syntactic sugar for writing nested ifs
18:50raek1 is neither false nor nil, therefore it counts as true
18:50raekso (or 1 0) short circuits and returns 1
18:51markomanoh, so how do you compare say strings in this case?
18:51markoman,(= "0" (or "1" "0"))
18:51clojurebotfalse
18:51raekwhat do you want to check for? if a string is either value a or b?
18:52markomanyes
18:52raekyou can't write that condition like that
18:52raekyou have to write something like (or (= a 0) (= b 0))
18:53raek(or (= s "foo") (= s "bar"))
18:53mreynoldsraek: Wouldn't case work here?
18:53markomani was figuring, either or outside or inside (=) ...
18:54mreynolds(case s "foo" (...) "bar" (....) (etc)) ?
18:54raekif you simply want to do a certain thing if a value is either a or b, you can also write is as (if (#{a b} x) ...)
18:55raekmreynolds: if you want to do different things when the string is "foo" and "bar", then yes
18:55mreynoldsraek: Ahhh, I got it. So, that statement you wrote, that creates a set and the set acts as a function to test for membership of x?
18:56raekyes
18:56mreynoldsHot damn that's nice
18:56raeksame as (contains? #{a b} x)
18:56markomannow it looks like what I was after
18:57raekmarkoman: or always mean the same thing. it has no special parsing when it occurs in a =
18:57markomani see
19:06amalloymarkoman: if you want to test which of several groups a value falls into, you can do it similarly with condp: ##(condp #(%1 %2) 'a '#{x y} "x or y", '#{a b} "a or b", "none of these")
19:06sexpbot⟹ "a or b"
19:08markomanhmh how did it actually return a or b, not x or y?
19:08amalloy_afkmarkoman: the value it was testing against was 'a
19:09markomanoh yes, there it is
19:09amalloy_afkit tried ##('#{x y} 'a), saw that was nil, then tried ##('#{a b} 'a) and it was true
19:09sexpbot((quote #{y x}) (quote a)) ⟹ nil
19:09sexpbot((quote #{a b}) (quote a)) ⟹ a
19:13markomanyes, nice things. but now my head need to meet a pillow
19:13markoman2am and counting
21:10chrissbxHow again does one look up the definition for the symbol at cursor in the clojure slime?
21:33technomancychrissbx: M-.
21:34technomancyswank-clojure's readme has the goods on that.
21:42chrissbxThanks!
22:18ataggartam i misreading the docs or does compojure muddle the distinction between parts of the url path and the query parameters?