#clojure logs

2012-03-04

16:58qbgI once tried to port condp to my syntax-rules system. Ouch
16:59amalloyhm. i can't tell what part of that dnolen is loud (excited?) about
16:59dnolenheh, nah - it's a micro optimization, but good to know
16:59qbgYeah, that cond clause bugs me too :)
17:02dnolenqbg: always feel free to leave comments on GitHub about things you think are worth improving.
17:02dnolenI'm excited that more folks are digging into how core.logic actually works.
17:03qbgdnolen: Leave comments how?
17:04dnolenqbg: oh darn, I guess you can only comment on commits
17:08bsteuberdid -?> survive the new contrib?
17:08bsteubercan't find it anywhere
17:09scriptoris clj-http the recommended way to make http requests in clojure?
17:09technomancyscriptor: yeah
17:11ibdknoxbsteuber: I think it's in core.incubator
17:12amalloyreally?
17:12bsteubernice, thx
17:13amalloyapparently yes
17:13amalloyugh, and it still has the same bug i tried to fix ages ago
17:14bsteuberamalloy: that would be?
17:15amalloyspecifically if you (refer-clojure :exclude [->]) or other similar things, it doesn't work. it macroexpands to (-> ...) instead of to (clojure.core/-> ...) like it should
17:15technomancyhas anyone gotten kibit to emit any output?
17:15RickInGAIn emacs, I have a file date-operations.clj with ns test-proj.date-operations at the top. In another file in the same directory, I have :use test-proj.date-operations and I get an error when I try and evaluate
17:16technomancyit just says "done." for every project I've tried so far, even some with purposefully-crappy code
17:17scriptorhmm, created a new project with lein new, plugin installed swank-clojure 1.4.0, did M-x clojure-jack-in
17:17pandeiroibdknox: was afk, so you think my probs are all that same issue with aot compilation? do i just need to keep rm -rf class/-ing constantly ?
17:17scriptorbut when I try to compile, it says it's unable to resolve symbol defproject
17:18ibdknoxpandeiro: I sent mail to the list, just set ^{:skip-aot true} on your :main entry. (example in the readme)
17:18scriptoroh, I see
17:19scriptorcan't do C-c C-k from project.clj
17:19pandeiroibdknox: cool, that's not too painful
17:19ibdknoxeh, I'm not happy about it
17:19pandeiroibdknox: you don't like the env variable solution?
17:19ibdknoxbut once the lein-newnew template exists for cljs projects it won't matter
17:19pandeiroof just having a $CLOJURESCRIPT_HOME?
17:19ibdknoxoh definitely not
17:20ibdknoxit's completely unacceptable to require people to download a repo of CLJS
17:20pandeirok, i withdraw that suggestion then
17:20pandeiroscrub the logs please
17:20ibdknoxmoreover that won't work in tons of hosted scenarios
17:20ibdknoxlol
17:20pandeirook
17:20ibdknoxit's fine for alpha stuff
17:20brehauti had a crack at integrating cljs into a python web workflow on the weekend
17:20ibdknoxbut long term, we need something better :)
17:20ibdknoxbrehaut: oh?
17:20brehautibdknox: moderate success
17:20pandeiroright, i also thought it's more economical just having the canonical repo in one place
17:21brehauti think i could get a polished demo going
17:21Bronsaamalloy: wouldn't be enough to substitute ~'~non-safe-name with ~non-safe-name to fix it? (here https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj#L25)
17:21pandeirobut i see that's impractical when you're talking about deployment and stuff
17:21brehautbut having to call cljsc is painful
17:21pandeiroibdknox: can you elaborate on the lein-newnew thing? is that something i can get already?
17:22ibdknoxpandeiro: it allows you easily create templates. It will replace lein-noir once lein 2 comes out
17:22pandeirobrehaut: when i was trying to use cljs for couchapps, i was using chris' cljs-watch tool, which is simple and awesome imo
17:23pandeirocljs-watch used $CLOJURESCRIPT_HOME, didn't it? i guess those were the early days
17:23ibdknoxpandeiro: it was before you *could* package the compiler in a jar
17:23ibdknoxI think I was the first to try
17:23ibdknoxit was a mess though
17:23brehautpandeiro: sure; theres external solutions that could be applied, but it makes it awkward to integrate with python tools (due to pythons piss poor build tool situation)
17:24pandeiroyeah but it worked :)
17:24ibdknoxbrehaut: noir.cljs.watcher might be useful
17:24ibdknoxbrehaut: you could probably package that into an uberjar and use it as a standalone build tool
17:24pandeirobrehaut: ah i see, i just went did building with bash and e-lisp, very ducttape style tho for sure
17:24Raynesibdknox, pandeiro: It's compatible with Lein 1.x too.
17:24ibdknoxyeah, I didn't mention that
17:25brehautibdknox: yeah, i think i need to look at something like that if i want to give this a real crack. if i can work out how to get hte webassets library to allow me to fire up a background process
17:26technomancyibdknox: yeah, no need to wait
17:27ibdknoxtechnomancy: but I liked only having 4 steps in my getting started thing :p I could probably add lein-newnew as a dep to my templates, but something about that seems bad to me
17:27technomancywell it'll only be another week before lein2 preview is out
17:27technomancyit's just a question of whether you want that to be a prereq
17:28technomancy"oh, by the way for all you OLD TIMERS who aren't already on lein2, here's a plugin install command to get you up to speed"
17:29ibdknoxyep
17:29ibdknoxthat's what I was planning on
17:29ibdknox:)
17:38tylergilliesi have a list consisting of some values e.g. (3 1 1/3) and i would like to iterate over the list, with a function and use the result of that function on the next item inthe list, keeping the same amount of elements in the new list
17:39tylergilliesi tried redce, but it just gave me one value
17:39tylergilliesinstead of 3
17:39amalloyreductions
17:39tylergilliesreductions as in reduce function?
17:40amalloy&(doc reductions)
17:40qbg,(doc reductions)
17:40lazybot⇒ "([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
17:40clojurebot"([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
17:40tylergilliesamalloy: thnx
17:41tylergilliestheres so many functions to learn heh
17:41qbgAt least they are there
17:41tylergilliesgod point
17:41tylergilliesgood
17:42tylergilliesah, that works nicely
17:42tylergilliesawesome
17:42tylergilliesthnx again
17:45scriptorwhat's the idiomatic way to reduce over a hashmap? Or should I use something else?
17:46pandeiroException in thread "main" java.lang.RuntimeException: Unable to resolve symbol: re\|
17:46pandeiromove-aot in this context, compiling:(noir/cljs/watcher.clj:104)
17:46pandeiroibdknox: ^ :(
17:46scriptorI'm just using the hashmap as a way to build a query string out of param-name->value associations
17:46qbgscriptor: reduce sounds good
17:46pandeiroi just cant win w/ cljs today
17:46TimMcscriptor: Maybe you should map and then join
17:46ibdknoxpandeiro: hm?
17:47y3didoes clojurescript suffer from the same spaghetti problems that js has when the js code doesn't have a framework like backbone helping it out. Or is clojurescript different because it's essentially clojure, and what works to structure clojure code will work with cljs code
17:47pandeiroupgraded to 0.2.1, added the :skip-aot tag, and now i get that error when i do lein run
17:47ibdknoxoh
17:47ibdknoxthat's my fault
17:47ibdknoxjust a sec
17:47scriptorTimMc: map and join should do it
17:47qbg&(apply str (map (fn [[k v]] (str k "=" v)) {"a" 1, "b" 2}))
17:47lazybot⇒ "a=1b=2"
17:47TimMcscriptor: That means you don't have to worry about boundary conditions either.
17:48TimMcqbg: *cough* URL-encoding *cough*
17:48qbg&(apply str (interpose "&" (map (fn [[k v]] (str k "=" v)) {"a" 1, "b" 2})))
17:48lazybot⇒ "a=1&b=2"
17:48qbgYeah, you'll obviously need to encode it
17:48TimMcqbg: clojure.string/join, not apply str interpose
17:48ibdknoxpandeiro: 0.2.2 lol
17:48ibdknoxy3di: yes. ;)
17:49scriptorqbg: yep, I'm guessing http-get will encode it for me
17:49scriptorer, *clj-http
17:49ibdknoxy3di: much like in Clojure the organization is left up to you, so how good/bad it is ends up primarily being driven by experience I think
17:49qbgreduce would be bad here because it'll make the computationally complexity bad
17:50qbg(well, if you're joining strings in the reduce that is)
17:53amalloythere's no way clj-http can encode it for you if you've already mashed it into a string. how can it know which & is intended to separate params, and which is part of a param value?
17:54TimMcSpeaking of which, I hope urlencode does UTF-8 encoding by default
17:54qbgI hope it doesn't use URLEncoder
17:55scriptortrue, amalloy
17:56amalloybesides, this function has been written a thousand times. why not find an existing implementation?
17:56pandeiroibdknox: works! still find it weird it spits out the .cljs files to the output dir though... the compiler never did that before... does it do it on yours too?
17:57ibdknoxyeah it does
17:57tylergilliesis there a function that returns a vector from a given list?
17:57ibdknox,(doc vec)
17:57clojurebot"([coll]); Creates a new vector containing the contents of coll."
17:58tylergilliesibdknox: thanks
17:58tylergilliesi was doing ,(doc vector)
17:58tylergilliesthat didn't work
18:00scriptordoing (vector a) is basically the same as [a], it creates a vector containing the argument
18:05scriptorwhat's wrong with URLEncode? I've found one using that and another snippet that uses Ring's url-encode
18:06qbgIt encodes spaces as + for one thing
18:06weavejesterscriptor: Ring's url-encode is currently just a wrapper around URLEncoder/encode
18:07scriptorah
18:07scriptorand doh, clj-http has a built-in way to let you pass a hash of query params
18:07weavejesterscriptor: However, in 1.1 I'm going to fix the "+" issue so that the Ring url-encode is technically correct.
18:07Raynesscriptor: And form params too.
18:07weavejesterscriptor: The Java URLEncoder doesn't strictly follow the spec. It's more a "form-urlencoded" encoder.
18:08scriptorweavejester: cool, is the "+" issue the only problem with it?
18:08weavejesterscriptor: I believe so.
18:11weavejesterCan anyone think of a good name for a function that acts like assoc, but creates an list or vector of values if the key already exists?
18:11weavejestere.g. (assoc-foo {} :a 1) => {:a 1}
18:12weavejester(assoc-foo {:a 1} :a 1) => {:a [1 1]}
18:12weavejesterNaming things is often the hardest part :(
18:13weavejesterMaybe… "assoc+" ?
18:13qbgassoc-conj?
18:13qbgThough that would imply it was already a collection inside
18:13weavejesterqbg: Yeah
18:13weavejesterassonj...
18:13weavejester:)
18:14scriptorassoc-conj-on-dup-key
18:14scriptor:p
18:14weavejesterscriptor: Accurate, but a little long :)
18:14brehautthere are only two hard problems in computer science: cache invalidation, naming things and off by one errors
18:14qbg(unnamed-function 23)
18:14weavejesterI think I might go with "assoc+"...
18:15AimHerebrehaut > I see what you did there
18:15brehautmisquoted someone without attribution?>
18:15scriptorweavejester: I'm not sure, I feel like someone who didn't know what it did might assume assoc+ literally +'d on duplicate keys
18:15pandeiroibdknox: playing around with watchtower found a typo in the readme - example is showing the watcher macro, not watch fn... just fyi
18:16weavejesterscriptor: I'm hoping that "assoc+" would be sufficiently unusual syntax for users to check the docs quick :)
18:16scriptorheh, fair enough
18:17AimHerebrehaut> the original quote didn't have the 'off by one error' either
18:18brehautAimHere: theres a common joke version of it that does have it added; that wasnt original humour on the part of me
18:19AimHereHeh, well I think I'll attempt the 'off by one error' gag in every list of things wrong in computing/mathematics from now on
18:19ibdknoxpandeiro: good catch :) Fixed.
18:21ibdknoxweavejester: is that just an alias for (update-in x [:a] conj 1)?
18:22ibdknoxI guess if you always want it to be a vector it's a bit more than that
18:24scriptorhmm, I'm doing (:require [clj-http.client :as client]), but I'm still getting 'get already refeers to #'clj-http.client/get in namespace: my-proj.core
18:29ibdknoxscriptor: you'll have to restart swank/the repl/whatever you're using
18:29ibdknoxor unmap it
18:29ibdknoxprobably easier just to restart
18:32weavejester&(update-in {} [:a] conj 1)
18:32lazybot⇒ {:a (1)}
18:32weavejesteribdknox: Apparently not
18:33weavejesteribdknox: It's for cases like headers and parameters where you sometimes have multiple values to a key, but most of the time it's just one value to a key.
18:33ibdknoxah, I missed that it's only supposed to be a coll in the > 1 case
18:59pandeiroibdknox: thinking about it, since noir-cljs outputs to one mega-file, is there any real reason for :output-dir to place files in resources/public/cljs/? when deploying one would probably just delete all its subdirectories leaving just bootstrap.js anyway, right? any thoughts?
19:00ibdknoxpandeiro: I personally prefer to have things together, but you can pass any options you want for either of those
19:31daakuis swank.cdt the best debugger option for emacs, or is there something better?
20:00francislshould "lein clojurescript watch" works on OSX or is it still in development?
20:06FrozenlockOk I'm stuck in a java-to-clojure problem again... how would that translate in clojure?
20:06Frozenlocksend(d, new CreateObjectRequest(ObjectType.analogInput, new SequenceOf<PropertyValue>(values)));
20:11brehautFrozenlock: start at the inner most expressions and work outward
20:11TimMcFrozenlock: First off, ignore the <generics>.
20:12TimMcFrozenlock: http://clojure.org/java_interop
20:12brehautFrozenlock: you have constructors and a class property, it shouldnt be too hard
20:12brehautFrozenlock: and as timmc said, you can ignore the generics annotation; generics are elided by the java compiler and dont actually exist at runtime
20:13FrozenlockGiven "test" as the value, I have (CreateObjectRequest. ObjectType/analogInput (SequenceOf. test))) for the inner part
20:13TimMclooks good
20:14FrozenlockTimMc: http://clojure.org/java_interop I looked at it for the better part of last hour, and still can't get how I can insert "send" in all of this.
20:14TimMcAh, how to call a method?
20:14FrozenlockThe "->" macro?
20:14TimMc-> just rearranges code
20:14TimMcFrozenlock: What is "send"?
20:15FrozenlockA method, as you said
20:16TimMcon what object?
20:16Frozenlockd
20:17TimMcI doubt that... unless it is d.send(...) in the original Java code
20:18FrozenlockNo it's not. :(
20:19TimMcThen send is a method of something else. What is it a method of?
20:21TimMc(hint: the answer is "this")
20:22mkcan anyone suggest some clojure podcasts/talks? (besides the ones on infoq)
20:23brehautmk: mostlylazy.com
20:23weavejesterDoes Clojure have a syntax for persistent queues, yet?
20:26mkbrehaut: thanks! any ones from there that you suggest?
20:26brehautmk: theres only 4 ;)
20:27TimMc&clojure.lang.PersistentQueue/EMPTY
20:27lazybot⇒ #<PersistentQueue clojure.lang.PersistentQueue@0>
20:27TimMcweavejester: Doesn't look like it ^
20:27mkbrehaut: :) all equal quality?
20:27TimMc,clojure.lang.PersistentQueue/EMPTY
20:27clojurebot#<PersistentQueue clojure.lang.PersistentQueue@0>
20:27weavejester&(clojure-version)
20:27lazybot⇒ "1.3.0"
20:27TimMcclojurebot is on 1.4 beta or whatever
20:27weavejesterHm, oh well. No big deal to write a queue function of my own.
20:29brehautmust be the only datastructure that hasnt got its own literal :P
20:30weavejesterI wonder what would be the best way to make a blocking queue in Clojure
20:31weavejesterMaybe put the queue in an atom in a promise...
20:31brehaut,(java.util.concurrent.LinkedBlockingQueue.)
20:31clojurebot#<LinkedBlockingQueue []>
20:31weavejesterOr that!
20:31brehauttheres also a blocking priority queue too
20:32weavejesterIt looks like you can have a timeout, too.
20:33brehautyeah, its really quite a nice implementation
20:33mkif I have a function that scrapes 10 webpages sequentially, how can I make this parallel in clojure, without making it messy?
20:33brehaut(pmap scrape seq-of-urls)
20:34TimMcHum. Can anyone recommend an RDBMS that, unlike MySQL, support a standalone mode? (DB-in-a-file, good for unit tests.)
20:34TimMcI'm using SQLite, which *only* operatres in standalone mode, but I'd like to find some alternatives.
20:36mkwait, really? that'll just create howevermany threads, but will enter and return from a function as if it were one thread?
20:36brehautmk: i think its backed onto a threadpool ?
20:36mkis there a way to limit the number of threads?
20:36brehautotherwise yes
20:38TimMcmk: Doubt it.
20:39pipelineTimMc: one of the reasons i've been wanting to learn clojure is that sqlkorma looked like such a neat library. why not just use sqlite behind orm for tests, postgres behind orm for real?
20:39brehautmk: i think its limited by the number of cores on the machine
20:39TimMcpipeline: Urgh, good point.
20:39FrozenlockTimMc: I'm lost. With: AcknowledgementService result;
20:39Frozenlockresult = send(d, new CreateObjectRequest(ObjectType.analogInput, new SequenceOf<PropertyValue>(values)));
20:39FrozenlockDo I have enough info to answer the question?
20:40TimMcNope.
20:40pipelineTimMc: or better yet, h-sql behind orm for tests -- then it can all be inside the damn build tree, w/ the db running out of a jar
20:40FrozenlockDamnit
20:40brehautTimMc, pipeline korma lets you generate the SQL without executing it, which is potentially useful for tests
20:40mkhmm. I wanted to use it for scraping, which would be limited by the network. Is there an alternative to pmap that isn't lazy, and where the number of threads can be specified?
20:40TimMcFrozenlock: "send" is some method in the same class as that snippet.
20:41TimMcFrozenlock: or in an ancestor class, I guess
20:41TimMcpipeline: SQLite can do in-memory DBs as well, so that's nice.
20:43TimMcpipeline: Currently I'm just persisting stuff to DB, and doing all the real processing with Clojure functions.
20:43TimMcsqlkorma doesn't gain me much (yet)
20:49TimMcAuxiliary question to the channel: How to inject the use of (e.g.) an in-memory SQLite database for running test code?
20:50Sgeo_How much does being on the JVM hurt Clojure as a language?
20:50qbgSgeo_: You mean from a technical standpoint, or social?
21:01tylergillieshow do i do (if (= foo bar) and (= bim biz))?
21:01TimMcI guess I'll make a db-spec var and (binding ...) it in the tests.
21:01qbgtylergillies: Use and?
21:01tylergilliesqbg: thnx
21:02tylergilliesdidn't know and was a function
21:02qbgIt is a macro
21:02RickInGA(if (and (= foo bar) (= bim biz))
21:03tylergilliesfeels like a steep learning curve heh
21:03qbg(to be precise)
21:03tylergilliesqbg: thats what i meant
21:03TimMctylergillies: It is a macro so that it can shortcut:
21:04TimMc&(and 5 false (throw (RuntimeException. "oops")))
21:04lazybot⇒ false
21:04TimMc&(or false 5 (throw (RuntimeException. "oops"))) ;; likewise
21:04lazybot⇒ 5
21:06RickInGATimMc: thanks for that explanation… I don't have any sense yet for why macros, or when, that was helpful
21:06FrozenlockThere's many "clojure for java programmers" on the web... yet I can't find "java for lisp programmers"
21:06tylergilliesFrozenlock: heh
21:06tylergilliesi wish i had that problem
21:07FrozenlockRather than..?
21:08tylergilliesi don't think there is an implicit "rather than" there
21:09brehautFrozenlock: there really isnt a huge amount of java you need to learn though
21:10brehautFrozenlock: as long as you understand the difference between an object and a class, a method and a function, and what statics are, you are mostly done
21:11FrozenlockSlowly getting there.
21:11FrozenlockSlow-ly
21:11brehautFrozenlock: have you dont any OO programming before?
21:12brehaut(ignoring how broad that umbrella is for the mean time)
21:12FrozenlockNope
21:13TimMcFrozenlock: Basic rundown: In OO, "methods" are functions that run in the context of an object of a specific class.
21:13FrozenlockJust happily hacking my way on Lisp and Emacslisp. Clojure seemed like a nice way to jump on the JVM without touching java. *dramatic music*
21:13TimMcFrozenlock: A class is a type, a collection of methods, and maybe some (probably mutable) data fields.
21:13FrozenlockWell yeah, I get that :P I just don't immediatly see it when looking at java code
21:14TimMc(and there are also static methods, which just run in the context of the class, but not an instance of it.)
21:14brehautfinally there is constructors which are magic and in java are run by the new keyword
21:14brehautbut really are just a special case of functions
21:15tylergilliesive never met anyone with no OO experience, that is very interesting
21:15FrozenlockI feel like the ape in a zoo -_-
21:15RickInGAhehe
21:15brehauttylergillies: ive met heaps; they all practise class oriented programming and call it OO ;)
21:16tylergilliesbrehaut: bwahahahahaha
21:16TimMchaha
21:16RickInGAbrehaut: it took me about 3 years to make that step
21:16brehaut[alan kay pop culture joke here]
21:16Sgeo_Frozenlock, maybe you should learn Smalltalk? Pure OO, and not ... Java.
21:16Sgeo_>.>
21:16Sgeo_Class-oriented OO too
21:17FrozenlockSo to summaries: object.method(class) ?
21:17brehautFrozenlock: nope
21:17Frozenlocksummarize
21:17Sgeo_object.method(argument1, argument2)
21:17brehautFrozenlock: classes are a combination of struct, namespace and factory function
21:17TimMcFrozenlock: object.method(object object, object)...
21:17tylergilliesi do object.method(hash) (in ruby)
21:17tylergilliesbut i guess hash == object
21:17brehautFrozenlock: you can think of a method as a function that has its first argument in a funny place
21:18TimMcFrozenlock: If you see send()... that's this.send()
21:18Sgeo_I guess now is a bad time to mention multi-methods
21:18TimMcYes.
21:18TimMcshush
21:18qbgThe Clojure interop method calls make that clear
21:18Sgeo_Frozenlock, you never touched CLOS?
21:19Sgeo_Although Java OO is less.. than CLOS
21:19Sgeo_>.>
21:21Sgeo_Frozenlock, note that things I say may be non-helpful.
21:21Sgeo_Including that statement.
21:22RickInGAfrozen lock do you have a desire to learn oo?
21:22FrozenlockTimMc: but in my example code, there isn't any this.send(), it's just send floating alone.
21:22qbgThe this. is implicit
21:23FrozenlockRickInGA: If it can help me (not just in java, but everywhere)
21:23TimMcFrozenlock: Any chance that send() is a static method (your snippet would be part of another static method in the same class)
21:24TimMcFrozenlock: Did you get that code from a public website you can link to?
21:26tylergillieswhy is this false?:
21:26tylergillies,(contains? ['tyler] 'tyler)
21:26clojurebotfalse
21:26FrozenlockIt's from the source of mango bacnet4j, I pasted the part I'm currently working on here http://pastebin.com/p4EcWKcA
21:26brehauttylergillies: contains? checks for the existance of a key, not a value
21:26brehaut,(contains? [:tyler] 0)
21:26clojurebottrue
21:26brehaut,(contains? {:tyler :foo} :tyler)
21:26clojurebottrue
21:27tylergilliesi need a function for value
21:27brehaut,(contains? #{:tyler} :typer)
21:27clojurebotfalse
21:27brehaut~contains?
21:27clojurebotCool story bro.
21:27brehaut~contains
21:27clojurebotIt's greek to me.
21:27brehaut~botsmack
21:27clojurebotclojurebot evades successfully!
21:27TimMccontains?
21:27TimMcbah
21:27brehauttylergillies: that requires a linear search of a vector
21:28brehaut,(some :tyler [:a :tyler :b])
21:28clojurebotnil
21:28brehautdamnit
21:28TimMcbrehaut: .contains
21:28TimMc*shrug*
21:28brehautTimMc: yeah that works, but its muddying the issue
21:28TimMcFrozenlock: "public static void test(LocalDevice d)" -- you're inside a static method, so send is another static.
21:28tylergillieslooking for something that does something similar to Array#includes? in ruby
21:29TimMcbrehaut: balderdash
21:29brehautTimMc: its testing value containment on a list or vector is a bit of a code smell; .contains makes it look like it isnt
21:30xeqi,(some #{:tyler} [:a :tyler :b])
21:30clojurebot:tyler
21:30brehautxeqi: thanks
21:31brehauttylergillies: a set of one item is like that is an idiomatic alternative to #(= :tyler %)
21:31tylergillieson http://www.4clojure.com/problem/95 im flattening the arg and returning false if it contains () or false
21:31tylergilliesthat might be a bad idea though
21:32FrozenlockTimMc: ... what are the implications?
21:32RickInGAanyone know how I view/change my class path on a mac?
21:32tylergilliesbrehaut: not sure i understand the last statement
21:33TimMcFrozenlock: Do you have any idea what send actually does? :-/
21:33TimMcIf not, it'll be hard to translate that code.
21:33brehauttylergillies: #(= %1 :a) is s function that takes one argument and returns :a (a truthy value) if its argument is equal to the keyword :a
21:33brehautoh, i lie, it returns true there
21:33brehautwhich is truthy
21:33qbgRickInGA: You set the class path when starting the jvm
21:34brehauttylergillies: #{…} is a set literal. sets are functions of their contents
21:34FrozenlockWell I _hope_ it sends the create-object-request via IP to destination
21:34brehauttylergillies: if a set contains the argument passed to it, it returns that argument
21:34brehaut,(map #{:a} [:a :b :c])
21:34clojurebot(:a nil nil)
21:34brehaut,(map #(= % :a) [:a :b :c]) ;; tylergillies
21:34clojurebot(true false false)
21:35tylergilliesbrehaut: ahhh, interesting thnx. still getting used to the concept of data structures being functions
21:35RickInGAqbg I have a project with 2 clj files. when I try to refer to the code file from the test file I get a class not found error
21:35RickInGAwhich I took to mean that I must not have . in the classpath
21:36qbgRickInGA: Are you using a build tool such as leiningen?
21:36RickInGAI used lein to create the project, now I am editing the files in emacs
21:36FrozenlockTimMc: But I don't know how to use this method in clojure. Is the "implicit" works also in clojure? (. -implicit- (send (arguments)))
21:36RickInGAI just bought this computer yesterday, brand new to mac os
21:36qbgAre you using lein to run the project?
21:37RickInGAI was trying to evaluate an expression in emacs (swank) (ns test-proj.date-operations-spec (:use test-proj.date-operations))
21:39RickInGAHaving two files in the same project know about each other seems pretty trivial, but I don't know anything about mac, so I assume that I need to set something in my environment that I didn't know to set.
21:39tylergillies,(contains? (flatten [1 [2 [3 [4 false nil] nil] nil] nil]) false)
21:39clojurebotfalse
21:39tylergillies....
21:40brehauttylergillies: just a hint: tree problems are frequently best approached recursively
21:40tylergilliesbrehaut: thanks, i haven't done much tree work
21:40TimMcFrozenlock: foo.bar(a1, a2) becomes (.bar foo a1 a2)
21:40tylergilliesor recursion for that matter ;)
21:41brehauttylergillies: the basic structure of your code probably wants to be of the form 'this is a tree if conditions C1 ; Cn are met, and the left node is a tree and the right node is a tree
21:41TimMcFrozenlock: Sorry, misunderstood -- no, there is no implicit "this" in Clojure.
21:42brehaut(except for proxys?)
21:42TimMcnor in static methods, in Java -- inside java.lang.Math, abs() is really Math.abs
21:42TimMcbrehaut: shhh
21:44TimMcbrehaut: That's just macro hax
21:44brehautTimMc: sure, but its still implicit
21:49RickInGAdo I have to build a project for one file in it to see another?
21:49mkwhat's the difference between apply and reduce?
21:50RickInGAmk: there isn't always one
21:50brehautmk: reduce takes a function of two arguments and sequence and recursively applies it, apply takes a function of any number of arguments and a sequence of arguments
21:51RickInGA(apply + [1 2 3]) is 1 + 2 + 3
21:51scriptoralso, the function that reduce uses takes an accumulator and an element from the collectionas those parameters
21:51scriptorand when it's done the accumulator is returned
21:51RickInGA(reduce + [1 2 3]) is ( (1 + 2) + 3)
21:51RickInGAthough maybe it would have been clearer if I used prefix notation :)
21:51scriptorso reduce is actually only similar to apply in very special cases
21:51mkso is apply (+ 1 2 3) while reduce is (+ 1 (+ 2 3))
21:52RickInGAmk: yep
21:52brehautnot quite
21:52brehautreduce is (+ (+ 1 2) 3)
21:52brehautdoesnt matter in this case, but it can do
21:52mkright :)
21:53brehauthaskell has a both left and right reduce's (called folds)
21:53scriptorone is lazy, the other tail recursive
21:54brehautscriptor: im not sure that makes sense
21:54mk(the case in question is 4clojure's #24 - everyone solves it using apply or reduce, while #23 has many sorts of solutions)
21:56brehautmk in this case, apply is used when the function takes varargs
21:57brehaut+ for instance has an optimized internal recursive implementation that is much faster than having to make a bunch of function calls
21:57scriptorbrehaut: hmm, it's been a while since I read up on it
21:58brehautscriptor: im pretty sure haskell has many versions of at least foldl, depending what semantics you want
21:59scriptor+ seems to use reduce1 when dealing with varargs
21:59mkwhich function is like reduce, but in unspecified order to take advantage of multicore?
21:59scriptorsource for anyone interested https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L866
22:01mkthe hell... I've noticed that I'm mistyping question marks as parens, and trying to hit ctrl-enter to send messages on irc
22:02tmciverWhat's the best Clojre lib for scraping a DOM? I've been looking at enlive but it looks like it hasn't been maintained in a while. Any opinions on clojure.data.zip (used to be clojure.contrib.zip-filter)?
22:02brehauttmciver: enlive is pretty solid though
22:02mktmciver: an alternative is to just go with a java library
22:03brehauttmciver: if you are scrapping an HTML dom you dont want to build off an xml lib
22:03brehauttmciver: you want to at least use some sort of tag soup implementation (enlive is built on one; theres also a clj-tagsoup i believe - both wrap the java lib of the same name)
22:04tmciverbrehaut: OK, so I need not be afraid that enlive appears old?
22:04brehautcorrect
22:05tmciverbrehaut: I'll check out clj-tagsoup as well. Thanks.
22:05mkI've been using enlive a bit recently and have found few problems (though I haven't figured out how to make it scrape in parallel)
22:06brehauttmciver: you can always just use enlive to load the doc and then scrap with the xml libs if need be
22:06brehautthe biggest downside for enlive is that its documentation is terse and some things are a little confusing to work out
22:07RickInGAfound my issue…. my files had dashes in them when they should have been underscores. date-operations ns should be in date_operations.clj
22:07tmciverbrehaut: Yeah, I've noticed that. :/
22:08brehauttmciver: if you are just scrapping though, its pretty straight forward
22:08brehautjust working out how to translate the CSS selectors
22:08tmciverbrehaut: I haven't looked too deeply at it yet, but do you know if enlive can also be used to generate generic xml?
22:08mkthere's a reasonable tutorial at https://github.com/swannodette/enlive-tutorial
22:08brehauttmciver: it depends if you need namespaces
22:08brehautif you dont then you are fine
22:08tmciverbrehaut: basically, I'm doing some relatively simple XSLT type of tranformations.
22:08brehautim using it on my site to generate atom frinstance
22:08tmciverno, I shouldn't.
22:09brehautyou should be fine then
22:09tmciverOK. Thanks again.
22:12RickInGAmy emacs is possessed. it keeps evaluating expressions while I type
22:13qbgIt codes for you
22:13qbgLearning at a geometric rate...
22:13RickInGAhaha
22:18ibdknoxwhat should I write about tonight?
22:20scriptorpredictive sexpr generation with modern editors
22:21ibdknoxlol
22:22ibdknoxI did some work on that for C# actually
22:22ibdknoxobviously not sexprs
22:22ibdknoxbut predictive expression completion
22:23scriptorautocomplete?
22:24RickInGAibdknox that was an improvement in vs2010 over 2008?
22:24ibdknoxnever made it anywhere
22:25ibdknoxI actually got pretty far with it, but it's hard to make it work completely generally
22:25ibdknoxscriptor: much smarter than autocomplete as it exists today
22:25tmciveribdknox: I started watching Bret Victor's "Inventing on Principle" video. Totally awesome. I volunteer you to write an emacs mode for Clojure with the behavior of Bret's JS editor.
22:25ibdknoxlol
22:25ibdknoxpfft emacs is no fun :p
22:26tmciverBlasphemer!
22:26ibdknoxtmciver: and actually I kinda did that already :)
22:26scriptoryou're a vim guy?
22:26ibdknoxyeah
22:26scriptorhmm, I use it for everything besides clojure
22:26ibdknoxtmciver: I have an instant compilation mode for cljs now that will poll for changes and pop them up on the screen immediately. So I could do my game demo from vim now :)
22:26tmciveribdknox: you did that already? Where is it? I wants it.
22:27tmciverDamn. Just cljs though, huh?
22:27ibdknoxhttp://github.com/ibdknox/noir-cljs
22:27ibdknoxyeah
22:27ibdknoxthough you could implement it trivially in clojure too
22:27ibdknoxnot sure what context it'd really be that useful in though
22:27tmciverHmm, sounds like yet another Clojure project that's over my head. I'll do it!
22:28ibdknoxhaha
22:28ibdknox:)
22:33daakui implemented some watching & reloading logic for use in the repl (requires java 7): https://github.com/nshah/auto-reload.clj
22:33ibdknoxdaaku: why does it require 7?
22:33daakuibdknox: uses the java 7 watching libraries
22:33ibdknoxoh
22:33daakui mean, watching files
22:33ibdknoxhttp://github.com/ibdknox/watchtower makes that simple :)
22:35daakuibdknox: cool, didn't know about that. would be cool to make watchtower use the the nio watching logic instead of polling if available
22:36ibdknoxwhen 7 gets some marketshare, absolutely
22:41technomancygraceful degradation can't be too hard
22:43qbgCheck for the existence of the appropriate classes at compile time and generate the needed code
22:46tylergilliesis there a way to call the current anonymous function without 'recur'?
22:47qbgIf you use fn you can give it a name
22:47technomancythere's the Y combinator
22:47qbg&((fn foo [] foo))
22:47lazybot⇒ #<sandbox6997$eval9948$foo__9949 sandbox6997$eval9948$foo__9949@123bb0>
22:47tylergilliesy combinator is intimidating
22:47technomancythat's true. and not terribly useful
22:48tylergilliesqbg: thnx
23:06tylergilliesany hints on how i can do https://refheap.com/paste/927 without any "catch" 4clojure doesn't like it: http://www.4clojure.com/problem/95
23:08RickInGAtylergilles: would if-let work for that one?
23:10jodaroaww man, one day tickets for clojure west announced like two days after i register for both days
23:10tmcivertylergillies: perhaps you could utilize the 'not-found' behavior of nth so that it doesn't throw.
23:10tmciver,(doc nth)
23:10clojurebot"([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."
23:11tmciverjodaro: that's how they get ya.
23:11jodaroi've been got, for sure
23:11jodarosaturday was iffy for me
23:11tylergilliestmciver: ah thnx, lisp reminds me of lojban where you have to memorize all the function names AND what positions they have heh
23:11jodaroi'm going to see if i can switch
23:13daakui'm trying to speed up some work that involves file io using pmap, which seems to have worked, and along with eliminating some reflection i've gone from 8 to 3 minutes -- now i'm seeing "sun.misc.unsafe.park" taking up roughly as much time as the readBytes on the file and i'm not sure what that is (thread dump here: https://gist.github.com/7e1b19809fc020b6ed18)
23:13tmcivertylergillies: huh, I'd never heard of lojban before. Interesting.
23:14daakuis this indicative of pmap's threads being expensive, and indicating that i should chunk + map + pmap to reduce that cost?
23:41tylergilliesany hints on how i can refactor this? https://refheap.com/paste/928
23:54tylergillieseverytime i see the bot say 'recently...' i think of a tv show. "Previously on clojure: 'omg jenny you're such a lazy list'"