2012-07-14
| 00:04 | xeqi | how you, uh... how you coming on that clojure -> elisp you working on? |
| 00:08 | duck1123 | If 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:09 | technomancy | xeqi: compiling to elisp? |
| 00:09 | technomancy | xeqi: I don't think it can happen; at least until elisp gets native immutability for at least strings; hopefully for lists too. |
| 00:10 | technomancy | more ranting on the topic here: http://technomancy.us/159 |
| 00:11 | duck1123 | I would love to see a good editor taking all the best parts from emacs but built with clojure |
| 00:12 | duck1123 | clooj didn't cut it |
| 00:12 | technomancy | the best parts from emacs are the decades worth of elisp that's accumulated around it |
| 00:13 | technomancy | you could make something that works really well for editing clojure, but you'd have to give up on magit, tramp, emacsclient, etc |
| 00:13 | duck1123 | true, but the best of those modules could be converted |
| 00:13 | technomancy | sure; how much time you got? =) |
| 00:14 | akhudek | probably not worth reinventing what already works |
| 00:15 | akhudek | what would emacs in clojure ultimately gain? |
| 00:15 | akhudek | I guess being able to write plugins with clojure... |
| 00:15 | duck1123 | a more powerful lisp system at the heart of the editor |
| 00:16 | technomancy | it's much more likely that emacs would start running on guile and you could compile to scheme instead |
| 00:16 | technomancy | by which I mean not very likely, but at least possible |
| 00:16 | sjl | s/with clojure/with all of the JVM ecosystem/ |
| 00:18 | eggsby | hey 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:18 | ibdknox | Light Table = Clojure! |
| 00:19 | ibdknox | but she is teh young |
| 00:19 | sjl | ibdknox: call me when it can run through tmux ;) |
| 00:19 | clojurebot | excusez-moi |
| 00:19 | eggsby | I wonder if light table works in lynx... |
| 00:19 | ibdknox | lol |
| 00:20 | sjl | that's the main problem really -- there are lots of new generation editors popping around but none run in a command line |
| 00:20 | ibdknox | why would they? |
| 00:20 | sjl | so I can't use any of the pretty things like vico, st2, etc |
| 00:20 | eggsby | yes but luckily you have vi for that sjl |
| 00:20 | sjl | eggsby: heh, yeah |
| 00:20 | duck1123 | So will Light Table ever get an application window, or will it always be strictly browser based? |
| 00:21 | technomancy | ibdknox: you can't run a distributed team with anything but SSH |
| 00:21 | ibdknox | technomancy: huh? |
| 00:21 | sjl | ibdknox: 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:21 | ibdknox | duck1123: yes, for mac there already is one |
| 00:21 | ibdknox | sjl: none of those things are strictly reliant on a command line |
| 00:22 | sjl | ibdknox: well yeah, once someone implements all their replacements we can ditch it, heh |
| 00:22 | andres-v | eggsby: M-( |
| 00:22 | technomancy | even inclusion-transformation-based GUI collaborative systems (which are really hard to get right) so far only work on a document-by-document basis |
| 00:22 | technomancy | which makes them useless for pairing |
| 00:23 | sjl | I 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:23 | andres-v | eggsby: or mark a region and then: ( |
| 00:23 | ibdknox | technomancy: a document-by-document basis? |
| 00:23 | duck1123 | I was too broke to consider donating, but I wish you well, and that hast to count for something |
| 00:24 | ibdknox | technomancy: as in the entire environment isn't shared? |
| 00:24 | technomancy | ibdknox: 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:24 | eggsby | ah, thanks andres-v |
| 00:24 | ibdknox | technomancy: sure, that's a limitation in the way people have though about the problem, not an inherent problem with a GUI solution |
| 00:25 | ibdknox | which 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:26 | ibdknox | it's a workaround |
| 00:27 | akhudek | anyone remember the days of X11 application forwarding? |
| 00:27 | technomancy | it's possible; it's just a lot of work and nobody's gotten it right yet |
| 00:27 | technomancy | a lot of work for something you can already get for free |
| 00:27 | ibdknox | technomancy: no argument there :) |
| 00:27 | ibdknox | eh |
| 00:28 | ibdknox | in a limited fashion yes |
| 00:28 | duck1123 | That's how I develop. My server is in the house and I'm forwarding my emacs to my mac out in the garage |
| 00:28 | ibdknox | doesn't mean we should just say fuck it, let's not innovate anymore |
| 00:28 | akhudek | ibdknox: completely agree, light table looks interesting |
| 00:29 | ibdknox | light table is infantile :) |
| 00:30 | ibdknox | It'll be very interesting to see where it ends up |
| 00:30 | ibdknox | tons of learning to do |
| 00:31 | akhudek | speaking of learning, I found the recent hacker news discussion on MVC versus finite state machines pretty interesting |
| 00:32 | sjl | so I'm guessing I just reimplemented something built-in, and probably did it poorly |
| 00:33 | sjl | https://github.com/sjl/caves/commit/cf1c6b442a70e7b207d2fef8d35a41da112a4c5f |
| 00:33 | sjl | Basically I wanted a way to give default implementations when defining a protocol |
| 00:33 | sjl | but 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:34 | sjl | so, 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:36 | Nican | I knew I read that somewhere else, is this reference to this? http://stevelosh.com/blog/2012/07/caves-of-clojure-04/#movement |
| 00:36 | sjl | But 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:37 | sjl | Nican: yeah. For that entry I just defined the functions when adding the Mobile aspect to the Player |
| 00:37 | sjl | since at that point I only had a player and nothing else |
| 00:37 | sjl | but if I wanted to add another creature that moved, I'd need to copy and paste the code |
| 00:37 | sjl | or add a helper function somewhere and manually type it out each time |
| 00:39 | sjl | that (do (defprotocol Foo ...) (def Foo ...)) feels particularly filthy. |
| 00:39 | akhudek | sjl: 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:40 | sjl | akhudek: 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:40 | Nican | http://clojure.org/protocols "No implementations are provided" |
| 00:40 | sjl | Nican: yeah that's what I'm trying to hack around, heh |
| 00:41 | sjl | akhudek: 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:41 | sjl | I think. |
| 00:43 | akhudek | sjl: I bet you could get the behaviour you want with a multimethod |
| 00:45 | Nican | Only 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:45 | sjl | akhudek: here's the example showing the problem with Object https://www.refheap.com/paste/3606 |
| 00:47 | akhudek | I see. If hello and world were both multimethods with default implementations, then it would be easy to override just one. |
| 00:47 | sjl | Nican: 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:48 | sjl | akhudek: yeah, but then they're not really grouped together in any special way |
| 00:49 | sjl | akhudek: 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:49 | sjl | akhudek: it's too permissive, i.e. those default implementations catch too much |
| 00:50 | akhudek | sjl: that's true, but you could consider writing functions like "is-mobile?" that has no default implementation |
| 00:50 | sjl | sure... that seems a bit ugly too though |
| 00:50 | akhudek | I mean, it sounds like you are partly using protocols as a type checking system |
| 00:51 | sjl | effectively, yes |
| 00:51 | akhudek | which as I understand it, wasn't really the intention of protocols |
| 00:51 | akhudek | would be nice to have an optional type system for clojure, that's for sure |
| 00:51 | sjl | https://github.com/frenchy64/typed-clojure |
| 00:51 | akhudek | yeah, I know of that, haven't checked on the progress though |
| 00:52 | sjl | seems to be active development, which is a good sign |
| 00:52 | akhudek | yeah, very! |
| 00:52 | sjl | I agree that optional static typing would be awesome |
| 00:52 | sjl | Haskell's typechecker would catch so much annoying crap |
| 00:54 | sjl | okay time to get to sleep, later |
| 00:54 | akhudek | night sjl |
| 00:54 | Nican | later |
| 02:19 | mindbender | I'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:20 | mindbender | I read something similar @ https://groups.google.com/forum/?fromgroups#!topic/leiningen/59655dfCNJg. I'm using lein 2 |
| 02:21 | mindbender | technomancy: any suggestions with ^-^ |
| 02:23 | tomoj | mindbender: it would help if you pasted (not in here) the full stack trace |
| 02:23 | tomoj | ..probably |
| 02:30 | mindbender | tomoj: just did. Here https://gist.github.com/55acd9099967140b6605. |
| 02:33 | tomoj | try :source-paths ["src/app/clj"] |
| 02:37 | metajack | Are PersistentTreeMaps not comparable? If not, why? |
| 02:40 | metajack | ,(compare (sorted-map) (sorted-map)) |
| 02:40 | clojurebot | 0 |
| 02:41 | metajack | ,(compare (sorted-map-by compare) (sorted-map-by compare)) |
| 02:41 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentTreeMap cannot be cast to java.lang.Comparable> |
| 02:41 | tomoj | ,(identical? (sorted-map) (sorted-map)) |
| 02:41 | clojurebot | true |
| 02:42 | metajack | so sorted-map would fail if they weren't identical? |
| 02:42 | tomoj | ,(let [x (sorted-map-by compare)] (compare x x)) |
| 02:43 | tomoj | yeah |
| 02:43 | tomoj | how would you compare sorted maps? |
| 02:44 | tomoj | assume both the keys and values are comparable? |
| 02:44 | mindbender | tomoj: worked. Thanks |
| 02:44 | metajack | keys are vectors of length 2 of longs, and values are keywords |
| 02:44 | metajack | so i believe so |
| 02:45 | tomoj | but if the values were not comparable, should PersistentTreeMap.compareTo throw an exception? |
| 02:45 | tomoj | I don't know actually the answer to your question ("why?") |
| 04:40 | AtKaaZ | hi, is there a program for 3D representation of clojure programs? |
| 04:41 | AtKaaZ | rather than you know textual |
| 04:47 | AtKaaZ | some kind of 3D graph visualization of the clojure code ? possibly with editing it too |
| 05:02 | TEttinger | AtKaaZ, I think there was something done like this |
| 05:02 | AtKaaZ | I would've hoped so, can you remember more precisely ? |
| 05:03 | AtKaaZ | a name of a program |
| 05:05 | AtKaaZ | I 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:10 | AtKaaZ | TEttinger did you mean clojureatlas ? |
| 05:10 | TEttinger | sorry AtKaaZ, was helping in another channel |
| 05:10 | AtKaaZ | it's quite ok |
| 05:10 | TEttinger | I haven't tried clojureatlas, i think you need money for it |
| 05:10 | AtKaaZ | yeah looks like it :/ |
| 05:10 | TEttinger | https://github.com/quil/quil maybe? |
| 05:13 | AtKaaZ | is that like clojureatlas ? it seems like it's only a 3D library for clojure? |
| 05:13 | AtKaaZ | or something to help you draw |
| 05:15 | TEttinger | http://keminglabs.com/c2/ maybe could be handled with some macros |
| 05:16 | TEttinger | lynaghk: ping |
| 05:17 | AtKaaZ | do 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:17 | AtKaaZ | (which is what I want btw :D) |
| 05:17 | TEttinger | yep, code is data |
| 05:18 | TEttinger | but you obviously need some way for it to know how to display different kinds of code |
| 05:18 | AtKaaZ | yeah for sure |
| 05:18 | AtKaaZ | can clojure create code on the fly at runtime ? |
| 05:18 | TEttinger | I think yes |
| 05:19 | AtKaaZ | is there a simple example of that maybe? that I could peek |
| 05:19 | TEttinger | not clojurescript, but clojure can |
| 05:19 | AtKaaZ | yeah the real clojure |
| 05:19 | TEttinger | well macros are "compile-time", but it compiles continuously IIRC |
| 05:19 | AtKaaZ | c2 seems definitely something I want to look into |
| 05:19 | TEttinger | you need to talk to someone who knows how to use macros, there are more qualified people here |
| 05:20 | AtKaaZ | alright thanks so far, I'll alt-tab and try read more |
| 05:20 | TEttinger | lynaghk wrote C2, might be good to stay and wait for a response |
| 05:20 | AtKaaZ | yeah I'll definitely hang in here |
| 05:20 | AtKaaZ | btw, what ide/editor do you use? |
| 05:20 | AtKaaZ | something with colors :D |
| 05:21 | TEttinger | yeah, 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:21 | TEttinger | oh I use Eclipse with rainbow parens via the main plugin, CCW |
| 05:22 | TEttinger | but I mostly use eclipse for editing and stick to the lein2 repl |
| 05:22 | TEttinger | I mean Leiningen v2 |
| 05:22 | TEttinger | the repl is better in that version, it auto-completes and other amazing stuff |
| 05:22 | AtKaaZ | i have eclipse and some clojure plugin cross something... |
| 05:22 | TEttinger | yep |
| 05:22 | TEttinger | counterclockwise |
| 05:23 | AtKaaZ | yeah that one |
| 05:23 | AtKaaZ | what else would I need ? rainbow parens? |
| 05:23 | TEttinger | it has it |
| 05:23 | TEttinger | or at least it should |
| 05:23 | AtKaaZ | ok |
| 05:23 | TEttinger | outer level is red, second nest is green, etc. (colors may have changed with newer versions) |
| 05:23 | AtKaaZ | that Liningen v2 is something outside eclipse? |
| 05:24 | TEttinger | oh yes |
| 05:24 | TEttinger | leiningen is the best way for managing clojure projects across OS's and IDEs |
| 05:25 | TEttinger | it is also one of two de facto dependency managers for clojure |
| 05:26 | TEttinger | https://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:26 | AtKaaZ | oh 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:26 | TEttinger | yeah, I just go into the command line i keep open at all times and just lein run |
| 05:26 | AtKaaZ | oh I see I need lein-eclipse |
| 05:26 | TEttinger | it recompiles if needed and runs |
| 05:27 | TEttinger | yeah, in your leiningen project file |
| 05:27 | TEttinger | it will automatically download it if it is a dependency or dev-dependency in your project file and you then run "lein deps" |
| 05:28 | TEttinger | no need to handle standalone downloads of most libs |
| 05:29 | AtKaaZ | alright 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:30 | TEttinger | yup |
| 05:30 | TEttinger | then run lein deps and it will grab it |
| 05:30 | AtKaaZ | can I have two lines with ":dev-dependencies" or do I have to append them in one line ? |
| 05:31 | TEttinger | :dev-dependencies [[lein-eclipse "1.0.0"]] |
| 05:31 | TEttinger | note the nested vectors |
| 05:32 | TEttinger | :dev-dependencies [[lein-eclipse "1.0.0"] [some-other-thing "1.2"]] |
| 05:32 | AtKaaZ | i understand |
| 05:32 | TEttinger | lines don't matter |
| 05:32 | AtKaaZ | however I'm curious what would happen if :dev-dependencies appears twice in project.clj |
| 05:32 | AtKaaZ | error? |
| 05:33 | TEttinger | probably an error when it tries to assign different values to one map entry |
| 05:33 | AtKaaZ | it acts as a clojure keyword? the ":" ones |
| 05:33 | TEttinger | like {:a "alpha" :b "beta" :a "alpha again"} |
| 05:33 | TEttinger | yes |
| 05:33 | AtKaaZ | makes sense, I like it |
| 05:33 | TEttinger | leiningen projects are clojure code |
| 05:34 | AtKaaZ | so that would err then. |
| 05:34 | TEttinger | and once you can visualize clojure code you can visualize lein files :D |
| 05:34 | AtKaaZ | sounds good to me |
| 05:35 | AtKaaZ | how do I get that prompt to run lein deps |
| 05:38 | msappler | hi. It seem to be bad for transactions if I have refs which have other refs in them as pointers? |
| 05:38 | AtKaaZ | oh i see I shouldn't be in eclipse while running lein deps |
| 05:41 | msappler | I have a grid data structure (for example width and height 100) so a grid of vector 100 of vector 100 cells |
| 05:42 | msappler | and each cell is a ref of a map which also holds :adjacent-cells the other cells'refs |
| 05:47 | y3di | does clojure not have a distinct else-if form? |
| 05:47 | TEttinger | y3di: maybe you want one of the other conditional macros? |
| 05:48 | TEttinger | http://clojuredocs.org/quickref/Clojure%20Core#OperationsFlow+Control |
| 05:48 | AtKaaZ | i managed to run lein deps and lein eclipse :) |
| 05:48 | TEttinger | woohoo! |
| 05:48 | AtKaaZ | lein.bat was in my case on windows |
| 05:48 | TEttinger | yep |
| 05:49 | TEttinger | it should create the needed .project and .classpath files |
| 05:49 | AtKaaZ | there are only 3 colors in clojure code, is that right ? |
| 05:49 | TEttinger | hm? |
| 05:49 | AtKaaZ | maybe 4 with the parenthesis |
| 05:49 | AtKaaZ | yeah it probably did, I had eclipse closed just for that |
| 05:51 | y3di | TEttinger, 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:51 | TEttinger | or clojuredocs.org/clojure_core/clojure.core/cond |
| 05:58 | AtKaaZ | how do you make it show errors in eclipse ? |
| 05:59 | AtKaaZ | like there's an error on line x and marked as red |
| 06:01 | AtKaaZ | switching to edit mode restricted does help some |
| 06:03 | TEttinger | AtKaaZ: you can change colors in Eclipse with Window->Preferences->Clojure |
| 06:03 | TEttinger | I don't know if the clojure plugin does that |
| 06:03 | TEttinger | the error markers |
| 06:04 | y3di | paredit is sposed to handle closing parens for me right? |
| 06:04 | TEttinger | y3di, I don't use it, but I think so yes |
| 06:04 | AtKaaZ | y3di it does for me if I switch from unrestricted edit |
| 06:06 | AtKaaZ | TEttinger thanks, I notice the rainbow parens are also there |
| 06:06 | TEttinger | yep |
| 06:06 | TEttinger | they won't show in the preview thoughh |
| 06:06 | y3di | hm, i don;t think i've installed it right then |
| 06:06 | TEttinger | you probably also want to make strings and symbols not the same color |
| 06:07 | y3di | tho i swear i did |
| 06:07 | y3di | is there a way to test whether i have a certain package installed in paredit |
| 06:17 | msappler | how can i see number of retries of my transactions |
| 06:21 | y3di | does every clojure file need a namespce |
| 06:21 | AtKaaZ | i think it's the package declaration in java |
| 06:21 | AtKaaZ | like* |
| 06:25 | y3di | nvm it was an issue with swankclojure |
| 06:25 | y3di | i have a notherquestion though |
| 06:25 | y3di | currently im printing a really larger number |
| 06:25 | y3di | and its displayed 297392^M or something like that |
| 06:25 | y3di | how can I get it to print the actual number |
| 06:26 | AtKaaZ | ^M makes me think of \n\r displayed in vim |
| 06:26 | AtKaaZ | or was it \r\n :D |
| 06:28 | AtKaaZ | if Chas Emerick here? |
| 06:28 | AtKaaZ | is* |
| 06:30 | y3di | AtKaaZ, do you know how to print it normally? |
| 06:31 | AtKaaZ | I don't sorry, I'm too new to clojure to even know how to code hello world:) |
| 06:32 | AtKaaZ | but I take it the number has more digits than 297392 ? |
| 06:32 | y3di | yea |
| 06:32 | AtKaaZ | no ideas then |
| 06:40 | y3di | this seems like it should be an easy problem to solve, but ive been googling and i cant find an answer |
| 06:41 | AtKaaZ | I don't suppose you could pastebin the program code? |
| 06:41 | AtKaaZ | or a simplified version of it:) |
| 06:45 | y3di | https://gist.github.com/3110511 |
| 06:46 | AtKaaZ | I get the same numbers without the ^M |
| 06:47 | y3di | oh |
| 06:47 | y3di | maybe i was just being a dumbass this entire time |
| 06:47 | AtKaaZ | lol |
| 06:47 | y3di | i tried entering that number as the solution, and it didn't work |
| 06:48 | AtKaaZ | well maybe indeed those numbers have no more digits |
| 06:48 | AtKaaZ | but the ^M seems to be the new line |
| 06:49 | AtKaaZ | if I do (println (reduce sum-if-divisible (range 1 10000))) I get 23331669 |
| 06:50 | AtKaaZ | or (println (reduce + (range 1 100000))) to get 4999950000 |
| 06:50 | AtKaaZ | (granted I've no idea what the program does) |
| 06:52 | y3di | nvm i figure itd out |
| 06:53 | AtKaaZ | I like knowing what the fix is, should you wish to share it:) |
| 06:54 | y3di | i did (range 1 1000) instead of (range 0 1000) |
| 06:54 | y3di | the problem was |
| 06:54 | y3di | summing up the integers between 1 and 1000 that are divisible by 3 or 5 |
| 06:55 | AtKaaZ | I eventually figured from the code, tho I am very new to clojure |
| 06:55 | AtKaaZ | thanks |
| 07:26 | evildaemon | Okay, sorry but I HAD to show this to somebody. |
| 07:26 | evildaemon | http://forums.thedailywtf.com/forums/p/26379/297191.aspx#297191 |
| 07:59 | zoldar | Hello. 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:09 | zoldar | ok, found it, had to use math operator with apostrophe: http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics |
| 08:10 | zoldar | seems it was going even beyond long range |
| 08:21 | daniel___ | is there a function which will give me this? "123456789" -> ("147" "258" "369") ? |
| 08:21 | daniel___ | like partition with interleave |
| 08:24 | eagleflo | daniel___: can't you compose exactly those two functions, partition and interleave, to achieve that? |
| 08:26 | daniel___ | ,(map #(apply str %) (partition 3 (apply str (apply interleave (partition 3 "123456789")))) |
| 08:27 | daniel___ | that should achieve it i think |
| 08:27 | daniel___ | &(map #(apply str %) (partition 3 (apply str (apply interleave (partition 3 "123456789")))) |
| 08:27 | lazybot | java.lang.RuntimeException: EOF while reading, starting at line 1 |
| 08:27 | daniel___ | &(map #(apply str %) (partition 3 (apply str (apply interleave (partition 3 "123456789"))))) |
| 08:27 | lazybot | ⇒ ("147" "258" "369") |
| 08:38 | wingy | what does Attempting to call unbound fn: #'user/zipmap2 mean? |
| 08:42 | wingy | oh nvm |
| 08:50 | wingy | i wonder a thing .. looking at "and" i see its calling itself |
| 08:50 | wingy | ,(source and) |
| 08:50 | wingy | &(source and) |
| 08:50 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: source in this context |
| 08:51 | wingy | here the source: https://gist.github.com/3111123 |
| 08:51 | wingy | could/should the self call be replaced by recur to introduce TCO? |
| 08:52 | wingy | if one calls and with a large nr of arguments that would eat up stack space with the current implementation? |
| 08:55 | wingy | yepp .. i got a stackoverflow error when running it with a long arg list :/ |
| 09:05 | wingy | isn't it possible to use recur instead in and macro? |
| 09:07 | rfgpfeiffer | has anybody got libgdx to play nicely with leiningen |
| 09:10 | yonatane | in (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:10 | yonatane | https://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L3376 |
| 09:23 | yonatane | wingy, 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:27 | wingy | yonatane: a fn or loop could always be used as recur point |
| 09:27 | wingy | so if you call recur in a fn where there is no loop the fn is the recur point |
| 09:28 | wingy | i tried to use recur but an error said the argument list didnt match |
| 09:28 | yonatane | but and is a macro. i'm not sure it's the same |
| 09:28 | wingy | it expected 0 args .. i guess the first argument list (it had multiple ones) was used and that was for no args [] |
| 09:31 | yonatane | well, i'm in the process of reading the clojure source. I'll tell you next year when i'm done ;) |
| 09:31 | wingy | perhaps you are right |
| 09:32 | wingy | https://gist.github.com/3111353 |
| 09:32 | wingy | the fn worked but not the macro |
| 09:33 | wingy | but 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:33 | wingy | anyway :) |
| 09:35 | yonatane | read this: https://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L406 |
| 09:36 | yonatane | i can't understand it yet |
| 09:37 | yonatane | maybe macroexpand it to get a hint |
| 09:47 | yonatane | wingy: (macroexpand '(recurme false)) |
| 09:47 | yonatane | ;=> (if false (recur false) "done") |
| 09:54 | yonatane | ok i just understood why with-open is recursive - to match the .close to the resource and close only opened resources. |
| 09:56 | wingy | yonatane: are you new to clj as well? |
| 09:56 | wingy | just trying to get it? |
| 10:03 | yonatane | i'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:06 | yonatane | but you can do a lot without knowing much. I have a pet facebook app using lein, noir, jdbc, sandbar, ring etc. |
| 10:13 | wingy | yeah .. but i love to get more about programming so you can create powerful, less buggy systems than your competitors |
| 10:13 | wingy | features added each week others could just dream of |
| 10:15 | wingy | this was a really good video http://blip.tv/clojure/clojure-concurrency-819147 |
| 10:15 | wingy | all rich's videos are of high quality |
| 10:18 | yonatane | have you watched the reducers video? |
| 10:19 | yonatane | http://vimeo.com/45561411 |
| 10:34 | wingy | dont think so |
| 10:34 | wingy | ill watch it later |
| 10:36 | wingy | persistent data structures remind me about how git is working |
| 10:42 | cshell | I 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:50 | andres-v | cshell: are you writing :id/foo or id/foo? (it shhould work with id/foo) |
| 10:51 | cshell | if i do id/foo I get a no such var |
| 10:51 | cshell | exceptiong |
| 10:53 | andres-v | cshell: I don't know that library, but what about: (require '(google [identity :as id])) and then use it like (id/foo ...) |
| 10:53 | cshell | it's just a custome on in there |
| 10:53 | cshell | that I created |
| 10:54 | cshell | it's not bound to a var so I don't think i can access it without a : |
| 11:00 | andres-v | and what is the name of the namespace, (ns google.identity) ? |
| 11:01 | inkybutton | hi 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:03 | cshell | andres-v: yes, google.identity is the namespace |
| 11:23 | andres-v | cshell: :( 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:04 | samaaron | is it possible to catch reader exceptions when evaling arbitrary strings? |
| 12:06 | wingy | why do we buy computers with multiple cores if softwares/games dont use them |
| 12:07 | samaaron | wingy: so we can play multiple games at the same time? |
| 12:07 | wingy | :) |
| 12:10 | antoineB | hello, i don't manage to use a simple defmulti example http://pastebin.com/cVMD9rt3 |
| 12:15 | duck1123 | No one would write multi-core software if there were no multi-core computers |
| 12:18 | jkkramer | antoineB: 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:19 | wingy | duck1123: smart :) |
| 12:19 | jkkramer | antoineB: you could try (ns-unmap *ns* 'emit) from within example.a namespace, and re-eval. or just restart repl/swank |
| 12:21 | wingy | i 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:23 | antoineB | jkkramer: i use C-c C-k i see the result expected, but when i type (emit "def") in the repl i get NullPOinterException |
| 12:24 | duck1123 | wingy: there was no lazy-seq around that ? |
| 12:24 | antoineB | if i eval the last expression of the file it works (see the last expression in the paste) |
| 12:25 | wingy | duck1123: its just an example code how map works .. nothing tied to clj |
| 12:25 | jkkramer | antoineB: is your repl in the right namespace and/or requiring the right stuff? |
| 12:25 | antoineB | no |
| 12:25 | wingy | but it works .. i just dont get how it gets out of the recursion |
| 12:26 | jkkramer | wingy: the defn you pasted works, because it's not recursive: map2 called regular map |
| 12:26 | yonatane | wingy: i don't see a recursion |
| 12:26 | wingy | oh |
| 12:26 | wingy | yeah typo |
| 12:26 | zdennis | I'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:27 | zdennis | *err. not core clases, core functions |
| 12:27 | wingy | ok it didnt work |
| 12:27 | wingy | (defn map2 [f coll] (cons (f (first coll)) (map2 f (rest coll)))) fails |
| 12:27 | wingy | nvm |
| 12:27 | wingy | an example from http://vimeo.com/45561411 |
| 12:30 | wingy | wii .. 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:30 | zdennis | the core functions I am overriding are max/min |
| 12:32 | zdennis | ah… I think I needed (:refer-clojure :exclude [max min]) in my point.clj ns |
| 12:32 | zdennis | is that bad form to define functions that share names and then to exclude core functions? |
| 12:32 | gfredericks | zdennis: yessir |
| 12:32 | gfredericks | zdennis: nossir |
| 12:33 | zdennis | gratzi @gfredericks |
| 12:35 | duck1123 | Does 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:13 | cshell | andres |
| 13:13 | antoineB | (case (class "aa") clojure.lang.PersistentList "p" java.lang.String "s" "A") |
| 13:13 | antoineB | what is wrong with my switch? |
| 13:16 | AWizzArd | antoineB: what result do you expect? |
| 13:17 | antoineB | "s" |
| 13:18 | antoineB | java.lang.String isn't a symbol |
| 13:18 | AWizzArd | case is a macro |
| 13:19 | antoineB | AWizzArd: see the doc for availble type you can check on |
| 13:19 | antoineB | they talk about "(Clojure) composites thereof" i don't know what it is |
| 13:21 | antoineB | (case (str (class "aa")) "class clojure.lang.PersistentList" "p" "class java.lang.String" "s" "A") |
| 13:21 | antoineB | this work |
| 13:21 | antoineB | notice the "class ..." |
| 13:22 | gfredericks | ,(doc case) |
| 13:22 | gfredericks | &(doc case) |
| 13:22 | lazybot | ⇒ "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:22 | AWizzArd | It must be constants. |
| 13:23 | gfredericks | antoineB: so apparently classes aren't in the set of constants you can use |
| 13:23 | AWizzArd | But fortunately there are mechanisms to do what you want. |
| 13:23 | antoineB | i hope |
| 13:23 | gfredericks | like multimethods |
| 13:23 | antoineB | my solution is very elegant |
| 13:24 | gfredericks | or cond |
| 13:24 | AWizzArd | You can try condp for example |
| 13:24 | antoineB | in fact i use this "case" in a multi method context |
| 13:25 | wingy | does anyone know why this doesnt return 6 |
| 13:25 | wingy | ,(-> 1 inc (partial * 3)) |
| 13:25 | AWizzArd | ,(condp instance? "aa" clojure.lang.PersistentList "p" java.lang.String "s") |
| 13:25 | cshell | it returns a function |
| 13:26 | AWizzArd | wingy: (partial (inc 1) * 3) is what you got |
| 13:26 | gfredericks | wingy: ##(-> 1 inc ((partial * 3))) |
| 13:26 | lazybot | ⇒ 6 |
| 13:26 | gfredericks | or ##(-> 1 inc (* 3)) |
| 13:26 | lazybot | ⇒ 6 |
| 13:27 | wingy | i thought that the args should return a fn |
| 13:27 | gfredericks | $google fogus thrush |
| 13:27 | lazybot | [fogus: Thrush in Clojure – Redux] http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/ |
| 13:27 | wingy | inc returns a fn |
| 13:27 | wingy | why shouldn't partial? |
| 13:27 | gfredericks | wingy: ^ that's a good read on what's going on |
| 13:27 | AWizzArd | inc should return a number |
| 13:27 | cshell | inc returns a function? |
| 13:27 | cshell | ,(inc 1) |
| 13:27 | wingy | i mean inc alone |
| 13:27 | AWizzArd | Not clojure.core.inc |
| 13:27 | cshell | inc is a function |
| 13:27 | wingy | so i guess the last one should run the function? |
| 13:28 | AWizzArd | (-> 1 inc) ==> (inc 1) ==> 2 |
| 13:28 | gfredericks | wingy: -> is a macro that works syntactically; it doesn't know if something is a function or not |
| 13:29 | AWizzArd | -> takes the first argument and puts it on position two in the following list |
| 13:29 | AWizzArd | (-> 1) take the one and return it |
| 13:29 | AWizzArd | (-> 1 inc) take the one and “put it into inc” |
| 13:30 | AWizzArd | (-> 1 inc dec) take the one and “put it into inc”. Take that result again and put it into dec. |
| 13:30 | AWizzArd | (-> 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:31 | gfredericks | ,(macroexpand '(-> 1 inc dec (* 10))) |
| 13:31 | gfredericks | &(macroexpand '(-> 1 inc dec (* 10))) |
| 13:31 | lazybot | ⇒ (* (clojure.core/-> (clojure.core/-> 1 inc) dec) 10) |
| 13:31 | gfredericks | &(macroexpand '(-> 1 inc dec (partial * 10))) |
| 13:31 | lazybot | ⇒ (partial (clojure.core/-> (clojure.core/-> 1 inc) dec) * 10) |
| 13:32 | gfredericks | oh those are not too helpful |
| 13:32 | gfredericks | &(clojure.walk/macroexpand-all '(-> 1 inc dec (* 10))) |
| 13:32 | lazybot | ⇒ (* (dec (inc 1)) 10) |
| 13:32 | gfredericks | &(clojure.walk/macroexpand-all '(-> 1 inc dec (partial * 10))) |
| 13:32 | lazybot | ⇒ (partial (dec (inc 1)) * 10) |
| 13:32 | wingy | i see |
| 13:35 | wingy | makes more sense now that i know -> is a macro |
| 13:36 | wingy | it gives a total new syntax |
| 13:36 | wingy | so if the 2nd form is a function it just wraps that one around () so it will be called with the value |
| 13:36 | wingy | (fn1 val) |
| 13:36 | gfredericks | $google github swiss-arrows |
| 13:36 | lazybot | [rplevy/swiss-arrows · GitHub] https://github.com/rplevy/swiss-arrows |
| 13:37 | AWizzArd | wingy: you can think of it as „bash pipe” |
| 13:37 | wingy | but if its already in a run form (fn1 arg2) it will put the val into it as the 1st arg (fn1 val arg2) |
| 13:37 | wingy | i thought that every fn should return itself but that wasnt the case |
| 13:37 | AWizzArd | take 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:38 | AWizzArd | A fn does typically not return itself. |
| 13:38 | wingy | but it could in this case with inc |
| 13:38 | AWizzArd | The symbol clojure.core.inc when evaled returns a function. |
| 13:38 | AWizzArd | inc is a symbol |
| 13:38 | wingy | i know |
| 13:38 | AWizzArd | no a function |
| 13:39 | AWizzArd | not |
| 13:39 | wingy | this was the confusion: (-> 1 inc (inc) ((partial * 3))) |
| 13:39 | AWizzArd | yes |
| 13:39 | wingy | diff between inc and (inc) .. they both work |
| 13:39 | bpr | does anyone know how feature-ful nrepl/emacs is compared to slime/swank? |
| 13:39 | gfredericks | that's because -> supports both |
| 13:39 | wingy | but if you have args like in partial you have to wrap it around () |
| 13:39 | gfredericks | it converts inc into (inc) before doing anything else |
| 13:39 | wingy | so it will know its one fn with args |
| 13:39 | wingy | yea |
| 13:39 | AWizzArd | Yes, the -> macro is nice and allows you to omit the parens, if the fn takes only one arg. |
| 13:40 | wingy | confusion gone :) |
| 13:41 | gfredericks | &((apply comp (repeat 10000 inc)) 1) |
| 13:41 | lazybot | ⇒ 10001 |
| 13:41 | gfredericks | lazybot: move this pile of bricks to the other side of the yard |
| 13:41 | gnarmis | maybe it needs sudo in there? |
| 13:42 | gfredericks | &(format "%s is not in the sudoers file. This incident will be reported." "gfredericks") |
| 13:42 | lazybot | ⇒ "gfredericks is not in the sudoers file. This incident will be reported." |
| 13:42 | gnarmis | hahaha |
| 13:49 | wingy | reducers are really hard to get |
| 13:50 | aphyr | Resurrecting a very old question: does anyone know why clojure.lang.Var is *not* backed by an InheritableThreadLocal? |
| 13:51 | aphyr | Seems 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:55 | clojure-newcomer | hey guys, its a bit quiet over in the #datomic channel, can anyone help with an ec2 DDB query ? |
| 14:04 | wingy | data structures imply the collections and not the literals/symbols? |
| 14:05 | cshell | wingy: what do you mean? |
| 14:07 | wingy | when 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:12 | uvtc | wingy: "data structure" would also mean collection of collection ... |
| 14:12 | wingy | uvtc: right but never literals right? |
| 14:13 | uvtc | wingy: I think of strings, booleans, numbers, keywords, etc. as "scalars". |
| 14:13 | wingy | literls is another word for scalars? |
| 14:14 | uvtc | wingy: note that `{:a 1 :b 2}` is a map literal. |
| 14:14 | wingy | i see |
| 14:14 | wingy | then the word scalar is better to use i think |
| 14:14 | wingy | scalar vs data structures |
| 14:14 | uvtc | wingy: As opposed to (hash-map :a 1 :b 2), which is not a map literal. |
| 14:16 | daniel___ | how can i calculate a sequence 0000 0001 0010 0100 1000 0011 0101... all possibilities |
| 14:17 | uvtc | wingy: 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:17 | daniel___ | i suppose its binary increments, which i can just convert to a string |
| 14:17 | gfredericks | daniel___: ##(let [bs [0 1]] (for [a bs b bs c bs d bs] (str a b c d))) could work |
| 14:17 | lazybot | ⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111") |
| 14:18 | wingy | uvtc: yeah thats a good perspective |
| 14:18 | uvtc | ,(for [i (range 2) j (range 2) k (range 2) m (range 2)] (str i j k m)) |
| 14:19 | uvtc | ,(println (for [i (range 2) j (range 2) k (range 2) m (range 2)] (str i j k m))) |
| 14:19 | uvtc | &(for [i (range 2) j (range 2) k (range 2) m (range 2)] (str i j k m)) |
| 14:19 | lazybot | ⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111") |
| 14:19 | daniel___ | oh lovely |
| 14:20 | uvtc | Whoops. Mine was the same as gfredericks , only I kept repeating myself. :) |
| 14:20 | uvtc | clojurebot: are you there? |
| 14:20 | uvtc | lazybot: what happened to clojurebot? |
| 14:20 | lazybot | It's AWWWW RIGHT! |
| 14:22 | gfredericks | &(for [i (range 16)] (subs 1 (Long/toString (+ 16 i) 2))) |
| 14:22 | lazybot | java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String |
| 14:22 | gfredericks | &(for [i (range 16)] (subs (Long/toString (+ 16 i) 2) 1)) |
| 14:22 | daniel___ | java.lang.Long/toBinaryString? |
| 14:22 | lazybot | ⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111") |
| 14:22 | gfredericks | I win |
| 14:22 | uvtc | kahnnnnnn! |
| 14:23 | hyPiRion | ##(for [i (range 16)] (clojure.pprint/cl-format nil "~4,'0B" i)) |
| 14:23 | lazybot | ⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111") |
| 14:24 | lazybot | ⇒ this syntax nil |
| 14:24 | gfredericks | is it worth going to the conj if I'm also going to strange loop? |
| 14:26 | daniel___ | the number of permutations when everything is distinct is factorial |
| 14:26 | daniel___ | in this case, what is it? |
| 14:27 | hyPiRion | exponential |
| 14:27 | gfredericks | 2^n |
| 14:27 | gfredericks | or m^n |
| 14:27 | uvtc | &(for [j (range 16)] (apply str (for [i (range 4)] (rand-int 2)))) |
| 14:27 | lazybot | Execution Timed Out! |
| 14:28 | uvtc | Was going to joke, "close enough". Odd that it timed out though... |
| 14:29 | hyPiRion | uvtc: Clojail is weird like that. |
| 14:29 | uvtc | &(for [j (range 16)] (apply str (for [i (range 4)] (rand-int 2)))) |
| 14:29 | lazybot | Execution Timed Out! |
| 14:30 | uvtc | hyPiRion: Ok. :) |
| 14:31 | hyPiRion | &(for [i (range 16)] (apply str (repeatedly 4 #(rand-int 2)))) |
| 14:31 | lazybot | ⇒ ("0000" "1000" "0101" "0101" "1100" "1011" "0101" "1100" "1111" "0101" "1110" "1000" "0011" "0010" "0111" "0011") |
| 14:31 | hyPiRion | It's something about the for comprehension I believe. |
| 14:33 | gfredericks | &(frequencies (repeatedly 16 (rand-int 16))) |
| 14:33 | uvtc | Ah. `repeatedly`. Thanks, hyPiRion. |
| 14:33 | lazybot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn |
| 14:33 | gfredericks | &(frequencies (repeatedly 16 #(rand-int 16))) |
| 14:33 | lazybot | ⇒ {2 1, 3 2, 4 3, 7 1, 8 3, 11 2, 12 1, 13 1, 15 2} |
| 14:50 | daniel___ | what are the alternatives to associative arrays? i suppose nested vectors is one way, what about if you want a non integer key? |
| 14:50 | daniel___ | a map of lists? |
| 14:50 | daniel___ | a map of vectors*? |
| 14:52 | gfredericks | vectors 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:52 | gfredericks | I must not know what an associative array is. |
| 14:53 | cshell | I'm confused too |
| 14:56 | yonatane | Is there a use-case for using protocols when java interop is not needed? |
| 14:57 | gfredericks | yes |
| 14:58 | gfredericks | actually I don't think protocols have very much at all to do with interop |
| 14:58 | gfredericks | only that you can extend a protocol to a java type |
| 15:02 | tmundal | (+ 1 2) |
| 15:02 | gfredericks | 3 |
| 15:02 | tmundal | :D |
| 15:03 | gfredericks | :D |
| 15:05 | yonatane | gredericks: do you have an example? |
| 15:06 | gfredericks | sorta |
| 15:06 | yonatane | Can 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:07 | tmundal | (loop [] (drink-more-beer) (recur)) |
| 15:07 | gfredericks | the 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:08 | gfredericks | so...no |
| 15:08 | yonatane | so an unqualified doseq outside my namespace will behave normally |
| 15:08 | gfredericks | yep |
| 15:08 | yonatane | that's no fun |
| 15:09 | gfredericks | you can redefine doseq directly if you just really want clojure to crash |
| 15:09 | aphyr | daniel___: Why can't you use a map? |
| 15:09 | gfredericks | but since it's a macro you'll only effect code that's loaded after you redefine it |
| 15:09 | yonatane | oh, doesn't matter. any other function then. |
| 15:10 | bpr | hey, 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:10 | gfredericks | yonatane: with-redefs will let you redefine stuff temporarily |
| 15:10 | gfredericks | yonatane: the only protocol example I care to bother dredging up is https://github.com/fredericksgary/ranguages/blob/master/src/ranguages/core.clj#L10 |
| 15:10 | bpr | i clearly could just use a tmp dir and copy everything over, but why take the extra step if i don't have to :) |
| 15:12 | daniel___ | sorry, something came up |
| 15:12 | daniel___ | aphyr: i can use a map :) |
| 15:13 | uvtc | bpr: I think `lein new foo` has always created the "foo" directory. |
| 15:13 | uvtc | bpr: At least, I've never seen it do anything different from that. |
| 15:14 | yonatane | gfredericks: if you've done it without a protocol, how would it be worse? |
| 15:14 | daniel___ | im used to thinking of everything in loops and arrays |
| 15:15 | gfredericks | yonatane: 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:15 | gfredericks | it 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:17 | yonatane | i'm coming for OO, and had the impression that a functional language does not need OO features |
| 15:17 | yonatane | *coming from |
| 15:18 | gfredericks | some 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:18 | gfredericks | they were first introduced to make clojure-in-clojure feasible |
| 15:18 | gfredericks | certainly clojurescript makes heavy use of them in its foundational stuff |
| 15:18 | gfredericks | as does core.logic |
| 15:19 | bpr | uvtc: "lein new foo ." used to put the new files in the current dir |
| 15:19 | gfredericks | I think for regular business data maps are still recommended |
| 15:19 | bpr | uvtc: 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:19 | uvtc | bpr: Oh. Didn't know that. Thanks. |
| 15:20 | bpr | yup |
| 15:20 | cshell | has anyone ever seen the IllegalArgumentException: Can't define method not in interfaces. when used in protocols? |
| 15:22 | yonatane | gfredericks: 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:22 | gfredericks | cshell: you're just defining a protocol and don't have any types/records yet? |
| 15:23 | gfredericks | yonatane: that sounds reasonable |
| 15:23 | gfredericks | yonatane: I think I've done that before |
| 15:23 | cshell | I have a defrecord for the protocol |
| 15:23 | cshell | implementation |
| 15:23 | yonatane | gfredericks: any other idiomatic way to do it? |
| 15:23 | cshell | I've done a lein clean |
| 15:23 | gfredericks | yonatane: not really |
| 15:23 | cshell | i found something that said to disable don't-recompile-if-same-source but I don't know where that is |
| 15:24 | gfredericks | yonatane: protocols are also great when you want something to be extensible |
| 15:24 | daniel___ | ach, earlier i meant multidimensional arrays, not associative arrays |
| 15:24 | gfredericks | daniel___: I think I've used flat maps and nested vectors in different contexts depending on exactly what sort of interface I wanted |
| 15:24 | cshell | gfredericks: it's the same problem as listed here: http://bit.ly/MpC3hL |
| 15:25 | gfredericks | ah ha |
| 15:25 | gfredericks | but this is presumably fixed and you're still having the problem? |
| 15:25 | cshell | yep |
| 15:26 | cshell | although a clean and repl restart isn't working |
| 15:26 | cshell | so I can't get past it |
| 15:26 | cshell | where else would lein put the compiled protocol def? |
| 15:26 | gfredericks | cshell: what's your protocol def look like? |
| 15:26 | daniel___ | gfredericks: ok |
| 15:26 | yonatane | gfredericks: 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:27 | cshell | gfredericks: https://www.refheap.com/paste/3609 |
| 15:27 | daniel___ | 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:27 | daniel___ | in this case, i suppose i want a vector of maps |
| 15:28 | cshell | it's complaingin about the update! method, that's what I just added today |
| 15:28 | gfredericks | yonatane: ...so you're asking the question again? |
| 15:28 | daniel___ | [{:10010011 <attacks>}{:10100000 <attacks>}..] |
| 15:28 | cshell | yonatane: you can create a closure with the token bound |
| 15:28 | daniel___ | [{:10010011 <attacks> :10100000 <attacks>}{}{}..] in fact |
| 15:28 | yonatane | gfredericks: Yeah, in light of records :). maybe a record with the token as ctor argument |
| 15:29 | gfredericks | daniel___: what does each map signify? |
| 15:29 | daniel___ | the ocupancy on a given file or rank |
| 15:29 | gfredericks | yonatane: I think that kind of thing is normally handled with dynamic vars |
| 15:29 | daniel___ | the key signifies that, and it maps to a bitboard with the possible attack squares |
| 15:29 | yonatane | cshell: yeah, but if i have several functions, do i create each one, or a map of functions, or some other thing? |
| 15:29 | gfredericks | daniel___: so why do you have multiple maps instead of one? |
| 15:30 | daniel___ | (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:30 | gfredericks | cshell: looks like the sig for update! doesn't match |
| 15:31 | cshell | gfredericks: omg, that's it |
| 15:31 | cshell | thanks g |
| 15:31 | cshell | *slaps forehead* |
| 15:31 | cshell | yonatane: what I do is make the protocol with the methods and parameters (but not the token) |
| 15:31 | cshell | then I create a deftype which has a constructor that has the token |
| 15:32 | daniel___ | so it will be 8 maps in a vector i suppose [{}{}{}{}{}{}{}{}] |
| 15:32 | daniel___ | the index signifying the square that the attacking piece is on |
| 15:32 | daniel___ | and then inside each map, i have an occupancy mapped to an attack board |
| 15:33 | gfredericks | cshell: doesn't that mean you have to pass around a type instead of a token? |
| 15:33 | daniel___ | dont have a clue how im going to generate such a structure |
| 15:33 | gfredericks | daniel___: why 8 maps instead of 64 then? |
| 15:34 | gfredericks | since there are 64 squares |
| 15:34 | daniel___ | because im just concentrating on a rank or file |
| 15:34 | cshell | I just call a factory method when I need the functionality and then pass that in as the this parameter on the protocols |
| 15:34 | gfredericks | cshell: right. So you have to pass in something, whether the type or the token; I can't see why that's any easier |
| 15:34 | daniel___ | the attacks are going to be the same for each rank or file, given the same occupancy |
| 15:36 | yonatane | gfredericks: 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:36 | cshell | yonatane: dynamic vars can get thread local bindings - so that helps with concurrency |
| 15:36 | gfredericks | yonatane: dynamic vars have thread-local values |
| 15:36 | yonatane | that's great |
| 15:37 | cshell | gfredericks: 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:37 | cshell | gfredericks: and maybe I have a stubbed implementation or something which doesn't need the token to return values |
| 15:37 | yonatane | so I can call a bunch of functions with a specific value of the var. |
| 15:37 | yonatane | setting the var only once |
| 15:37 | gfredericks | yonatane: ofter the dynamic var is accompanied by a with-foo macro that sets it for you |
| 15:38 | gfredericks | s/ofter/often/ |
| 15:38 | gfredericks | yonatane: e.g., clojure.whatsit.jdbc's with-connection |
| 15:38 | yonatane | gfredericks: exactly! |
| 15:39 | gfredericks | it'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:39 | gfredericks | also if you use a monad people stop being your friend |
| 15:39 | cshell | haha |
| 15:40 | gfredericks | on the other hand, some times you can do similar things quite succinctly using -> |
| 15:42 | uvtc | Regarding the url-shortener example in the "Clojure Programming" book (Oreilly), (page 537), |
| 15:42 | uvtc | ~CPOR |
| 15:42 | uvtc | it uses a Ref to refer to its `mappings` data structure (mappings of string id's to long urls). |
| 15:42 | uvtc | Why 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:42 | uvtc | Why not instead use an atom here? |
| 15:44 | gfredericks | I *THINK* that there is a use case for a single ref which is |
| 15:44 | gfredericks | you want to read it, update it based on what you read, and also do something else with the read value |
| 15:44 | gfredericks | where on earth did I see this |
| 15:44 | gfredericks | it was in one of hiredman's codez |
| 15:45 | gfredericks | uvtc: imagine you wanted to use an atom to implement a queue |
| 15:45 | gfredericks | and have worker threads pulling stuff off to work on |
| 15:45 | gfredericks | think about how (defn pull-thing-off-queue [] ...) would be defined |
| 15:46 | uvtc | Ah. 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:46 | gfredericks | well that sounds doable actually |
| 15:46 | gfredericks | with an atom |
| 15:46 | gfredericks | unless you're trying to return info on whether it was there or not |
| 15:47 | uvtc | The check to see what the mapping contains, and also the alteration, are both inside a dosync. |
| 15:47 | gfredericks | (swap! a #(if (% k) % (assoc % k v))) |
| 15:47 | gfredericks | I'm not sure why ^ that wouldn't work |
| 15:48 | uvtc | gfredericks: Will think on that. Thanks. |
| 15:48 | gfredericks | next time cemerick is around ask him what on earth |
| 15:49 | uvtc | Will do. |
| 15:50 | wingy | what is the :test meta doing in the meta data of a function? |
| 15:50 | gfredericks | pointing to a test? |
| 15:51 | wingy | whe is it executed? |
| 15:51 | wingy | when |
| 15:51 | wingy | manually by user? |
| 15:52 | gfredericks | or by any framework that looks for that sort of thing |
| 15:52 | gfredericks | I dunno which ones do |
| 15:52 | wingy | ok |
| 15:56 | dgrnbrg | is it possible to have a type hint for an array of IFns? |
| 15:57 | dgrnbrg | I tried ^"[Lclojure.lang.IFn", but it said classnotfound |
| 15:57 | gfredericks | I don't remember the syntax but I'm sure it is |
| 15:57 | dgrnbrg | i can't find it anywhere on google |
| 15:57 | dgrnbrg | i found the syntax for primitive arrays |
| 15:58 | gfredericks | $google clojure array type-hints |
| 15:58 | lazybot | [Array Type Hints in Clojure] http://asymmetrical-view.com/2009/07/02/clojure-primitive-arrays.html |
| 15:58 | dgrnbrg | that post only talk about primitive arrays |
| 15:58 | gfredericks | it says primitive but it looks like he has an example with String |
| 15:59 | dnolen | ^"[Lclojure.lang.IFn;" |
| 15:59 | daniel___ | 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:59 | dnolen | ,(type (make-array clojure.lang.IFn 2)) |
| 16:00 | dgrnbrg | oh, semicolon |
| 16:00 | dgrnbrg | i missed that |
| 16:00 | gfredericks | &(doc map-indexed) |
| 16:00 | lazybot | ⇒ "([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:00 | dgrnbrg | hooray! |
| 16:00 | daniel___ | map-indexed, thats the one |
| 16:00 | dgrnbrg | it was the semicolon |
| 16:03 | dgrnbrg | i just got a job writing clojure all day |
| 16:03 | dgrnbrg | it's pretty awesome |
| 16:03 | gfredericks | that sounds pretty awesome |
| 16:05 | dgrnbrg | i get to integrate things like storm, cascalog, leiningen, and incanter with our java code base |
| 16:07 | eggsby | sounds like a lot of work |
| 16:07 | eggsby | but congrats :) |
| 16:10 | uvtc | dgrnbrg: nice. New job, or current one switching you to working on Clojure stuff? |
| 16:10 | dgrnbrg | it's actually the same job |
| 16:10 | dgrnbrg | i was previously working on our in-house distributed analysis framework |
| 16:10 | dgrnbrg | i made the case that clojure brings a lot to the table |
| 16:11 | dgrnbrg | so we're building an experimental system in clojure to iterate faster and explore the possibilities |
| 16:11 | uvtc | Hooo doggie. :) |
| 16:11 | dgrnbrg | that's built on our analysis framework |
| 16:11 | dgrnbrg | it's pretty awesome |
| 16:11 | dgrnbrg | we write emacs plugins, compilers, and think about new modes of interaction |
| 16:11 | dgrnbrg | like light table, but in our domain |
| 16:13 | eggsby | nice |
| 16:13 | eggsby | I'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:14 | antoineB | is there a function to get the number of a list ? example: (get 3 '(a b c d)) => c |
| 16:15 | uvtc | antihero: `nth` |
| 16:15 | dnolen | antoineB: nth |
| 16:15 | dgrnbrg | ,(nth 2 '(a b c d)) |
| 16:15 | uvtc | Whoops. Sorry antihero --- premature autocomplete. :) |
| 16:15 | dgrnbrg | &1 |
| 16:15 | lazybot | ⇒ 1 |
| 16:15 | antoineB | thanks |
| 16:15 | dgrnbrg | &(nth 2 '(a b c d)) |
| 16:15 | lazybot | java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number |
| 16:15 | dgrnbrg | &(nth '(a b c d) 2) |
| 16:15 | lazybot | ⇒ c |
| 16:20 | antoineB | a function for the size or lenght of a list? |
| 16:21 | eggsby | count |
| 16:21 | piotr | antoineB: you should have a look at http://clojure.org/cheatsheet |
| 16:21 | eggsby | you don't use get and count as often as you'd think antoineB |
| 16:22 | gfredericks | $findfn [1 2 3 40] 4 |
| 16:22 | lazybot | [clojure.core/count] |
| 16:22 | eggsby | they aren't used as often as .length and someArray[nth] |
| 16:22 | gfredericks | ,(.length '(a b c d)) |
| 16:22 | gfredericks | &(.length '(a b c d)) |
| 16:22 | lazybot | java.lang.IllegalArgumentException: No matching field found: length for class clojure.lang.PersistentList |
| 16:23 | antoineB | what is the difference with .length ? |
| 16:23 | eggsby | rather, as often as .length and array accessors in java/imperitive langs :p |
| 16:23 | eggsby | imperative even |
| 16:23 | antoineB | ok |
| 16:23 | wingy | when creating a var with def .. is that var called a variable? |
| 16:23 | wingy | or just a var |
| 16:24 | gfredericks | &(.length '[a b c d]) |
| 16:24 | lazybot | ⇒ 4 |
| 16:24 | gfredericks | wingy: a var |
| 16:24 | wingy | there are no variables in clj? |
| 16:24 | gfredericks | not local variables |
| 16:24 | wingy | what is a global variable? |
| 16:25 | wingy | atom, ref, var and agent? |
| 16:25 | gfredericks | well the changey things that exist are |
| 16:25 | aphyr | gfredericks: what about let frames? |
| 16:25 | uvtc | gfredericks: 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:25 | eggsby | ya, I like calling them values instead of variables |
| 16:25 | gfredericks | uvtc: how do you do int x = 12; x = 13;? |
| 16:26 | antoineB | (def x 12) |
| 16:26 | uvtc | gfredericks: I suppose create an atom with the value 12, then later swap in 13 for it. |
| 16:26 | eggsby | lol, (let [x 12] (let x [13] ;; do stuff)) |
| 16:26 | eggsby | it's beautiful |
| 16:26 | gfredericks | eggsby: those are two different x's |
| 16:26 | gfredericks | the first one doesn't change |
| 16:26 | eggsby | right |
| 16:26 | gfredericks | so clojure has explicit reference types |
| 16:27 | gfredericks | and the java types can have mutable fields |
| 16:27 | wingy | (i think i shall just forget the word variable) |
| 16:27 | gfredericks | but you cannot create a locally-scoped name that points to one thing and then change it to point to another thing |
| 16:27 | wingy | references are bound to values if you wanna simulate changing states/values |
| 16:28 | eggsby | ya |
| 16:28 | eggsby | well you were right stuff stuff like 'atom' is closer to a var wingy |
| 16:28 | daniel___ | clojure makes my brain hurt |
| 16:28 | gfredericks | ruby makes my fingers hurt |
| 16:29 | wingy | another 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:29 | eggsby | ya |
| 16:29 | uvtc | daniel___: feel the burn. Only a few ... more ... reps. |
| 16:29 | eggsby | so a hashmap can have anything as its key wingy |
| 16:29 | eggsby | like strings or symbols |
| 16:29 | eggsby | {"myString" 1, 'mySym 2} |
| 16:29 | antoineB | perl makes me confuse |
| 16:29 | eggsby | you could get out strings with :strs or symbs, similar to how you would get :keywords out with :keys |
| 16:30 | wingy | eggsby: ah .. i think i know what the problem was with :syms .. i didnt quote |
| 16:30 | wingy | yepp that was the problem |
| 16:30 | wingy | eggsby: thx |
| 16:30 | uvtc | gfredericks: 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:31 | dgrnbrg | does 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)" ... |
| 16:31 | wingy | clojure makes my eyes, heart and brain happy |
| 16:31 | antoineB | clojure have name wich refer to an object |
| 16:31 | uvtc | antoineB: funny thing about Perl though, it seems to have at least one thing in common with Clojure: practicality. |
| 16:31 | wingy | i have become a happier person overall since 2 weeks ago |
| 16:32 | wingy | thats weird a lang can have that effect on you |
| 16:32 | gfredericks | uvtc: 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:32 | akhudek | uvtc: 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:33 | uvtc | akhudek: don't worry --- I stop the comparison at that. :) |
| 16:33 | eggsby | uvtc: 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:34 | eggsby | s/mutea/muta |
| 16:34 | wingy | off topic question: is there anyone here from Stockholm? |
| 16:35 | gfredericks | eggsby: it can still be bad to the extent that it keeps you from using mostly pure functions |
| 16:35 | antoineB | uvtc: in perl you loose so many time to learn the many syntaxicaly ways of doing something instead of learning the different semantics ways |
| 16:35 | eggsby | gfredericks: I haven't heard a compelling argument about why pure is better than impure, is there anything I should read? :p |
| 16:36 | Squee-D | Side effects are the hardest things to debug? |
| 16:36 | gfredericks | bam |
| 16:36 | wingy | eggsby: easier to test since all the thing a pure fn need is passed as args |
| 16:36 | gfredericks | yeah, for debugging and testing, pure functions are huge |
| 16:36 | Squee-D | and im new to lisp, but thats what 'compels' me to learn it. |
| 16:38 | wingy | eggsby: 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:38 | eggsby | ya but i'm not going to start using the state monad in exchange for an atom |
| 16:38 | gfredericks | so 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:38 | Squee-D | Otherwise you may as well be using scala :D |
| 16:38 | eggsby | I don't see practical benefit, your transformation functions can still be pure functions... |
| 16:38 | wingy | fns dependent on global states is spaghetti |
| 16:38 | wingy | bad abstractions |
| 16:38 | gfredericks | eggsby: I didn't say all pure, I said mostly pure |
| 16:39 | Squee-D | you cant do all pure |
| 16:39 | daniel___ | im hating this function but im struggling to come up with something better: https://gist.github.com/3113254 |
| 16:39 | Squee-D | lol |
| 16:39 | daniel___ | 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:40 | daniel___ | the board is a vector of length 9: [\space \X \space \O ... ] |
| 16:40 | antoineB | i never understand the monad stuff |
| 16:41 | antoineB | is it a way to force the programmer to test all the possble case? |
| 16:41 | antoineB | like Option[] in scala? |
| 16:41 | eggsby | it's just a way to capture the entire notion of a computation antoineB |
| 16:41 | gfredericks | daniel___: (def in-a-rows (let [idx (partition 3 (range 9))] idx (map list idx) [[0 4 8] [2 4 6]])) |
| 16:41 | gfredericks | ^ then use that |
| 16:42 | gfredericks | antoineB: just figuring out what the possible cases are is rather difficult in a dynamic language |
| 16:42 | antoineB | what is "the entire notion of a computation"? |
| 16:42 | gfredericks | qubits! |
| 16:43 | eggsby | antoineB: http://www.scribd.com/doc/72134705/Comprehending-Monads can explain monads far better than I ever could |
| 16:44 | daniel___ | gfredericks: not sure what that does exactly |
| 16:44 | daniel___ | ,(def in-a-rows (let [idx (partition 3 (range 9))] idx (map list idx) [[0 4 8] [2 4 6]])) |
| 16:44 | daniel___ | ,in-a-rows |
| 16:45 | gfredericks | &(let [idx (partition 3 (range 9))] idx (map list |
| 16:45 | gfredericks | idx) [[0 4 8] [2 4 6]]) |
| 16:45 | lazybot | java.lang.RuntimeException: EOF while reading, starting at line 1 |
| 16:45 | gfredericks | &(let [idx (partition 3 (range 9))] idx (map list idx) [[0 4 8] [2 4 6]]) |
| 16:45 | lazybot | ⇒ [[0 4 8] [2 4 6]] |
| 16:45 | gfredericks | mrrrrmrmmm |
| 16:45 | gfredericks | ah I forgot the concat |
| 16:45 | gfredericks | &(let [idx (partition 3 (range 9))] (concat idx (map list idx) [[0 4 8] [2 4 6]])) |
| 16:45 | lazybot | ⇒ ((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:45 | antoineB | eggsby: espected on irc the font isn't so uggly :) |
| 16:45 | gfredericks | man I really screwed that up |
| 16:45 | daniel___ | :/ |
| 16:46 | gfredericks | &(let [idx (partition 3 (range 9))] (concat idx (apply map list idx) [[0 4 8] [2 4 6]])) |
| 16:46 | lazybot | ⇒ ((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:46 | gfredericks | okay that's what I meant |
| 16:46 | gfredericks | then you can write functions that iterate over all 3-in-a-rows without thinking about what that structure actually is |
| 16:48 | daniel___ | why are the last two vectors |
| 16:48 | daniel___ | the diagonals |
| 16:48 | gfredericks | cuz I gave them explicitly; isn't supposed to make a diff |
| 16:49 | daniel___ | i cant think hwo to iterate over them, without using a load of if/or/and statements like before |
| 16:50 | gfredericks | (some (fn [[a b c]] (= (board a) (board b) (board c))) three-in-rows)? |
| 16:51 | daniel___ | what about detecting whether it's a \X or a \O |
| 16:52 | gfredericks | use one of the indices in the result of that expression? |
| 16:52 | gfredericks | depends on what kind of output you're looking for exactly |
| 16:53 | daniel___ | i guess either \O \X or nil |
| 16:53 | daniel___ | then i can test for not nil |
| 16:53 | daniel___ | and whatever is returned is the winner |
| 16:53 | daniel___ | i lack a serious amount of creativity or something |
| 16:54 | daniel___ | 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:54 | daniel___ | ? |
| 16:54 | gfredericks | (some (fn [[a b c]] (if (= (board a) (board b) (board c)) (board a))) three-in-rows) |
| 16:54 | emezeske | daniel___: Nobody can see a good solution to *every* problem ^_^ |
| 16:55 | gfredericks | daniel___: I can see a good solution to these kind of silly problems because I've done them over and over. |
| 16:55 | wingy | i wanna get to that point i can read code very fast |
| 16:55 | wingy | to be thinking in code |
| 16:56 | emezeske | wingy: There's only one way to do that, AFAIK: read more code. :) |
| 16:56 | wingy | yeah |
| 16:56 | gfredericks | daniel___: where by "silly" I mean "not directly practical" |
| 16:56 | akhudek | wingy: think in datastructures, not code |
| 16:56 | wingy | akhudek: right .. everything is data |
| 16:56 | wingy | that's what you wanna say? |
| 16:56 | akhudek | pretty much |
| 16:57 | akhudek | I always think in trees, lists, vectors, etc |
| 16:57 | akhudek | translates to many languages easily |
| 16:57 | gfredericks | daniel___: https://github.com/fredericksgary/tictactoe/blob/master/src/ttt/core.clj#L69 |
| 16:57 | akhudek | functional languages just make it easier to directly implement this kind of thinking |
| 16:57 | akhudek | e.g. "transform each element in the list with function X" |
| 16:57 | wingy | akhudek: one of the fundamentals of FP is to manipulate these data structures right |
| 16:57 | wingy | i read somewhere that algorithms are overrated |
| 16:58 | akhudek | well, algorithms are not overrated |
| 16:58 | wingy | most of the things you do is to manipulate data |
| 16:58 | akhudek | but to create good algorithms you need to think about data structures |
| 16:59 | emezeske | wingy: 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:59 | antoineB | akhudek: algorithm go with datastructure |
| 16:59 | akhudek | that's exactly right |
| 17:00 | antoineB | there is no datastructure on a side and algorithm on another side |
| 17:00 | emezeske | wingy: But the reality is that datastructures and algorithms are really just two aspects of the same thing |
| 17:00 | gfredericks | datastrorithms |
| 17:00 | wingy | hmm interesting |
| 17:00 | wingy | they go hand in hand |
| 17:00 | emezeske | gfredericks: haha |
| 17:00 | antoineB | algotucture |
| 17:01 | akhudek | and they are language independent too |
| 17:01 | akhudek | for the most part |
| 17:01 | wingy | emezeske: what do you mean two aspects of the same thing |
| 17:01 | hyPiRion | emezeske: I'd say algorithms are "operations" on datastructures. |
| 17:01 | akhudek | obviously language can make particular algorithms and data structures easier or harder to write (or sometimes impossible) |
| 17:01 | gfredericks | never impossible! |
| 17:01 | wingy | hyPiRion: that seems fair |
| 17:02 | wingy | yeah .. its not a lot of fun to do FP in javascript |
| 17:02 | daniel___ | my version so far: https://github.com/danielstockton/naughts-and-crosses/blob/master/src/naughts_and_crosses/core.clj |
| 17:02 | emezeske | wingy: Well, I guess I just mean that some algorithms can't be described without describing their underlying datastructure |
| 17:02 | wingy | ; function {} nightmare |
| 17:02 | wingy | i realized clj is so concise so it really fits very well as a cli lang |
| 17:02 | antoineB | hyPiRion: flat data itself a datastructure |
| 17:03 | antoineB | *is itself |
| 17:03 | gfredericks | wingy: the underscore lib helps slightly |
| 17:03 | wingy | gfredericks: yeah .. but i ended up switching to livescript |
| 17:03 | cheater__ | but is the data structure data? |
| 17:03 | arohner | is there a built-in fn for casting a byte to an unsigned byte? i.e. (unsigned-byte -106) => 153 |
| 17:03 | antoineB | its not a lot of fun to do javascript |
| 17:03 | wingy | a better coffeescript with FP features |
| 17:03 | gfredericks | $findfn -106 153 |
| 17:03 | lazybot | [] |
| 17:04 | gfredericks | wingy: but now you're using cljs? |
| 17:04 | cheater__ | $findfn 153 -106 |
| 17:04 | lazybot | [] |
| 17:04 | cheater__ | interesting. |
| 17:04 | antoineB | cheater__: it's meta data or not :) |
| 17:04 | akhudek | arohner: java doesn't have unsigned types :-( |
| 17:04 | antoineB | or meta meta data |
| 17:04 | wingy | gfredericks: once i mastered server side with clj/datomic i plan to use cljs for frontend |
| 17:04 | akhudek | I think there are some convenience functions to simulate them anyways though |
| 17:05 | arohner | akhudek: I know, but I'd still like to treat it as unsigned, turning into a short or int if necessary |
| 17:05 | akhudek | arohner: I'm trying to remember where I read this, maybe it is Java7 that introduced something to handle this |
| 17:06 | ivan | Java 8 has some real unsigned ints |
| 17:08 | akhudek | ack, sorry, I can't seem to find it, but I remember that it was specific either to 1.7 or 1.8 |
| 17:08 | daniel___ | arohner there is unchecked-byte |
| 17:08 | daniel___ | oh, hes gone |
| 17:09 | hyPiRion | daniel___: that wouldn't convert it to an unsigned byte, though. |
| 17:09 | hyPiRion | ,(unchecked-byte -106) |
| 17:10 | gfredericks | lazybot should watch for , messages and respond if clojurebot doesn't. |
| 17:10 | daniel___ | hyPiRion: nope |
| 17:10 | gfredericks | maybe they should just keep tabs on eachother in the background |
| 17:12 | wingy | so 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:13 | wingy | doing tasks like 4clojure all day? |
| 17:13 | gfredericks | use it for stuff and read/participate-in discussions |
| 17:13 | antoineB | try to write your own dsl in clojure? |
| 17:13 | cheater__ | what is cljs? |
| 17:14 | wingy | clojurescript |
| 17:14 | cheater__ | what's that do? |
| 17:14 | antoineB | it compile to javascript |
| 17:14 | cheater__ | neato |
| 17:14 | emezeske | wingy: 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:14 | cheater__ | does it work well in browsers? |
| 17:14 | cheater__ | or is it mostly for v8 & co? |
| 17:15 | wingy | antoineB: DSLs using macro seem fun .. perhaps i could write a DSL for my business domain |
| 17:15 | gfredericks | cheater__: it works well in browsers |
| 17:15 | emezeske | wingy: Plus if you contribute something useful, you might get a free code review :) |
| 17:15 | cheater__ | gfredericks: even in ie7? |
| 17:15 | wingy | emezeske: yeah :) |
| 17:15 | gfredericks | cheater__: I'd be surprised if it didn't |
| 17:16 | emezeske | cheater__: CLJS uses the google closure compiler and library, which I'm pretty sure supports really old browsers |
| 17:16 | wingy | hope more books will be available .. i like reading books |
| 17:17 | wingy | would be cool if they had lynda videos for clojure .. i searched but they arent any |
| 17:17 | cheater__ | lynda? hahah. |
| 17:17 | wingy | cheater_: thats what i used to learn programming back in the days :) |
| 17:18 | cheater__ | at least it's not w3schools. |
| 17:18 | wingy | i just think fun stuff makes the entry easier |
| 17:18 | wingy | like head first series |
| 17:18 | wingy | so great |
| 17:19 | antoineB | i fail the first problem of 4clojure :/ |
| 17:19 | wingy | like when we have light table ready to rock .. i think it will convert a lot of people to clj |
| 17:19 | wingy | the tooling is really important for a lang's survival |
| 17:20 | antoineB | anyone who wants do an interactive test in swank? (you change the code, it change the result of your tests) |
| 17:21 | cheater__ | huh? |
| 17:21 | cheater__ | antoineB: what problem did you fail at? |
| 17:21 | antoineB | write your tests, write your function and have directly the result of your tests |
| 17:22 | antoineB | change your function, modify the result and so on |
| 17:22 | cheater__ | i don't understand :) |
| 17:23 | antoineB | when you write, your function you see the tests are executed (using the current function) |
| 17:24 | antoineB | and you see the result |
| 17:24 | antoineB | you don't need compile/eval + run the test |
| 17:25 | cheater__ | i'm sorry i see words but i don't know what they refer to |
| 17:25 | wingy | im so glad i moved on from php when i read this http://www.slideshare.net/fabpot/design-patternrevisitedphp53 |
| 17:25 | cheater__ | wingy: was going to click, but noticed "php" in url |
| 17:26 | gnarmis | anyone else doing a deep dive into emacs? just setup swank and all…things seem to work! |
| 17:26 | gnarmis | coming from vim |
| 17:27 | gfredericks | I did that 4 months ago maybe |
| 17:27 | antoineB | i just do clojure-jack-in |
| 17:27 | antoineB | that all |
| 17:31 | wingy | wow, never knew about condition-map in fns .. are there good use cases for those? |
| 17:32 | wingy | when would you wanna have a certain check in a condition-map instead of putting in the function itself |
| 17:32 | gfredericks | when you want the program to crash due to programmer error |
| 17:32 | gfredericks | rather than some other sort of exceptional case |
| 17:33 | gfredericks | they're the kind of thing you should be comfortable disabling in production |
| 17:34 | cheater__ | hey guys can someone explain this to me?#(+ % 5) |
| 17:34 | cheater__ | is % the "unshift"? |
| 17:34 | gfredericks | it's the arg |
| 17:34 | Raynes | (fn [x] (+ x 5)) |
| 17:34 | wingy | cheater__: the first arg |
| 17:34 | cheater__ | what if i have multiple args? |
| 17:34 | gfredericks | %1 %2 |
| 17:34 | wingy | the same as %1 |
| 17:34 | Raynes | #(+ % %2) |
| 17:34 | cheater__ | ah k |
| 17:35 | cheater__ | is #() the same as function definition? |
| 17:35 | gfredericks | man we can't resist easy questions apparently |
| 17:35 | Raynes | I feel insulted when people don't answer in code. |
| 17:35 | gfredericks | cheater__: it's a reader macro; you can use read-string to see what it expands to |
| 17:35 | gfredericks | &(read-string "#(+ %1 %2)") |
| 17:35 | lazybot | ⇒ (fn* [p1__69903# p2__69904#] (+ p1__69903# p2__69904#)) |
| 17:35 | gfredericks | Raynes: ^ there you go :P |
| 17:36 | cheater__ | ok so fn defines an anonymous function? |
| 17:36 | gfredericks | yeah |
| 17:36 | cheater__ | what if i do (fn add-five [x] (+ x 5)) ? |
| 17:36 | cheater__ | is it still anonymous? |
| 17:36 | wingy | cheater__: you should pick up the book "Programming Clojure" .. it will walk you through all this stuff |
| 17:36 | Raynes | Yes. |
| 17:37 | Raynes | You can't access add-five outside the scope of add-five. |
| 17:37 | gfredericks | Raynes: say that in code |
| 17:37 | cheater__ | i can't wait till a book arrives from amazon |
| 17:37 | cheater__ | i need to know clojure now ! |
| 17:37 | cheater__ | :) |
| 17:37 | cheater__ | Raynes: thanks |
| 17:37 | Raynes | &(do (fn add-five [x] (+ x 5)) (add-five 5)) |
| 17:37 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: add-five in this context |
| 17:37 | Raynes | gfredericks: ^ |
| 17:37 | cheater__ | Raynes: i was wondering why they ever give names to anonymous functions, i guess it's only for recursion? |
| 17:37 | gfredericks | Raynes: phew |
| 17:38 | wingy | cheater__: there is an ebook i think |
| 17:38 | gfredericks | cheater__: alse I think it will leak into the compiled class name, which can be nice |
| 17:38 | cheater__ | wingy: i'm just going through 4clojure since you guys linked it. |
| 17:38 | wingy | cheater__: i think basic knowledge before doing 4clojure is better |
| 17:38 | Raynes | &((fn to-five [x] (if (< 5 x) (to-five (inc x)) x)) 1) |
| 17:38 | lazybot | ⇒ 1 |
| 17:38 | cheater__ | i thought 4clojure was for learning basic knowledge |
| 17:38 | Raynes | I lose. |
| 17:39 | Raynes | &((fn to-five [x] (if (< x 5) (to-five (inc x)) x)) 1) |
| 17:39 | lazybot | ⇒ 5 |
| 17:39 | Raynes | &((fn [x] (if (< x 5) (recur (inc x)) x)) 1) |
| 17:39 | lazybot | ⇒ 5 |
| 17:39 | cheater__ | is "partial" the same as currying? |
| 17:39 | Raynes | No. |
| 17:39 | cheater__ | what's the diff? |
| 17:40 | Raynes | One is called partial application and the other is called currying. |
| 17:40 | wingy | gfredericks: cant still create a use case in my head regarding pre and post condition map .. would you mind give me a concrete example? |
| 17:40 | cheater__ | is there an actual difference? |
| 17:40 | wingy | eg. if they don't pass a wrong data type? |
| 17:40 | wingy | i mean if they pass a wrong data type? |
| 17:40 | wingy | but that would be like type checking |
| 17:41 | gfredericks | you can check arbitrary things |
| 17:41 | gfredericks | so it's kind of stronger than type checking |
| 17:41 | wingy | like no trailing whitespace in strings? |
| 17:41 | gfredericks | sure |
| 17:41 | emezeske | cheater__: There is a difference. Currying would mean that ((fn [a b] (+ a b) 1) would return a function like (fn [b] (+ 1 b)) |
| 17:41 | Raynes | cheater__: http://stackoverflow.com/questions/218025/what-is-the-difference-between-currying-and-partial-application |
| 17:42 | emezeske | cheater__: Clojure does not support that, though, it would complain about wrong arity to the first fn |
| 17:42 | gfredericks | emezeske: http://github.com/fredericksgary/currj |
| 17:43 | wingy | gfredericks: 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:43 | emezeske | gfredericks: that is super cool. |
| 17:43 | ldh | i'm struggling to configure jetty from lein-ring. I've got: |
| 17:43 | ldh | :ring {:handler my-app.core/app |
| 17:43 | ldh | :adapter { :configurator (fn [& more] (println "Configuring"))}} |
| 17:43 | ldh | which gives me : java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn |
| 17:43 | gfredericks | wingy: I imagine they're available in the post conditions, but probably most postconditions just refer to %, the return value |
| 17:45 | ldh | if 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:45 | wingy | gfredericks: i created an example: (defn constrained-sqr [x] {:pre [(pos? x)] :post [(= x 1)]} (* x x)) |
| 17:46 | weavejester | ldh: Embedding functions in the project.clj file is not really what it's designed for... |
| 17:46 | wingy | what does the word :pre and :post refer to? |
| 17:46 | wingy | they both check the parameter list |
| 17:46 | weavejester | ldh: What do you need to configure? |
| 17:46 | gfredericks | wingy: :pre gets run before, :post gets run after |
| 17:47 | ldh | weavejester: 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:47 | wingy | whats the exact difference? and before/after what btw? the fn body execution? |
| 17:47 | gfredericks | yes |
| 17:47 | gfredericks | that is the exact difference |
| 17:47 | gfredericks | and of course :pre can't access the return value |
| 17:48 | wingy | i see .. putting % in pre generates error |
| 17:48 | gfredericks | quite |
| 17:48 | weavejester | ldh: 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:49 | wingy | but is there a reason for wanting to assert the argument list again in a post conditin? |
| 17:49 | wingy | condition |
| 17:49 | wingy | seems like you are really interested in the return value |
| 17:49 | gfredericks | wingy: 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:50 | wingy | yeah |
| 17:50 | wingy | this was a quite hidden feature .. haven't encountered it yet in 2 books |
| 17:51 | oskarth | :q |
| 17:51 | oskarth | wrong winodw |
| 17:51 | ldh | weavejester: 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:51 | weavejester | ldh: You can apply the "wrap-reload" middleware directly. |
| 17:52 | weavejester | ldh: It's in ring.middleware.reload in the ring/ring-devel package |
| 17:52 | ldh | weavejester: i thought as much. fantastic, thanks. |
| 17:52 | Squee-D | oskarth oh i though you were licking your nose |
| 17:52 | Squee-D | :P |
| 17:52 | gfredericks | lol |
| 17:53 | Squee-D | thanks, I'll be here all week. With very little useful to say :D |
| 17:53 | gfredericks | ,:q |
| 17:53 | gfredericks | &:q |
| 17:53 | lazybot | ⇒ :q |
| 17:54 | Squee-D | im really enjoying Land Of Lisp. If anyone asks for a noob primer, this thing is great |
| 17:55 | gfredericks | apparently cljs does not have pre/post conditions |
| 17:55 | wingy | oh |
| 17:56 | wingy | i hope cljs could be as near clj as possible though |
| 17:56 | wingy | so there is no surprise |
| 17:56 | wingy | pre/post seems possible to do at least |
| 18:07 | arohner | $findfn 154 -106 |
| 18:07 | lazybot | [] |
| 18:22 | bpr | is there a more succinct way to do: https://www.refheap.com/paste/3610 |
| 18:25 | gfredericks | bpr: that looks like a reduce |
| 18:25 | bpr | ah blah |
| 18:25 | bpr | yes |
| 18:45 | oskarth | Squee-D: lol :p |
| 18:45 | oskarth | using vim with clojure is kind of like that |
| 18:52 | Squee-D | i believe it :D |
| 18:55 | wingy | seems that data structures refer to not only collections but to scalars as well: http://clojure.org/data_structures |
| 19:47 | wingy | oh my bad i think |
| 19:47 | wingy | data structures don't refer to scalars .. weird that they are mentioned in the same section though |
| 19:49 | duck1123 | well, do you consider 7 to be a data structure? |
| 19:50 | wingy | watching a video where he explains data structures |
| 19:50 | gfredericks | I'm using 7 as a data structure in my cljs program :) |
| 19:50 | wingy | it seems that scalars are data structures as well |
| 19:50 | duck1123 | I don't see the point of 7 |
| 19:50 | duck1123 | and they eat all the cake |
| 19:50 | gfredericks | (extend-type js/Number IBasisVector ...) |
| 19:51 | wingy | i just wanna know if the term "data structure" refer to scalar values as well |
| 19:52 | wingy | could someone confirm that |
| 19:52 | gfredericks | I would think not |
| 19:52 | duck1123 | what does it matter |
| 19:52 | duck1123 | clojure doesn't really concern itself with "scalar" |
| 19:53 | duck1123 | I mean there's things that return sequences and what not, but the concept of scalar isn't really special |
| 19:54 | duck1123 | If the function doesn't work with non-collections or non-seqable things, it'll say as such |
| 20:04 | wingy | but watching this video rich says that the reader reads in data structures |
| 20:04 | wingy | when you type 1 in the repl you get returned the data structure of it |
| 20:04 | wingy | which is just 1 |
| 20:05 | wingy | so it seems that all numbers, strings, booleans, keywords etc are called data structures as well |
| 20:06 | duck1123 | sure |
| 20:09 | gfredericks | I think he was probably being loose with his language |
| 20:10 | gfredericks | precisely defining data structures was not his intention at that moment |
| 20:10 | wingy | so you are saying that by data structures he mean collections |
| 20:10 | wingy | list, vector, map and set only |
| 20:11 | gfredericks | yeah |
| 20:12 | gfredericks | he was probably describing homoiconicity |
| 20:12 | wingy | what do we call the other ones? |
| 20:12 | gfredericks | scalars |
| 20:12 | wingy | and both scalars and data structures are forms right |
| 20:12 | gfredericks | yeah; a form is usually something evalable; or at least code-like |
| 20:13 | gfredericks | rather than data-like |
| 20:13 | gfredericks | it's a distinction of purpose |
| 20:13 | wingy | '(1 2 3) is a form? |
| 20:13 | gfredericks | probably not; depends on the purpose |
| 20:13 | wingy | but then you can probably say it evals to itself |
| 20:13 | wingy | just like :keyword is |
| 20:13 | gfredericks | no it doesn't |
| 20:14 | wingy | oh |
| 20:14 | wingy | but :keyword is? |
| 20:14 | gfredericks | :keyword does eval to itself |
| 20:14 | wingy | ok .. thought that what you saw returned in the repl was the evaluation |
| 20:15 | wingy | so its confusing the scalar values are listed in the Data Structures section |
| 20:15 | gfredericks | if '(1 2 3) evaled to itself then you could run (eval *1) all day and get the same thing |
| 20:15 | wingy | incidental confusion! |
| 20:15 | gfredericks | wingy: it's not a word meant to be stressed over |
| 20:16 | LesZedCB | why is it not a form? is it not equivalent to (quote (1 2 3))? |
| 20:16 | wingy | but when the same term is mentiond all over in books and in blogs etc you kinda wanna know what they exactly mean :) |
| 20:16 | gfredericks | it is |
| 20:17 | gfredericks | LesZedCB: I was using a somewhat constrained definition of form; if you meant "anything output by the reader" then yes it is |
| 20:17 | LesZedCB | well, isn't a form technically just any valid clojure data structure? |
| 20:17 | gfredericks | wingy: if you want something generally accepted look at the wikipedia article |
| 20:17 | xumingmingv | I'm trying to build this lein plugin: https://github.com/febeling/lein-junit |
| 20:17 | gfredericks | LesZedCB: it doesn't have a techincal definition that I'm aware of |
| 20:18 | xumingmingv | but seems leiningen:leiningen:jar:1.7.0 can not be found in clojars.org |
| 20:18 | xumingmingv | anybody know why? |
| 20:18 | gfredericks | LesZedCB: I can imagine a majority of people believing what you said though, so I might just be ignorant |
| 20:21 | LesZedCB | so, i have a question about '&' used in variadic functions. |
| 20:22 | LesZedCB | suppose (fn useless [x & rest] (println rest)) |
| 20:23 | dnolen | gfredericks: wingy: LesZedCB: I think a "form" would refer to anything that is readable - that is will be accepted by the reader. |
| 20:23 | LesZedCB | how does & fit in with the language? for example I can't evaluate (type &) |
| 20:23 | LesZedCB | dnolen: That makes sense, thanks! |
| 20:25 | wingy | i just use (read) to know what is a form |
| 20:25 | wingy | & is a form as well since it can be read |
| 20:25 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: is in this context |
| 20:26 | LesZedCB | & is not a form by itself, and [x & rest] is not a form by itself |
| 20:26 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: is in this context |
| 20:26 | wingy | why can i do |
| 20:26 | wingy | (read) |
| 20:26 | wingy | then type & |
| 20:26 | LesZedCB | (read &) you mean? |
| 20:26 | wingy | i returns & which means it has to be a form |
| 20:26 | wingy | no |
| 20:26 | wingy | (read) .. then & and hit enter |
| 20:27 | wingy | everything (read) can read must be a form i guess |
| 20:28 | LesZedCB | hmm. interestingly, in the lein REPL, "(read) &" does not evaluate, and in the clojure repl, it does |
| 20:30 | wingy | im in lein repl |
| 20:30 | wingy | it does read for me |
| 20:30 | wingy | lein 2 |
| 20:31 | LesZedCB | oh, I see what you did |
| 20:31 | LesZedCB | try (read-string "&") |
| 20:31 | wingy | yeah |
| 20:31 | wingy | the same |
| 20:31 | wingy | but reading a string instead of a stream |
| 20:31 | wingy | so that means & is a form right :) |
| 20:32 | LesZedCB | sorry, right. but try just "&" |
| 20:33 | dnolen | LesZedCB: 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:34 | wingy | ok so what gfredericks said |
| 20:34 | wingy | code like thing |
| 20:34 | LesZedCB | dnolen: yes that makes sence, if it can pass read and eval. |
| 20:34 | musicalchair | a form has evaluation semantics |
| 20:35 | wingy | could one say that a form is an expression? |
| 20:35 | wingy | on the other hand an expression could be composed of multiple forms .. i think i get it |
| 20:35 | musicalchair | I would say all forms are expressions but not all expressions are forms |
| 20:35 | wingy | yeah |
| 20:37 | gfredericks | dnolen: that's funny I would have assumed it would refer to post-read if anything |
| 20:37 | gfredericks | as in (defmacro fooball [form] ...) |
| 20:38 | gfredericks | and "s-expression" might refer to the string version |
| 20:39 | gfredericks | wingy: this just confirms that it doesn't matter all that much :) |
| 20:39 | wingy | yeah haha |
| 20:40 | gfredericks | &(eval (eval :foo)) |
| 20:40 | lazybot | java.lang.SecurityException: You tripped the alarm! eval is bad! |
| 20:40 | gfredericks | aw poopsmith |
| 20:41 | wingy | clj is too cool |
| 20:41 | wingy | ill teach my son clj that's for sure |
| 20:41 | gfredericks | good luck explaining what "the jvm" is |
| 20:42 | wingy | why would that be a hard thing |
| 20:43 | wingy | its a platform for runing clj |
| 20:43 | gfredericks | that's what computers are |
| 20:43 | gfredericks | or maybe operating systems |
| 20:43 | wingy | but then jvm is an abstraction on top of OSes |
| 20:43 | wingy | so we don't have to care about the OSes |
| 20:43 | wingy | i think he'll get the pic |
| 20:44 | gfredericks | but we do have to care about the jvms |
| 20:44 | wingy | perhaps he won't even bother with understanding OSes |
| 20:44 | musicalchair | not if you're a little kid learning clojure |
| 20:44 | wingy | thats because i dont get it |
| 20:44 | gfredericks | in the future people will not be familiar with the existence of "operating systems" |
| 20:44 | wingy | :D |
| 20:45 | gfredericks | &:D |
| 20:45 | lazybot | ⇒ :D |
| 20:45 | wingy | lol |
| 20:45 | LesZedCB | lol |
| 20:45 | gfredericks | &'<o.o> |
| 20:45 | lazybot | ⇒ <o.o> |
| 20:45 | duck1123 | I gave my son a Ruby shell to play with. I'll let him get a bit older before I try lisp |
| 20:45 | gfredericks | look son. if you give it a funny face it will give you one back. |
| 20:45 | LesZedCB | thanks for the response. cheers! |
| 20:46 | wingy | duck1123: why not clj immediately? |
| 20:46 | gfredericks | he has to learn about assignment and mutable data structures before he can learn to avoid them |
| 20:46 | duck1123 | he was 5 |
| 20:46 | wingy | does he? can't we just start correct |
| 20:47 | wingy | and then show him the OOP where everything is a mess |
| 20:47 | gfredericks | no. start with GOTO and malloc. |
| 20:47 | duck1123 | He's 7 now, he may be able to grok it. |
| 20:47 | wingy | duck1123: i think people can get things when they are 4-5 really quickly .. if they have a good teacher |
| 20:47 | duck1123 | Kids these days don't appreciate not needing to number their lines by 10 |
| 20:47 | wingy | a 10 years old can be way smarter than a 30 years old if he started early |
| 20:48 | wingy | i won't put my boy through hell like the one i had to go through |
| 20:48 | duck1123 | I was thinking that if I was going to teach him Clojure, I would use light table for that instant response |
| 20:49 | wingy | i teach him lisp immediately .. syntax comes and goes .. logic stays forever! |
| 20:49 | wingy | i want him to tell his teacher that |
| 20:50 | mefisto` | I agree... I want to do the same thing with my daughter (due in 1 month!) |
| 20:51 | gfredericks | man I should get my son to type his first paren before he gets out his first word |
| 20:51 | wingy | i wont dare to teach my girl computer |
| 20:51 | wingy | she can't be as geeky as me |
| 20:51 | wingy | i'll teach her design! |
| 20:52 | duck1123 | I want to give my daughter as much opportunity as possible to learn science and technology |
| 20:52 | gfredericks | duck1123: teach your son design! |
| 20:53 | wingy | yeah who knows .. maybe it will be more trendy for girls to know programming |
| 20:53 | gfredericks | your mother and I will love you no matter what you do, as long as it's trendy. |
| 20:53 | wingy | i teach my girl design .. my boy programming .. they both do an app together by 15 years old and bring me money |
| 20:54 | mattmoss | Awesome sauce, duck1123: "Kids these days don't appreciate not needing to number their lines by 10." |
| 20:55 | gfredericks | if I had designed the language they would have been numbered by 7 |
| 20:55 | mattmoss | Line numbers written in base 7 as well? Or is that too easy? |
| 20:55 | gfredericks | no too easy |
| 20:55 | gfredericks | base 10 |
| 20:56 | mattmoss | 20 GOTO 10 becomes 26 GOTO 13 |
| 20:56 | duck1123 | I 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:59 | mattmoss | POKE 1024,42 |
| 21:00 | wingy | what 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:01 | gfredericks | wingy: same var |
| 21:01 | hyPiRion | You could try it out. |
| 21:01 | wingy | hyPiRion: didn't know how to compare them to see if they were the same |
| 21:01 | wingy | (identical? (def a 1) (def a 2)) ;=> true |
| 21:04 | duck1123 | wingy: you're creating the var a and altering its root binding |
| 21:06 | wingy | is that idiomatic way of changing a value of a var? |
| 21:06 | wingy | or should i use binding or atom? |
| 21:07 | wingy | or let |
| 21:07 | gfredericks | you don't normally want to change the root binding |
| 21:07 | gfredericks | what are you trying to do? |
| 21:08 | wingy | nothing .. watching videos are questions arise :) |
| 21:08 | wingy | nvm |
| 21:08 | wingy | ill get to it later more in depth |
| 21:08 | quizme | i have an array of 10 things wrapped in an atom. How can i access those 10 things from another clojure process ? |
| 21:09 | gfredericks | deref the atom? |
| 21:09 | gfredericks | and access the 10 things? |
| 21:09 | duck1123 | quizme: do you have the atom stored in a var that both threads can read? |
| 21:10 | quizme | i want to access it from a different process |
| 21:10 | duck1123 | avout? |
| 21:10 | quizme | i mean i want to fire up two different leiningen projects |
| 21:10 | duck1123 | https://github.com/liebke/avout |
| 21:10 | quizme | and have them share the same atom |
| 21:11 | duck1123 | you'll need to store it somewhere outside of the jvms memory or send it to the other process somehow |
| 21:11 | gfredericks | ah ha |
| 21:12 | quizme | how can i send it to the other process ? |
| 21:12 | quizme | i guess i have to create a socket |
| 21:13 | duck1123 | open a socket between the two, store it in a queue, a myriad of ways |
| 21:13 | duck1123 | check out that link i just sen |
| 21:13 | quizme | duck1123 ok thank you |
| 21:16 | quizme | duc1123 looks awesome. |
| 21:18 | duck1123 | I've only played with it a little bit. I want to make use of it, but just haven't had the time |
| 21:18 | duck1123 | also, slacker is kind of cool for inter-process communication |
| 21:21 | duck1123 | I 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:35 | emezeske | duck1123: Is a websocket client something that runs in the browser? |
| 21:35 | duck1123 | well it can, but it could be any connection really |
| 21:36 | emezeske | duck1123: I was just going to suggest "rlwrap" to get readline features, but it only works for command-line tools |
| 21:36 | duck1123 | I found a swing one, but it was no good and the node.js stuff I found was more of a library |
| 21:37 | duck1123 | I've been building out a command interface to my server that works over the open websocket connection |
| 21:37 | emezeske | You might try staring it via rlwrap |
| 21:37 | emezeske | It tends to have pretty decent results for normal REPL type things |
| 21:38 | duck1123 | I could probably take my cljs code and make a node.js command |
| 21:38 | duck1123 | never done that before |
| 22:43 | sjl | is there something special I need to do to include images in my /resources/ directory when hosting a Noir site on Heroku? |
| 22:43 | sjl | The rest of the /resources/ work, and the image resources work locally... |
| 22:44 | technomancy | with compojure IIRC the "site" handler does that for you |
| 22:44 | technomancy | or wrap-resource with raw ring |
| 22:44 | technomancy | not sure how noir does it |
| 22:44 | sjl | nevermind, git is being an asshole |
| 22:45 | sjl | git commit --all-but-not-really-all-lol |
| 22:45 | sjl | sorry for the noise |
| 22:46 | musicalchair | could anyone explain under what circumstances I would use clojure.contrib.graph/stratification-list? Google hasn't been particularly illuminating for me |
| 22:47 | sjl | musicalchair: well clojure.contrib is abandoned, so effectively: "None" |
| 22:47 | duck1123 | Slightly 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:48 | musicalchair | sjl: I'm aware it's not officially supported, but the code still works and presumably the concept still lives |
| 22:48 | sjl | musicalchair: sure |
| 22:49 | emezeske | duck1123: I think more context is needed to explain firebug's behavior |
| 22:49 | emezeske | duck1123: Regarding communications, I think using pr-str/read-string for (de)serialization is pretty common |
| 22:50 | emezeske | duck1123: Although I know some people use JSON and other formats |
| 22:50 | duck1123 | I'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:51 | duck1123 | what 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:51 | duck1123 | I'm hesitant to use clj forms as I want the websocket connection usable from outside of the site |
| 22:52 | sjl | duck1123: heh, you're going to cry when I tell you the answer. |
| 22:52 | sjl | duck1123: try {a = "b"} |
| 22:52 | duck1123 | see, my issue is that clojure.data.json gives me the form I said above |
| 22:53 | emezeske | duck1123: Or try x = {"a" : "b"} |
| 22:53 | emezeske | duck1123: I think the {string : string} format only works for assignment |
| 22:53 | duck1123 | wow |
| 22:54 | sjl | try { 1 + 3; } |
| 22:54 | sjl | lol |
| 22:54 | sjl | Firebug is parsing the braces as a block, not the start of an object literal |
| 23:00 | duck1123 | Ok, 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:01 | duck1123 | It's because I was using eval. Need to find the fix for tha |
| 23:03 | duck1123 | got it |
| 23:42 | ned | i'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:45 | jkkramer | ,((fn [x] (concat "Hello, " x "!")) "ned") |
| 23:45 | ned | ,(+ 9 9) |
| 23:45 | jkkramer | &((fn [x] (concat "Hello, " x "!")) "ned") |
| 23:45 | lazybot | ⇒ (\H \e \l \l \o \, \space \n \e \d \!) |
| 23:46 | ned | oh hm, what's the appropriate concat method then |
| 23:46 | duck1123 | just use str (sorry for spoiler) |
| 23:46 | ned | duck1123: haha no need to apologize, i thought i was doing something dumb and i was! |
| 23:48 | duck1123 | if you have a seq of charachters like that... (apply str coll) |
| 23:48 | michaelr` | good morning! |