#clojure logs

2011-07-25

01:18HavvyHow do you get a random element out of a set?
01:31technomancyHavvy: (rand-nth (vec myset)) might be best
01:35HavvyYeah, I ended up going with that...is there a reason sets don't come with an assoc and rand-nth by itself?
01:37technomancyassoc takes three args, so it doesn't make sense for sets. I would argue that dissoc should work on sets instead of making folks use disj, but I can see the argument for parallels.
01:37technomancyrand-nth doesn't work because nth doesn't work
01:37technomancynth doesn't work because it's not ordered.
01:38HavvyI meant the functionality more than the individual function names;
01:40technomancyrand-nth relies on nth working
01:41HavvySo there is nothing more efficient for sets than (conj (disj set old-val) new-val)?
01:41technomancythat's just how it's implemented
01:41Havvytechnomancy: Yeah, it's a seq function.
01:46technomancyI imagine any kind of random-chooser on sets would have to do the moral equivalent of converting it to a vector first anyway
01:47HavvyEh, true.
01:48hiredmanwell, the set sits on some kind of tree structure, a random walk of that structure would get you a random item
01:55technomancymaybe so
03:03neotykMorning everyone!
03:14dbushenkohi all!
03:22bobnormalnot exactly a throbbing hub of intellectual exchange, is it
03:23tufflaxthis? it is! not just right now :)
03:25tufflaxs/not just/just not/
03:25lazybot<tufflax> this? it is! just not right now :)
03:26tufflax:P
03:34ibdknoxhey guys, for those of you doing webdev. I just released the 1.1.0 version of noir with a full set of concept docs
03:34ibdknoxnew docs here: http://www.webnoir.org/tutorials
03:36arimannice design
03:48hanDerPederibdknox: Congrats! looks really interesting
03:48ibdknoxty ty
03:49ibdknoxnow that that's out, I can start coming up with my client side framework in cljs ;)
03:49ibdknoxit'd be pretty cool to have a completely integrated webstack like that
03:51dbushenkodoes it support heroku?
03:54hanDerPederhttp://thecomputersarewinning.com/post/clojure-heroku-noir-mongo
03:56ibdknoxit should work pretty much anywhere
03:56ibdknoxelastic beanstalk
03:56ibdknoxheroku
03:56ibdknoxanything with java on it
04:25ejacksonHappy Monday folks.
04:30Fossioh yeah
04:30Fossifinally
04:30Fossiwaited all weekend
04:34ejacksonYes now I get to put down Clojure and pick up Matlab.
04:40maaclHas anyone been able to get the Convex Hull ClojureScript demo (http://bit.ly/qP8alt) to work? I just get two empty text boxes.
04:48ibdknoxworks fine for me in chrome
06:13liquidproofhello guys, what would be the best way to execute a function periodically, say, every 30 seconds or so?
06:15ejacksonput it in a future, with a (do (my-function) (thread/sleep 30000)) might work.
06:15ejacksonjust make sure you keep a handle on the future so you can cancel it
06:15liquidproofalright, i'll take a look
06:15liquidproofthanks
06:16ejacksonyou'll also want to use a ref type to store any output
06:16liquidproofwhy ref?
06:16liquidproofwhy not, say, agent?
06:16ejacksonsorry, i meant any reference type
06:16ejacksonbeing lazy
06:16liquidproofhaha, np
06:34voltonHi, why is that a legal expression?
06:34volton,(Integer/MAX_VALUE)
06:34clojurebot2147483647
06:37ejacksonbecause MAX_VALUE is a static in the Integer class
06:38voltonSo it behaves both like function and like a constant?
06:39ejacksonah, I missed the ()
06:39teromClassname/staticfield expands to (. Classname staticfield)
06:55Pisketti ~
06:57scottjHow come the clojurescript repl dies on any error and is there an option to disable that?
08:19voltonAs a beginner I find that quite confusing because Integer/MAX_VALUE behaves like nothing I have seen in Lisp before
08:21opqdonuthow?
08:21voltonwell (Integer/MAX_VALUE) indicates that it si a function
08:22voltonand this behaves like a constant:
08:22volton,Integer/MAX_VALUE
08:22clojurebot2147483647
08:22voltonam I missing something?
08:23opqdonutfields and methods can look the same in clojure
08:23opqdonutit's really just a convenience
08:23voltonokay
08:23opqdonutweirdly the (Classname/staticField) case is not listed on http://clojure.org/java_interop
08:24cemerickIt's definitely not idiomatic.
08:25cemerickvolton: this may help you:
08:26cemerick&(macroexpand '(Integer/MAX_VALUE))
08:26lazybot⇒ (. Integer MAX_VALUE)
08:26voltonoh thanks
08:26cemerickThe actual operator is `.`, the interop special form.
08:27cemerickI suspect the fact that (Integer/MAX_VALUE) and Integer/MAX_VALUE might just be vestigial.
08:27cemerickthe fact that they are the same, that is
08:27terom(Classname/staticField) and (Classname/staticMethod) are indistinguishable, both expand to (. Classname ...)
08:28terom(the latter being a static method with no arguments)
08:28cemerickright; I forget which "wins" in such cases
08:29teromSo it's kind of coincidence that (Classname/staticField) works and you should not use it.
08:30voltonIn fact I find it quite discomforting that it works
08:32voltonIn "The Joy of Clojure" they first use (+ Integer/MAX_VALUE Integer/MAX_VALUE)
08:32voltonAnd then they use (unchecked-add (Integer/MAX_VALUE) (Integer/MAX_VALUE))
08:33voltonThat's what got me confused
08:34teromThat's a little confusing yes... since (unchecked-add Integer/MAX_VALUE Integer/MAX_VALUE) works as well...
08:36voltonindeed
08:49teromhttp://joyofclojure.com/errata/ does not list that, maybe one could add a comment there.
09:10arimani have table with many dynamic records (they are creating by (map)) and i want to create additional column with incrementing value. How can i do incrementing value?
09:11arimanhttp://paste.org.ru/?5p3y42 code.
09:25ffaillaariman: would map-indexed work?
09:27arimanffailla yes, i'm working at it.
09:28ariman*on, sure
09:31wjlroeAnyone know why with the latest swank-clojure + slime + slime-repl emacs packages installed, I get no repl when I do a `slime-connect` ?
09:32arimansolved.
09:32scottjwjlroe: are you installing swank-clojure out of elpa?
09:32wjlroescottj: yeah
09:32scottjI don't think you're supposed to, I think you should be running swank from lein
09:33wjlroescottj: well I'm running `lein swank` on the cmd lie
09:33wjlroes/lie/line
09:33lazybot<wjlroe> scottj: well I'm running `lein swank` on the cmd line
09:33scottjwjlroe: in that case I don't know
09:34scottjis your swank in lein up-to-date?
09:34wjlroescottj: I'll check...
09:41tufflaxHow do I use a gen-class from another clojure file/namespace? I required it but (new gen-class-name) does not work.
09:42arimanis there function for checking is number even or not?
09:42tufflaxeven?
09:42raektufflax: you need to import it just like a java class
09:42tufflaxok hm, i saw some examples using require, but ok...
09:42raekalso you need to AOT compile the namespace
09:43tufflaxok
09:44arimanok, im just developed it :)
09:44raekimport does only introduce a shorthand name for the class, so you can use the full name instead if you want to
09:44arimansuch a complicated case
09:44raek,even?
09:44clojurebot#<core$even_QMARK_ clojure.core$even_QMARK_@e3990b>
10:00tufflaxWhat does "namespace my-ns not found after loading my_ns" mean?
10:01ejacksontufflax: probably that you misnamed your namespace
10:02ejacksonif you story the file as my_ns.clj it must be namespace my-ns
10:02ejacksonnote the _ and -, Java gets persnickety about that
10:02tufflaxlet me see...
10:03arimanhow can i do some list like http://paste.org.ru/?s9j7ph ?
10:04lnostdal-laptop..perhaps it's just random, but any reason why await doesn't return the agent? .. NIL seems like a useless return value
10:04tufflaxwell it says "namespace game.user_interface not found after loading /game/user_interface" like it expects it to have the name game.user_interface
10:04lnostdal-laptopoh, it can take several agents ...hm
10:05lnostdal-laptop..and await1 was what i was looking for ....... :)
10:06raektufflax: sounds like you have a typo in the ns form
10:06raekthe namespace name and the file name have to match
10:07tufflaxthey do, but the ns has - where the filename has _
10:08ejacksonthat is as it should be
10:08raekhrm, but why does it say "namespace game.user_interface"? I would expect "namespace game.user-interface"
10:09tufflaxyes i find that strange too
10:09raekand this happens when you do (require 'game.user-interface) ?
10:10tufflax(:require (game [user-interface :as ui])) in another ns
10:11raektry removing any fiels in the classes/ directory
10:11raek*files
10:12tufflaxwas just about to, let's see
10:14tufflaxok now I get "namespace game.user-interface not found after loading /game/user_interface" the underscore turned into a dash...
10:15raekand in src/game/user_interface.clj you have (ns game.user-interface ...)?
10:16tufflaxoh now it works, i changed the name when trying different things
10:16tufflaxthank you
10:16tufflaxso the old class file was the problem
10:53ejacksontufflax: aaaah, interesting.
11:10theignoratiI want to create a function that accepts one or more parameters, and uses them as parameters for an overloaded method on a java object that accepts 1, 3 or 4 parameters, how would I do that?
11:12raektheignorati: (defn foo ([x a] (.foo x a)) ([x a b c] (.foo x a b c)) ([x a b c d] (.foo x a b c d)))
11:13raekthe methods are separate methods even though they have the same name
11:13theignoratiok I thought I was going to have to do something with [&
11:13theignoratithanks
11:14raekalso, vadiadic functions in java correspond to functions taking an array as the last argument on the JVM level
11:16raekso to call "Object bar(Object x, Object... y)" you need to do (.bar x (into-array y))
11:16raek* (.bar the-object x (into-array y))
11:17raektheignorati: so for that method you would define a function like this (defn bar [x y & args] (.bar x y (into-array args)))
11:19theignoraticheers :)
11:19theignoratidont think I've ever used a variadic function in java
11:19gtrakif I compile clojurescript from clojure, will it be exposed to google's closure library, or would I need to include that in my html?
11:21raekI think if you use the advanced mode, all your code including the libraries will become a single file
11:22gtrakah, neat, can I store that JS string in a map somewhere? If I'm in a WAR file, I don't think I can have files
11:24raekyou should be able to serve static files (e.g. your script) with servlet containers
11:24raekmaybe not with jetty they way you launch it from clojure when doing development
11:28gtrakif I could keep the compiler running and just cache everything in memory, it shouldn't be too bad, it won't scale to a site with lots of pages for sure
11:39wjlroeSlime+Emacs+Clojure is just not working for me now. Any way I try. If I do "lein swank" and connect from emacs "slime-connect" it error with http://pastebin.com/4RvZa0JQ (slime-clj is installed from ELPA). If I try "clojure-jack-in" from emacs, I just get an error that lein is not found (and I don't know how to configure the path for the bash process emacs spawns to run that...).
11:40raekslime-clj/swank-clj are new libraries that should not be confused with slime/swank-clojure
11:41wjlroeraek: is there a guide for using slime-clj/swank-clj ?
11:41wjlroeI've tried everything I can find and it's all broken
11:41raekif you want to use clojure-jack-in, then the latter is what you want to use
11:41wjlroeThis all used to work, but today it's all broken
11:41raekI have never used the -clj ones
11:41hugodswank-clj is now ritz, to try and reduce the confusion
11:42raekoh, great
11:42wjlroeslime/swank-clojure is what I've been using for ages - starting swank from leiningen. But today that's just not working at all
11:42raekwjlroe: maybe having the -clj ones at the same time is causing a conflict?
11:42hugodwjlroe: remove slime-clj
11:42wjlroeraek: hugod: ok I'll try that
11:43raekhugod: you are the author of the -clj libs, right?
11:43hugodyep
11:43raekwjlroe: you probably want to avoid the swank-clojure *elisp* package too
11:43hugodraek: well, ritz started as a refactored swank-clojure
11:44raekand remove any slime versions installed through the package manager of your OS
11:44wjlroeraek: there are none - OS X
11:45raekokay, just checking :) I've seen lots of people installed the slime debian package
11:45raeka common source of conflicts
11:45wjlroesure
11:46raekwjlroe: this is a good tutorial: http://technomancy.us/149
11:46raekalso make sure you don't have multiple versions of swank-clojure on the classpath at the same time
11:46wjlroeraek: I think it's working! It must have been the clusterfuck of all the different clj libraries in emacs that messed it up
11:46raeke.g. one from :dev-dependencies and installed as a plugin
11:46wjlroeNo offense to the -clj libraries intended
11:56wjlroewith paredit, how do you fix mismatched parenthesis? I have [somthing (blah ))] - can't delete that paren
11:57ejacksonwjlroe: cut and paste :P
11:57wjlroeoh :(
11:57wjlroeoh ok
11:57ejacksonwhich, in my experience, generally how i get mismatches in the first place :)
11:57wjlroeI thought you meant edit somewhere else and paste in...
11:57wjlroeok cool
11:57wjlroethanks
11:58ejacksonoh no, just cut out the offender.
11:58Scriptorwjlroe: I like to keep this handy when using paredit: http://www.emacswiki.org/emacs/PareditCheatsheet
11:58wjlroeScriptor: yeah was checking that out
11:59Scriptorhmm, but I guess that won't help with parens that are already mismatched
11:59wjlroeyeah - highlight and C-w does it
12:02tufflaxCan I give a name to the class that I'm creating an instance of with proxy? :p
12:03chousertufflax: nope, sorry
12:04chousertufflax: you can discover its name at runtime if you'd like.
12:18dbushenkois there a way to define a private mutable java field with clojure?
12:18dbushenkowithout refs, etc.
12:19arimanis it not ok to compare two strings with "=" ?
12:19dbushenkoe.g. I want to generate a JPA class and need normal mutable fields
12:19ejacksonariman: I should think so.
12:20arimanhm
12:26raekariman: it is ok
12:26chouserdbushenko: deftype can do that
12:26dbushenkochouser: thanks, I'll have a look
12:27arimanraek strange, i don't get a positive result with .equals/=/even compare.
12:28raek,(= "foo" (str "f" "o" "o"))
12:28clojurebottrue
12:28ariman(def ddd [{:abs "a" :b "b"},{:abs "a" :b "b"}]) (defn ch [data toch] (if (= toch (data :abs)) (str toch (data :abs)) "no")) (map ch ddd "a")
12:28ariman,(def ddd [{:abs "a" :b "b"},{:abs "a" :b "b"}]) (defn ch [data toch] (if (= toch (data :abs)) (str toch (data :abs)) "no")) (map ch ddd "a")
12:28clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
12:28arimanomg
12:29arimanbtw this code returns false
12:30hiredman,(seq "a")
12:30clojurebot(\a)
12:30hiredman,(= "a" (seq "a"))
12:30clojurebotfalse
12:30raeklet's see, (map ch ddd "a") is the same as (list (ch (first ddd) "a"))
12:31hiredmanraek: no it isn't
12:31raekso only one element of ddd is processed. is this intentional?
12:31hiredmanyou forgot to call first on "a"
12:31raekright. replace "a" with \a
12:33arimani think it doesn't matters
12:33arimanor not?
12:33arimaneven that it should returns true
12:34hiredmanariman: it does matter you are comparing a string "a" to the character \a
12:34raek(dd {:abs "a" :b "b"} \a) --> (if (= \a "a") (str \a "a") "no") --> "no"
12:35arimanhmm
12:38manutter,(map (fn [a b] [a b]) [1 2] [1])
12:38clojurebot([1 1])
12:39arimansorry guys i don't understand what should i do
12:39pdk(doc dd)
12:40clojurebotIt's greek to me.
12:40manutter,(= "a" ({:abs "a", :b "b"} :abs))
12:40clojurebottrue
12:41manutterariman: one thing you might want to do is (map #(ch % "a") ddd) instead of (map ch ddd "a")
12:41raekariman: in your call (map ch ddd "a") you give map a sequence of maps (called ddd) and a sequence of characters (the characters in the string "a")
12:41manutterwhen you give a map two sequences, it iterates through both sequences one element at a time
12:41raekariman: map takes one item from each collection you give it and calls the function on them
12:42manutter,(map (fn [a b] (str a " and " b)) [1 2 3] "a")
12:42clojurebot("1 and a")
12:43manutter,(map (fn [a b] [a b]) [1 2] "a")
12:43clojurebot([1 \a])
12:43arimanthank you
12:43ariman(map #(ch % "a") ddd) works
12:43raekif you want to call cc with the same "toch" each time, you should do something like what manutter showed you
12:44raekalso, when calling map with an anonymous function, consider for: (for [data ddd] (ch data "a"))
12:44raekespecially if the function has more than one level of parentheses
12:44arimanget it
12:45raekI prefer for because map+fn expressions idnents so ugly when they are large :-)
12:46manutterThe caveat is if you have multiple sequences, for and map behave differently
12:46manutter,(map (fn [a b] [a b]) [1 2] [1 2])
12:46clojurebot([1 1] [2 2])
12:46manutter,(for [a [1 2], b [1 2]] [a b])
12:46clojurebot([1 1] [1 2] [2 1] [2 2])
12:48pdk[12:45] <raek> I prefer for because map+fn expressions idnents so ugly when they are large :-)
12:48pdksounds like a job for some macros :p
12:51tufflaxchouser: ok... I noticed that the name of a proxy I made was "user.proxy$java.lang.Object$0", how stable are they between runs? How much can I rely on them? :p
12:53chousertufflax: IIRC, it's safe to rely on that name as long as these remain unchanged: the class and set of interfaces inherited, and the version of Clojure.
12:53chouserhaving said that, I'd be a little uncomfortable relying on the name being stable from one JVM run to the next. What do you need it for?
12:56amalloypdk: a macro like...for?
12:57tufflaxchouser I'm making a game, and there is this GUI lib that requires me to give the name of a Listener in the XML description of the UI. But then one can provide instances in the java/clojure code and it tries to match the name of the class to the name given in the xml, or something like that, im not totally clear on this :p
12:57amalloyhiredman: "SANBOX DENIED" doesn't have enough Ds
12:58hiredmanDENIED
12:58chousertufflax: yeah, if you actually need the name of the class outside the runtime (like in an xml file) I'd recommend genclass. It's sometimes a pain to set up, but not to bad to use and modify once you've got it working.
12:59amalloychouser, tufflax: or deftype?
12:59pdkyeah
12:59pdkF is for for
12:59pdkand F is for effin amazing
12:59amalloy<3 for
12:59chouseramalloy: ah, good point -- if he doesn't have to inherit from a concrete class.
13:00amalloychouser: do you want a pull request for data.xml, or is it governed by the same jira-based rules as monolithic contrib?
13:09chouseramalloy: same rules, so ticket + patch. ...except there is no data.xml jira project yet
13:09amalloysigh. jira is so soul-crushing
13:09chouseror maybe I can give you commit access to the github repo
13:09chouserI'll ask.
13:09amalloythanks
13:11technomancythe one good thing about jira: it encourages giving more people commit access to work around how annoying it is =)
13:31arimansorry i can't find how i can use multiple conditions in if-else construction
13:31amalloycond
13:32amalloyor i guess you might mean and/or
13:32arimanyep
13:32amalloyyep what
13:32arimanand/or
13:33manutter,(if (and (= 1 1) (> 3 2)) "yes" "no")
13:33clojurebot"yes"
13:33amalloy&(if (and (zero? 0) (zero? 1)) "two different numbers are zero!" "looks okay")
13:33lazybot⇒ "looks okay"
13:33manutter,(if (or (false? 0) (false? nil)) "At least one is true")
13:33clojurebotnil
13:34arimanah, i completely forgot about notation, thx
13:35manutter(if (or (and (sequential []) (or (and (nil? x) (pos? 4) (or ... ah, ferget it
13:36amalloy&(if (every? zero? (repeatedly 3 #(rand-int 2))) "Three in a row!")
13:36lazybot⇒ nil
13:57hiredmanclojurebot: ping?
14:08jcromartieyou killed clojurebot! you bastard!
14:11amalloy~guards
14:11clojurebotSEIZE HIM!
14:11amalloy:(
14:11amalloyoh it worked
14:11amalloyhaha i was all set to mourn
14:11jcromartiehah
14:11jcromartieclojurebot: ping?
14:11clojurebotPONG!
14:11jcromartieI see
14:11amalloymaybe he just has hiredman set on /ignore
14:13ejacksonif he's going to show such spirit then perhaps we could get him to sort the ML...
14:13amalloywe should start a second, secret mailing list
14:14Scriptorno-blog-posts-allowed
14:19hiredmansaw a java process taking ~90% cpu time, so I killed and restarted clojurebot, but of course that was the wrong process
14:21amalloyhiredman: which one was it, out of curiosity?
14:21hiredmanelasticsearch
14:21hiredman~search for jrockit
14:21clojurebot<#clojure:coopernurse> cemerick: agreed. the JVM seems to favor long running processes. redeploying seems like a decent route -- I guess I've just been bit by that in the past. perhaps I should take a look at jrockit
14:21clojurebot<#clojure:cemerick> or, use a VM that doesn't have permgen (jrockit is now free)
14:21clojurebot<#clojure:coopernurse> cemerick: oops, that's jrockit..
14:21clojurebot<#clojure:pjstadig> the JRockit Virtual Edition looks kinda cool
14:23amalloyhiredman: is it intentional that he doesn't include /me actions in his search?
14:23hiredmanno idea, clojurebot may just ignore those in general
14:25hiredmanah
14:26hiredmanactions use an :action key instead of :message and the indexing plugin does (when message ...)
14:27gtrakis sexpbot a thing of the past?
14:27dnolen,*clojure-version*
14:27clojurebot{:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"}
14:27ejackson$botsnack
14:27lazybotejackson: Thanks! Om nom nom!!
14:27ejacksongtrak: nope.
14:28jcromartieso there's only two bots here
14:29jcromartieI am always sad when I go to other language channels and there's no equivalent bot
14:29jcromartielike, there will never be a C#bot
14:29dnolen,(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1)))
14:29clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
14:29dnolen,(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1))))
14:29clojurebot"Elapsed time: 203.927 msecs"
14:29dnolen,(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1)))
14:29clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
14:29dnolenerg
14:29amalloyjcromartie: i don't see why not. ##java has a bot; it could be written in C# instead
14:29amalloydnolen: try lazybot!
14:30gtrakejackson, well there used to be sexpbot, now there is lazybot
14:30dnolen&(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1)))
14:30lazybotjava.lang.IllegalArgumentException: Unable to resolve classname: long
14:30dnolenheh
14:30dnolen,(let [f (fn ^long [^long a] (+ a 1))] (time (dotimes [_ 1e6] (f 1))))
14:30clojurebot"Elapsed time: 395.026 msecs"
14:31ejacksongtrak: i think its the same bot, dude.
14:31gtraksneaky
14:31amalloydnolen: new 1.3 feature, i guess?
14:32ejacksoni can't seem to find any 'proper' docs on Google Closure library. Is there a javadoc, or some API overiew that I'm missing (barring the source)
14:32TimMcTHere are always two Sith^W#clojure bots.
14:32gtrakI just bought the book
14:32dnolenamalloy: yeah
14:32ejacksonthe google docs are rather sparse
14:32amalloyi was just hoping to show off his automatic paren-correction
14:32gtrakejackson, http://www.amazon.com/Closure-Definitive-Guide-Michael-Bolin/dp/1449381871/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1311618789&amp;sr=1-1
14:33amalloy&(let [f (fn [a] (+ a 1))] (time (dotimes [_ 1e3] (f 1)))
14:33lazybot⇒ "Elapsed time: 3.242758 msecs" nil ; Adjusted to (let [f (fn [a] (+ a 1))] (time (dotimes [_ 1000.0] (f 1))))
14:33TimMc&(identity 1e3
14:33lazybot⇒ 1000.0 ; Adjusted to (identity 1000.0)
14:33ejacksongtrak: oh, I'd assumed that was compiler deepthinkery
14:34gtrakcheck out the ToC
14:34TimMcInteresting that it prints 1000.0 instead of 1e3. Makes sense, though.
14:34amalloyTimMc: sure. 1e3 is fixed by the reader
14:35hiredman,1e10
14:35clojurebot1.0E10
14:35amalloyhar har
14:35hiredmanif it takes long enough it will print in scientific notation
14:35ejacksongtrak: *SOLD* To the idiot with the ginger beard. Thanks.
14:36hiredman(we have a test fixture at work that times tests for each namespace and some of them print out in scientific notation)
14:37gtrakI was just in the midst of learning javascript when you guys had to go ahead and blow my mind
14:37Hodapppsssh, javascript
14:37ejacksonwelcome to Clojure
14:38jcromartieis there something wrong with ginger beards?
14:38amalloyhiredman: i hope you're timing in milliseconds, not seconds
14:38TimMc*ginger bread
14:38hiredmanamalloy: me too
14:41ejacksonjcromartie: they are highly correlated with gingers. Cant trust those people.
14:42jcromartieI'm no ginger, but I have a ginger beard
14:42ejacksonnaah, you're just still in the closet.
14:42jcromartiemy brother is a ginger. he can't walk to his car without getting sunburned
14:43ejacksonand he deserves it !
14:52nickikHallo, im tring ClojureScript but if I want to start the repl i get "Error occurred during initialization of VM. Could not reserve enough space for object heap"
14:52nickikI just cloned the github repro and ran the bootstrap script
14:53mrBlissnickik: you probably don't have enough RAM available
14:53chouserRhino is a hog -- eats memory and cpu
14:53leedais there a built-in function that does this: (assoc x :a (concat (x :a []) [2]))
14:54nickikbut if you just do script/repl it should just start a clojure repl right?
14:54nickikand that should work since i use normal clojure all the time
14:55nickikI have 1GB of free memory
14:56phaonickik, it is jvm
14:56manutternickik: I edited the file in script/repl and told it to use 768m instead of 2G -- it worked, but no promises.
14:57manutter(where "worked" means "booted to the user=> prompt without throwing the OOM exception")
14:58nickikjava -server -Xmx2G -Xms2G -Xmn256m -cp 'lib/*:src/clj:src/cljs' clojure.main
14:58nickikwitch one is memory?
14:58manutterI changed both the -Xmx2G and -Xms2G
14:58manutterin my abysmal Java ignorance...
14:58nickikk
14:59amalloychouser: sweet, thanks
14:59Scriptorheh, I just took those 2 flags out
14:59nickik@Scriptor do the simplest thing possible
15:00amalloyleeda: update-in
15:00chouseramalloy: eh? what'd I do?
15:00amalloychouser: just got an email about push access to contrib repos
15:00leedaamalloy: thanks
15:03amalloyleeda: though using concat with vectors is a little bizarre
15:03chouseramalloy: oh, sorry -- didn't see that email yet. Yay!
15:03leedaamalloy: oh i should use conj right?
15:03amalloyleeda: conj, or into if you want to add multiple things
15:03amalloythe classic way to do your example would be ##(update-in {} [:a] (fnil conj []) 2)
15:03lazybot⇒ {:a [2]}
15:03leedaamalloy: thanks
15:06chouseramalloy: so, I'm not 100% sure I want to have the two modules
15:06jcromartieamalloy: what about: ##(merge-with concat {} {:a [2]})
15:06lazybot⇒ {:a [2]}
15:06amalloychouser: you mean, a prxml module plus the...whatever module you have already? i agree
15:07jcromartie,(merge-with concat {:a [1 2]} {:a [3]})
15:07clojurebot{:a (1 2 3)}
15:07leedajcromartie: nice
15:07chouseroh, sorry, no I mean a module that depends only on xml features provided by Java 1.5, and another module (for pull-parsing) that depends on a 3rd party lib (though it could actually just depend on java 1.6)
15:07jcromartienotice it returns a seq though
15:07amalloyjcromartie: don't use concat if you have vectors already
15:08amalloyjust merge-with into
15:08jcromartieah, nice
15:08jcromartieeven better
15:08amalloychouser: oh, i haven't looked at the pull-parser stuff at all
15:08jcromartie,(merge-with into {} {:x [2]} {:x [3 4]})
15:08clojurebot{:x [2 3 4]}
15:08leedawhat would be the easiest way to only append the item if it's not already in the vector?
15:08jcromartieleeda: use a set :)
15:08amalloyleeda: use a set instead of a vector :P
15:08chouseramalloy: either way, I think the prxml stuff should go in the main module
15:09leedaah, nice
15:09amalloychouser: k. i just pushed it
15:10jcromartie,(println "##(println \",(println \\\"woah\\\")\")")
15:10clojurebot##(println ",(println \"woah\")")
15:10lazybot⇒ ,(println "woah") nil
15:10chouseramalloy: thanks! I'll take a look at it tonight
15:10jcromartieoh not quite, eh
15:10amalloyi didn't add a test since i didn't want to deal with maven, but i suppose now that it's in "real" code i will
15:11jcromartiewho wants to make a lazybot<-->clojurebot ping-ponging quine?
15:11amalloyjcromartie: tried and failed, hundreds of times
15:11amalloylazybot's arrow makes it hard, on purpose
15:12jcromartiearrow?
15:12clojurebotarrows is http://ro-che.info/ccc/12.html
15:13amalloyjcromartie: ⇒ ,(println "woah") nil ;; see that arrow in his output? if not, your client doesn't render unicode very well
15:13jcromartieah right
15:13jcromartieyes I see it
15:14amalloy,(#(% %) #(% %)) ##(#(% %) #(% %)) ;; you can get them to race though
15:14clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.StackOverflowError>
15:14lazybotjava.lang.StackOverflowError
15:15jcromartiewhoever wrote this should be slapped http://en.wikipedia.org/wiki/Arrow_(computer_science)
15:15amalloyjcromartie: never read any haskell wiki entries before? they usually look like that
15:16jcromartieI love the part "Note that <arrow symbol> defines a category of types, with the obvious choices for id and <a small circle>."
15:16jcromartieOBVIOUSLY
15:16technomancythe typesetting always gives it away
15:16jcromartieI mean, GOSH you freaking IDIOT!
15:16ejacksonjcromartie: I'll give you 10 on the dollar that a ginger wrote that doc :P
15:17jcromartieI read once: "I want to learn Haskell but I don't know enough math"
15:18ejacksondoes anybody have a recommendation for a book on HTML5/CSS/JavaScript/DOM etc ? I have not done this stuff before, but it looks like now is an opportune moment.
15:21triyoHmm don't think thats gonna be one book.
15:21triyoFor Javascript you could read "Javascript, The good Parts"
15:21triyohttp://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742
15:22ejacksonwow: Crockford finally digs through the steaming pile of good intentions
15:23ejacksonsounds a delight.
15:23pjstadigi guess i blinked or something, but ... is sexpbot now known as lazybot?
15:25jcromartiehere's a tip: don't keep Visine next to superglue
15:25triyoejackson: I went the Definitive guide route, the diff looks something like this when you remove the bad parts: http://nerdnirvana.org/wp-content/uploads/2009/09/javascript.jpg
15:25triyo;-)
15:25ejacksonLOL !
15:26mjg123Hi can someone help me understand why I can't use "recur" here https://gist.github.com/1104951 ?
15:26amalloypjstadig: yeah
15:27hiredmanmjg123: recur is not in the tail position
15:27amalloymjg123: recur is only for defining algorithms that require no stack space
15:27mjg123recur is not in the tail position?
15:27amalloybecause you plan to cons something onto the result of the recursion, you need to keep track of your place in the stack in order to do the consing when the sub-function returns
15:27pjstadigmjg123: the result of the "recur" is passed to cons which becomes the result of calculate
15:28mjg123because cons happens after
15:28pjstadigso cons is in the tail position, not the recur
15:28mjg123Ah I see
15:28mjg123can this be easily converted to tail-recursion?
15:30mjg123it seems not :)
15:31nickik@mjg123 not to fast my inet is slow
15:35amalloymjg123: there are two reasonable choices if you want something that doesn't need stack space
15:35amalloy(probably more than two)
15:35amalloyyou can do the classic transformation of keeping an accumulator, initialized to [], and conj onto that every time you recur
15:36amalloyor you can rewrite it with ##(doc iterate)
15:36lazybot⇒ "([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"
15:36mjg123amalloy: the accumulator approach is like the 2nd one on that gist?
15:36amalloyuhhh, the second what?
15:37mjg123I added another code snippet to the gist
15:37mjg123https://gist.github.com/1104951
15:37hiredmanor use reduce?
15:38amalloyhiredman: right, if he's willing to add multiple copies of a coin at each step
15:38pjstadiguntested code, but https://gist.github.com/1104978
15:38hiredmanamalloy: huh?
15:38amalloythere was a discussion of this algorithm in here about a week ago, with me and dnolen and...someone else
15:38triyothats the iteration version. First example is the leaner version
15:38amalloyhiredman: what is he reducing over? a list of all the coin denominations?
15:39triyolinear cannot be tail recursed
15:39hiredmanamalloy: no idea, what is this doing?
15:39mjg123I'm using it as a coding problem at our FP club - it sounds easy but it's a great puzzle.
15:40amalloyhiredman: it looks like he's making change for an amount
15:40amalloyand returning a seq of coins
15:40triyomjg123: you can use loop/recure instead shift (recur ..) to the left.
15:40mjg123yes, eg (calculate [1 2 5] 9) => (5 2 2)
15:40triyoso it falls in the tail position.
15:41hiredmanseems reducable to me, the only problem is lack of early termination for reduce
15:42hiredmana solution using iterate may come out nicely, is there a reason to have a vector of coin denominations instead of a set?
15:42amalloyhiredman: you have to do the coins in largest=>smallest order or the algorithm doesn't work well
15:43mjg123Could be done with a set tho, just (apply max) when you make your choice of coin
15:43amalloyhere are the solutions dnolen and i wrote last time: https://gist.github.com/1074857/0f32b3d64cd7641ef975f8fa6e08f26518a6cae4 and https://gist.github.com/1074808
15:44mjg123it's not a set because part II of the problem will be to make change from a given number of coins
15:44mjg123(ie using what coins you have in your pocket right now, make 84)
15:45dnolenhttps://gist.github.com/1074818 is the last version I did, the shortest and fastest.
15:45mjg123wow that's great amalloy & dnolen
15:46mjg123really good (and lucky) to see others' solutions
15:48mjg123then part III, "using what coins you have in your pocket right now, make 84 and 26 and 13"
15:49ejacksonaaaaaaah, the Closure Library cames with a demo directory !
15:50ejacksonsweet jumping jehova !
15:52ejacksoni can have clojure with an interface i want to look at !
15:53hiredmanyou mean emacs?
15:53ejacksoncurses !
15:54Scriptorncurses?
15:55ejacksonndeed
15:55ejacksonnow that was a MAN's interface. Before all those stupid butterflies.
15:58phaoclojure is more like scheme or common lisp?
15:59chouserphao: probably slightly more like scheme. But different enough from both to count as it's own dialect of lisp.
16:06theignoratidoes (read-line) not work when you run something with leiningen?
16:11kjeldahlAnybody know if leiningen outputs anything similar to cake.log when running threaded stuff with output in repl?
16:11kjeldahl(after emacs clojure-jack-in in my case I guess)
16:12hiredmanit goes to some buffer
16:14kjeldahlhmm, can't find anything
16:15neotykGood evening everyone!
16:16arohnerneotyk: http://www.total-knowledge.com/~ilya/mips/ugt.html
16:17nickikHaving this error running script/repljs "Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: sun.org.mozilla.javascript.internal.Context, compiling:(cljs/compiler.clj:956)". did somebody have the same problem?
16:17neotykarohner: Morning than
16:17arohnerneotyk: :-)
16:18hiredmannickik: your jdk is missing rhino
16:19nickikah, I thought thats standart.
16:19hiredmanit is
16:19hiredmanyou are non-standard
16:19nickikhow do i get it?
16:20theignoratithe internet
16:20hiredman~non-standard
16:20clojurebotalign yourself with the standard or be crushed
16:20amalloyhah
16:20hiredmannickik: first figure out what java you have installed
16:21hiredmanjre or jdk (rhino comes with the jdk) and which version, etc
16:21chousernickik: you're probably using openjdk instead of sun's
16:21theignoratidoesn't come with the openjdk
16:23hiredmanclojurebot: non-standard is <reply> your nonconformance has been noted and we will come for you
16:23clojurebotAlles klar
16:24nickikchouser, ok i will switch
16:25kjeldahlhiredman: It didn't send to any buffer, but binding *out* like described here http://stackoverflow.com/questions/4532862/understanding-output-in-clojure-using-swank-slime worked. Thanks anyway.
16:27scottjis it just me or does the clojurescript repl die everytime an exception is thrown (I don't think other repls do this)?
16:32neotykhow crazy it is to run against HEAD of closure-library?
16:50schlechtvin a ClojureScript REPL: how do I use something from a different namespace, i.e. cljs.reader? I get cryptic exceptions with require, use and (ns xxx (:require ...))
16:54dnolenschlechtv: I don't think use/require are supported as fns yet - only the macro form works I think.
16:54schlechtvdnolen, meaning (ns ...)?
16:58schlechtvdnolen, this fails: (ns tst (:require [cljs.reader :as rdr]))
16:59neotykis there easier way to support ClojureScript swank than one via inferior-lisp?
17:12dnolenschlechtv: sorry I didn't mean to imply that you could run that interactively at the REPL.
17:14schlechtvdnolen, fair enough, I was just frantically trying to figure out if I made a syntactic mistake :)
17:14schlechtvdnolen, so it simply doesn't work, no?
17:18schlechtvdnolen, that makes playing with the reader and thus with ClojureScript's answer to JSON a bit unwieldy, no? or am I missing something?
17:20dnolenschlechtv: some Clojure/core folks said they'd take a patch to make require work as an fn.
17:22schlechtvdnolen, I'm sure... unfortunately I'm far better at finding lose ends than at tying them :-)
17:23dnolenschlechtv: I think that's going to be the case for a while with ClojureScript. From the looks of it, it does seem like you're supposed to be able to play with the reader from the REPL.
17:24schlechtvdnolen, I'll hang in there and play with some of the other features in the meantime. Thanks for the assistance!
17:28skyboundcan anyone offer advice on cljs & node? i have run into this error http://groups.google.com/group/clojure/browse_thread/thread/67256b0b198e1533/84bafb2ab8aa0e3f?show_docid=84bafb2ab8aa0e3f ; compiling with :simple & :pretty-print seems to imply that accessing 'goog.global.Date.prototype.cljs$core$IEquiv$ = !0;' fails, but deciphering why is beyond me :-(
17:34gtrakcan I use a :gen-class'd clj from clojure without precompiling with lein compile?
17:35amalloyi hope not
17:36gtrakso that's AOT only?
17:36amalloy&(doc gen-class)
17:36lazybot⇒ "Macro ([& options]); When compiling, generates compiled bytecode for a class with the given package-qualified :name (which, as all names in these parameters, can be a string or symbol), and writes the .class file to the *compile-path* directory. When not compiling,... http://gist.github.com/1105293
17:37technomancybut, but, clojure.org says that all clojure features are supported at runtime!
17:37gtrakhmmm, why'd they prevent it from happening?
17:37amalloytechnomancy: just a different run-time? the time when you run the compiler?
17:38technomancyhehe
17:38gtrakamalloy, I thought clojure generates classes all the time, there's no way to pass in a dynamically generated class in some java code that the clojure is calling?
17:39amalloyuhhh
17:39amalloyi'm not sure that made sense
17:40technomancygtrak: clojure can't regenerate classes with a given name repeatedly
17:40technomancyjava code that requires gen-class generally needs a named class
17:40technomancyif it doesn't, you can use reify
17:40gtrakright, can it do it once at runtime though?
17:41hiredmanyou can fudge it with defrecord and deftype
17:41technomancygtrak: if you want to call clojure.core/compile by hand, I think so.
17:42gtrakah ok, it's not the preferred way then
17:45hiredmanhttps://github.com/hiredman/agilezen-jdbc/blob/master/src/agilezen_jdbc/core.clj#L254 depending on what you do with the classname you can fake it out
17:46gtrakah, neato
17:48nickikhaha I typed (+ 1 1) and it returned 2. finally ClojureScript works.
19:08neotykGuys can you tell me if it works for you? http://ec2-46-137-58-250.eu-west-1.compute.amazonaws.com:8108/
19:08neotykthat is Clojure talking with ClojureScript via WebSocket
19:08neotykhow cool is that?
19:10neotykthanks I see it works :-)
19:12gfrlogneotyk: clojurebot is not responding over your channel
19:12neotykgfrlog: should it?
19:12gfrlogneotyk: no
19:13gfrlogso I guess it's working
19:13neotykit is just a proof of concept
19:14Raynes"popup blocked"
19:14Raynes:o
19:14neotykwill have to polish it a bit, but I'm frilled by having clojure talking to clojure over webscoket
19:14neotykRaynes: this is debug window if you care to see it
19:14RaynesAh.
19:15neotykdefault debug of closure-library is like that
19:15Raynesneotyk: Nodejs can do TCP sockets. :>
19:16neotykeverything can do tcp this days
19:17scottjfor anything in a clojurescript app to be compiled in closure advanced mode does everything have to be advanced mode compatible? could you have clojurescript+closure libs compiled in advanced mode while some of the clojurescript calls jquerymobile which is just included not touched by closure?
19:17Raynesneotyk: I'm not sure what you're planning to do with your toys, but I'm writing a clojurescript client for http://github.com/flatland/portal as we speak. Might be useful to you when it's finished.
19:18neotykRaynes: not sure, I'm big fan of swank/slime
19:19neotykscottj: you can via js* form
19:20neotykgood night everyone!
19:20scottjis (js/foo a b) special syntax for calling js forms?
19:21RaynesIt's a shortcut to goog globals.
19:21neotyklook at cljs.core
19:22leeda,(contains? [1] 1)
19:22clojurebotfalse
19:22leedawhat's up with that?
19:22amalloycontains?
19:22clojurebotcontains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains
19:22Raynes&(doc contains?)
19:22lazybot⇒ "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or... http://gist.github.com/1105524
19:22leedaoh... oops
19:22amalloyway to go, bots. you have this one covered
19:23Raynesscottj: https://github.com/clojure/clojurescript/commit/954e8529b1ec814f40af77d6035f90e93a9126ea should clear things up a bit.
19:23scottjRaynes: thanks
19:23technomancyis it too early for oscon adventurers?
19:45leedacan I use lein for a dependency that is a Java library?
19:46hiredmanthat is what lein does
19:46mdeboardleeda: yeh u can
19:46leedahow do i specify it? https://github.com/notnoop/java-apns/wiki/installation
19:49technomancyleeda: try "lein help tutorial"; it's explained in there
19:49mdeboardleeda: https://github.com/vitalyper/clj-http/blob/master/src/clj_http/core.clj
19:49mdeboardfor an example
19:49mdeboard(not promised to work )
19:49leedacool, thanks a lot.
19:49hiredmanmdeboard: what does that have to do with lein?
19:50mdeboardwow i have no idea
19:50mdeboardmy brain broke like 2 minutes ago
19:50mdeboardsorry leeda, got myself turned around
19:50technomancymdeboard: just restart swank; that should bring it back to normal
19:50leedahaha
19:51mdeboardin my defense ijust remapped ctlr->caps in emacs
19:51mdeboardso
19:51mdeboardyeah
19:56leedaokay i thought [com.notnoop.apns/apns "0.1.1"] would work, but it says that the artifact "com.notnoop.apns:apns:jar:0.1.1" is missing... am i still doing it wrong, or maybe it really is missing?
19:59leedaoh i changed the version to 0.1.6 and it worked. thanks everyone.
20:45jsnikerisHi all. I've written a fn to convert months between two different formats, e.g. "jun" -> "06" and vice versa. However, I'm thinking there must be a way that is more concise. Any ideas? https://gist.github.com/1105641
20:49aaelonyclj-time might do this (and more)...
20:50jsnikerisThat's what I'm using
20:50aaelonyah, sorry.
20:51jsnikerisaaelony: np
20:54mdeboardhow would one produce an hmac sha1 message digest in clojure?
20:59winkhttps://bitbucket.org/tebeka/clj-digest/src maybe?
21:08mdeboardyeah that's good for sha1 but not for hmac standard
21:08mdeboardbeen using that to no avail :)
21:26chouseramalloy: looks great. Willing to add any tests for your new xml code?
21:26amalloychouser: yeah, i grudgingly volunteered a few hours ago in irc, but i gather you missed it
21:41mdeboardHA
21:41mdeboardOh man
21:41mdeboardI just made Clojure give me that sweet hexdigest hmac sha1 chocha
21:41mdeboardyou beautiful thing
21:47amalloyah, i remember the first time i ran maven. didn't even know what it was supposed to be/do, and hit C-c because it certainly couldn't be *intended* to download this much stuff i'd never heard of
21:47tarcieriso like... Clojure kinda leaks JVM internals all over the place... how does that stuff work in ClojureScript?
21:48tarcieriI guess I should just play with ClojureScript and see for myself
21:48mdeboardtarcieri: "leaks jvm internals"?
21:48tarcieriwhat does `Integer do on ClojureScript?
21:49tarcieriI assume it doesn't qualify it to java.lang.Integer
21:52amalloychouser: one of the tests i'd like to write fails, because i convert :empty (as opposed to [:empty]) into {:tag :empty, :attrs {}, :content nil} instead of :content (). care to take a position on whether that's a distinction you want to enforce?
21:53hiredmanis the map a struct? (cannot leave out the :content key?)
21:53amalloyhiredman: it's a record
21:55amalloyi can certainly make it set a :content of (), but from the client's POV it shouldn't matter which is used; if they write something of their own that sets a :content of nil, i don't think we want it to compare as not= to something with a :content of ()
21:56hiredmanmmm
21:57hiredmanbut what about the result of :content (map foo some-empty-seq)
21:58amalloyhiredman: right, that's what [:empty] (wrapped with brackets) yields. maybe i'm just being silly in even wanting this
21:58hiredman,(= nil ()) ; and all the wishing does not make it so
21:58clojurebotfalse
21:59jcromartieWhat's the current way to use sessions from compojure?
21:59amalloyjcromartie: sandbar is popular, i think
22:01scottjsandbar or noir for stateful ones, compojure itself for functional ones.
22:01jcromartiehttps://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/session.clj
22:01jcromartieyeah
22:02jcromartieNoir is "the" Clojure web framework :)
22:02jcromartieaccording to its site
22:03jcromartieI guess I'll grab Noir
22:16chouseramalloy: hm, I guess I don't have an opinion. I'd need to think about it more. You think it's an important distinction?
22:19mdeboardoh man
22:20mdeboardI'm really excited and want to brag. I wrote a wrapper in Clojure for the US Dept of Labor API as a self-teaching project and I just finished it!
22:20mdeboardI'm more excited than a puppy who just found his you-know-what
22:22chousermdeboard: congrats!
22:22amalloychouser: not especially, but because my test used = and the things compared not=, it artificially became important
22:22mdeboardchouser: thanks! really thrilled irl
22:23amalloyie, if you revert https://github.com/clojure/data.xml/commit/21998b then the test fails to pass
22:24amalloyi kinda wanted to be ambivalent about the two, but hiredman has me mostly convinced that that's a naive thing to want
22:25chouserIt would probably be best to use ()
22:26chouserbecause in most (all?) contexts, :content is a lazy seq. An empty lazy seq is (), not nil.
22:26amalloy*nod*
22:28amalloywell, i'm gonna head home. glad to finally have some code of mine in clojure/contrib
22:29chouseramalloy: Thanks so much, I really appreciate it.
23:12technomancyanyone up for some golf?
23:12technomancy(int (Math/ceil (/ (:_total-hits (meta results)) (float page-size))))
23:15technomancyah, the float is unnecessary
23:16technomancynice that Math/ceil works on ratios
23:16amalloytechnomancy: as is the int/ceil combo: (int (+ .5 x)) does the same
23:16technomancyhmm; no fewer tokens though
23:17amalloymore tokens, even
23:17technomancyyeah
23:17amalloybut fewer characters
23:17technomancyI just need int that rounds up
23:17amalloy&(doc unchecked-do-what-technomancy-wants)
23:17lazybotjava.lang.Exception: Unable to resolve var: unchecked-do-what-technomancy-wants in this context
23:17amalloy$findfn 0.7 1
23:18lazybot[]
23:18technomancyoh man... + 0.5 *does* take it from 83 columns to 79.
23:18technomancyhard to resist
23:19amalloyyou can even afford to put a semicolon as the end. "look! it's documented!"
23:20hiredmanhave you arrowed it yet?
23:20zmarilPardon me, how was the first macro written? "Programming Clojure" says that defmacro is itself a macro. If you check the source of defmacro with repl-utils, then you bump up against something called setMacro which doesn't seem to exist anywhere.
23:20technomancywait that's not right
23:21technomancy,(int 0.9)
23:21clojurebot0
23:21zmarilIs there another way to define macros somehow?
23:21amalloytechnomancy: haha sorry, that trick is for rounding, not for ceil
23:21hiredmanzmaril: a macro is just a function with a particular bit set that lets the compiler know it is a macro
23:22technomancy83 columns!!!oneone
23:23duck1123Does anyone know if it's possible to add my resources directory to the classpath with maven? (the source, not the copied versions)
23:23zmarilhiredman: That makes sense. But how did they write the first macro then? Is it the same way they defined what a function is but just with this particular bit set?
23:23duck1123I'm messing around with soy templates and I have to reprocess the resources to get the changes picked up
23:23hiredman(-> results meta :_total-hits (/ page-size) Math/ceil int)
23:24joegallothe first macro stands on the back of a turtle, and then it's just turtles all the way down
23:24technomancyhiredman: aw dang; right as soon as I push =)
23:24hiredmanI asked if you arrowed it
23:27zmarilThat is what every programmer says. C was written in C, Clojure was written in Clojure, Javascript was written in a week.
23:27hiredmanclojure is written in java
23:28amalloyand C was written in asm. later, someone rewrote it in C
23:28zmarilRight but isn't the big push to write clojure in clojure? I thought that was part of the point of ClojureScript
23:28hiredmanasm? not B?
23:28technomancyhiredman: I thought you were making a joke about monadic arrows =(
23:29amalloyhaha me too
23:29dnolen_zmaril: there's no "big push" to get Clojure in Clojure as of yet. ClojureScript is a step in that direction.
23:30amalloyhiredman: i'm hardly an expert, but i didn't think B was involved in implementing C, just as an ideological ancestor
23:30hiredmanamalloy: sure
23:32zmarildnolen_: ah. back to the books then.
23:36qedIf I have a structure like [[0 1 1 '(0)] [...]], and I want to call #(= (range %1 %2 %3) %4) across each [...], how do I do that?
23:38qedWhat's a good way to get at the inner [...]'s, and assert that some function called on the first elements of any [...] is equal to the 4th?
23:39amalloyqed: it's simpler if you instead use [['(0) 0 1 1] ...]
23:39amalloythen you can do (for [[result & args] test-cases] (= result (apply range args)))
23:41gtrak``is there such a thing as a lein clojurescript plugin yet?
23:43PupenoI want to play around with IMAP, is JavaMail the way to go or should I try something different?
23:46rimmjob_if i do my java homework in clojure, would my teacher be able to tell?
23:46duck1123rimmjob_: He'll probably want source
23:47duck1123and even still, you can tell it's clojure by looking at the class names
23:47rimmjob_oh ok :*(
23:48PupenoI'd give extra points if a student uses Clojure instead of Java… but then again… I'm not teaching and I can more or less understand Clojure. If the teacher doesn't, you are probably causing him a problem because he won't be able to know whether what you did is right or wrong.
23:49duck1123Welcome to the world of a programmer. forced to use something when you really want to use clojure. :)
23:49amalloyPupeno: nah, easy, it would be wrong: using a language that is not the one you're supposed to be learning
23:49duck1123Pupeno: I tried to pull that in my C# class. Didn't go over well
23:50rimmjob_i use it at work and my boss doesnt care
23:50amalloyrimmjob_: that's because your boss cares about getting things done
23:50PupenoIt might depend on the teacher.
23:50amalloywhen you take a class like "data structures", ask about implementing your stuff in clojure
23:50amalloywhen you take a class called "java", do your stuff in java
23:51rimmjob_its conurrency in java :*((
23:51amalloybut seriously, i know someone who'd be way more well-placed to judge what your teacher would want: your teacher
23:51hiredmanI started a lisp->java source code generator thing a while back
23:51Pupenorimmjob_: you might end up like me once… as teacher assistant.
23:51hiredmanwent looking for it the other day and could not find it
23:52amalloymeh. then definitely use java: it has all kinda of exciting problems you won't be able to solve if you use clojure, because clojure doesn't have them
23:52duck1123rimmjob_: then all you can really do is sit back and make "clojure does this better" comments
23:53rimmjob_ill try to be as smug as possible
23:53gtrak``are you allowed to use libraries at all?
23:54rimmjob_um he hasnt really said anything about it
23:55duck1123probably only the one specific library the book uses
23:55duck1123importing clojure's data structurs for the chapter on avoiding deadlocks probably won't fly
23:57amalloyand wouldn't really be learning anything anyway
23:57amalloyi mean, if you don't spend your whole life writing clojure, you'll want to know how to avoid deadlocks in a mutable language
23:58amalloyeven if you don't like java's syntax, learning the concepts is good
23:59rimmjob_i geuss youre right