#clojure logs

2012-07-14

00:04xeqihow you, uh... how you coming on that clojure -> elisp you working on?
00:08duck1123If I'm getting a "Don't know how to create ISeq from: clojure.lang.Symbol" in cljs, how can I find where it's happening? I don't se line numbers for any of my code from cljsbuild
00:09technomancyxeqi: compiling to elisp?
00:09technomancyxeqi: I don't think it can happen; at least until elisp gets native immutability for at least strings; hopefully for lists too.
00:10technomancymore ranting on the topic here: http://technomancy.us/159
00:11duck1123I would love to see a good editor taking all the best parts from emacs but built with clojure
00:12duck1123clooj didn't cut it
00:12technomancythe best parts from emacs are the decades worth of elisp that's accumulated around it
00:13technomancyyou could make something that works really well for editing clojure, but you'd have to give up on magit, tramp, emacsclient, etc
00:13duck1123true, but the best of those modules could be converted
00:13technomancysure; how much time you got? =)
00:14akhudekprobably not worth reinventing what already works
00:15akhudekwhat would emacs in clojure ultimately gain?
00:15akhudekI guess being able to write plugins with clojure...
00:15duck1123a more powerful lisp system at the heart of the editor
00:16technomancyit's much more likely that emacs would start running on guile and you could compile to scheme instead
00:16technomancyby which I mean not very likely, but at least possible
00:16sjls/with clojure/with all of the JVM ecosystem/
00:18eggsbyhey guys, in paredit mode how do I add a surrounding paren if I forgot one? every time I try to enter one it just puts it outside the form :/
00:18ibdknoxLight Table = Clojure!
00:19ibdknoxbut she is teh young
00:19sjlibdknox: call me when it can run through tmux ;)
00:19clojurebotexcusez-moi
00:19eggsbyI wonder if light table works in lynx...
00:19ibdknoxlol
00:20sjlthat's the main problem really -- there are lots of new generation editors popping around but none run in a command line
00:20ibdknoxwhy would they?
00:20sjlso I can't use any of the pretty things like vico, st2, etc
00:20eggsbyyes but luckily you have vi for that sjl
00:20sjleggsby: heh, yeah
00:20duck1123So will Light Table ever get an application window, or will it always be strictly browser based?
00:21technomancyibdknox: you can't run a distributed team with anything but SSH
00:21ibdknoxtechnomancy: huh?
00:21sjlibdknox: editing a file in a command line is not going away any time soon (when ssh'ed into a server, pairing through tmux, or just for those that live in tmux locally)
00:21ibdknoxduck1123: yes, for mac there already is one
00:21ibdknoxsjl: none of those things are strictly reliant on a command line
00:22sjlibdknox: well yeah, once someone implements all their replacements we can ditch it, heh
00:22andres-veggsby: M-(
00:22technomancyeven inclusion-transformation-based GUI collaborative systems (which are really hard to get right) so far only work on a document-by-document basis
00:22technomancywhich makes them useless for pairing
00:23sjlI gave money to light table because I want to see where it goes and hopefully it'll kick the other editing communities a bit and prod them into making awesome stuff too
00:23andres-veggsby: or mark a region and then: (
00:23ibdknoxtechnomancy: a document-by-document basis?
00:23duck1123I was too broke to consider donating, but I wish you well, and that hast to count for something
00:24ibdknoxtechnomancy: as in the entire environment isn't shared?
00:24technomancyibdknox: with things like gobby you have a set of docs you're subscribed to, but it doesn't coordinate focus or repl/shell buffers
00:24eggsbyah, thanks andres-v
00:24ibdknoxtechnomancy: sure, that's a limitation in the way people have though about the problem, not an inherent problem with a GUI solution
00:25ibdknoxwhich is not to say I'll be working on that any time soon, but I don't think the argument should be "x can't be run on the command line" - that's not a real solution
00:26ibdknoxit's a workaround
00:27akhudekanyone remember the days of X11 application forwarding?
00:27technomancyit's possible; it's just a lot of work and nobody's gotten it right yet
00:27technomancya lot of work for something you can already get for free
00:27ibdknoxtechnomancy: no argument there :)
00:27ibdknoxeh
00:28ibdknoxin a limited fashion yes
00:28duck1123That's how I develop. My server is in the house and I'm forwarding my emacs to my mac out in the garage
00:28ibdknoxdoesn't mean we should just say fuck it, let's not innovate anymore
00:28akhudekibdknox: completely agree, light table looks interesting
00:29ibdknoxlight table is infantile :)
00:30ibdknoxIt'll be very interesting to see where it ends up
00:30ibdknoxtons of learning to do
00:31akhudekspeaking of learning, I found the recent hacker news discussion on MVC versus finite state machines pretty interesting
00:32sjlso I'm guessing I just reimplemented something built-in, and probably did it poorly
00:33sjlhttps://github.com/sjl/caves/commit/cf1c6b442a70e7b207d2fef8d35a41da112a4c5f
00:33sjlBasically I wanted a way to give default implementations when defining a protocol
00:33sjlbut not just define the protocol for Object, because I only want the types that specifically implement the protocol to (maybe) get the default methods
00:34sjlso, for example, in my game: lots of things are going to implement Mobile, and need a can-move? function. Most of those all have the same movement rules, but occasionally some will want to override
00:36NicanI knew I read that somewhere else, is this reference to this? http://stevelosh.com/blog/2012/07/caves-of-clojure-04/#movement
00:36sjlBut I'm not entirely sure whether this pair of macros is going to blow up in my face later... so hopefully someone can confirm whether they're sane or not
00:37sjlNican: yeah. For that entry I just defined the functions when adding the Mobile aspect to the Player
00:37sjlsince at that point I only had a player and nothing else
00:37sjlbut if I wanted to add another creature that moved, I'd need to copy and paste the code
00:37sjlor add a helper function somewhere and manually type it out each time
00:39sjlthat (do (defprotocol Foo ...) (def Foo ...)) feels particularly filthy.
00:39akhudeksjl: so the only problem with using Object is that it won't throw an error if you pass it something that doesn't implement the protocol?
00:40sjlakhudek: well, no, implementing it on Object won't let me override just one of the methods -- either it gets all the defaults or none of them
00:40Nicanhttp://clojure.org/protocols "No implementations are provided"
00:40sjlNican: yeah that's what I'm trying to hack around, heh
00:41sjlakhudek: because if the type you give it implements Foospect, it uses the methods defined for the thing you're giving it. If the type *doesn't* implement Foospect at all, *then* it falls back to Object's implementations
00:41sjlI think.
00:43akhudeksjl: I bet you could get the behaviour you want with a multimethod
00:45NicanOnly interesthing things I found: http://fulldisclojure.blogspot.com/2010/08/thoughts-on-protocols.html http://stackoverflow.com/questions/10732355/clojure-defprotocol-default-implementaion-not-inlined/10732895#10732895
00:45sjlakhudek: here's the example showing the problem with Object https://www.refheap.com/paste/3606
00:47akhudekI see. If hello and world were both multimethods with default implementations, then it would be easy to override just one.
00:47sjlNican: yeah, that first link goes about halfway to where my code goes (my code uses the merging maps into extend trick, but defines the defaults as metadata on the protocol itself)
00:48sjlakhudek: yeah, but then they're not really grouped together in any special way
00:49sjlakhudek: plus, it doesn't solve the case of me wanting to distinguish "something that is Mobile, regardless of whether it uses the default impls" and "something that is not Mobile at all", right?
00:49sjlakhudek: it's too permissive, i.e. those default implementations catch too much
00:50akhudeksjl: that's true, but you could consider writing functions like "is-mobile?" that has no default implementation
00:50sjlsure... that seems a bit ugly too though
00:50akhudekI mean, it sounds like you are partly using protocols as a type checking system
00:51sjleffectively, yes
00:51akhudekwhich as I understand it, wasn't really the intention of protocols
00:51akhudekwould be nice to have an optional type system for clojure, that's for sure
00:51sjlhttps://github.com/frenchy64/typed-clojure
00:51akhudekyeah, I know of that, haven't checked on the progress though
00:52sjlseems to be active development, which is a good sign
00:52akhudekyeah, very!
00:52sjlI agree that optional static typing would be awesome
00:52sjlHaskell's typechecker would catch so much annoying crap
00:54sjlokay time to get to sleep, later
00:54akhudeknight sjl
00:54Nicanlater
02:19mindbenderI'm getting this error when trying to run `foreman start` from my project: java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: java.lang.Character
02:20mindbenderI read something similar @ https://groups.google.com/forum/?fromgroups#!topic/leiningen/59655dfCNJg. I'm using lein 2
02:21mindbendertechnomancy: any suggestions with ^-^
02:23tomojmindbender: it would help if you pasted (not in here) the full stack trace
02:23tomoj..probably
02:30mindbendertomoj: just did. Here https://gist.github.com/55acd9099967140b6605.
02:33tomojtry :source-paths ["src/app/clj"]
02:37metajackAre PersistentTreeMaps not comparable? If not, why?
02:40metajack,(compare (sorted-map) (sorted-map))
02:40clojurebot0
02:41metajack,(compare (sorted-map-by compare) (sorted-map-by compare))
02:41clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentTreeMap cannot be cast to java.lang.Comparable>
02:41tomoj,(identical? (sorted-map) (sorted-map))
02:41clojurebottrue
02:42metajackso sorted-map would fail if they weren't identical?
02:42tomoj,(let [x (sorted-map-by compare)] (compare x x))
02:43tomojyeah
02:43tomojhow would you compare sorted maps?
02:44tomojassume both the keys and values are comparable?
02:44mindbendertomoj: worked. Thanks
02:44metajackkeys are vectors of length 2 of longs, and values are keywords
02:44metajackso i believe so
02:45tomojbut if the values were not comparable, should PersistentTreeMap.compareTo throw an exception?
02:45tomojI don't know actually the answer to your question ("why?")
04:40AtKaaZhi, is there a program for 3D representation of clojure programs?
04:41AtKaaZrather than you know textual
04:47AtKaaZsome kind of 3D graph visualization of the clojure code ? possibly with editing it too
05:02TEttingerAtKaaZ, I think there was something done like this
05:02AtKaaZI would've hoped so, can you remember more precisely ?
05:03AtKaaZa name of a program
05:05AtKaaZI would think that this could be applied right after the Reader part of clojure, also I've no experience with clojure just starting to read about it
05:10AtKaaZTEttinger did you mean clojureatlas ?
05:10TEttingersorry AtKaaZ, was helping in another channel
05:10AtKaaZit's quite ok
05:10TEttingerI haven't tried clojureatlas, i think you need money for it
05:10AtKaaZyeah looks like it :/
05:10TEttingerhttps://github.com/quil/quil maybe?
05:13AtKaaZis that like clojureatlas ? it seems like it's only a 3D library for clojure?
05:13AtKaaZor something to help you draw
05:15TEttingerhttp://keminglabs.com/c2/ maybe could be handled with some macros
05:16TEttingerlynaghk: ping
05:17AtKaaZdo you mean that by using macros I can make c2 draw graphs of the clojure code ? sort of like using the clojure source code as data for c2 to draw it?
05:17AtKaaZ(which is what I want btw :D)
05:17TEttingeryep, code is data
05:18TEttingerbut you obviously need some way for it to know how to display different kinds of code
05:18AtKaaZyeah for sure
05:18AtKaaZcan clojure create code on the fly at runtime ?
05:18TEttingerI think yes
05:19AtKaaZis there a simple example of that maybe? that I could peek
05:19TEttingernot clojurescript, but clojure can
05:19AtKaaZyeah the real clojure
05:19TEttingerwell macros are "compile-time", but it compiles continuously IIRC
05:19AtKaaZc2 seems definitely something I want to look into
05:19TEttingeryou need to talk to someone who knows how to use macros, there are more qualified people here
05:20AtKaaZalright thanks so far, I'll alt-tab and try read more
05:20TEttingerlynaghk wrote C2, might be good to stay and wait for a response
05:20AtKaaZyeah I'll definitely hang in here
05:20AtKaaZbtw, what ide/editor do you use?
05:20AtKaaZsomething with colors :D
05:21TEttingeryeah, I am having a mess of a time in #coffeescript right now explaining what I hope is the right thing to someone with very poor English-language skills
05:21TEttingeroh I use Eclipse with rainbow parens via the main plugin, CCW
05:22TEttingerbut I mostly use eclipse for editing and stick to the lein2 repl
05:22TEttingerI mean Leiningen v2
05:22TEttingerthe repl is better in that version, it auto-completes and other amazing stuff
05:22AtKaaZi have eclipse and some clojure plugin cross something...
05:22TEttingeryep
05:22TEttingercounterclockwise
05:23AtKaaZyeah that one
05:23AtKaaZwhat else would I need ? rainbow parens?
05:23TEttingerit has it
05:23TEttingeror at least it should
05:23AtKaaZok
05:23TEttingerouter level is red, second nest is green, etc. (colors may have changed with newer versions)
05:23AtKaaZthat Liningen v2 is something outside eclipse?
05:24TEttingeroh yes
05:24TEttingerleiningen is the best way for managing clojure projects across OS's and IDEs
05:25TEttingerit is also one of two de facto dependency managers for clojure
05:26TEttingerhttps://github.com/technomancy/leiningen/ is the main tool, http://timpner.com/computing/clojure-importing-a-leiningen-project-into-eclipse/ is how to make your leiningen project work in eclipse (not the other way around though)
05:26AtKaaZoh i see, btw, did I notice right that eclipse doesn't auto build my clojure project (or recompile it) when I modify the source, so I cannot know right away if I made mistakes (Project->Build auto... is on)
05:26TEttingeryeah, I just go into the command line i keep open at all times and just lein run
05:26AtKaaZoh I see I need lein-eclipse
05:26TEttingerit recompiles if needed and runs
05:27TEttingeryeah, in your leiningen project file
05:27TEttingerit will automatically download it if it is a dependency or dev-dependency in your project file and you then run "lein deps"
05:28TEttingerno need to handle standalone downloads of most libs
05:29AtKaaZalright so if a project doesn't have lein-eclipse as dep in the project.clj then to make it work in eclipse correctly i need to add it as dep ?
05:30TEttingeryup
05:30TEttingerthen run lein deps and it will grab it
05:30AtKaaZcan I have two lines with ":dev-dependencies" or do I have to append them in one line ?
05:31TEttinger:dev-dependencies [[lein-eclipse "1.0.0"]]
05:31TEttingernote the nested vectors
05:32TEttinger:dev-dependencies [[lein-eclipse "1.0.0"] [some-other-thing "1.2"]]
05:32AtKaaZi understand
05:32TEttingerlines don't matter
05:32AtKaaZhowever I'm curious what would happen if :dev-dependencies appears twice in project.clj
05:32AtKaaZerror?
05:33TEttingerprobably an error when it tries to assign different values to one map entry
05:33AtKaaZit acts as a clojure keyword? the ":" ones
05:33TEttingerlike {:a "alpha" :b "beta" :a "alpha again"}
05:33TEttingeryes
05:33AtKaaZmakes sense, I like it
05:33TEttingerleiningen projects are clojure code
05:34AtKaaZso that would err then.
05:34TEttingerand once you can visualize clojure code you can visualize lein files :D
05:34AtKaaZsounds good to me
05:35AtKaaZhow do I get that prompt to run lein deps
05:38msapplerhi. It seem to be bad for transactions if I have refs which have other refs in them as pointers?
05:38AtKaaZoh i see I shouldn't be in eclipse while running lein deps
05:41msapplerI have a grid data structure (for example width and height 100) so a grid of vector 100 of vector 100 cells
05:42msapplerand each cell is a ref of a map which also holds :adjacent-cells the other cells'refs
05:47y3didoes clojure not have a distinct else-if form?
05:47TEttingery3di: maybe you want one of the other conditional macros?
05:48TEttingerhttp://clojuredocs.org/quickref/Clojure%20Core#OperationsFlow+Control
05:48AtKaaZi managed to run lein deps and lein eclipse :)
05:48TEttingerwoohoo!
05:48AtKaaZlein.bat was in my case on windows
05:48TEttingeryep
05:49TEttingerit should create the needed .project and .classpath files
05:49AtKaaZthere are only 3 colors in clojure code, is that right ?
05:49TEttingerhm?
05:49AtKaaZmaybe 4 with the parenthesis
05:49AtKaaZyeah it probably did, I had eclipse closed just for that
05:51y3diTEttinger, yea i'm not seeing any elseif forms. I guess I should just use another if statement as the last argument of the first if?
05:51TEttingeror clojuredocs.org/clojure_core/clojure.core/cond
05:58AtKaaZhow do you make it show errors in eclipse ?
05:59AtKaaZlike there's an error on line x and marked as red
06:01AtKaaZswitching to edit mode restricted does help some
06:03TEttingerAtKaaZ: you can change colors in Eclipse with Window->Preferences->Clojure
06:03TEttingerI don't know if the clojure plugin does that
06:03TEttingerthe error markers
06:04y3diparedit is sposed to handle closing parens for me right?
06:04TEttingery3di, I don't use it, but I think so yes
06:04AtKaaZy3di it does for me if I switch from unrestricted edit
06:06AtKaaZTEttinger thanks, I notice the rainbow parens are also there
06:06TEttingeryep
06:06TEttingerthey won't show in the preview thoughh
06:06y3dihm, i don;t think i've installed it right then
06:06TEttingeryou probably also want to make strings and symbols not the same color
06:07y3ditho i swear i did
06:07y3diis there a way to test whether i have a certain package installed in paredit
06:17msapplerhow can i see number of retries of my transactions
06:21y3didoes every clojure file need a namespce
06:21AtKaaZi think it's the package declaration in java
06:21AtKaaZlike*
06:25y3dinvm it was an issue with swankclojure
06:25y3dii have a notherquestion though
06:25y3dicurrently im printing a really larger number
06:25y3diand its displayed 297392^M or something like that
06:25y3dihow can I get it to print the actual number
06:26AtKaaZ^M makes me think of \n\r displayed in vim
06:26AtKaaZor was it \r\n :D
06:28AtKaaZif Chas Emerick here?
06:28AtKaaZis*
06:30y3diAtKaaZ, do you know how to print it normally?
06:31AtKaaZI don't sorry, I'm too new to clojure to even know how to code hello world:)
06:32AtKaaZbut I take it the number has more digits than 297392 ?
06:32y3diyea
06:32AtKaaZno ideas then
06:40y3dithis seems like it should be an easy problem to solve, but ive been googling and i cant find an answer
06:41AtKaaZI don't suppose you could pastebin the program code?
06:41AtKaaZor a simplified version of it:)
06:45y3dihttps://gist.github.com/3110511
06:46AtKaaZI get the same numbers without the ^M
06:47y3dioh
06:47y3dimaybe i was just being a dumbass this entire time
06:47AtKaaZlol
06:47y3dii tried entering that number as the solution, and it didn't work
06:48AtKaaZwell maybe indeed those numbers have no more digits
06:48AtKaaZbut the ^M seems to be the new line
06:49AtKaaZif I do (println (reduce sum-if-divisible (range 1 10000))) I get 23331669
06:50AtKaaZor (println (reduce + (range 1 100000))) to get 4999950000
06:50AtKaaZ(granted I've no idea what the program does)
06:52y3dinvm i figure itd out
06:53AtKaaZI like knowing what the fix is, should you wish to share it:)
06:54y3dii did (range 1 1000) instead of (range 0 1000)
06:54y3dithe problem was
06:54y3disumming up the integers between 1 and 1000 that are divisible by 3 or 5
06:55AtKaaZI eventually figured from the code, tho I am very new to clojure
06:55AtKaaZthanks
07:26evildaemonOkay, sorry but I HAD to show this to somebody.
07:26evildaemonhttp://forums.thedailywtf.com/forums/p/26379/297191.aspx#297191
07:59zoldarHello. Why do I get integer overflow when running that taking larger sequences from that collection? https://www.refheap.com/paste/3607 (that's problem #147 from 4clojure). Shouldn't clojure automatically promote to long when needed? shouldn't it be long in the first place?
08:09zoldarok, found it, had to use math operator with apostrophe: http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics
08:10zoldarseems it was going even beyond long range
08:21daniel___is there a function which will give me this? "123456789" -> ("147" "258" "369") ?
08:21daniel___like partition with interleave
08:24eagleflodaniel___: can't you compose exactly those two functions, partition and interleave, to achieve that?
08:26daniel___,(map #(apply str %) (partition 3 (apply str (apply interleave (partition 3 "123456789"))))
08:27daniel___that should achieve it i think
08:27daniel___&(map #(apply str %) (partition 3 (apply str (apply interleave (partition 3 "123456789"))))
08:27lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
08:27daniel___&(map #(apply str %) (partition 3 (apply str (apply interleave (partition 3 "123456789")))))
08:27lazybot⇒ ("147" "258" "369")
08:38wingywhat does Attempting to call unbound fn: #'user/zipmap2 mean?
08:42wingyoh nvm
08:50wingyi wonder a thing .. looking at "and" i see its calling itself
08:50wingy,(source and)
08:50wingy&(source and)
08:50lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
08:51wingyhere the source: https://gist.github.com/3111123
08:51wingycould/should the self call be replaced by recur to introduce TCO?
08:52wingyif one calls and with a large nr of arguments that would eat up stack space with the current implementation?
08:55wingyyepp .. i got a stackoverflow error when running it with a long arg list :/
09:05wingyisn't it possible to use recur instead in and macro?
09:07rfgpfeifferhas anybody got libgdx to play nicely with leiningen
09:10yonatanein (defmacro with-open... why does it call with-open recursively to resolve bindings? Couldn't it just call let with the entire bindings vector at once?
09:10yonatanehttps://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L3376
09:23yonatanewingy, since i'm new as well i can only guess, so i guess there's no recur point (e.g loop or function definition) in the and macro. Maybe having it there would cause other problems, and isn't worth the trouble since having so many arguments is bad style.
09:27wingyyonatane: a fn or loop could always be used as recur point
09:27wingyso if you call recur in a fn where there is no loop the fn is the recur point
09:28wingyi tried to use recur but an error said the argument list didnt match
09:28yonatanebut and is a macro. i'm not sure it's the same
09:28wingyit expected 0 args .. i guess the first argument list (it had multiple ones) was used and that was for no args []
09:31yonatanewell, i'm in the process of reading the clojure source. I'll tell you next year when i'm done ;)
09:31wingyperhaps you are right
09:32wingyhttps://gist.github.com/3111353
09:32wingythe fn worked but not the macro
09:33wingybut the error message is strange: java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 0 args, got: 1, compiling:(NO_SOURCE_PATH:2:30)||
09:33wingyanyway :)
09:35yonataneread this: https://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L406
09:36yonatanei can't understand it yet
09:37yonatanemaybe macroexpand it to get a hint
09:47yonatanewingy: (macroexpand '(recurme false))
09:47yonatane;=> (if false (recur false) "done")
09:54yonataneok i just understood why with-open is recursive - to match the .close to the resource and close only opened resources.
09:56wingyyonatane: are you new to clj as well?
09:56wingyjust trying to get it?
10:03yonatanei'm not totally new. there are entire parts that i don't know at all, like macros which i just now read enough to answer you
10:06yonatanebut you can do a lot without knowing much. I have a pet facebook app using lein, noir, jdbc, sandbar, ring etc.
10:13wingyyeah .. but i love to get more about programming so you can create powerful, less buggy systems than your competitors
10:13wingyfeatures added each week others could just dream of
10:15wingythis was a really good video http://blip.tv/clojure/clojure-concurrency-819147
10:15wingyall rich's videos are of high quality
10:18yonatanehave you watched the reducers video?
10:19yonatanehttp://vimeo.com/45561411
10:34wingydont think so
10:34wingyill watch it later
10:36wingypersistent data structures remind me about how git is working
10:42cshellI have a namespace (:require [google.identity :as id]) - what's the correct way to reference keywords in that namespace? :id/foo doesn't work - but :google.identity/foo does
10:50andres-vcshell: are you writing :id/foo or id/foo? (it shhould work with id/foo)
10:51cshellif i do id/foo I get a no such var
10:51cshellexceptiong
10:53andres-vcshell: I don't know that library, but what about: (require '(google [identity :as id])) and then use it like (id/foo ...)
10:53cshellit's just a custome on in there
10:53cshellthat I created
10:54cshellit's not bound to a var so I don't think i can access it without a :
11:00andres-vand what is the name of the namespace, (ns google.identity) ?
11:01inkybuttonhi everyone, i'm using js->clj on a json feed in clojurescript, but the result is a vector containing single characters of the feed string - a bug?
11:03cshellandres-v: yes, google.identity is the namespace
11:23andres-vcshell: :( I am testing a couple of simple namespaces and referencing a def from each other with require from the repl and it works but I don't know where is the difference with your code
12:04samaaronis it possible to catch reader exceptions when evaling arbitrary strings?
12:06wingywhy do we buy computers with multiple cores if softwares/games dont use them
12:07samaaronwingy: so we can play multiple games at the same time?
12:07wingy:)
12:10antoineBhello, i don't manage to use a simple defmulti example http://pastebin.com/cVMD9rt3
12:15duck1123No one would write multi-core software if there were no multi-core computers
12:18jkkramerantoineB: that should work. if you're developing interactively and changed the definition of defmulti, you may be getting bit by its defonce semantics -- i.e., re-evaling from emacs won't change the definition
12:19wingyduck1123: smart :)
12:19jkkramerantoineB: you could try (ns-unmap *ns* 'emit) from within example.a namespace, and re-eval. or just restart repl/swank
12:21wingyi dont get this one: (defn map2 [f coll] (cons (f (first coll)) (map f (rest coll)))) isn't the recursion infinite since there is no base case to get out of it?
12:23antoineBjkkramer: i use C-c C-k i see the result expected, but when i type (emit "def") in the repl i get NullPOinterException
12:24duck1123wingy: there was no lazy-seq around that ?
12:24antoineBif i eval the last expression of the file it works (see the last expression in the paste)
12:25wingyduck1123: its just an example code how map works .. nothing tied to clj
12:25jkkramerantoineB: is your repl in the right namespace and/or requiring the right stuff?
12:25antoineBno
12:25wingybut it works .. i just dont get how it gets out of the recursion
12:26jkkramerwingy: the defn you pasted works, because it's not recursive: map2 called regular map
12:26yonatanewingy: i don't see a recursion
12:26wingyoh
12:26wingyyeah typo
12:26zdennisI've got two functions in my point namespace, but I always receive the warnings that I am overriding clojure-core classes, but when I require them I am excluding them. could any one help me understand what I'm doing wrong? https://gist.github.com/89d7095f77f1b7d96801
12:27zdennis*err. not core clases, core functions
12:27wingyok it didnt work
12:27wingy(defn map2 [f coll] (cons (f (first coll)) (map2 f (rest coll)))) fails
12:27wingynvm
12:27wingyan example from http://vimeo.com/45561411
12:30wingywii .. starting to get recursion .. you have to have a base case, this works: (defn map2 [f coll] (if (empty? coll) '() (cons (f (first coll)) (map2 f (rest coll)))))
12:30zdennisthe core functions I am overriding are max/min
12:32zdennisah… I think I needed (:refer-clojure :exclude [max min]) in my point.clj ns
12:32zdennisis that bad form to define functions that share names and then to exclude core functions?
12:32gfrederickszdennis: yessir
12:32gfrederickszdennis: nossir
12:33zdennisgratzi @gfredericks
12:35duck1123Does anyone know about waltz? I'm trying to find out if it's possible to define the machine with an initial state, or if I have to just set it afterwards
13:13cshellandres
13:13antoineB(case (class "aa") clojure.lang.PersistentList "p" java.lang.String "s" "A")
13:13antoineBwhat is wrong with my switch?
13:16AWizzArdantoineB: what result do you expect?
13:17antoineB"s"
13:18antoineBjava.lang.String isn't a symbol
13:18AWizzArdcase is a macro
13:19antoineBAWizzArd: see the doc for availble type you can check on
13:19antoineBthey talk about "(Clojure) composites thereof" i don't know what it is
13:21antoineB(case (str (class "aa")) "class clojure.lang.PersistentList" "p" "class java.lang.String" "s" "A")
13:21antoineBthis work
13:21antoineBnotice the "class ..."
13:22gfredericks,(doc case)
13:22gfredericks&(doc case)
13:22lazybot⇒ "Macro ([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are not evaluated. They must be compile-time literals, and ne... https://www.refheap.com/paste/3608
13:22AWizzArdIt must be constants.
13:23gfredericksantoineB: so apparently classes aren't in the set of constants you can use
13:23AWizzArdBut fortunately there are mechanisms to do what you want.
13:23antoineBi hope
13:23gfrederickslike multimethods
13:23antoineBmy solution is very elegant
13:24gfredericksor cond
13:24AWizzArdYou can try condp for example
13:24antoineBin fact i use this "case" in a multi method context
13:25wingydoes anyone know why this doesnt return 6
13:25wingy,(-> 1 inc (partial * 3))
13:25AWizzArd,(condp instance? "aa" clojure.lang.PersistentList "p" java.lang.String "s")
13:25cshellit returns a function
13:26AWizzArdwingy: (partial (inc 1) * 3) is what you got
13:26gfrederickswingy: ##(-> 1 inc ((partial * 3)))
13:26lazybot⇒ 6
13:26gfredericksor ##(-> 1 inc (* 3))
13:26lazybot⇒ 6
13:27wingyi thought that the args should return a fn
13:27gfredericks$google fogus thrush
13:27lazybot[fogus: Thrush in Clojure – Redux] http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/
13:27wingyinc returns a fn
13:27wingywhy shouldn't partial?
13:27gfrederickswingy: ^ that's a good read on what's going on
13:27AWizzArdinc should return a number
13:27cshellinc returns a function?
13:27cshell,(inc 1)
13:27wingyi mean inc alone
13:27AWizzArdNot clojure.core.inc
13:27cshellinc is a function
13:27wingyso i guess the last one should run the function?
13:28AWizzArd(-> 1 inc) ==> (inc 1) ==> 2
13:28gfrederickswingy: -> is a macro that works syntactically; it doesn't know if something is a function or not
13:29AWizzArd-> takes the first argument and puts it on position two in the following list
13:29AWizzArd(-> 1) take the one and return it
13:29AWizzArd(-> 1 inc) take the one and “put it into inc”
13:30AWizzArd(-> 1 inc dec) take the one and “put it into inc”. Take that result again and put it into dec.
13:30AWizzArd(-> 1 inc dec (* 10) ) take the one and “put it into inc”. Take that result again and put it into dec. The result from that put as first arg into (* 10), making it (* 1 10)
13:31gfredericks,(macroexpand '(-> 1 inc dec (* 10)))
13:31gfredericks&(macroexpand '(-> 1 inc dec (* 10)))
13:31lazybot⇒ (* (clojure.core/-> (clojure.core/-> 1 inc) dec) 10)
13:31gfredericks&(macroexpand '(-> 1 inc dec (partial * 10)))
13:31lazybot⇒ (partial (clojure.core/-> (clojure.core/-> 1 inc) dec) * 10)
13:32gfredericksoh those are not too helpful
13:32gfredericks&(clojure.walk/macroexpand-all '(-> 1 inc dec (* 10)))
13:32lazybot⇒ (* (dec (inc 1)) 10)
13:32gfredericks&(clojure.walk/macroexpand-all '(-> 1 inc dec (partial * 10)))
13:32lazybot⇒ (partial (dec (inc 1)) * 10)
13:32wingyi see
13:35wingymakes more sense now that i know -> is a macro
13:36wingyit gives a total new syntax
13:36wingyso if the 2nd form is a function it just wraps that one around () so it will be called with the value
13:36wingy(fn1 val)
13:36gfredericks$google github swiss-arrows
13:36lazybot[rplevy/swiss-arrows · GitHub] https://github.com/rplevy/swiss-arrows
13:37AWizzArdwingy: you can think of it as „bash pipe”
13:37wingybut if its already in a run form (fn1 arg2) it will put the val into it as the 1st arg (fn1 val arg2)
13:37wingyi thought that every fn should return itself but that wasnt the case
13:37AWizzArdtake a thing t1 and pass it into the next function to get a thing t2. Take t2 and pass it into the next function to get thing t3. Take t3 and pass it into the next function, etc…
13:38AWizzArdA fn does typically not return itself.
13:38wingybut it could in this case with inc
13:38AWizzArdThe symbol clojure.core.inc when evaled returns a function.
13:38AWizzArdinc is a symbol
13:38wingyi know
13:38AWizzArdno a function
13:39AWizzArdnot
13:39wingythis was the confusion: (-> 1 inc (inc) ((partial * 3)))
13:39AWizzArdyes
13:39wingydiff between inc and (inc) .. they both work
13:39bprdoes anyone know how feature-ful nrepl/emacs is compared to slime/swank?
13:39gfredericksthat's because -> supports both
13:39wingybut if you have args like in partial you have to wrap it around ()
13:39gfredericksit converts inc into (inc) before doing anything else
13:39wingyso it will know its one fn with args
13:39wingyyea
13:39AWizzArdYes, the -> macro is nice and allows you to omit the parens, if the fn takes only one arg.
13:40wingyconfusion gone :)
13:41gfredericks&((apply comp (repeat 10000 inc)) 1)
13:41lazybot⇒ 10001
13:41gfrederickslazybot: move this pile of bricks to the other side of the yard
13:41gnarmismaybe it needs sudo in there?
13:42gfredericks&(format "%s is not in the sudoers file. This incident will be reported." "gfredericks")
13:42lazybot⇒ "gfredericks is not in the sudoers file. This incident will be reported."
13:42gnarmishahaha
13:49wingyreducers are really hard to get
13:50aphyrResurrecting a very old question: does anyone know why clojure.lang.Var is *not* backed by an InheritableThreadLocal?
13:51aphyrSeems like in almost every case where using dynamic bindings, I really want bound-fn/future's ability to carry the bindings onto threads I might spawn.
13:55clojure-newcomerhey guys, its a bit quiet over in the #datomic channel, can anyone help with an ec2 DDB query ?
14:04wingydata structures imply the collections and not the literals/symbols?
14:05cshellwingy: what do you mean?
14:07wingywhen someone says data structure he means a collection (either a list, vector, map or set) and not a literal (string, boolean, number, keyword and character) right?
14:12uvtcwingy: "data structure" would also mean collection of collection ...
14:12wingyuvtc: right but never literals right?
14:13uvtcwingy: I think of strings, booleans, numbers, keywords, etc. as "scalars".
14:13wingyliterls is another word for scalars?
14:14uvtcwingy: note that `{:a 1 :b 2}` is a map literal.
14:14wingyi see
14:14wingythen the word scalar is better to use i think
14:14wingyscalar vs data structures
14:14uvtcwingy: As opposed to (hash-map :a 1 :b 2), which is not a map literal.
14:16daniel___how can i calculate a sequence 0000 0001 0010 0100 1000 0011 0101... all possibilities
14:17uvtcwingy: Heh. It's difficult for me to put into words the definition of "literal". It means, "You can tell what this is by looking at it --- it literally is what I just typed" :)
14:17daniel___i suppose its binary increments, which i can just convert to a string
14:17gfredericksdaniel___: ##(let [bs [0 1]] (for [a bs b bs c bs d bs] (str a b c d))) could work
14:17lazybot⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111")
14:18wingyuvtc: yeah thats a good perspective
14:18uvtc,(for [i (range 2) j (range 2) k (range 2) m (range 2)] (str i j k m))
14:19uvtc,(println (for [i (range 2) j (range 2) k (range 2) m (range 2)] (str i j k m)))
14:19uvtc&(for [i (range 2) j (range 2) k (range 2) m (range 2)] (str i j k m))
14:19lazybot⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111")
14:19daniel___oh lovely
14:20uvtcWhoops. Mine was the same as gfredericks , only I kept repeating myself. :)
14:20uvtcclojurebot: are you there?
14:20uvtclazybot: what happened to clojurebot?
14:20lazybotIt's AWWWW RIGHT!
14:22gfredericks&(for [i (range 16)] (subs 1 (Long/toString (+ 16 i) 2)))
14:22lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
14:22gfredericks&(for [i (range 16)] (subs (Long/toString (+ 16 i) 2) 1))
14:22daniel___java.lang.Long/toBinaryString?
14:22lazybot⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111")
14:22gfredericksI win
14:22uvtckahnnnnnn!
14:23hyPiRion##(for [i (range 16)] (clojure.pprint/cl-format nil "~4,'0B" i))
14:23lazybot⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111")
14:24lazybot⇒ this syntax nil
14:24gfredericksis it worth going to the conj if I'm also going to strange loop?
14:26daniel___the number of permutations when everything is distinct is factorial
14:26daniel___in this case, what is it?
14:27hyPiRionexponential
14:27gfredericks2^n
14:27gfredericksor m^n
14:27uvtc&(for [j (range 16)] (apply str (for [i (range 4)] (rand-int 2))))
14:27lazybotExecution Timed Out!
14:28uvtcWas going to joke, "close enough". Odd that it timed out though...
14:29hyPiRionuvtc: Clojail is weird like that.
14:29uvtc&(for [j (range 16)] (apply str (for [i (range 4)] (rand-int 2))))
14:29lazybotExecution Timed Out!
14:30uvtchyPiRion: Ok. :)
14:31hyPiRion&(for [i (range 16)] (apply str (repeatedly 4 #(rand-int 2))))
14:31lazybot⇒ ("0000" "1000" "0101" "0101" "1100" "1011" "0101" "1100" "1111" "0101" "1110" "1000" "0011" "0010" "0111" "0011")
14:31hyPiRionIt's something about the for comprehension I believe.
14:33gfredericks&(frequencies (repeatedly 16 (rand-int 16)))
14:33uvtcAh. `repeatedly`. Thanks, hyPiRion.
14:33lazybotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
14:33gfredericks&(frequencies (repeatedly 16 #(rand-int 16)))
14:33lazybot⇒ {2 1, 3 2, 4 3, 7 1, 8 3, 11 2, 12 1, 13 1, 15 2}
14:50daniel___what are the alternatives to associative arrays? i suppose nested vectors is one way, what about if you want a non integer key?
14:50daniel___a map of lists?
14:50daniel___a map of vectors*?
14:52gfredericksvectors are somewhat like maps with keys of (range n); so in that sense maps will always be more flexible. I don't quite understand the details of your question.
14:52gfredericksI must not know what an associative array is.
14:53cshellI'm confused too
14:56yonataneIs there a use-case for using protocols when java interop is not needed?
14:57gfredericksyes
14:58gfredericksactually I don't think protocols have very much at all to do with interop
14:58gfredericksonly that you can extend a protocol to a java type
15:02tmundal(+ 1 2)
15:02gfredericks3
15:02tmundal:D
15:03gfredericks:D
15:05yonatanegredericks: do you have an example?
15:06gfrederickssorta
15:06yonataneCan I define a protocol with common function names like doseq, and implement it in some random crazy way, and so existing code would behave crazily when passed my implementation?
15:07tmundal(loop [] (drink-more-beer) (recur))
15:07gfredericksthe function names that belong to your protocol are vars in the namespace you define them in. So (ns foo.bar) (defprotocol FooBar (doseq [x y])) will just create foo.bar/doseq, which is not the same as clojure.core/doseq
15:08gfredericksso...no
15:08yonataneso an unqualified doseq outside my namespace will behave normally
15:08gfredericksyep
15:08yonatanethat's no fun
15:09gfredericksyou can redefine doseq directly if you just really want clojure to crash
15:09aphyrdaniel___: Why can't you use a map?
15:09gfredericksbut since it's a macro you'll only effect code that's loaded after you redefine it
15:09yonataneoh, doesn't matter. any other function then.
15:10bprhey, i'm using lein2 and i want to do lein2 new foo and have the files/directories dumped into my current dir. I used to be able to do lein new foo . with v1.7.0, is there a way to do this in lein2?
15:10gfredericksyonatane: with-redefs will let you redefine stuff temporarily
15:10gfredericksyonatane: the only protocol example I care to bother dredging up is https://github.com/fredericksgary/ranguages/blob/master/src/ranguages/core.clj#L10
15:10bpri clearly could just use a tmp dir and copy everything over, but why take the extra step if i don't have to :)
15:12daniel___sorry, something came up
15:12daniel___aphyr: i can use a map :)
15:13uvtcbpr: I think `lein new foo` has always created the "foo" directory.
15:13uvtcbpr: At least, I've never seen it do anything different from that.
15:14yonatanegfredericks: if you've done it without a protocol, how would it be worse?
15:14daniel___im used to thinking of everything in loops and arrays
15:15gfredericksyonatane: well you can't really use types/records without protocols; so I would've been using raw maps, and my single-location implementation would have a giant cond checking the types of the maps
15:15gfredericksit gives you the interface/implementation separation that a lot of people think is clean but I'm not smart enough to argue convincingly for
15:17yonatanei'm coming for OO, and had the impression that a functional language does not need OO features
15:17yonatane*coming from
15:18gfrederickssome people find some of the features useful. I don't think it's expected that you use protocols/records/types for most application-level stuff
15:18gfredericksthey were first introduced to make clojure-in-clojure feasible
15:18gfrederickscertainly clojurescript makes heavy use of them in its foundational stuff
15:18gfredericksas does core.logic
15:19bpruvtc: "lein new foo ." used to put the new files in the current dir
15:19gfredericksI think for regular business data maps are still recommended
15:19bpruvtc: this is because in v1.7.0 the third parameter was an optional one used to specify the directory to put the new project
15:19uvtcbpr: Oh. Didn't know that. Thanks.
15:20bpryup
15:20cshellhas anyone ever seen the IllegalArgumentException: Can't define method not in interfaces. when used in protocols?
15:22yonatanegfredericks: how about when you want a common persistency protocol, where you don't know if it will go to mysql or to text files, would you use the protocol mechanism?
15:22gfrederickscshell: you're just defining a protocol and don't have any types/records yet?
15:23gfredericksyonatane: that sounds reasonable
15:23gfredericksyonatane: I think I've done that before
15:23cshellI have a defrecord for the protocol
15:23cshellimplementation
15:23yonatanegfredericks: any other idiomatic way to do it?
15:23cshellI've done a lein clean
15:23gfredericksyonatane: not really
15:23cshelli found something that said to disable don't-recompile-if-same-source but I don't know where that is
15:24gfredericksyonatane: protocols are also great when you want something to be extensible
15:24daniel___ach, earlier i meant multidimensional arrays, not associative arrays
15:24gfredericksdaniel___: I think I've used flat maps and nested vectors in different contexts depending on exactly what sort of interface I wanted
15:24cshellgfredericks: it's the same problem as listed here: http://bit.ly/MpC3hL
15:25gfredericksah ha
15:25gfredericksbut this is presumably fixed and you're still having the problem?
15:25cshellyep
15:26cshellalthough a clean and repl restart isn't working
15:26cshellso I can't get past it
15:26cshellwhere else would lein put the compiled protocol def?
15:26gfrederickscshell: what's your protocol def look like?
15:26daniel___gfredericks: ok
15:26yonatanegfredericks: i recently asked how to implement an api that requires a client token throughout, and i didn't want all the functions to have the token as a parameter.
15:27cshellgfredericks: https://www.refheap.com/paste/3609
15:27daniel___im trying to write a chess engine, and generate a table of file attacks: http://chessprogramming.wikispaces.com/Rotated+Bitboards (file_attacks[R][10011011])
15:27daniel___in this case, i suppose i want a vector of maps
15:28cshellit's complaingin about the update! method, that's what I just added today
15:28gfredericksyonatane: ...so you're asking the question again?
15:28daniel___[{:10010011 <attacks>}{:10100000 <attacks>}..]
15:28cshellyonatane: you can create a closure with the token bound
15:28daniel___[{:10010011 <attacks> :10100000 <attacks>}{}{}..] in fact
15:28yonatanegfredericks: Yeah, in light of records :). maybe a record with the token as ctor argument
15:29gfredericksdaniel___: what does each map signify?
15:29daniel___the ocupancy on a given file or rank
15:29gfredericksyonatane: I think that kind of thing is normally handled with dynamic vars
15:29daniel___the key signifies that, and it maps to a bitboard with the possible attack squares
15:29yonatanecshell: yeah, but if i have several functions, do i create each one, or a map of functions, or some other thing?
15:29gfredericksdaniel___: so why do you have multiple maps instead of one?
15:30daniel___(file_attacks[R][10011011]) the first dimension is the square that a rook is on for example, and inside that element i have a map of all the occupancies
15:30gfrederickscshell: looks like the sig for update! doesn't match
15:31cshellgfredericks: omg, that's it
15:31cshellthanks g
15:31cshell*slaps forehead*
15:31cshellyonatane: what I do is make the protocol with the methods and parameters (but not the token)
15:31cshellthen I create a deftype which has a constructor that has the token
15:32daniel___so it will be 8 maps in a vector i suppose [{}{}{}{}{}{}{}{}]
15:32daniel___the index signifying the square that the attacking piece is on
15:32daniel___and then inside each map, i have an occupancy mapped to an attack board
15:33gfrederickscshell: doesn't that mean you have to pass around a type instead of a token?
15:33daniel___dont have a clue how im going to generate such a structure
15:33gfredericksdaniel___: why 8 maps instead of 64 then?
15:34gfrederickssince there are 64 squares
15:34daniel___because im just concentrating on a rank or file
15:34cshellI just call a factory method when I need the functionality and then pass that in as the this parameter on the protocols
15:34gfrederickscshell: right. So you have to pass in something, whether the type or the token; I can't see why that's any easier
15:34daniel___the attacks are going to be the same for each rank or file, given the same occupancy
15:36yonatanegfredericks: I should read about bindings more. I asked before about a case where i have multiple tokens to handle. Maybe I can change the binding of the token var for each one. I wonder how it handles concurrency.
15:36cshellyonatane: dynamic vars can get thread local bindings - so that helps with concurrency
15:36gfredericksyonatane: dynamic vars have thread-local values
15:36yonatanethat's great
15:37cshellgfredericks: Hmm, that's a good poing gfredicks - I always did it because it took that off of the interface - the this has to be there anyway
15:37cshellgfredericks: and maybe I have a stubbed implementation or something which doesn't need the token to return values
15:37yonataneso I can call a bunch of functions with a specific value of the var.
15:37yonatanesetting the var only once
15:37gfredericksyonatane: ofter the dynamic var is accompanied by a with-foo macro that sets it for you
15:38gfrederickss/ofter/often/
15:38gfredericksyonatane: e.g., clojure.whatsit.jdbc's with-connection
15:38yonatanegfredericks: exactly!
15:39gfredericksit's a mildly controversial tactic since it kills function purity. but you can only put up with so much ceremony in the name of purity
15:39gfredericksalso if you use a monad people stop being your friend
15:39cshellhaha
15:40gfrederickson the other hand, some times you can do similar things quite succinctly using ->
15:42uvtcRegarding the url-shortener example in the "Clojure Programming" book (Oreilly), (page 537),
15:42uvtc~CPOR
15:42uvtcit uses a Ref to refer to its `mappings` data structure (mappings of string id's to long urls).
15:42uvtcWhy does it use a Ref? My understanding is that refs are for when you want to coordinate changes to multiple refs that are connected or interdependent in some way. But here we've only got *one* ref; the mapping. It doesn't need to coordinate with any other data structures.
15:42uvtcWhy not instead use an atom here?
15:44gfredericksI *THINK* that there is a use case for a single ref which is
15:44gfredericksyou want to read it, update it based on what you read, and also do something else with the read value
15:44gfrederickswhere on earth did I see this
15:44gfredericksit was in one of hiredman's codez
15:45gfredericksuvtc: imagine you wanted to use an atom to implement a queue
15:45gfredericksand have worker threads pulling stuff off to work on
15:45gfredericksthink about how (defn pull-thing-off-queue [] ...) would be defined
15:46uvtcAh. That's what's going on in the example I noted. You're checking the contents of `mappings`, and if a given value isn't yet in it, you assoc it.
15:46gfrederickswell that sounds doable actually
15:46gfrederickswith an atom
15:46gfredericksunless you're trying to return info on whether it was there or not
15:47uvtcThe check to see what the mapping contains, and also the alteration, are both inside a dosync.
15:47gfredericks(swap! a #(if (% k) % (assoc % k v)))
15:47gfredericksI'm not sure why ^ that wouldn't work
15:48uvtcgfredericks: Will think on that. Thanks.
15:48gfredericksnext time cemerick is around ask him what on earth
15:49uvtcWill do.
15:50wingywhat is the :test meta doing in the meta data of a function?
15:50gfrederickspointing to a test?
15:51wingywhe is it executed?
15:51wingywhen
15:51wingymanually by user?
15:52gfredericksor by any framework that looks for that sort of thing
15:52gfredericksI dunno which ones do
15:52wingyok
15:56dgrnbrgis it possible to have a type hint for an array of IFns?
15:57dgrnbrgI tried ^"[Lclojure.lang.IFn", but it said classnotfound
15:57gfredericksI don't remember the syntax but I'm sure it is
15:57dgrnbrgi can't find it anywhere on google
15:57dgrnbrgi found the syntax for primitive arrays
15:58gfredericks$google clojure array type-hints
15:58lazybot[Array Type Hints in Clojure] http://asymmetrical-view.com/2009/07/02/clojure-primitive-arrays.html
15:58dgrnbrgthat post only talk about primitive arrays
15:58gfredericksit says primitive but it looks like he has an example with String
15:59dnolen^"[Lclojure.lang.IFn;"
15:59daniel___with a vector like [\X \X \O \X \O \O \X \X \X], how would i iterate over it and return two sets X #{0 1 3 6 7 8} & O #{2 4 5} with the indexes?
15:59dnolen,(type (make-array clojure.lang.IFn 2))
16:00dgrnbrgoh, semicolon
16:00dgrnbrgi missed that
16:00gfredericks&(doc map-indexed)
16:00lazybot⇒ "([f coll]); Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thus function f should accept 2 arguments, index and item."
16:00dgrnbrghooray!
16:00daniel___map-indexed, thats the one
16:00dgrnbrgit was the semicolon
16:03dgrnbrgi just got a job writing clojure all day
16:03dgrnbrgit's pretty awesome
16:03gfredericksthat sounds pretty awesome
16:05dgrnbrgi get to integrate things like storm, cascalog, leiningen, and incanter with our java code base
16:07eggsbysounds like a lot of work
16:07eggsbybut congrats :)
16:10uvtcdgrnbrg: nice. New job, or current one switching you to working on Clojure stuff?
16:10dgrnbrgit's actually the same job
16:10dgrnbrgi was previously working on our in-house distributed analysis framework
16:10dgrnbrgi made the case that clojure brings a lot to the table
16:11dgrnbrgso we're building an experimental system in clojure to iterate faster and explore the possibilities
16:11uvtcHooo doggie. :)
16:11dgrnbrgthat's built on our analysis framework
16:11dgrnbrgit's pretty awesome
16:11dgrnbrgwe write emacs plugins, compilers, and think about new modes of interaction
16:11dgrnbrglike light table, but in our domain
16:13eggsbynice
16:13eggsbyI'm working on some analytics/continuous delivery stuff in clj for my work, a lot more fun than maintaining old groovy and spring mvc apps...
16:14antoineBis there a function to get the number of a list ? example: (get 3 '(a b c d)) => c
16:15uvtcantihero: `nth`
16:15dnolenantoineB: nth
16:15dgrnbrg,(nth 2 '(a b c d))
16:15uvtcWhoops. Sorry antihero --- premature autocomplete. :)
16:15dgrnbrg&1
16:15lazybot⇒ 1
16:15antoineBthanks
16:15dgrnbrg&(nth 2 '(a b c d))
16:15lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number
16:15dgrnbrg&(nth '(a b c d) 2)
16:15lazybot⇒ c
16:20antoineBa function for the size or lenght of a list?
16:21eggsbycount
16:21piotrantoineB: you should have a look at http://clojure.org/cheatsheet
16:21eggsbyyou don't use get and count as often as you'd think antoineB
16:22gfredericks$findfn [1 2 3 40] 4
16:22lazybot[clojure.core/count]
16:22eggsbythey aren't used as often as .length and someArray[nth]
16:22gfredericks,(.length '(a b c d))
16:22gfredericks&(.length '(a b c d))
16:22lazybotjava.lang.IllegalArgumentException: No matching field found: length for class clojure.lang.PersistentList
16:23antoineBwhat is the difference with .length ?
16:23eggsbyrather, as often as .length and array accessors in java/imperitive langs :p
16:23eggsbyimperative even
16:23antoineBok
16:23wingywhen creating a var with def .. is that var called a variable?
16:23wingyor just a var
16:24gfredericks&(.length '[a b c d])
16:24lazybot⇒ 4
16:24gfrederickswingy: a var
16:24wingythere are no variables in clj?
16:24gfredericksnot local variables
16:24wingywhat is a global variable?
16:25wingyatom, ref, var and agent?
16:25gfrederickswell the changey things that exist are
16:25aphyrgfredericks: what about let frames?
16:25uvtcgfredericks: it seems to me that there *are* variables in Clojure, except that they're not called "variables" per se, and you don't vary them in-place, but rather modify them to refer to different values when you need to change them.
16:25eggsbyya, I like calling them values instead of variables
16:25gfredericksuvtc: how do you do int x = 12; x = 13;?
16:26antoineB(def x 12)
16:26uvtcgfredericks: I suppose create an atom with the value 12, then later swap in 13 for it.
16:26eggsbylol, (let [x 12] (let x [13] ;; do stuff))
16:26eggsbyit's beautiful
16:26gfrederickseggsby: those are two different x's
16:26gfredericksthe first one doesn't change
16:26eggsbyright
16:26gfredericksso clojure has explicit reference types
16:27gfredericksand the java types can have mutable fields
16:27wingy(i think i shall just forget the word variable)
16:27gfredericksbut you cannot create a locally-scoped name that points to one thing and then change it to point to another thing
16:27wingyreferences are bound to values if you wanna simulate changing states/values
16:28eggsbyya
16:28eggsbywell you were right stuff stuff like 'atom' is closer to a var wingy
16:28daniel___clojure makes my brain hurt
16:28gfredericksruby makes my fingers hurt
16:29wingyanother question regarding a comment i read in the reference regaring descructuring "There are similar :strs and :syms directives for matching string and symbol keys."
16:29eggsbyya
16:29uvtcdaniel___: feel the burn. Only a few ... more ... reps.
16:29eggsbyso a hashmap can have anything as its key wingy
16:29eggsbylike strings or symbols
16:29eggsby{"myString" 1, 'mySym 2}
16:29antoineBperl makes me confuse
16:29eggsbyyou could get out strings with :strs or symbs, similar to how you would get :keywords out with :keys
16:30wingyeggsby: ah .. i think i know what the problem was with :syms .. i didnt quote
16:30wingyyepp that was the problem
16:30wingyeggsby: thx
16:30uvtcgfredericks: But do you see what I mean? I think it's confusing to say that Clojure doesn't have variables. Seems more accurate to say that it has no local variables, but it's got "global variables" --- with the caveat that you can't modify them in-place; you instead change which value they refer to.
16:31dgrnbrgdoes anyone know how to get lein to stop saying "Could not find artifact org.clojure:clojure:pom:1.+ in central (http://repo1.maven.org/maven2)&quot; ...
16:31wingyclojure makes my eyes, heart and brain happy
16:31antoineBclojure have name wich refer to an object
16:31uvtcantoineB: funny thing about Perl though, it seems to have at least one thing in common with Clojure: practicality.
16:31wingyi have become a happier person overall since 2 weeks ago
16:32wingythats weird a lang can have that effect on you
16:32gfredericksuvtc: the question doesn't mean too much until you rigorously define variable. I think the concept I was going for is what most people mean when asking such a question.
16:32akhudekuvtc: you wouldn't say that if you've ever tried to build a relatively large code base in perl that remotely needs nice data structures
16:33uvtcakhudek: don't worry --- I stop the comparison at that. :)
16:33eggsbyuvtc: it's fine so long as you acknowledge that global mutable state isn't bad so long as it isn't concurrently muteable, which clj enforces
16:34eggsbys/mutea/muta
16:34wingyoff topic question: is there anyone here from Stockholm?
16:35gfrederickseggsby: it can still be bad to the extent that it keeps you from using mostly pure functions
16:35antoineBuvtc: in perl you loose so many time to learn the many syntaxicaly ways of doing something instead of learning the different semantics ways
16:35eggsbygfredericks: I haven't heard a compelling argument about why pure is better than impure, is there anything I should read? :p
16:36Squee-DSide effects are the hardest things to debug?
16:36gfredericksbam
16:36wingyeggsby: easier to test since all the thing a pure fn need is passed as args
16:36gfredericksyeah, for debugging and testing, pure functions are huge
16:36Squee-Dand im new to lisp, but thats what 'compels' me to learn it.
16:38wingyeggsby: i think it's also better for concurrency since now you can run that fn not caring about place and time it is run
16:38eggsbyya but i'm not going to start using the state monad in exchange for an atom
16:38gfredericksso there's this piece of code I wrote that's in production, but I'm not actively working on it. The ops guy says it crashes, and is crashing in a part of the code that is pure functions. So rather than doing all sorts of poking around on production, I just have him send me a log of the input to the pure part of the code, and I have a fully reproducible failing test in 2 seconds.
16:38Squee-DOtherwise you may as well be using scala :D
16:38eggsbyI don't see practical benefit, your transformation functions can still be pure functions...
16:38wingyfns dependent on global states is spaghetti
16:38wingybad abstractions
16:38gfrederickseggsby: I didn't say all pure, I said mostly pure
16:39Squee-Dyou cant do all pure
16:39daniel___im hating this function but im struggling to come up with something better: https://gist.github.com/3113254
16:39Squee-Dlol
16:39daniel___can anyone think of a clever way of detecting a winner (and even better, detecting the player \X or \O) in a game of tictactoe
16:40daniel___the board is a vector of length 9: [\space \X \space \O ... ]
16:40antoineBi never understand the monad stuff
16:41antoineBis it a way to force the programmer to test all the possble case?
16:41antoineBlike Option[] in scala?
16:41eggsbyit's just a way to capture the entire notion of a computation antoineB
16:41gfredericksdaniel___: (def in-a-rows (let [idx (partition 3 (range 9))] idx (map list idx) [[0 4 8] [2 4 6]]))
16:41gfredericks^ then use that
16:42gfredericksantoineB: just figuring out what the possible cases are is rather difficult in a dynamic language
16:42antoineBwhat is "the entire notion of a computation"?
16:42gfredericksqubits!
16:43eggsbyantoineB: http://www.scribd.com/doc/72134705/Comprehending-Monads can explain monads far better than I ever could
16:44daniel___gfredericks: not sure what that does exactly
16:44daniel___,(def in-a-rows (let [idx (partition 3 (range 9))] idx (map list idx) [[0 4 8] [2 4 6]]))
16:44daniel___,in-a-rows
16:45gfredericks&(let [idx (partition 3 (range 9))] idx (map list
16:45gfredericks idx) [[0 4 8] [2 4 6]])
16:45lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
16:45gfredericks&(let [idx (partition 3 (range 9))] idx (map list idx) [[0 4 8] [2 4 6]])
16:45lazybot⇒ [[0 4 8] [2 4 6]]
16:45gfredericksmrrrrmrmmm
16:45gfredericksah I forgot the concat
16:45gfredericks&(let [idx (partition 3 (range 9))] (concat idx (map list idx) [[0 4 8] [2 4 6]]))
16:45lazybot⇒ ((0 1 2) (3 4 5) (6 7 8) ((0 1 2)) ((3 4 5)) ((6 7 8)) [0 4 8] [2 4 6])
16:45antoineBeggsby: espected on irc the font isn't so uggly :)
16:45gfredericksman I really screwed that up
16:45daniel___:/
16:46gfredericks&(let [idx (partition 3 (range 9))] (concat idx (apply map list idx) [[0 4 8] [2 4 6]]))
16:46lazybot⇒ ((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) [0 4 8] [2 4 6])
16:46gfredericksokay that's what I meant
16:46gfredericksthen you can write functions that iterate over all 3-in-a-rows without thinking about what that structure actually is
16:48daniel___why are the last two vectors
16:48daniel___the diagonals
16:48gfrederickscuz I gave them explicitly; isn't supposed to make a diff
16:49daniel___i cant think hwo to iterate over them, without using a load of if/or/and statements like before
16:50gfredericks(some (fn [[a b c]] (= (board a) (board b) (board c))) three-in-rows)?
16:51daniel___what about detecting whether it's a \X or a \O
16:52gfredericksuse one of the indices in the result of that expression?
16:52gfredericksdepends on what kind of output you're looking for exactly
16:53daniel___i guess either \O \X or nil
16:53daniel___then i can test for not nil
16:53daniel___and whatever is returned is the winner
16:53daniel___i lack a serious amount of creativity or something
16:54daniel___how do you arrive at the point where you can see a good solution to every problem? just doing loads of 4clojure type challenges
16:54daniel___?
16:54gfredericks(some (fn [[a b c]] (if (= (board a) (board b) (board c)) (board a))) three-in-rows)
16:54emezeskedaniel___: Nobody can see a good solution to *every* problem ^_^
16:55gfredericksdaniel___: I can see a good solution to these kind of silly problems because I've done them over and over.
16:55wingyi wanna get to that point i can read code very fast
16:55wingyto be thinking in code
16:56emezeskewingy: There's only one way to do that, AFAIK: read more code. :)
16:56wingyyeah
16:56gfredericksdaniel___: where by "silly" I mean "not directly practical"
16:56akhudekwingy: think in datastructures, not code
16:56wingyakhudek: right .. everything is data
16:56wingythat's what you wanna say?
16:56akhudekpretty much
16:57akhudekI always think in trees, lists, vectors, etc
16:57akhudektranslates to many languages easily
16:57gfredericksdaniel___: https://github.com/fredericksgary/tictactoe/blob/master/src/ttt/core.clj#L69
16:57akhudekfunctional languages just make it easier to directly implement this kind of thinking
16:57akhudeke.g. "transform each element in the list with function X"
16:57wingyakhudek: one of the fundamentals of FP is to manipulate these data structures right
16:57wingyi read somewhere that algorithms are overrated
16:58akhudekwell, algorithms are not overrated
16:58wingymost of the things you do is to manipulate data
16:58akhudekbut to create good algorithms you need to think about data structures
16:59emezeskewingy: I think the "algorithms are overrated" thing means something to the effect of "once you have the right datastructure, the right algorithm is much more obvious"
16:59antoineBakhudek: algorithm go with datastructure
16:59akhudekthat's exactly right
17:00antoineBthere is no datastructure on a side and algorithm on another side
17:00emezeskewingy: But the reality is that datastructures and algorithms are really just two aspects of the same thing
17:00gfredericksdatastrorithms
17:00wingyhmm interesting
17:00wingythey go hand in hand
17:00emezeskegfredericks: haha
17:00antoineBalgotucture
17:01akhudekand they are language independent too
17:01akhudekfor the most part
17:01wingyemezeske: what do you mean two aspects of the same thing
17:01hyPiRionemezeske: I'd say algorithms are "operations" on datastructures.
17:01akhudekobviously language can make particular algorithms and data structures easier or harder to write (or sometimes impossible)
17:01gfredericksnever impossible!
17:01wingyhyPiRion: that seems fair
17:02wingyyeah .. its not a lot of fun to do FP in javascript
17:02daniel___my version so far: https://github.com/danielstockton/naughts-and-crosses/blob/master/src/naughts_and_crosses/core.clj
17:02emezeskewingy: Well, I guess I just mean that some algorithms can't be described without describing their underlying datastructure
17:02wingy; function {} nightmare
17:02wingyi realized clj is so concise so it really fits very well as a cli lang
17:02antoineBhyPiRion: flat data itself a datastructure
17:03antoineB*is itself
17:03gfrederickswingy: the underscore lib helps slightly
17:03wingygfredericks: yeah .. but i ended up switching to livescript
17:03cheater__but is the data structure data?
17:03arohneris there a built-in fn for casting a byte to an unsigned byte? i.e. (unsigned-byte -106) => 153
17:03antoineBits not a lot of fun to do javascript
17:03wingya better coffeescript with FP features
17:03gfredericks$findfn -106 153
17:03lazybot[]
17:04gfrederickswingy: but now you're using cljs?
17:04cheater__$findfn 153 -106
17:04lazybot[]
17:04cheater__interesting.
17:04antoineBcheater__: it's meta data or not :)
17:04akhudekarohner: java doesn't have unsigned types :-(
17:04antoineBor meta meta data
17:04wingygfredericks: once i mastered server side with clj/datomic i plan to use cljs for frontend
17:04akhudekI think there are some convenience functions to simulate them anyways though
17:05arohnerakhudek: I know, but I'd still like to treat it as unsigned, turning into a short or int if necessary
17:05akhudekarohner: I'm trying to remember where I read this, maybe it is Java7 that introduced something to handle this
17:06ivanJava 8 has some real unsigned ints
17:08akhudekack, sorry, I can't seem to find it, but I remember that it was specific either to 1.7 or 1.8
17:08daniel___arohner there is unchecked-byte
17:08daniel___oh, hes gone
17:09hyPiRiondaniel___: that wouldn't convert it to an unsigned byte, though.
17:09hyPiRion,(unchecked-byte -106)
17:10gfrederickslazybot should watch for , messages and respond if clojurebot doesn't.
17:10daniel___hyPiRion: nope
17:10gfredericksmaybe they should just keep tabs on eachother in the background
17:12wingyso once you have mastered all basic stuff in clj and cljs .. how do you ensure that you develop your skills to read and write idiomatic code. should one just pick a random lib in github and read the source code? that sounds boring
17:13wingydoing tasks like 4clojure all day?
17:13gfredericksuse it for stuff and read/participate-in discussions
17:13antoineBtry to write your own dsl in clojure?
17:13cheater__what is cljs?
17:14wingyclojurescript
17:14cheater__what's that do?
17:14antoineBit compile to javascript
17:14cheater__neato
17:14emezeskewingy: You could always contribute to an open source project, which would force you to read source code but might not be boring due to having a purpose
17:14cheater__does it work well in browsers?
17:14cheater__or is it mostly for v8 & co?
17:15wingyantoineB: DSLs using macro seem fun .. perhaps i could write a DSL for my business domain
17:15gfrederickscheater__: it works well in browsers
17:15emezeskewingy: Plus if you contribute something useful, you might get a free code review :)
17:15cheater__gfredericks: even in ie7?
17:15wingyemezeske: yeah :)
17:15gfrederickscheater__: I'd be surprised if it didn't
17:16emezeskecheater__: CLJS uses the google closure compiler and library, which I'm pretty sure supports really old browsers
17:16wingyhope more books will be available .. i like reading books
17:17wingywould be cool if they had lynda videos for clojure .. i searched but they arent any
17:17cheater__lynda? hahah.
17:17wingycheater_: thats what i used to learn programming back in the days :)
17:18cheater__at least it's not w3schools.
17:18wingyi just think fun stuff makes the entry easier
17:18wingylike head first series
17:18wingyso great
17:19antoineBi fail the first problem of 4clojure :/
17:19wingylike when we have light table ready to rock .. i think it will convert a lot of people to clj
17:19wingythe tooling is really important for a lang's survival
17:20antoineBanyone who wants do an interactive test in swank? (you change the code, it change the result of your tests)
17:21cheater__huh?
17:21cheater__antoineB: what problem did you fail at?
17:21antoineBwrite your tests, write your function and have directly the result of your tests
17:22antoineBchange your function, modify the result and so on
17:22cheater__i don't understand :)
17:23antoineBwhen you write, your function you see the tests are executed (using the current function)
17:24antoineBand you see the result
17:24antoineByou don't need compile/eval + run the test
17:25cheater__i'm sorry i see words but i don't know what they refer to
17:25wingyim so glad i moved on from php when i read this http://www.slideshare.net/fabpot/design-patternrevisitedphp53
17:25cheater__wingy: was going to click, but noticed "php" in url
17:26gnarmisanyone else doing a deep dive into emacs? just setup swank and all…things seem to work!
17:26gnarmiscoming from vim
17:27gfredericksI did that 4 months ago maybe
17:27antoineBi just do clojure-jack-in
17:27antoineBthat all
17:31wingywow, never knew about condition-map in fns .. are there good use cases for those?
17:32wingywhen would you wanna have a certain check in a condition-map instead of putting in the function itself
17:32gfrederickswhen you want the program to crash due to programmer error
17:32gfredericksrather than some other sort of exceptional case
17:33gfredericksthey're the kind of thing you should be comfortable disabling in production
17:34cheater__hey guys can someone explain this to me?#(+ % 5)
17:34cheater__is % the "unshift"?
17:34gfredericksit's the arg
17:34Raynes(fn [x] (+ x 5))
17:34wingycheater__: the first arg
17:34cheater__what if i have multiple args?
17:34gfredericks%1 %2
17:34wingythe same as %1
17:34Raynes#(+ % %2)
17:34cheater__ah k
17:35cheater__is #() the same as function definition?
17:35gfredericksman we can't resist easy questions apparently
17:35RaynesI feel insulted when people don't answer in code.
17:35gfrederickscheater__: it's a reader macro; you can use read-string to see what it expands to
17:35gfredericks&(read-string "#(+ %1 %2)")
17:35lazybot⇒ (fn* [p1__69903# p2__69904#] (+ p1__69903# p2__69904#))
17:35gfredericksRaynes: ^ there you go :P
17:36cheater__ok so fn defines an anonymous function?
17:36gfredericksyeah
17:36cheater__what if i do (fn add-five [x] (+ x 5)) ?
17:36cheater__is it still anonymous?
17:36wingycheater__: you should pick up the book "Programming Clojure" .. it will walk you through all this stuff
17:36RaynesYes.
17:37RaynesYou can't access add-five outside the scope of add-five.
17:37gfredericksRaynes: say that in code
17:37cheater__i can't wait till a book arrives from amazon
17:37cheater__i need to know clojure now !
17:37cheater__:)
17:37cheater__Raynes: thanks
17:37Raynes&(do (fn add-five [x] (+ x 5)) (add-five 5))
17:37lazybotjava.lang.RuntimeException: Unable to resolve symbol: add-five in this context
17:37Raynesgfredericks: ^
17:37cheater__Raynes: i was wondering why they ever give names to anonymous functions, i guess it's only for recursion?
17:37gfredericksRaynes: phew
17:38wingycheater__: there is an ebook i think
17:38gfrederickscheater__: alse I think it will leak into the compiled class name, which can be nice
17:38cheater__wingy: i'm just going through 4clojure since you guys linked it.
17:38wingycheater__: i think basic knowledge before doing 4clojure is better
17:38Raynes&((fn to-five [x] (if (< 5 x) (to-five (inc x)) x)) 1)
17:38lazybot⇒ 1
17:38cheater__i thought 4clojure was for learning basic knowledge
17:38RaynesI lose.
17:39Raynes&((fn to-five [x] (if (< x 5) (to-five (inc x)) x)) 1)
17:39lazybot⇒ 5
17:39Raynes&((fn [x] (if (< x 5) (recur (inc x)) x)) 1)
17:39lazybot⇒ 5
17:39cheater__is "partial" the same as currying?
17:39RaynesNo.
17:39cheater__what's the diff?
17:40RaynesOne is called partial application and the other is called currying.
17:40wingygfredericks: cant still create a use case in my head regarding pre and post condition map .. would you mind give me a concrete example?
17:40cheater__is there an actual difference?
17:40wingyeg. if they don't pass a wrong data type?
17:40wingyi mean if they pass a wrong data type?
17:40wingybut that would be like type checking
17:41gfredericksyou can check arbitrary things
17:41gfredericksso it's kind of stronger than type checking
17:41wingylike no trailing whitespace in strings?
17:41gfrederickssure
17:41emezeskecheater__: There is a difference. Currying would mean that ((fn [a b] (+ a b) 1) would return a function like (fn [b] (+ 1 b))
17:41Raynescheater__: http://stackoverflow.com/questions/218025/what-is-the-difference-between-currying-and-partial-application
17:42emezeskecheater__: Clojure does not support that, though, it would complain about wrong arity to the first fn
17:42gfredericksemezeske: http://github.com/fredericksgary/currj
17:43wingygfredericks: I thought that pre condition is used for fn parameter list while post condition is used for return value .. but after reading this line "pre-expr and post-expr are boolean expressions that may refer to the parameters of the function." post condition seems to be used for parameter list as well
17:43emezeskegfredericks: that is super cool.
17:43ldhi'm struggling to configure jetty from lein-ring. I've got:
17:43ldh :ring {:handler my-app.core/app
17:43ldh :adapter { :configurator (fn [& more] (println "Configuring"))}}
17:43ldhwhich gives me : java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
17:43gfrederickswingy: I imagine they're available in the post conditions, but probably most postconditions just refer to %, the return value
17:45ldhif i unquote the configurator function (as suggested here:http://stackoverflow.com/questions/10289617/clojure-ring-jetty-i-am-using-lein-ring-server-how-do-i-configure-the-jetty) i get ReaderException: java.lang.Exception: Unreadable form
17:45wingygfredericks: i created an example: (defn constrained-sqr [x] {:pre [(pos? x)] :post [(= x 1)]} (* x x))
17:46weavejesterldh: Embedding functions in the project.clj file is not really what it's designed for...
17:46wingywhat does the word :pre and :post refer to?
17:46wingythey both check the parameter list
17:46weavejesterldh: What do you need to configure?
17:46gfrederickswingy: :pre gets run before, :post gets run after
17:47ldhweavejester: i'm playing with configuring log handlers. i'd prefer not embedding it in project.clj actually, but had no luck trying to refer to a function elsewhere either
17:47wingywhats the exact difference? and before/after what btw? the fn body execution?
17:47gfredericksyes
17:47gfredericksthat is the exact difference
17:47gfredericksand of course :pre can't access the return value
17:48wingyi see .. putting % in pre generates error
17:48gfredericksquite
17:48weavejesterldh: Hm, you might need to use the adapter directly. If you need to do a lot of work with a specific adapter, then lein-ring is probably not the right tool to use.
17:49wingybut is there a reason for wanting to assert the argument list again in a post conditin?
17:49wingycondition
17:49wingyseems like you are really interested in the return value
17:49gfrederickswingy: right; probably the only reason you can use the args at all is if you want to say something about the args and the return value together
17:50wingyyeah
17:50wingythis was a quite hidden feature .. haven't encountered it yet in 2 books
17:51oskarth:q
17:51oskarthwrong winodw
17:51ldhweavejester: ok, thanks. i can just use 'lein run' and call run-jetty from within my main function and configure it that way, but then i lose the nice code reloading
17:51weavejesterldh: You can apply the "wrap-reload" middleware directly.
17:52weavejesterldh: It's in ring.middleware.reload in the ring/ring-devel package
17:52ldhweavejester: i thought as much. fantastic, thanks.
17:52Squee-Doskarth oh i though you were licking your nose
17:52Squee-D:P
17:52gfrederickslol
17:53Squee-Dthanks, I'll be here all week. With very little useful to say :D
17:53gfredericks,:q
17:53gfredericks&:q
17:53lazybot⇒ :q
17:54Squee-Dim really enjoying Land Of Lisp. If anyone asks for a noob primer, this thing is great
17:55gfredericksapparently cljs does not have pre/post conditions
17:55wingyoh
17:56wingyi hope cljs could be as near clj as possible though
17:56wingyso there is no surprise
17:56wingypre/post seems possible to do at least
18:07arohner$findfn 154 -106
18:07lazybot[]
18:22bpris there a more succinct way to do: https://www.refheap.com/paste/3610
18:25gfredericksbpr: that looks like a reduce
18:25bprah blah
18:25bpryes
18:45oskarthSquee-D: lol :p
18:45oskarthusing vim with clojure is kind of like that
18:52Squee-Di believe it :D
18:55wingyseems that data structures refer to not only collections but to scalars as well: http://clojure.org/data_structures
19:47wingyoh my bad i think
19:47wingydata structures don't refer to scalars .. weird that they are mentioned in the same section though
19:49duck1123well, do you consider 7 to be a data structure?
19:50wingywatching a video where he explains data structures
19:50gfredericksI'm using 7 as a data structure in my cljs program :)
19:50wingyit seems that scalars are data structures as well
19:50duck1123I don't see the point of 7
19:50duck1123and they eat all the cake
19:50gfredericks(extend-type js/Number IBasisVector ...)
19:51wingyi just wanna know if the term "data structure" refer to scalar values as well
19:52wingycould someone confirm that
19:52gfredericksI would think not
19:52duck1123what does it matter
19:52duck1123clojure doesn't really concern itself with "scalar"
19:53duck1123I mean there's things that return sequences and what not, but the concept of scalar isn't really special
19:54duck1123If the function doesn't work with non-collections or non-seqable things, it'll say as such
20:04wingybut watching this video rich says that the reader reads in data structures
20:04wingywhen you type 1 in the repl you get returned the data structure of it
20:04wingywhich is just 1
20:05wingyso it seems that all numbers, strings, booleans, keywords etc are called data structures as well
20:06duck1123sure
20:09gfredericksI think he was probably being loose with his language
20:10gfredericksprecisely defining data structures was not his intention at that moment
20:10wingyso you are saying that by data structures he mean collections
20:10wingylist, vector, map and set only
20:11gfredericksyeah
20:12gfrederickshe was probably describing homoiconicity
20:12wingywhat do we call the other ones?
20:12gfredericksscalars
20:12wingyand both scalars and data structures are forms right
20:12gfredericksyeah; a form is usually something evalable; or at least code-like
20:13gfredericksrather than data-like
20:13gfredericksit's a distinction of purpose
20:13wingy'(1 2 3) is a form?
20:13gfredericksprobably not; depends on the purpose
20:13wingybut then you can probably say it evals to itself
20:13wingyjust like :keyword is
20:13gfredericksno it doesn't
20:14wingyoh
20:14wingybut :keyword is?
20:14gfredericks:keyword does eval to itself
20:14wingyok .. thought that what you saw returned in the repl was the evaluation
20:15wingyso its confusing the scalar values are listed in the Data Structures section
20:15gfredericksif '(1 2 3) evaled to itself then you could run (eval *1) all day and get the same thing
20:15wingyincidental confusion!
20:15gfrederickswingy: it's not a word meant to be stressed over
20:16LesZedCBwhy is it not a form? is it not equivalent to (quote (1 2 3))?
20:16wingybut when the same term is mentiond all over in books and in blogs etc you kinda wanna know what they exactly mean :)
20:16gfredericksit is
20:17gfredericksLesZedCB: I was using a somewhat constrained definition of form; if you meant "anything output by the reader" then yes it is
20:17LesZedCBwell, isn't a form technically just any valid clojure data structure?
20:17gfrederickswingy: if you want something generally accepted look at the wikipedia article
20:17xumingmingvI'm trying to build this lein plugin: https://github.com/febeling/lein-junit
20:17gfredericksLesZedCB: it doesn't have a techincal definition that I'm aware of
20:18xumingmingvbut seems leiningen:leiningen:jar:1.7.0 can not be found in clojars.org
20:18xumingmingvanybody know why?
20:18gfredericksLesZedCB: I can imagine a majority of people believing what you said though, so I might just be ignorant
20:21LesZedCBso, i have a question about '&' used in variadic functions.
20:22LesZedCBsuppose (fn useless [x & rest] (println rest))
20:23dnolengfredericks: wingy: LesZedCB: I think a "form" would refer to anything that is readable - that is will be accepted by the reader.
20:23LesZedCBhow does & fit in with the language? for example I can't evaluate (type &)
20:23LesZedCBdnolen: That makes sense, thanks!
20:25wingyi just use (read) to know what is a form
20:25wingy& is a form as well since it can be read
20:25lazybotjava.lang.RuntimeException: Unable to resolve symbol: is in this context
20:26LesZedCB& is not a form by itself, and [x & rest] is not a form by itself
20:26lazybotjava.lang.RuntimeException: Unable to resolve symbol: is in this context
20:26wingywhy can i do
20:26wingy(read)
20:26wingythen type &
20:26LesZedCB(read &) you mean?
20:26wingyi returns & which means it has to be a form
20:26wingyno
20:26wingy(read) .. then & and hit enter
20:27wingyeverything (read) can read must be a form i guess
20:28LesZedCBhmm. interestingly, in the lein REPL, "(read) &" does not evaluate, and in the clojure repl, it does
20:30wingyim in lein repl
20:30wingyit does read for me
20:30wingylein 2
20:31LesZedCBoh, I see what you did
20:31LesZedCBtry (read-string "&")
20:31wingyyeah
20:31wingythe same
20:31wingybut reading a string instead of a stream
20:31wingyso that means & is a form right :)
20:32LesZedCBsorry, right. but try just "&"
20:33dnolenLesZedCB: my earlier definition may be too loose, seems like in other Lisps - "form" means acceptable to the reader as well being meaningful when evaluted (in terms of the core language).
20:34wingyok so what gfredericks said
20:34wingycode like thing
20:34LesZedCBdnolen: yes that makes sence, if it can pass read and eval.
20:34musicalchaira form has evaluation semantics
20:35wingycould one say that a form is an expression?
20:35wingyon the other hand an expression could be composed of multiple forms .. i think i get it
20:35musicalchairI would say all forms are expressions but not all expressions are forms
20:35wingyyeah
20:37gfredericksdnolen: that's funny I would have assumed it would refer to post-read if anything
20:37gfredericksas in (defmacro fooball [form] ...)
20:38gfredericksand "s-expression" might refer to the string version
20:39gfrederickswingy: this just confirms that it doesn't matter all that much :)
20:39wingyyeah haha
20:40gfredericks&(eval (eval :foo))
20:40lazybotjava.lang.SecurityException: You tripped the alarm! eval is bad!
20:40gfredericksaw poopsmith
20:41wingyclj is too cool
20:41wingyill teach my son clj that's for sure
20:41gfredericksgood luck explaining what "the jvm" is
20:42wingywhy would that be a hard thing
20:43wingyits a platform for runing clj
20:43gfredericksthat's what computers are
20:43gfredericksor maybe operating systems
20:43wingybut then jvm is an abstraction on top of OSes
20:43wingyso we don't have to care about the OSes
20:43wingyi think he'll get the pic
20:44gfredericksbut we do have to care about the jvms
20:44wingyperhaps he won't even bother with understanding OSes
20:44musicalchairnot if you're a little kid learning clojure
20:44wingythats because i dont get it
20:44gfredericksin the future people will not be familiar with the existence of "operating systems"
20:44wingy:D
20:45gfredericks&:D
20:45lazybot⇒ :D
20:45wingylol
20:45LesZedCBlol
20:45gfredericks&'<o.o>
20:45lazybot⇒ <o.o>
20:45duck1123I gave my son a Ruby shell to play with. I'll let him get a bit older before I try lisp
20:45gfrederickslook son. if you give it a funny face it will give you one back.
20:45LesZedCBthanks for the response. cheers!
20:46wingyduck1123: why not clj immediately?
20:46gfrederickshe has to learn about assignment and mutable data structures before he can learn to avoid them
20:46duck1123he was 5
20:46wingydoes he? can't we just start correct
20:47wingyand then show him the OOP where everything is a mess
20:47gfredericksno. start with GOTO and malloc.
20:47duck1123He's 7 now, he may be able to grok it.
20:47wingyduck1123: i think people can get things when they are 4-5 really quickly .. if they have a good teacher
20:47duck1123Kids these days don't appreciate not needing to number their lines by 10
20:47wingya 10 years old can be way smarter than a 30 years old if he started early
20:48wingyi won't put my boy through hell like the one i had to go through
20:48duck1123I was thinking that if I was going to teach him Clojure, I would use light table for that instant response
20:49wingyi teach him lisp immediately .. syntax comes and goes .. logic stays forever!
20:49wingyi want him to tell his teacher that
20:50mefisto`I agree... I want to do the same thing with my daughter (due in 1 month!)
20:51gfredericksman I should get my son to type his first paren before he gets out his first word
20:51wingyi wont dare to teach my girl computer
20:51wingyshe can't be as geeky as me
20:51wingyi'll teach her design!
20:52duck1123I want to give my daughter as much opportunity as possible to learn science and technology
20:52gfredericksduck1123: teach your son design!
20:53wingyyeah who knows .. maybe it will be more trendy for girls to know programming
20:53gfredericksyour mother and I will love you no matter what you do, as long as it's trendy.
20:53wingyi teach my girl design .. my boy programming .. they both do an app together by 15 years old and bring me money
20:54mattmossAwesome sauce, duck1123: "Kids these days don't appreciate not needing to number their lines by 10."
20:55gfredericksif I had designed the language they would have been numbered by 7
20:55mattmossLine numbers written in base 7 as well? Or is that too easy?
20:55gfredericksno too easy
20:55gfredericksbase 10
20:56mattmoss20 GOTO 10 becomes 26 GOTO 13
20:56duck1123I still have my old Atari XE. I would ride the bus to school while reading my BASIC manual then go home and try out new programs
20:59mattmossPOKE 1024,42
21:00wingywhat happens when i have (def a 1) (def a 2) .. is it creating 2 separate vars or 1 var but the value is changed?
21:01gfrederickswingy: same var
21:01hyPiRionYou could try it out.
21:01wingyhyPiRion: didn't know how to compare them to see if they were the same
21:01wingy(identical? (def a 1) (def a 2)) ;=> true
21:04duck1123wingy: you're creating the var a and altering its root binding
21:06wingyis that idiomatic way of changing a value of a var?
21:06wingyor should i use binding or atom?
21:07wingyor let
21:07gfredericksyou don't normally want to change the root binding
21:07gfrederickswhat are you trying to do?
21:08wingynothing .. watching videos are questions arise :)
21:08wingynvm
21:08wingyill get to it later more in depth
21:08quizmei have an array of 10 things wrapped in an atom. How can i access those 10 things from another clojure process ?
21:09gfredericksderef the atom?
21:09gfredericksand access the 10 things?
21:09duck1123quizme: do you have the atom stored in a var that both threads can read?
21:10quizmei want to access it from a different process
21:10duck1123avout?
21:10quizmei mean i want to fire up two different leiningen projects
21:10duck1123https://github.com/liebke/avout
21:10quizmeand have them share the same atom
21:11duck1123you'll need to store it somewhere outside of the jvms memory or send it to the other process somehow
21:11gfredericksah ha
21:12quizmehow can i send it to the other process ?
21:12quizmei guess i have to create a socket
21:13duck1123open a socket between the two, store it in a queue, a myriad of ways
21:13duck1123check out that link i just sen
21:13quizmeduck1123 ok thank you
21:16quizmeduc1123 looks awesome.
21:18duck1123I've only played with it a little bit. I want to make use of it, but just haven't had the time
21:18duck1123also, slacker is kind of cool for inter-process communication
21:21duck1123I really wish there was a decent websocket client with the features of readline. There's a chrome one, but it doesn't support command history
21:35emezeskeduck1123: Is a websocket client something that runs in the browser?
21:35duck1123well it can, but it could be any connection really
21:36emezeskeduck1123: I was just going to suggest "rlwrap" to get readline features, but it only works for command-line tools
21:36duck1123I found a swing one, but it was no good and the node.js stuff I found was more of a library
21:37duck1123I've been building out a command interface to my server that works over the open websocket connection
21:37emezeskeYou might try staring it via rlwrap
21:37emezeskeIt tends to have pretty decent results for normal REPL type things
21:38duck1123I could probably take my cljs code and make a node.js command
21:38duck1123never done that before
22:43sjlis there something special I need to do to include images in my /resources/ directory when hosting a Noir site on Heroku?
22:43sjlThe rest of the /resources/ work, and the image resources work locally...
22:44technomancywith compojure IIRC the "site" handler does that for you
22:44technomancyor wrap-resource with raw ring
22:44technomancynot sure how noir does it
22:44sjlnevermind, git is being an asshole
22:45sjlgit commit --all-but-not-really-all-lol
22:45sjlsorry for the noise
22:46musicalchaircould anyone explain under what circumstances I would use clojure.contrib.graph/stratification-list? Google hasn't been particularly illuminating for me
22:47sjlmusicalchair: well clojure.contrib is abandoned, so effectively: "None"
22:47duck1123Slightly OT. Does anyone know why firebug complains about {"a": "b"} saying it has an invalid label. Should I be doing all my communication as clj forms?
22:48musicalchairsjl: I'm aware it's not officially supported, but the code still works and presumably the concept still lives
22:48sjlmusicalchair: sure
22:49emezeskeduck1123: I think more context is needed to explain firebug's behavior
22:49emezeskeduck1123: Regarding communications, I think using pr-str/read-string for (de)serialization is pretty common
22:50emezeskeduck1123: Although I know some people use JSON and other formats
22:50duck1123I'm just trying to eval that form in the js console. I'm trying to figure out why my json communication isn't working
22:51duck1123what is the safe way to eval the string with cljs, looks like the jquery one didn't get ported to jayq, but I'm sure I could use that
22:51duck1123I'm hesitant to use clj forms as I want the websocket connection usable from outside of the site
22:52sjlduck1123: heh, you're going to cry when I tell you the answer.
22:52sjlduck1123: try {a = "b"}
22:52duck1123see, my issue is that clojure.data.json gives me the form I said above
22:53emezeskeduck1123: Or try x = {"a" : "b"}
22:53emezeskeduck1123: I think the {string : string} format only works for assignment
22:53duck1123wow
22:54sjltry { 1 + 3; }
22:54sjllol
22:54sjlFirebug is parsing the braces as a block, not the start of an object literal
23:00duck1123Ok, I screwed it up, but if you go to renfer.name and send in your js console: jiksnu.websocket.send("whoami") you can see what's going on
23:01duck1123It's because I was using eval. Need to find the fix for tha
23:03duck1123got it
23:42nedi'm doing problem 16 on 4clojure but am having a bit of a challenge with it anyone know why (fn [x] (concat "Hello, " x "!")) won't work ?
23:45jkkramer,((fn [x] (concat "Hello, " x "!")) "ned")
23:45ned,(+ 9 9)
23:45jkkramer&((fn [x] (concat "Hello, " x "!")) "ned")
23:45lazybot⇒ (\H \e \l \l \o \, \space \n \e \d \!)
23:46nedoh hm, what's the appropriate concat method then
23:46duck1123just use str (sorry for spoiler)
23:46nedduck1123: haha no need to apologize, i thought i was doing something dumb and i was!
23:48duck1123if you have a seq of charachters like that... (apply str coll)
23:48michaelr`good morning!