#clojure logs

2011-02-15

00:13rata_raek: I was reading your blog post http://blog.raek.se/2011/01/24/executors-in-clojure/ and think is misleading to put the comment "return value is discarded" there, because that anonymous fn is actually returning the value of (task)... I'd put it after (Thread. f) or (.start)
02:07rata_$source distinct
02:07sexpbotdistinct is http://is.gd/k1Z62H
02:11rata_it'd be nice if distinct optionally takes a fn to put in the place of contains?
03:03thorwilhow do i cancel kill-buffer in emacs?
03:13LauJensenthorwil: C-g ?
03:15thorwilworks, thanks!
04:34thorwil(defn #^Server start [handlers & {:keys [port join?] :or {port 8080 join? false}}]
04:35thorwilmeans start takes handlers and either arguments for port and join?, or will use defaults for them?
04:38raekthorwil: it means that you can call the function like this: (start handlers :port 123 :join? true)
04:38raekthorwil: yes, those values listed there are used as defaults if you don't pass anything else
04:39raek& { } means that the rest of the args - for instance a b c d - will be treated as the map {a b, c d}
04:39sexpbot⟹ {}
04:39raeksexpbot: :)
04:40thorwilty. that line is from appengine-magic. whenever is use start, slime in emacs might still do one or two thinsg, then stop working
04:41raekand join? is not true?
04:42thorwilthe fact it doesn't just fall flat immediately led me to believe an explicit :join? false could help
04:42thorwilbut it doesn't and makes no difference seeing those defaults
04:42raekit just stops evaluating your code after a while?
04:42thorwilyes
04:43raekthat's weird
04:43thorwili even used "lein repl" and did all the appengine-magic stuff there
04:43raekis your computer using a lot CPU during that time?
04:43thorwilplus "lein swank" in another terminal
04:43raekno hangs with lein repl?
04:44thorwilthe lein repl seems to work fine. but additional swank/slime/emacs doesn'T
04:44thorwilwhich makes me wonder how one lein repl may interact with lein swank?
04:45thorwilraek: no, judging by noise level, there is no noteworthy cpu use (my fans are rather good indicator)
04:46raekif you start the repl with lein repl and then evaluate (require 'swank.swank) (swank.swank/start-server 4005)
04:46raekdoes both the lein repl and the slime repl hang?
04:47rata_raek: did you read what I wrote you before?
04:49thorwilraek: nothing hangs, i just get. "nil", "java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String (NO_SOURCE_FILE:0)"
04:50raekrata_: yes. the anonymous function would normally return the value, but in this case it is invoked with Future/run rather than IFn/invoke
04:51raekhow I thought about it, was that the value of the (task) expression is not used
04:51rata_that's because it's invoked from Thread
04:52raekyes?
04:53rata_I just said it to you because when reading it I got confused by the comment
04:53raekif that anonymous function could be used by someone else, then the return value may not be ignored
04:53rata_that is it
04:53raekyeah, that makes sense
04:54rata_=)
04:54rata_I'm heading bed now
04:54rata_good night
04:59raekthorwil: oh, sorry. (swank.swank/start-repl 4005) is what I should have written
05:02AWizzArdNice, very fast Haskell server: http://docs.yesodweb.com/blog/warp-speed-ahead
05:05AWizzArdWhat can Aleph do? 10k requests/sec? Those 190k/sec are pretty awesome.
05:06thorwilraek: by itself, that works
05:09thorwilraek: after 3 or 4 successful C-c C-k, it's back to never finish compiling
05:11thorwilbut the lein repl still works fine
05:22raekok, that's strange.
05:23raekthorwil: you could try the 1.3.0-SNAPSHOT version of swank-clojure to see whether that makes any difference in order to pinpoint if this is an issue of slime or swank-clojure
05:25thorwilraek: ok, but isn't it more likely that appengine-magic does starting the server wrong?
05:26raekI have no idea ;-)
05:26raekbut it's strange that you get different behaviour when doing it without swank
05:40thorwilraek: the 1.3.0-SNAPSHOT doesn' like me: http://paste.pocoo.org/raw/338833/
06:23thorwili was hoping https://github.com/weavejester/lein-ring/#readme could be a workaround, but both "lein ring server" and "lein ring war" fail with: "java.lang.IllegalStateException: Var appengine-magic.core/default-war-root is unbound."
06:32opqdonutlein war of the rings
06:36Dranik:-)
07:23_na_ka_na_what are the better ways to round a float/double to 2 decimals ?
07:24raek_na_ka_na_: for presentation to the user, or for calculations?
07:26_na_ka_na_raek, presentation
07:29raekI would use something like ##(format "%.2f" 12.3456)
07:29sexpbot⟹ "12.35"
07:30_na_ka_na_hmm, i was just looking at java.text.DecimalFormat also
07:30_na_ka_na_does that always round half up ?
07:30raekhttp://download.oracle.com/javase/6/docs/api/java/util/Formatter.html
07:31raek"then the value will be rounded using the round half up algorithm."
07:31raekseems so
07:31_na_ka_na_raek, how about if i needed it for calculations, so 1.3333 -> 1.33 not "1.33" ?
07:32raek_na_ka_na_: then you should no use a double, but a BigDecimal
07:32raeksince doubles can't represent decimal digits in loss less way
07:33_na_ka_na_ya i know BigDecimals, there's also a with-precision function in core
07:33_na_ka_na_but suppose for some reason i want to 1.3333 -> 1.33
07:33_na_ka_na_and remain in double
07:34raekseems like a weird thing to do with floating point numbers
07:35_na_ka_na_hmm ya that was just for knowing
07:35_na_ka_na_format seems to be what i was looking for
08:08thorwildoes anyone know of an example on how to make use of "lein run"?
08:44raekthorwil: see lein help run (if you have lein 1.4.something)
08:45raek"lein run" runs the -main function in the namespaces specified with :main in the project.clj
08:45raek"lein run -m <namespace>" runs the -main function of another namespace
08:46thorwilraek: i did. after reading all i could find i gave up. looks like it used to allow what i want, but now is just complicated from my pov
08:47raekthere is a lein plugin called lein-run too
08:47thorwili also tried some recipes to have clojure shell scripts. none worked. so now i have a run.sh with a single line to use a run.cj :}
08:48raekwhat is complicated by "lein run" (without -m)?
08:48thorwiland with that construct, i'm now finding out that the effect from the script is not equivalent to using the same in a repl
08:50thorwilraek: i didn't manage to translate a few lines into something usable with lein run. it does seem like i would have to put what should be a script into a module
08:51thorwilnote that after 2 days of nearly nothing working as expected and not much working at all, my mind is like cheese
08:51raekhere is a thread re. lein run, btw: http://groups.google.com/group/leiningen/browse_thread/thread/4baef9db6d012bc3
08:52raekwhat do you mean by module?
08:52raeknamespace?
08:52clojurebotamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
08:53thorwilraek: with mudule i mean a .clj below src/
08:54raekit seems that it is preferred to only have defs (or things that turn into defs) at the top level of a namespace. this allows you to 'require' the namespace and also AOT compile it.
08:54raekI think clojure is closer to java when it comes to how a program is started
08:55raekwhen compared to scripting languages
08:57thorwil what i'm after is not having to repeat "lein repl" followed by http://paste.pocoo.org/raw/338906/
08:58thorwilwhere (ae/start tlog-app) is currently optional, as that seems to screw up slime somehow
08:59raekhrm. compile messes up the development process
09:00raekmaybe you could do something like this: (ns tlog.main (:use tlog.core) (:require [... :as ae])) (defn -main [] (ae/start tlog-app))
09:00thorwilwhich reminds me that i have to try what that ring reload thing does
09:01raekand add :main tlog.main, :aot [tlog-app] to your project.clj
09:01raekI don't think lein run is made for the case when you need AOT compilation
09:02raekbut doing lein compile && lein run with the above could work
09:06thorwileither i have even less of a clue than i though, or "main" doesn't make much sense in this context
09:07thorwilthat's my core: http://paste.pocoo.org/show/338911/
09:08raekthorwil: if you wrap the last line in a (defn -main [] ...), you should be able to use that namespace as your main namespace
09:09raekhrm, wait. does that line start the server?
09:10raekignore that utterance.
09:12raekthorwil: is AOT compilation required by appengine-magic to run it locally?
09:13thorwilraek: no. afaik it's not even required for deployment
09:15raekthorwil: try adding (defn -main [] (ae/start tlog-app)) at the bottom of tlog/core.clj and add :main tlog.core to you project.clj
09:15raekthen executing "lein run" should be the same as evaluating (require 'tlog.core) (tlog.core/-main)
09:16raekAOT compilation complicates things...
09:17thorwili just hoped it would only slow down local startup :)
09:18thorwilsome signs of progress, but have to take a break
09:18thorwilthank you very much, raek!
09:19raeknp. I hope things got simpler in end.... :)
09:21jkdufairhow would i instantiate a class given a string representation of the classname?
09:26Dranikjkdufair, try to convert the string to symbol using the function "symbol"
09:26jkdufairok. will try. was trying Class/forName
09:27raekjkdufair: there is a method in clojure.lang.Reflector for creating an instance when you have a class
09:27raekif there is a zero-arg constructor, things might be even simpler
09:28jkdufairah ok. i'm finding neither (new (symbol "java.lang.String")) nor (new (Class/forName "java.lang.String")) work
09:28jkdufairi'm writing a macro, so i don't think i can do something like ~classname.
09:28jkdufairthere may be constructor args
09:28raekjkdufair: you cannot apply new as a function, since it is a special form
09:29jkdufairoh that makes sens
09:29jkdufairi'll take a look in c.l.Reflector
09:29raekbut if you are in a macro, you can just generate (new ~(symbol class-name) ~@constructor-args)
09:29raek(with a syntax-quote on that)
09:29jkdufairoh super!
09:29jkdufairof course
09:29jkdufairthx
09:30raekbut this requires the class name to be known when the macro is expanded
09:30jkdufairit will be. it's being passed into the macro
09:30Dranikraek: why isn't this (new (symbol "String") "123") working?
09:31raekDranik: because new is a special form that does not evaluate the (symbol "String") argument
09:32raekthere has to be a symbol there in the code
09:32Dranikraek, ooops, I did think it is a function...
09:35jkdufairraek: hey thanks so much. i haven't written enough macros (or clojure really) for it to be intuitive
09:54khaliGthere is something very weird about proxy methods, i don't understand why sometimes it wont use a method i've just added
09:56khaliGis there a way of inspecting an object for the methods it can respond to?
09:57ejacksonkhaliG: try show from c.c.repl-utils
09:58khaliGyep sure enough the method doesn't exist when i query it from the repl
09:59khaliGbut the form compiled fine and there were no warnings
10:00khaliGthis might be a stupid question but can you redefine an interface?
10:01khaliGbecause if you cant that might explain why i cant use the newer method :/
10:02Chousukeyou need to recompile if you redefine an interface.
10:03Chousukeinterfaces are java stuff, therefore static
10:03khaliGhm yea restarting lein swank and it picks up the method
10:23khaliG_http://clojure.pastebin.com/EBAaYpQD
10:23khaliG_man what are you supposed to do, reboot your machine after changing an interface?!
10:23khaliG_ha
10:26rmarianskiyou have to restart lein swank to pick up interface changes?
10:26rmarianskirecompiling the whole thing doesn't pick them up?
10:26khaliG_define "recompiling the whole thing"
10:26khaliG_the source file?
10:28rmarianskiya
10:28khaliG_well at the moment i can't do that because of clj-time shadowing something or rather, but i did the next best thing -- recompiled the interface defn form and the function which uses it (via proxy)
10:28khaliG_but that wasnt enough
10:28khaliG_clojure, with all the interactivity of lisp, except when you're redefining interface ;P
10:38TimMckhaliG_: You should be using the emacs go-back-in-time-and-do-it-differently command.
10:38TimMcJust hit Chronos-R. (YOu don't have a Chronos key? Too bad.)
10:40jkdufairI think the Chronos key is available on the Optimus Maximus keyboard. Coming soon!
10:46raekor the Space-cadet keyboard... (http://en.wikipedia.org/wiki/Space_cadet_keyboard)
10:47raekpossible modifier keys: control, meta, hyper, super, shift, top, front
10:53raekkhaliG_: clojure can't do much about interfaces. they are static due to the JVM. have you considered a protocol instead?
10:54raekthey have the dynamic goodies that you are used to in Lisp-land
11:12khaliG_raek, i'll check em out, thanks
11:12khaliG_TimMc, haha :)
11:32jweiss_it appears that constructors with signature like MyObj(Integer i, String... strs) cannot be called like (MyObj. 5 "hi" "there")
11:33jweiss_has to be (MyObj. 5 (into-array ["hi" "there"]) ?
11:33jweiss_i am guessing that "String..." is a java compiler thing, not actually different from String[] in the bytecode?
11:35raekjweiss_: iirc, that is how it is. with show from repl-utils you can see the real signature
11:36jweiss_raek: yeah, javap shows that it really is String[] in the bytecode
11:36jweiss_so the compiler kind of throws away information, that sucks
11:37jweiss_can't tell after compilation whether it uses varargs or not.
11:45raekthere is a flag in the class file that signals if the method is variadic
11:47raekhttp://download.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#isVarArgs()
11:57jkdufairwhat's the right tool to use in emacs for refactoring? tags?
12:04jweiss_raek: if there's a variadic flag, why doesn't clojure "do the right thing"?
12:11dnolenfunny that SMT solvers use a Lisp syntax
12:21jkdufairis there any simple way to instantiate a record given a map that would match the field names and values?
12:33dnolenjkdufair: make a constructor fn that takes keyword arguments - that's a one liner, then (apply ctor-fn (-> your-map reduce concat))
12:34amalloydnolen: surely just (apply concat your-map) is clearer
12:34amalloyand jkdufair, while a ctor-fn is a good idea in general, ##(doc struct-map) is already one if you don't mind using it
12:34sexpbot⟹ "([s & inits]); Returns a new structmap instance with the keys of the structure-basis. keyvals may contain all, some or none of the basis keys - where values are not supplied they will default to nil. keyvals can also contain keys not in the basis."
12:35jkdufairi'm using defrecord vs. structmap and afaict you only get the constructors you're given. though the apply solution seems like it ought to work
12:36dnolenamalloy: I always forget about apply. struct-map doesn't help you with records, also I think struct-map kv pairs must be in the right order.
12:36amalloydnolen: you're right about records but wrong about pair ordering
12:36jkdufairyeah, it's the ordering i'm not sure about
12:36jkdufairmaps aren't ordered, righ?
12:37dnolenamalloy: you're right. I haven't used structs in 2 years. create-struct has that limitation.
12:38amalloydnolen: yeah, i haven't used structs either. maps or records all the way
12:38jkdufairoverall, i'm trying to build a RESTful frontend to appengine entities (which are implemented as records). i'll have a map of fields that i've decoded from json and a record type and want to instantiate
12:39jkdufairi'll play with the constructor fn and apply
12:40jkdufairactually, i still don't think it'll work. seems i'd have to reflect on the record type to get the field names
12:40amalloy$google defrecord2
12:40sexpbotFirst out of 23 results is: david-mcneil/defrecord2 - GitHub
12:40sexpbothttps://github.com/david-mcneil/defrecord2
12:40amalloyjkdufair: might be useful
12:41jkdufairoh very nice. many thx. nice to hang out in the company of those who live and breathe clojure
12:42dnolenjkdufair: if you don't have a ton of records, it's easy to create lookup map that holds record-name -> vector of ordered field keys
12:42jkdufairinteresting that it will let you print in an eval-able form. maybe i'll skip the whole json thing. i'll just parse the s-exp on the iPhone side of my app.
12:42jkdufairi won't know how many records i'll have. it's a framework to REST-ify GAE
12:43dnolen,(map {:arg2 'bar :arg1 'foo} [:arg1 :arg2])
12:43clojurebot(foo bar)
12:43jkdufairmaybe i'll just port clojure to the iPhone so i can just eval the records on that side
12:46thorwili tried lost of things, including what is now http://paste.pocoo.org/show/339055/
12:47thorwilbut i always get no such var: ae, or some other missing symbol
12:54jkdufairthorwil: are you getting it on the def-appengine-app or on the start?
12:54thorwiljkdufair: on "lein run"
12:55jkdufairwhat about if you try ae/start on the REPL?
12:55jkdufairthat's what i'm doing for the time being and it works ok
12:55thorwiljkdufair: that's what i have been doing
12:55jkdufairand it works?
12:56jkdufairor that's where you're getting the error?
13:15khaliG_i remember coming across something pretty about dealing with nils when chaining function calls.. does anyone remember how it's done?
13:15amalloykhaliG_: fnil, -?>, and maybe-m are the things you probably want to look at
13:15khaliG_cheers!
13:15amalloymaybe-m is pretty heavy, and -?> is hard to google for so i'll tell you it's in clojure.contrib.core
13:27khaliG_amalloy, they're pretty cool but don't think either of fnil or -?> will work for my situation :)
13:32amalloykhaliG_: really? what are you trying to do?
13:32khaliG_probably easier if i show you. (.getDate this row column) returns a date or nil, if it's a date i want to return (.day <date>) and if it was nil return the empty string
13:33amalloy(or (-?> this (.getDate row column) .day) "")
13:34amalloythat is, if you want the nil-failure case to return something other than nil, wrap it up in a top-level or
13:38khaliG_yea hm, dont know how to fix that expression you've provided but it doesn't work as in
13:39khaliG_*as is
13:41amalloykhaliG_: works fine for me: (or (-?> test ((constantly nil)) .size) "") returns ""
13:41Scriptor&(or (-?> test ((constantly nil)) .size) "")
13:42amalloyScriptor: there's a netsplit somewhere, sexpbot isn't here
13:42Scriptorwhat about clojurebot?
13:42hiredman~ping
13:42amalloy,(use 'clojure.contrib.core)
13:42clojurebotPONG!
13:42clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/core__init.class or clojure/contrib/core.clj on classpath:
13:43amalloyhm. maybe sexpbot died during the split and didn't come back. Raynes, you around?
13:43khaliG_amalloy, i think it's the the this
13:45amalloykhaliG_: you said that (.getDate this row column) returns a date. (-?> this (.getDate row column)) macroexpands into exactly that
13:48khaliG_how did you macroexpand it?
13:48khaliG_(just out of interest)
13:55khaliG_amalloy, got it, it was close but the this went inside the (.getDate ...) form
13:55amalloykhaliG_: it's supposed to, isn't it? that's the point
13:55amalloykhaliG_: (macroexpand '(-?> this (.getDate row column) .day))
13:56amalloylooks a little hairy because of the nil-checking, but you can take out the ? and still see the basics of what it's doing
13:56khaliG_it used -> which i haven't come across before
13:56amalloykhaliG_: -> and ->> are wonderful
13:56khaliG_so much to learn!
13:57amalloy&(use 'clojure.walk)
13:57amalloydamn it sexpbot i know you're in here
13:58amalloykhaliG_: http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E
14:00khaliG_i'm not sure which is easier to read :)
14:15TimMcYay, I wrote my first defmacro!
14:15TimMc(My only prior experience with macros was syntax-rules in Scheme, which was nice for what it could do.)
14:17thorwilraek: sorry, but i'm still struggling with http://paste.pocoo.org/show/339055/ it's always either "no such var" for ae or some class not found (i tried many variations)
14:20khaliG_man this shadowing thign is really painful, i keep shadowing vars by importing a random library!
14:20khaliG_i might just have to use full paths to things instead of using :use
14:23amalloykhaliG_: unqualified :use is a bad idea for this and other reasons
14:24bytecolorkhaliG_: have you used the :only key to a use form? (use [clojure.contrib.core :only (-?>)]). less namespace pollution that way.
14:24khaliG_i think any use is bad then, amalloy
14:24amalloyin general you're better off with (:use [foo.bar :only [blah baz]]) or (:require [foo.bar :as b])
14:25khaliG_or people who write libraries can add prefixes to avoid clashes
14:25amalloykhaliG_: no, that is nuts
14:25bytecolorthe namespace _is_ the prefix
14:25khaliG_but i dont like that either :/
14:25amalloythat is what namespaces are *for*.
14:27khaliG_yes but randomlibrary.something.core/foo is hard to use
14:27amalloywhen you use a library, your job is to refer/require/use in the way that makes the code easiest to read and write
14:27khaliG_not hard to use, but hard to read in a way, although its clearer, but unclearer at the same time
14:27amalloyrarrrrrgh which is why you should use :use/:only or :require/:as
14:28khaliG_hmmm i get what you mean
14:37khaliG_amalloy, even so you're forced to use clumsy names just because someone else used the nice ones
14:37amalloykhaliG_: i think you don't understand what require/as does
14:37mefestokhaliG_: require as lets you alias the namespace
14:38khaliG_i didn't notice the as, but that's probably why
14:38khaliG_can you give it a custom name?
14:38amalloysee for example http://github.com/Raynes/sexpbot/blob/master/src/sexpbot/plugins/markov.clj
14:38mefestokhaliG_: so you can choose the name you want for the namespace portion: (require '[com.really.long.library :as lib])
14:38mefesto(lib/foo)
14:38amalloyi require the string library as s, and then call its functions as s/join, etc
14:38khaliG_amalloy, oh that's clever!
14:38khaliG_clojure ftw :)
14:38amalloy(that said, don't use c.c.string - it's deprecated and i'm a bad person for using it)
14:39khaliG_understood, that's sweet.
14:40TimMcSome of those classnames are as long as CLojure library names.
14:40khaliG_i'm going to use it straight away
14:40bartjer, does enlive support xpath based selections ?
14:40amalloyTimMc: don't hold your breath
14:40TimMcamalloy: I know.
14:41TimMcI don't even know what would be involved in implementing that.
14:41amalloy:as renames the package, not the fn. refer does let you rename actual functions, but it's not often used and i doubt anyone will port it to classes
14:42bartj&lastseen cgrand
14:42amalloyTimMc: it wouldn't be that hard actually, but it would be a net loss in terms of added complexity vs usefulness
14:45TimMcI'll have to trust you on the added complexity.
14:48TimMcOh huh, doseq does a Cartesian cross for multiple seqs.
14:48TimMc(doseq [a [1 2] b [3 4]] (println a b)) for instance
14:49amalloyTimMc: it's basically the same as ##(doc for)
14:49sexpbot⟹ "Macro ([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost f... http://gist.github.com/828092
14:50mefestoTimMc: are you wanting to iterate both colls at the same time?
14:50TimMcmefesto: Yeah, but I took care of that.
14:51TimMcmap vector
14:52amalloyTimMc: fwiw, ##(doseq [[a b] (map vector [[1 2] [3 4]])] (println a b))
14:52sexpbot⟹ [1 2] nil [3 4] nil nil
14:52TimMcyup
14:53amalloyoh, too many square brackets :P. you get the idea
14:53TimMcYeah, that's what I ended up using.
15:16odyssomayHi, is there any way to add a "init" function to a proxy?
15:17raekthorwil: should "tlog-app" in the last line really be quoted?
15:17raekthorwil: also, you have this in two separate files, right?
15:17raek(you don't need to have the -main function in a separate namespace. you could have it in tlog.core instead)
15:17raekclojure will expect one namespace per file
15:22thorwilraek: one file. though i suspected that can't be right. if i just remove the main ns, i end up with "java.lang.ClassNotFoundException: appengine-magic.core"
15:22thorwiland tlog-app shouldn't be quoted, yes
15:22raekhave you executed lein deps?
15:23raeklooks like the jar is not on the classpath
15:23raekoh wait, now I see it
15:24raekthorwil: remove the closing parenthesis on the first line
15:25thorwilouch! :)
15:26thorwilbut that alone still doesn't do the trick. state: http://paste.pocoo.org/show/339165/
15:26raekyou get some other error?
15:26thorwilException in thread "main" java.lang.Exception: No such var: ae/start (core.clj:14)
15:28raek:( https://github.com/gcv/appengine-magic/blob/master/src/appengine_magic/core.clj
15:28raekit does some "magic" that causes the #'start var and friends to not always load...
15:30raekthis is bad.
15:32raekit won't load a part of the library if you're not running from swank, vimclojure or the clojure repl...
15:32thorwilso i need to do the equivalent of (load "core_local") myself?
15:33thorwilor start jetty myself, without going through ae
15:33gtrakouch
15:33raekI saw that you created a ticket for the other thing. you should definitely create on for this
15:38raekthorwil: you could try (load "/appengine-magic/core_local") before the start call
15:38raekhrm.
15:38raekmaybe (load "/appengine_magic/core_local") even
15:38raekI'd never guess that any clojure lib would do something equivalent to "browser sniffing" in the JavaScript world
15:40thorwilwith (load "/appengine_magic/core_local") (ae/start tlog-app) it's still "Caused by: java.lang.Exception: No such var: ae/start"
15:40raekthe load expression did not complain?
15:40thorwilno
15:40thorwilthe exception is for the (ae/start tlog-app) line
15:42raekappengine-magic has a lot of dependencies to download...
15:46thorwilraek: i'd happily file a bug, but feel uneasy to do so, as i can't make the connection between my issue and that file you linked to
15:46raekI can create a ticket
15:47thorwilraek: if you say that's the cause, i will believe you, but filing bugs where i can respond the questions ...
15:47thorwilraek: cool, thanks
15:48thorwil"can't respond", even
15:51thorwili now use (future (run-jetty (var tlog.core/tlog-app-handler) {:port 8080}))) and that works, so far
15:52raekthorwil: I managed to get your code working by adding (load "/appengine_magic/core_local") after the ns form
15:53raekthorwil: instead of running run-jetty in another thread, you can simply pass it the :join? false option
15:54thorwilraek: replicated. you're great! :)
16:07TimMcHaha, I just realized I can use prinln in macros to determine how far the compiler has gotten! (lein is hanging on this compile for whatever reason)
16:07TimMc*println
16:08Chousukeheh
16:09TimMcNext up: A GUI that asks "Continue compiling? y/n"
16:10amalloyTimMc: better still: "Override default expansion of (this-form) and replace it with _____ <enter text here>?"
16:10TimMcnice
16:10amalloypretty sure you would deserve to be murdered if you ever did that, but it's a funny idea
16:10TimMc"Enter password to continue compiling: ____"
16:11amalloyTimMc: you have no ambition! ask for a credit card number
16:13thorwilgood night!
16:15TimMcWTF, I can use lein run but not lein compile... any way to tell what's going on in there? It seems to get slower each time, too.
16:15rata_hi
16:15Scriptorhey rata_
16:16rata_hey Scriptor
16:16raekamalloy: (import 'javax.swing.JOptionPane) (defn break [] (= (JOptionPane/showConfirmDialog nil "Continue compiling? y/n" "Compiler" JOptionPane/YES_NO_OPTION) JOptionPane/YES_OPTION))
16:17raek(when-not (= ...) (throw (Exception. "Ok. I'l stop")))
16:18raekeh
16:18raekTimMc: ^
16:19TimMcYou forgot the calls to java.net that check whether my site has a sentinel page up indicating whether I've been paid for the code yet. :-P
16:21amalloyTimMc: that's too easy to hack. maybe your site could host the compiled version of the code and you just curl it
16:22TimMc:-)
16:23TimMcNow I'm imagining code that compiles differently on Thursdays.
16:27TimMcHmm. Anyone else experienced hangs with lein or Java compilation?
16:27TimMcI don't even have 2.2250738585072012e-308 in my code.
16:28amalloyhaha
16:28raekTimMc: do you have code at the top level of the namespace that - for instance - starts a web server?
16:28TimMcNope.
16:28raekor any code on the top level that does not in the end turn into a def of some sort
16:29TimMcI made some pretty standard changes to my code, and now it won't compile.
16:29TimMcBizarrely, it still runs.
16:30raekhave you pinpointed where it hangs? (e.g. by commenting out everything, and then enable one var at a time)
16:31TimMcNot yet, need to commit first.
16:38TimMcOho!
16:38TimMcI move the creation of a JFrame out to a (def ...).
16:38TimMc*moved
16:42TimMchttps://github.com/timmc/CS4300-HW3/blob/bcdbb09765f687057e781b5ef375ff8e3a141016/src/timmcHW3/core.clj#L463-471
16:45amalloyindeed. you probably want to make that something more like (defn frame [] (...)) (defn launch [] (.setVisible (frame)))
16:46TimMcamalloy: Yeah... I think I'm failing to understand something about the compiler.
16:46amalloyTimMc: the compiler has to resolve all the defs
16:46amalloybecause those happen at compile time
16:47TimMcNow I see that my code actually runs at compile time...
16:47amalloyif the value you're def'ing is a jframe, it has to build a jframe
16:47TimMc...I suppose that is so that macros can run.
16:47amalloyTimMc: and for other reasons, too
16:47raekexactly
16:47TimMcThere's a real epiphany happening over here.
16:48amalloypersonally i'd kill the top-level defs and either wrap them in functions which call each other, or replace them with one big old function with a big (let) block
16:50TimMcThere will be a bunch of GUI elements, so not the latter.
16:51TimMcThe top-level defs are nice because I can have them refer to each other. I think I'll make a macro that allows me to create and def these things in one statement.
16:51amalloyTimMc: i don't see how that follows. (let [controls (doto (JPanel.) stuff) canvas (doto (JPanel.) (.add controls))]) is no more complicated or nested than what you have
16:52TimMcAll my menu items and buttons and stuff in one let? No thanks.
16:54TimMcThere will be on the order of 20-30 elements. They'll all have event handlers and need to be enabled and disabled by each others' event handlers.
16:56TimMcI'm fairly sure that there will be at least several cases where two elements' event handlers each need to see the other element.
16:57amalloyTimMc: if that's the case your defs won't work either unless you re-def them
16:58amalloywhich is super-gross. i think you're better off constructing a nested-map kind of hierarchy (which you can do by parts however you want)
16:58shafirecan i use clojure just with repl?
16:59shafireor can i call a function after compiling without repl?
16:59shafire-just +only
17:00TimMcshafire: If you compile the Clojure program, you ca certainly call the main method.
17:01shafirehow can i do it?
17:01TimMcshafire: Use a build tool like Leiningen or Cake. I use lein to compile my programs into jar files, which ca then be run with java -jar.
17:02shafireTimMc: so i cant do something like that:
17:02shafire(def hello (fn [] "Hello world"))
17:02shafire(hello)
17:02shafirewhen i compile it and run, console is empty :(
17:03TimMcshafire: Try wrapping a (println ...) around the Hello world.
17:04shafireouch TimMc :) thank you! :)
17:04TimMc:-)
17:04TimMcshafire: (defn -main [& args] (println "Hello world"))
17:05shafirewhen i run your example code, console is empty?
17:06TimMcHow are you running it?
17:06jweiss_anyone know how to use repl-utils/show to list just the constructors
17:07jweiss_(show ExtendedSelenium (fn [m] (.contains (:text m) "init")))
17:08jweiss_that works, but not very well
17:15amalloyjweiss_: (comp (memfn contains "init") :text) would probably be equivalent, if you find that more palatable
17:16jweiss_amalloy: that's shorter :) but i was thinking of a more reliable way, since there could be other fields that contain the text "init"
17:18amalloyjweiss_: (show Integer (comp #{java.lang.reflect.Constructor} class :member))
17:19jweiss_amalloy: there ya go, i was on my way to using :member, :class :)
17:19jweiss_thanks
17:32rata_amalloy: what you said about nested-maps to store gui elements made me think about a possible dsl to express gui elements (something like cgrand's regex lib)
17:34amalloyrata_: i think someone wrote something like this and posted it to the newsgroup. i think it was pretty skeletal but you might find something useful to work with
17:35shafireTimMc: with intellij idea
17:36rata_amalloy: great... sadly I don't know much about gui design/development, but having something like that in clojure would be certainly great
17:38rata_I hope the idea prospers
18:26sritchie_hey, guys, I've got a quick style question --
18:26sritchie_I've got a simple function that applies one function to each of two arguments, and takes the difference of the results
18:26sritchie_which of these two versions is preferable, idiomatically?
18:26sritchie_https://gist.github.com/828499
18:27raekI prefer the first one
18:27amalloysritchie_: for exactly two args, the first one is probably best
18:27raeksince you have a finite (and low) number of cases
18:27sritchie_I'm comparing two date-time objects, to find the difference in months between the two -- so, I need the difference in year, and the difference in month
18:28sritchie_okay, that's what I had suspected -- I suppose the second version would hint that maybe this function could be used for more, but really it's not meant to be
18:28amalloyfor even three args i'd probably use the map/reduce (or map/apply) version
18:29amalloyand if you rewrote it as (defn delta [f & data] (reduce - (map f data))) it's not that bad
18:31sritchie_I'm finding it very easy in clojure to think about how my code will affect other programmers, when they read it
18:31sritchie_amalloy: that code you just posted is equivalent, of course, and doesn't repeat the f, but hints that this function is meant to scale
18:32amalloyright. as you say it doesn't make much sense for -
18:32sritchie_I'm finding those "hints" to others to be a really valuable bonus of the language's flexibility
18:32sritchie_amalloy: but I see what you're saying, about a three argument version
18:49polypusanyone know why (letfn [ (f [x] x)] (f 8)) works but trying to directly compile what it macroexpands to, namely (letfn* [f (clojure.core/fn f [x] x)] (f 8)) gives the error "clojure.lang.Compiler$MetaExpr cannot be cast to clojure.lang.Compiler$ObjExpr".
18:50amalloypolypus: letfn* is probably not allowed in general
18:58polypusamalloy: figured, but it's still a bit mysterious that a macro should be able to produce something which doesn't compile directly. what i really need is a letrec form
18:58amalloy$source letfn
18:58sexpbotletfn is http://is.gd/ZQ8ctX
18:59polypusyeah, it's just a regular macro, so there's some magic somewhere
19:00amalloypolypus: letfn* is a compiler symbol
19:01amalloyit's not immediately obvious to me why this is a problem, but you can see it in src/jvm/clojure/lang/Compiler.java
19:04polypusi was hoping to be able to use the letfn* form because i need to be able to go (letfn* [f (let [some-precalculations (foo)] (fn f [x] (g x some-precalculations))) g ...])
19:08amalloypolypus: are you trying to write a macro of your own that expands into letfn*?
19:08polypusamalloy: correct
19:08amalloyif so, you probably need to quote it so that macroexpand doesn't turn it into myns.foo/letfn*
19:09amalloyie, `(~'letfn* ...) or (cons 'letfn* `(...))
19:14amalloypolypus: does that help?
19:15polypusamalloy: not really sure what you mean. the letfn* symbol will not be qualified by the expander as it isn't a binding symbol in a let form
19:24amalloy&(macroexpand '(letfn* [1 20]))
19:24sexpbot⟹ (letfn* [1 20])
19:24amalloy&(macroexpand '(`(letfn* [1 20])))
19:24sexpbot⟹ ((clojure.core/seq (clojure.core/concat (clojure.core/list (quote letfn*)) (clojure.core/list (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list 1) (clojure.core/list 20))))))))
19:25amalloy&`(letfn* [1 20])
19:25sexpbot⟹ (letfn* [1 20])
19:25amalloyhm. maybe you're right
19:25amalloyi thought the macroexpander worked on the whole form, not just bindings
19:31amalloy&`(test [1 20])
19:31sexpbot⟹ (clojure.core/test [1 20])
19:31amalloy&`(fwerf3 [1 20])
19:31sexpbot⟹ (clojure.core/fwerf3 [1 20])
19:31amalloypolypus: okay good, i was right about that much. all symbols get namespace-qualified, regardless of let bindings
19:32amalloybut it seems to know that letfn* is a compiler symbol that it shouldn't touch, so that's probably not your issue
19:40rata_polypus: why don't you expand to let?
19:42polypusamalloy: weird, why do all symbols except letfn* get qualified
19:42polypus&`(let [])
19:42sexpbot⟹ (clojure.core/let [])
19:42polypus&`(letfn* [])
19:42sexpbot⟹ (letfn* [])
19:42amalloypolypus: your statement is incorrect
19:42polypusrata_: because i need the recursion
19:42amalloy&`(do [])
19:42sexpbot⟹ (do [])
19:43amalloyit expands any symbols that aren't compiler-level special forms
19:43rata_polypus: there's no problem with let and recursion
19:43amalloyrata_: he needs the mutual reference
19:43polypusamalloy: right
19:43rata_ok
19:43polypusi need something like scheme's letrec
19:44polypusbasically i have a bunch of mutually recursive functions
19:45rata_you could do somthing with currying and let, but there's probably an easier way
19:47amalloypolypus: not a very satisfying solution, but have you tried making them not mutually-recursive?
19:47polypusanyways, i'll have to ponder it some. ty for tips
19:47polypusamalloy, no that's impossible. they must be mutually recursive
19:48TimMcpolypus: You can always have them pass references to themselves around. :-P
19:49amalloypolypus: you're wrong. any mutually recursive functions can be rewritten to simple recursion
19:50rata_polypus: have you some code to play with?
19:50amalloysee http://en.wikipedia.org/wiki/Mutual_recursion#cite_note-2
19:50polypusamalloy: i know, but what i'm doing is actually quite comlicated and it would involve a macro having to analyse and rewrite user supplied functions. so i'd like to find a simple solution first
19:50polypuscomplicated
19:51amalloypolypus: can you expand into a letfn instead of directly into letfn*?
19:52polypusno because i need to say (letfn [f (let [s (setup)] (fn f [] (g s)))] ...)
19:53polypusbut you just made me think of a way
19:54rata_polypus: you can make the fn you want to call an argument of the fn and then use partial to make the actual fns
19:55amalloypolypus: (let [s (setup)] (letfn [f ...]))
19:55polypusmacro could expand to (let [fstate ... gstate ...] (letfn [(f [] ...
19:55polypusyou beat me to it, except each function has a differnt state
19:55amalloywhatever
19:55polypus?
19:56amalloythe different state stuff. implementation detail :P
19:57polypuswell, that should work, thanks for helping heat up the old cogs
20:54TimMcamalloy: I'm trying the approach where all my GUI elements are stored in a map inside a ref, instead of global defs.
20:55TimMcThe problem is that I'm getting all these reflection warnings now, since everything is behind a ref.
20:55TimMcShould I just give up on avoiding reflection?
20:57amalloyTimMc: (defn ^JPanel canvas [big-old-map] (-> @big-old-map :frame :content-panel :canvas)) or something?
20:58TimMcamalloy: You want I should create an accessor for every item? :-(
20:59amalloyTimMc: you don't have to do it that way
20:59amalloy(let [^JPanel hinted-panel unhinted-panel] (use hinted-panel))
21:00cdddrJust wondering... is there a more preferable way of doing (sort-by #(-> % meta :line) x), or is it pretty much fine?
21:00amalloycdddr: (comp :line meta)
21:01TimMcamalloy: That's what I do when I'll be using an item more than once in a method body.
21:01cdddramalloy: Ooh, thanks.
21:03cdddrAnd there's partial, too. I'm in heaven.
21:03brehautcdddr: dont forget juxt or complement
21:04TimMcamalloy: Ah, I just figured something out -- the root of the reflection problems in (.length (.name *@props*)) is actually the deref.
21:04TimMcs/*@/@*/
21:04amalloybrehaut: fnil always gets left out of the list of neat HOFs
21:05brehautamalloy: of course!
21:05brehautalso, is there a par equiv for juxt?
21:05amalloybrehaut: par?
21:05hiredman,(doc pvalues)
21:05clojurebot"([& exprs]); Returns a lazy sequence of the values of the exprs, which are evaluated in parallel"
21:06cdddrWow, juxt. Yeah, I sense some code beautifying is imminent. :)
21:06brehautbest with an example ((par inc dec) ((juxt inc dec) 1)) -> [3 -1]
21:07brehauthiredman: i think thats different, but huh awesome
21:08hiredmanright
21:08amalloybrehaut: (defn pjuxt [& fs] (fn [& args] (pmap #(apply % args) fs)))?
21:08hiredmanthere isn't a pjuxt, but there are a number of slightly similar things
21:08brehautamalloy: the parallel name is probably bad choice, its an arrows thing;
21:08brehautamalloy: its not actually 'parallel' in terms of concurrency
21:08amalloyoh partial
21:09brehautits an arrows thing
21:09amalloyyou keep saying that. pointer to what an "arrows thing" is?
21:09brehautin haskell juxt and par have operator names (***) and (&&&)
21:09hiredmanhe wants something like (map x [inc dec] [1 2]) -> (2 1)
21:09hiredmanwhere you solve for x
21:11brehaut(defn par [& fs] (fn [s] (map #(%1 %2) fs s)))
21:11brehauti think
21:13brehautthis entire conversation will (ironically) teach me not to try and do two things at once.
21:14amalloybrehaut: i've seen #(%1 %2) so many times. why isn't this in core as (defn invoke [f & args] (apply f args))?
21:14amalloythen you could (map invoke fs s)
21:14brehautthats a really good point
21:15amalloyi've used .invoke in some cases, which works for eg ->, but not for actual HOFish stuff
21:15cdddrUh, what's a good use for fnil, anyway?
21:16amalloycdddr: update-in, mostly
21:16amalloy&(update-in {:a 10} [:b] (fnil inc 0))
21:16sexpbot⟹ {:b 1, :a 10}
21:17cdddrOoh, I see.
21:27cdddrIf I have a list of strings, is there a Clojure way to look for something like "xxyzzy" anystr1 anystr1... anystrN "foobar", besides finding foobar's index, subtracting N and testing for xyzzy?
21:28pdksome maybe?
21:30cdddrHmm. Some would just work if it operated on rests, not elements. Ah, well, my clunky way works too.
21:36pdk(doc split)
21:36clojurebotPardon?
21:48amalloycdddr: glue the list together into a single string and test against #"xxyzzy.*?foobar" perhaps?
21:49cdddramalloy: Would work, except I need N as a parameter. I was just checking, really.
21:50cdddramalloy: Well, I guess I could use groups in the regexp and \w and count on the result and something else, but erh, whatever.
21:50amalloyyeah
21:52amalloycdddr: there's definitely a better lazier way though, probably involving drop-while, iterate, and nthg
21:52amalloy*nth
21:52simardI sometimes miss the calc mode in clojure, is there anything like it ? (infix notation)
21:52TimMccdddr: Basically, what you want is a regex for general structures.
21:52TimMcsimard: I'm sure you could write a macro for that.
21:53simardTimMc: hum, maybe
21:53TimMcI sure as heck don't know defmacro well enough to do that.
21:54amalloyit's been written before, for example i think Joy of Clojure has a version of it
21:55amalloycdddr: TimMc makes a good point. you could shoehorn this into a problem for fnparse with little difficulty
22:09cdddrTimMc, amalloy: Yeah, I could do that, but seeing as I'm still a bit afraid of Clojure, something based on #(take (count %) (iterate rest %)) works as well.
22:15cdddrHeh, turns out I was being retarded, and I don't need to do that. :)
22:27amalloycdddr: the most optimized code is the code you never have to write
22:31simardis there a more concise way of doing (take 10 (iterate inc 1)) ? (I mean with an infinite seq, not (range 1 10)
22:33amalloyi don't think so, and if there were it would probably be less readable and not much shorter
22:33simardk
22:33brehaut(take 10 (range)) ?
22:33simardthat would start at zero though
22:34amalloy(rest (take 10 (range))) :P
22:35simard:)
22:35amalloyer. that's wrong though. (take 10 (rest (range)))
22:36simardnice
22:38amalloy$findfn 3 5 (range 10) [3 4 5 6 7]
22:38sexpbot[]
22:38pdk,(range 1 11)
22:38clojurebot(1 2 3 4 5 6 7 8 9 10)
22:38brehaut(def natural-numbers (lazy-cat [1] (map inc natural-numbers))) (take 10 natural numbers)
22:38amalloylooks like there's no built-in for it
22:40simardbrehaut: I like you definition.. looks a lot like set theory :)
22:41brehautits all good except for the potential to blow stack ;)
22:41brehauterr heap
22:41amalloybrehaut: you are a villain! defining recursive functions is great, but recursive values...
22:42brehautamalloy: its no different to the fib trick :)
22:42amalloybrehaut: i don't approve of that in general, but the fib trick is pretty
22:42brehautyeah its a pretty niche thing
22:43simardso what should I avoid here exactly ?
22:43simardusing it ? :P
22:43brehautyes
22:43amalloynever (def some-var some-lazy-seq)
22:43simardthat's sad, why though exactly ?
22:43clojurebotdefmulti doc is (defmulti #^{:doc "docs for foo"} foo class)
22:43brehautsimard: it holds onto the head of the seq
22:44brehautwhich means it holds onto the entire sequence
22:44amalloyinstead, (defn make-some-var [] (make-some-lazy-seq))
22:44brehautif you do (nth natural-numbers 10000000)
22:44brehautyou sudden have 10000000 million objects that will never be collected
22:45simard(def primes
22:45simard (for [x (iterate inc 1) :when (prime? x)] x))
22:45simardwhat about this
22:46brehautit doesnt matter how you define it, its still an endless sequence that will never be collected
22:46simardso how would you write the primes example to make it ok ?
22:46brehautyou use an explicit cache in an atom for example
22:46brehautusing a memoize function
22:47brehautthat lets you access the cache from outside the memozised function and empty if you need your ram back
22:47brehautalternatively if you only need it for a short time
22:47brehaut(defn primes [] (for ....))
22:47brehautand then request the sequence on demand
22:49simardlike so ? (take 10 (primes))
22:49simardI fail to see the difference
22:49brehautsimard: the rule of thumb is that you never want to hold onto the head of a lazy seq
22:49brehautsimard: in that situation, primes comes into existance in your expression
22:49simardoh
22:49brehautonce you have taken your 10 primes
22:50simardI se
22:50simardsee
22:50brehautthe entire structure is able to be freed
22:50simardso the seq was held by variable 'primes'
22:50simardit's a bit late here I'm getting slow
22:50simard:)
22:55sritchie_hey all -- is there anything native that would accomplish something like (map #(%1 %2) [#(+ 5 %) #(+ 3 %)] [1 2])
22:55sritchie_essentially, applying the first item of the first vector to the rest, down the line
22:55brehautnot to my knowledge
22:57amalloyif only my (invoke) function from an hour or two ago existed already...
22:57brehautamalloy: indeed; you should propose it on the mailing list or something
23:00simardso if I do that.. (let [p (take 10 (primes))] ..), I'm safe and efficient, right ?
23:00brehautsimard: with the take sure
23:01simardI could actually do (let [p (primes)] ... ) and do some takes there
23:01brehautyou could
23:01brehautit does depend on what you do with p
23:01brehautif you just consume it inside the let, yes its safe
23:01simardyeah, well I might have to take more and more primes ;)
23:02brehautif you go and pass it to something else, then no potentially not
23:02brehautif you really need lots of primes, perhaps you should investigate non-naïve methods of generating them
23:02simardyou mean sieves
23:03simardor is that naive too
23:03brehauti understand that there is a huge range of methods
23:03sritchie_one other quick one -- if I'm writing that's a general case (say, delta-period) of a few special cases (delta-days and delta-months, for example), my two choices are to write a general function that takes special parameters and returns a special case function... or the first option in this gist:
23:03sritchie_https://gist.github.com/542ce3e9533201c3b457
23:03simardI could use fermat's little theorem
23:04simardand stuff, but right now I'm just leaning clojure (and solving euler project along the way)
23:04brehautsritchie_: how about flipping the arge order so that span is first, and then use partial
23:04sritchie_simard: here's a nice sieve algorithm, from project euer -- http://projecteuler.net/project/resources/010_7c4950764b52402fe1d29323af4e6c6f/010_overview.pdf
23:04sritchie_s/euer/euler
23:04sexpbot<sritchie_> simard: here's a nice sieve algorithm, from project euler -- http://projecteuler.net/project/resources/010_7c4950764b52402fe1d29323af4e6c6f/010_overview.pdf
23:05brehautsimard: my point is not 'use a specific primes algo' and more that if you are having performance concerns, perhaps you need to reconsider how you are representing / computing the resource in question
23:06sritchie_brehaut: so I'd have (def sixteens (partial delta-periods day 16))
23:06brehautsritchie_: i have no idea what 'day' is
23:06brehautbut i guess?
23:06sritchie_brehaut: sorry, I'm using the clj-time library --
23:06brehautok
23:06brehautthen sure
23:07sritchie_but to work with NASA's MODIS tiles, I need to calculate sixteen day periods from the first of the year
23:07sritchie_(the last one gets hacked off, of course)
23:07sritchie_or monthly periods, or eight day periods.
23:07brehautsritchie_: yeah having had another look at your code
23:07brehauti would definately swap unit and span with start and end and use partial
23:07brehautsaves having to reimplement it yourself adhoc in your second example
23:07simardhow can I clear the user namespace ?
23:07simardwithout restarting..
23:08sritchie_brehaut: is partial more efficient than returning a function?
23:08brehautsritchie_: gives you the simple definitions of your second, without sacrificing being able to just call the whole function without a semicurried form
23:08brehautsritchie_: a partial does return a function
23:08sritchie_brehaut: oh, I see what you're saying -- it leaves the option open to call delta-periods
23:09sritchie_brehaut: got it
23:17johnmn3evening
23:17johnmn3or what have you.
23:17amalloyjohnmn3: always morning in ugt
23:17johnmn3anyone in here ever tried to use egit with eclipse?
23:19johnmn3I'm trying it out. I did a push to github and it pushed more than what I wanted it to.. "/lib" folder, etc. Now I can't delete them from github!
23:19johnmn3I try to set those folders to "ignore" in eclipse and do another push, but they are still there up on github
23:19amalloyjohnmn3: delete them locally and push again. that said, why are you here instead of on #git?
23:20johnmn3amalloy, I figure I'll get heat there for using egit :/
23:20johnmn3"why don't you just use git?" they'll say
23:20johnmn3I'll try though
23:20amalloyjohnmn3: don't tell them :P
23:20brehautjohnmn3: tell them to shove it :P
23:20amalloy"i pushed more than i meant, how do i delete it"
23:20DespiteItAllYou should use Fugitive :)
23:21johnmn3but I wouldn't want to delete my local "/lib" folder. I just want it to not be pushed to github
23:21brehautamalloys solution is more politic
23:21brehautjohnmn3: i future you might want to consider putting it in your gitignore
23:21johnmn3well, I've already found the answer if I was using git from the command line
23:21johnmn3git rm
23:22johnmn3brehaut, I did. I'm not sure if I'm doing that right.. because it seems not to ignore it.. or maybe it is ignoring it, but that still doesn't delete the files on the remote side.. not sure.
23:24brehautjohnmn3: keep track of this link http://help.github.com/egit-corruption/
23:24amalloyjohnmn3: you are missing some basic git concepts. commits are "pointers" to snapshots of the whole repository; to delete some files create a commit that doesn't have them (by deleting or moving them locally). then once you've pushed that snapshot you can recreate them by whatever means are convenient
23:25brehautjohnmn3: http://wiki.eclipse.org/EGit/User_Guide that too
23:25johnmn3amalloy, so I can recommit an old branch locally, after the push, and everything in my local directory will be restored?
23:26johnmn3I have been reading those docs
23:26johnmn3the user_guide is quite informative.. that's what got me this far, at least.
23:27brehautok cool. one thing thats fundamental about git is that no matter the UI you use, you need to know what its down at least at the level of the command line tools, even if you dont use them yourself
23:27brehautand preferably lower
23:27amalloyi don't understand your question about "recommit", but you can always delete things safely. anything that's been committed, whether pushed or not, can be retrieved
23:31simardfor the sieve of eratosthenes, the algorithm requires an array of booleans, initialised to false and then set to true whenever convenient (or the other way around anyway)
23:31simardwhat's the most efficient way to do that with clojure, considering data is immutable ?
23:31brehautyou mean aside from an array of bools?
23:32simardyes
23:32simardand as fast ;)
23:32brehautvector of bools
23:32brehautif i was a prolog system you would now be greated with 'No.'
23:32simardnearly as fast ?
23:32simardno what does prolog do :P
23:33simardnow
23:33brehautdefine nearly
23:33simardhehe
23:33simardthat's harder
23:33brehautvector of bools is probably your closest thing?
23:33brehautits not close though
23:34simardany way around this ?
23:34brehautarray of bools
23:34tomojhow big does it get?
23:34amalloybrehaut: set of ints
23:34simardtomoj: N
23:35simard:D
23:35amalloysimard: ##(char 0x221e)
23:35sexpbot⟹ \∞
23:36brehautamalloy: i dont know the algo, im presuming the array of bools is used to determine if a number is in the set?
23:36simardamalloy: so removing elements from a set is efficient ?
23:36tomojoh, I remember now
23:36amalloysimard: who cares? you're adding elements to a set
23:37simardand that's efficient
23:37simardnot bad
23:37amalloybut yes, both are O(log32 N), which is effectively constant
23:37amalloybrehaut: yeah
23:37brehautamalloy: ah right, then yes definately the best option :)
23:38amalloyand this will be a lot more space-efficient for large N
23:38simardhow so ?
23:38amalloysince iirc the number of primes below N is O(log n), which is how much space you'll need
23:38simardyou mean there are much less primes than numbers ?
23:38amalloyindeed
23:39tomojI don't see how that would work
23:39simardbut these numbers require much more than one bit
23:39simardto represent
23:39simardI guess it depends on how large an N :)
23:39amalloysimard: so?
23:39amalloysimard: and a bool is using more than one bit anyway
23:40tomojdon't you add composites to the set?
23:40amalloydo you? it's been a while
23:40amalloyi guess you do
23:40johnmn3can't more than two bools to a set, right?
23:40tomojor start with all the numbers and remove them to leave the primes?
23:40simardt
23:41simardtomoj: well initially that's what I was asking, about performance
23:41simardI am now told it's equally efficient ?
23:44amalloysimard: meh. (a) like brehaut says, if you care about efficiency for huge N stop using a bad algorithm; (b) even if you were using 32 times as many bits (rather than 4 times as many) that's pretty insignificant for any number you'll care about
23:44tomojit would seem like hash sets would be much worse than arrays of bools at the sieve
23:44simardthat's pretty clear
23:45simardI just wanted to keep it.. clojury
23:45simardbetter care about efficiency right now
23:46tomojit also seems like transient vectors of bools would be faster than transient sets
23:47tomojat the cost of using all the ~O(N) memory up front instead of just eventually growing to ~O(N-log N) ?
23:48ihodesmaking the seive efficient seems like an exercise in futility. if you're just doing it for fun, that's one thing. otherwise do something like testing for pseduoprimeness to the n base for enough n's
23:49ihodeswhich is at least something that can be done concurrently, which i don't think the sieve can
23:51simardfermat's little theorem seems to be hard to compute for big pseudoprimes right ?
23:53ihodesnah, since you can use binary decomp. on the exponent, then only have O(log2 n) multiplications all mod the psuedoprime
23:54ihodesthat's vague, but no--be happy to explain in more detail if too vague
23:56simardhttp://en.wikipedia.org/wiki/Exponentiation_by_squaring
23:56simardthis ?
23:57ihodesyeah, that's what you can do once the decomp is done
23:58ihodese.g. we'd get 13 = 1 0 1 1
23:58ihodesso 13 = 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0
23:59ihodesand then use that info for expo by squaring
23:59ihodessince we have 13 in terms of a sum of powers of 2
23:59ihodesand this works quickly for numbers >>>> 13