2014-08-14
| 00:41 | johnwalker | technomancy: here is the plugin i was talking about: https://github.com/johnwalker/lein-plz |
| 00:41 | johnwalker | haven't switched from rewrite to just lein yet |
| 00:41 | johnwalker | and i have to add user support abbreviations, but it does the job |
| 02:12 | arrdem | johnwalker: nice one! |
| 02:13 | arrdem | johnwalker: would/could you add a clojars search? `lein pls add meajure` would be amaze |
| 02:37 | johnwalker | arrdem: thanks :) |
| 02:38 | arrdem | lol @ :pls profile key |
| 02:38 | johnwalker | arrdem: i think i like that idea |
| 02:38 | johnwalker | yeah i was in a good mood when i made it |
| 02:39 | arrdem | johnwalker: I just think it makes sense... ~80% of the time I know artifact ID but not always group ID. consequently being able to say `lein pls add ...` have search as a fallback would be amaze |
| 02:39 | johnwalker | i still am. lein is pretty good |
| 02:40 | johnwalker | i'll check search results. if they're unique enough, i'll do it ;p |
| 02:40 | johnwalker | it might be easier to just specify the full dependency once and remember it by the abbreviation |
| 02:41 | arrdem | that could work too. |
| 02:41 | arrdem | even defaulting to the first result, and printing the dep vector prior to adding would be nice |
| 02:41 | johnwalker | or a "did you mean ?" when an abbrev isn't found |
| 02:41 | johnwalker | so much you can do with the idea |
| 02:42 | arrdem | eh that's real search tho |
| 02:42 | arrdem | just default to the first clojars result, tell me what it was and make me deal with the failure cases |
| 02:42 | johnwalker | ahh, i like that |
| 02:42 | arrdem | that'll cover the overwhelming majority of my use |
| 02:42 | arrdem | also what's your typed-clojure work? were you the GSoC student this year? |
| 02:42 | johnwalker | oh nah, i just made an emacs minor mode ;) |
| 02:43 | arrdem | o |
| 02:43 | johnwalker | i've been following oxcart |
| 02:43 | johnwalker | very exciting |
| 02:43 | arrdem | today's been the real fun... |
| 02:44 | arrdem | http://github.com/oxlang |
| 02:44 | supreme__ | possible to write GUI os x applications in clojure? |
| 02:44 | johnwalker | oh my |
| 02:44 | arrdem | yeah I went full retard today |
| 02:44 | arrdem | supreme__: anything's possible with a turing complete langauge featuring FFI... |
| 02:45 | johnwalker | that will be interesting |
| 02:45 | arrdem | that clojure build totally works |
| 02:45 | arrdem | the next question is how do I need to structure the Oxcart compiler such that lib-clojure is a runtime dep of Oxcart compiled programs. |
| 02:46 | arrdem | because that's the last thing to do. |
| 02:46 | arrdem | that and really test the shit out of it. |
| 02:47 | johnwalker | this will be where the rubber meets the road |
| 02:48 | johnwalker | does clojure settle for "good enough" ? (i'm looking at you python) |
| 02:49 | arrdem | eh... I think that Oxcart/Oxlang really isn't Clojure and tbaldridge has some I think pursuasive oppinions on that point |
| 02:49 | arrdem | that said I think Clojure is a really nice lisp, and having a static lisp for the JVM would be nice |
| 02:51 | johnwalker | maybe not, but it's the same crowd |
| 02:52 | johnwalker | he probably knows better though |
| 02:53 | johnwalker | oh wow a tweet, thanks ! |
| 02:54 | arrdem | lolz |
| 03:10 | johnwalker | this plugin just gave me flashbacks from runescape |
| 03:12 | arrdem | lol |
| 03:42 | clgv | can I convince clojure.test.check to skip shrinking? I have a use case where I just want it to fail |
| 03:44 | lvh | What's the thing I should use these days for SQL interaction? still korma, or sqlvingo or whatever it's called |
| 03:44 | lvh | sqlingvo |
| 03:44 | lvh | apparently. |
| 03:44 | lvh | I like that the latter gives me DDL :) |
| 03:44 | clgv | lvh: depends on your needs. a student of mine just used clojure.java.jdbc |
| 03:45 | clgv | but it was a small project with few business objects |
| 03:45 | lvh | clgv: Okay, fair enough. |
| 03:45 | clgv | lvh: what is sqlvingo? |
| 03:46 | lvh | clgv: Me horribly misspelling sqlingvo |
| 03:46 | lvh | https://github.com/r0man/sqlingvo |
| 03:46 | lvh | It looks like an extremely close representation of SQL as sexps |
| 03:46 | lvh | which I like :) |
| 03:46 | lvh | clgv: None of my business, but "student"? Are you a teacher? :) |
| 03:47 | lvh | Where do I go so that I get to write clj? |
| 03:47 | clgv | lvh: not really teacher, but phd student with teaching obligations ;) |
| 03:48 | lvh | clgv: my favorite teacher ever was a phd student |
| 03:48 | lvh | (eh, acutally a postdoc at that point I think) |
| 03:48 | lvh | unfortunately no longer with us :( |
| 03:48 | clgv | sqlingvo looks like a thin layer above clojure.javajdbs |
| 03:48 | lvh | https://en.wikipedia.org/wiki/Len_Sassaman |
| 03:49 | lvh | clgv: yes |
| 03:49 | clgv | oh |
| 03:49 | lvh | clgv: I consider that a virtue looking at the code examples |
| 03:50 | lvh | I don't actually dislike sql other than paredit not working with it ;) |
| 03:51 | clgv | you could make it symbols and stuff via reader literals, but not sure whether it would be worth it ;) |
| 03:53 | lvh | clgv: I guess as a side effect, it is not good at producing polyglot sql |
| 05:52 | qswz | How do you import a project created with Leiningen, in Eclipse, counterclockwise doesn't allow that |
| 05:53 | qswz | ah ok, with new and other location |
| 05:56 | noidi | yes, create a new Eclipse project on top of the Leiningen project, right click the project in Package Explorer and select Configure -> Convert to Leiningen project |
| 05:59 | qswz | yep |
| 06:08 | r4vi | there is probably a lein plugin |
| 06:08 | r4vi | i use lein-idea to create intellij projects |
| 06:11 | r4vi | qswz: this might be useful https://clojars.org/lein-ccw |
| 06:15 | qswz | r4vi: ok |
| 06:17 | sm0ke | any simple and fast way for maintaining a pool of connectino objects? |
| 06:17 | sm0ke | custom connection objects not necessarily rdb |
| 06:20 | sm0ke | a simple assoc and dissoc from #{} ? |
| 06:22 | dbushenko | sm0ke, why not? just use atom over it |
| 06:23 | sm0ke | yep |
| 06:25 | clgv | qswz: better use the builtin way since that lein plugin seems pretty old |
| 06:26 | qswz | yes, that's what I did |
| 06:26 | clgv | you can have a look at the issues on google code to see whether their is an issues for "leiningen project import" |
| 06:27 | qswz | create from location is the same as importing I guess :) |
| 06:37 | smokeweed | question w.r.t ClojureScript: is it possible to extend native Javascript types like HTMLCollection? |
| 06:42 | smokeweed | I actually tried it and while extening "object" works for plain old JS objects, I cannot find any info how to extend other types, like HTMLCollection |
| 06:54 | clgv | smokeweed: extend a la `reify`? |
| 06:55 | TimMc | clgv: Did you get an answer on shrinking? |
| 06:55 | clgv | TimMc: no |
| 06:55 | smokeweed | clgv: hm, could you be more specific? I'm actually learning ClojureScript at the very same moment and I'm not sure what do you mean, |
| 06:56 | Bronsa | smokeweed: extend js/HTMLCollection |
| 06:57 | TimMc | clgv: You don't want *any* shrinking, or just some part? |
| 06:57 | TimMc | I think clojure.test.check.generators/return might do what you want even in the latter case. |
| 06:58 | TimMc | Or wait! clojure.test.check.generators/no-shrink :-) |
| 06:58 | clgv | TimMc: ah great thanks! |
| 06:59 | clgv | that should be in the docs ;) |
| 06:59 | smokeweed | Bronsa: it seems to work, thanks |
| 06:59 | TimMc | indeed |
| 07:12 | thesaskw_ | Hi, what will happen if I use the same namespace in two files? Will the functions defined there be able to see each other? What about loading order? |
| 07:13 | thesaskw_ | Ok, found answer: http://stackoverflow.com/a/4692067/343699 |
| 07:14 | llasram | thesaskw_: BTW, that approach is not recommended by most of the community |
| 07:14 | llasram | thesaskw_: Clojure itself handles it fine, but you'll find that much of your tooling will get annoyed, which transitively will annoy any collaborators :-) |
| 07:15 | thesaskw_ | llasram: so what is the recommended practice? |
| 07:15 | llasram | thesaskw_: Just have one namespace per file |
| 07:15 | llasram | And one file per namespace |
| 07:15 | thesaskw_ | llasram: thanks |
| 07:17 | zot | newbie question: (first (filter …)) is there a better form, akin to "find" in some other contexts, that returns the first item matching a predicate? [some appears to return the result of the predicate check, not the initial item] |
| 07:18 | TEttinger | some, zot? |
| 07:18 | TEttinger | (doc some) |
| 07:18 | clojurebot | "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)" |
| 07:18 | llasram | zot: Not in the standard library. An eager `ffilter`/`filter-first` function is a pretty common utility though |
| 07:19 | llasram | zot: e.g. https://gist.github.com/llasram/995be648aa22e0630ce8 |
| 07:19 | TEttinger | ~useful |
| 07:19 | clojurebot | Gabh mo leithscéal? |
| 07:19 | llasram | Yeah, there's probably one in flatland/useful |
| 07:19 | TEttinger | but yeah that reduced solution seems best |
| 07:19 | zot | llasram/TEttinger: tnx |
| 07:19 | zot | and bummer :( |
| 07:19 | TEttinger | reduced was clojure 1.4 or 1.5? |
| 07:19 | TEttinger | (doc reduced) |
| 07:19 | clojurebot | "([x]); Wraps x in a way such that a reduce will terminate with the value x" |
| 07:20 | llasram | TEttinger: 1.5 |
| 07:20 | llasram | Aaaaages ago |
| 07:20 | TEttinger | but yeah the set thing will work, zot |
| 07:20 | TEttinger | ,(some #{:fred} [:bob :fred :sue]) |
| 07:20 | clojurebot | :fred |
| 07:21 | TEttinger | ,(some #{:fred} [:bob :sue]) |
| 07:21 | clojurebot | nil |
| 07:21 | llasram | TEttinger: you seem to be answering a different question than they actually had, especially as they mention `some` in their initial q... :-) |
| 07:21 | TEttinger | I missed that |
| 07:22 | TEttinger | so it's really a sorting thing |
| 07:23 | TEttinger | ,(some #(when (or (= % :bob) (= % :sue)) %) [:bob :fred :sue]) |
| 07:23 | clojurebot | :bob |
| 07:23 | TEttinger | that seems to return the value, not the result of the equality check... |
| 07:24 | TEttinger | ,(some #(when (or (= % :bob) (= % :sue)) %) [:bobby :fred :susie]) |
| 07:24 | clojurebot | nil |
| 07:25 | TEttinger | zot, could just using a different return value from the predicate work? |
| 07:25 | llasram | Or just use (comp first filter) -- it's really fine |
| 07:25 | TEttinger | yeah, that too |
| 07:33 | zot | for me the big thing i don't yet understand is the lazy-factor of clojure, so running filter seems needless if it can be short-circuiting |
| 07:33 | zot | "big" is overstated :) |
| 07:33 | zot | thanks for all the help! |
| 07:38 | kitallis | does anyone else get these on Heroku when using comp or partial: "Caused by: java.lang.IllegalArgumentException: No matching ctor found for class clojure.core$comp$fn__4192"? |
| 07:59 | lvh | Is there an easier way to specify (:require [a.b.x :as x] [a.b.y :as y] [a.b.z :as z])? |
| 08:09 | Bronsa | lvh: there's (:require [a.b [x :as x] [y :as y] [z :as z]]) |
| 08:10 | lvh | Bronsa: ooh, thanks :) |
| 08:10 | lvh | Bronsa: nothing with "i want things called whatever their name is" semantics? |
| 08:11 | Bronsa | lvh: you mean to avoid the `x :as x` pattern? |
| 08:11 | lvh | right |
| 08:11 | Bronsa | no, unfortunately |
| 08:16 | lvh | Bronsa: okiedokie, thanks though, that makes it look a bit less ugly already |
| 08:16 | lvh | I wonder if that was an intentional design decision |
| 09:09 | dawkirst | hi, busy leaning Clojure. as an experiment I'm trying to replicate https://gist.github.com/emilesilvis/1f171e838137a4ca7889 in Clojure. The function returns the indices of the pair of characters that is furthest apart with only unique strings between them. |
| 09:09 | dawkirst | any ideas? |
| 10:21 | atyz | Is there a way to look at what values you have memoized, and if so possibly remove an entry? |
| 10:21 | atyz | I know this isn't the *best* way to do this but I'm looking for a simple caching solution |
| 10:23 | _alejand1o | atyz: not in the default implementation |
| 10:23 | _alejand1o | but you could use https://github.com/clojure/core.cache |
| 10:23 | _alejand1o | or write your own memoize (it's pretty straightforward code) |
| 10:25 | bobwilliams | any recommendations on a good library for md5? |
| 10:25 | bobwilliams | thanks in advance! |
| 10:27 | atyz | bobwilliams: I used pandect |
| 10:27 | bobwilliams | atyz: thanks! |
| 10:27 | bobwilliams | looks like it has a decent amount of stars to github too |
| 10:27 | _alejandro | bobwilliams: https://github.com/tebeka/clj-digest ? |
| 10:28 | bobwilliams | _alejandro: thanks! |
| 10:30 | atyz | _alejandro: this library looks good, just debating writing my own |
| 10:30 | _alejandro | atyz: Yeah, I'd probably opt for writing my own if the needs are simple enough |
| 10:31 | atyz | _alejandro: its not *that* simple, I need a ttl on the values and want to only cache in certain cases |
| 10:33 | _alejandro | atyz: hmm, seems like core.cache is the way to go if that ttl implementation does what you need |
| 10:38 | clgv | atyz: you can easily implement a custom cache strategy for usage with core.cache |
| 10:38 | atyz | clgv: Thats what I'm leaning towards |
| 11:27 | atyz | I feel dumb, am I doing something wrong? https://www.refheap.com/2a4f20a48d177237e96f74060 _alejandro clgv ? |
| 11:27 | rweir | which bit? |
| 11:28 | rweir | remember that line 7 throws away the mutated map |
| 11:28 | gdev | atyz, classic mistake when playing with immutable data structures |
| 11:28 | atyz | gdev: i figured I should be using an atom/ |
| 11:29 | atyz | But followed what was in the docs |
| 11:29 | gdev | atyz, well the new value needs to be stored somewhere no matter what you use |
| 11:29 | rweir | well, it's fine, it's just that you threw it away |
| 11:29 | atyz | rweir: ah I see |
| 11:29 | atyz | That was dumb of me |
| 11:29 | rweir | I guess you wanted C to point at the result of asso |
| 11:29 | rweir | c |
| 11:29 | atyz | https://github.com/clojure/core.cache/wiki/Using |
| 11:30 | atyz | Let me try something |
| 11:30 | myguidingstar | hi all, how do I check type of a Clojurescript/om cursor during rendering phase? |
| 11:30 | gdev | atyz, it's a classic mistake that everyone has made. if it doesn't have a "!" on it, you're not going to be able to do PLOP |
| 11:32 | atyz | rweir: https://www.refheap.com/89184 it seems that its not mutable |
| 11:32 | rweir | ? |
| 11:32 | rweir | presumably cache/miss also returns a cache |
| 11:32 | rweir | ie the exact same problem as in the previous case |
| 11:33 | rweir | as gdev says, if there's not a !, it's unlikely to be mutating anything in place |
| 11:33 | myguidingstar | I'm writing a recursive function that check for type to decide if it should recur https://gist.github.com/myguidingstar/9f9ef153d7f2274ac761 |
| 11:33 | atyz | So then I'm confused. How am I supposed ot update the cache? |
| 11:33 | _alejandro | rweir: I thought the `!` was to do with transaction unsafe vs safe? |
| 11:34 | rweir | atyz, bind C to the return value of the thing again |
| 11:34 | rweir | _alejandro, iunno |
| 11:34 | myguidingstar | the list version works, but the vector one doesn't |
| 11:36 | atyz | rweir: using something like with-redefs? |
| 11:36 | atyz | That seems dirty |
| 11:36 | rweir | that sounds like a bad idea |
| 11:36 | rweir | depends what you're doing |
| 11:36 | atyz | I assumed the library would be responsible for keeping its var up to date |
| 11:37 | rweir | maybe the cache lives in some object you pass around |
| 11:37 | rweir | maybe it's a global var |
| 11:37 | atyz | (class C) |
| 11:37 | atyz | clojure.core.cache.FIFOCache |
| 11:37 | rweir | atyz, you'll need to mentally adjust, then - in clojure, most things are immutable |
| 11:37 | atyz | So its its own data structure |
| 11:37 | rweir | [and this is a feature] |
| 11:38 | atyz | rweir: No i get it, my issue is that this library gives me a store. And i'm calling a fn that would presumably update its store |
| 11:38 | atyz | The store is supposed to be mutable |
| 11:38 | atyz | (in this case) |
| 11:39 | _alejandro | atyz: maybe worth looking at https://github.com/clojure/core.memoize/ ? |
| 11:39 | atyz | _alejandro: they are written by the same person, from what I can see, core.cache is what he is working on now |
| 11:39 | _alejandro | atyz: basically uses core.cache ans puts it in an atom |
| 11:39 | _alejandro | *and |
| 11:40 | _alejandro | atyz: I think memoize is built on top of cache |
| 11:40 | rweir | atyz, right, but you need to adjust to how things in clojure works |
| 11:40 | rweir | atyz, pretty much everything is going to return a new thing, not mutate things in place |
| 11:40 | rweir | atyz, you might want to just put the cache in a var for now |
| 11:41 | atyz | rweir: I understand that, I understand that and I'm not new to the concept of immutablity |
| 11:41 | rweir | atyz, ok, I just mean to reinforce that expecting the library to have an implicit global it mutates is not really reasonable in clojure |
| 11:42 | atyz | _alejandro: core.memoize was last updated a year ago this one, 9 days ago |
| 11:43 | _alejandro | atyz: yeah, I'm not really pushing that library, just saying that if you look at the implementation it uses a cache from core.cache and puts it in an atom, then swap!s it as needed |
| 11:43 | atyz | rweir: it would make sense to me in this case, as it is a mutable store. So you're probably right with the assoc. However from a usability standpoint (where tehy are building me a mutable datastructure) and giving me an interface to it. I would expect it to maintain its own state |
| 11:43 | _alejandro | atyz: so may be a pattern worth emulating |
| 11:44 | rweir | atyz, in other languages, ok, but in clojure this is how pretty much everything works |
| 11:44 | rweir | i guess this isn't progressing, though, so eot for me |
| 11:45 | atyz | Even the docs say it works like that https://github.com/clojure/core.cache/wiki/LRU |
| 11:46 | rweir | where? |
| 11:46 | clojurebot | where is forget where is forget where |
| 11:46 | rweir | the -> examples are passing the cache around |
| 11:47 | rweir | it does say "Like all of the implementations in core.cache, LRUCache instances operate like regular maps and are immutable. All caveats apply regarding the proper usage patterns." though |
| 11:47 | _alejandro | C is not actually modified |
| 11:49 | atyz | rweir: actually you're right here |
| 11:49 | atyz | My apologies |
| 11:50 | rweir | oh, no worries, i continue to find it confusing in clojure |
| 11:52 | sdegutis | Am I correct in understanding that a result clause from a (case) statement will not be executed at all unless its test expression matches? |
| 11:54 | Bronsa | sdegutis: definitely |
| 11:54 | sdegutis | Thank you Bronsa for your time and thoughtful answer. |
| 11:55 | rweir | atyz, well, the lame answer is just def again |
| 11:56 | rweir | atyz, (http://clojure.org/vars) |
| 11:56 | rweir | atyz, but http://clojure.org/atoms is probably a better idea |
| 12:01 | BobSchack | Hay all I just wrote a in depth blog post on transducers http://bendyworks.com/transducers-clojures-next-big-idea/. What is good form for announcing this? |
| 12:02 | scottj | BobSchack: reddit.com/r/clojure has had several transducer blog posts posted there |
| 12:03 | scottj | BobSchack: twitter too, and you can try your chances on hacker news. personally I think the mailing list would not be a good place, since I wouldn't like to see every clojure blog post announced there. |
| 12:04 | scottj | BobSchack: you can also contact planet clojure maintainer to get your blog added there |
| 12:05 | BobSchack | Oh thanks the email is on the site correct? |
| 12:05 | scottj | idk |
| 12:08 | mkrlearner | I want to try out some sample website development in Clojure. I have Rails background. I know the community is against frameworks, but can someone point out some good place where I can get a quick website, like in 1 or 2 days? (I know the language quite well already) |
| 12:10 | tanzoniteblack | mkrlearner: you might check out http://www.luminusweb.net ; it's a (biased) collection of clojure libraries hooked together in a lein template for web development |
| 12:11 | tanzoniteblack | well...by biased I really just mean it selected what tend to be the most accepted and common libraries for the given job, and it covers most things you'll want for web development |
| 12:11 | tmciver | Anyone here have experience using Clojure with OSGi? |
| 12:12 | atyz | rweir: atoms is definitely a better idea, the def would work badly if you have concurrent requests |
| 12:12 | Jaood | transducers are becoming the new monad tutorials ;) |
| 12:13 | atyz | and at that point, its probably just better for me to reimplement memoize |
| 12:13 | tmciver | I've tried most of the things that I could find online without success. There's a Clojure OSGi bundle for CCW which I tried but I think it relies on running in Equinox (Eclipse) which I'm not using. |
| 12:13 | rweir | atyz, yes |
| 12:13 | rweir | atyz, reimplement? |
| 12:13 | atyz | write my own |
| 12:14 | sdegutis | Is it possible, inside a catch-block, to call the default exception-handling mechanism, but continue on as if I handled it? |
| 12:14 | tmciver | I'm using Apache Felix embedded in an app and using it as a plugin system for plugins written in Clojure but AOT compiled. |
| 12:14 | sdegutis | I'm trying to use the default printing code without having to rewrite it myself, but still continue on as if the try-block was handled by me. |
| 12:14 | rweir | atyz, but how did that follow from the above? |
| 12:15 | technomancy | tmciver: talios is the only one I know who's done that, but he's in an NZ TZ |
| 12:16 | kovrik_ | sdegutis: are you the author of Hydra/Zephyros? |
| 12:17 | sdegutis | kovrik_: Yes. |
| 12:18 | tmciver | technomancy: talios is Mark Derricutt? I tried emailing him directly but no response. Is he here often do you know? |
| 12:18 | technomancy | tmciver: I don't overlap with his TZ all that much but I see him every so often |
| 12:18 | tmciver | technomancy: I'll have to stay up late and corner him. :) |
| 12:21 | llasram | sdegutis: clojure.tools.logging lets you log an exception + backtrace, which sounds like what you actually want? |
| 12:22 | llasram | (as does pretty much any JVM logging library) |
| 12:22 | sdegutis | llasram: I want to print the exception as if I never caught it, but carry on after my (try) statement. |
| 12:22 | llasram | Yes. That is what happens. |
| 12:22 | llasram | You catch the exception, log it, then move on |
| 12:23 | sdegutis | This is what I'm doing now: https://gist.github.com/sdegutis/52a1a9fccf0ea31a4c06 |
| 12:23 | sdegutis | I can continue to do it this way, but I was hoping there was a more built-in way. |
| 12:23 | sdegutis | kovrik_: Why do you ask, kind person? |
| 12:23 | llasram | sdegutis: using tools.logging or whatnot turns it into one line in the catch |
| 12:24 | llasram | So I'm not sure what more you want? |
| 12:24 | sdegutis | Right now it's just two lines; that would turn into one line and a dependency. |
| 12:24 | llasram | *shrug* |
| 12:24 | sdegutis | I was hoping there was a built-in way. |
| 12:24 | sdegutis | But if not, I'll do this. |
| 12:24 | sdegutis | Thanks. |
| 12:24 | llasram | If you consider logging an optional dependency, then have fun :-) |
| 12:25 | tanzoniteblack | sdegutis: you can always write a function to do all that for you, given an Exception/Throwable ...but then you'll just be recreating tools.logging ad hoc |
| 12:26 | kovrik_ | sdegutis: I just love and use your Hydra (and Zephyros) :) Keep doing! |
| 12:27 | sdegutis | kovrik_: Thank you, friendly human. |
| 12:27 | tanzoniteblack | also, as a general warning, println statements for logging errors can get a little screwy if you start having things run in parallel (i.e. *out* isn't guaranteed to always be defined depending on how you run your code) |
| 12:27 | sdegutis | tanzoniteblack: Which I've done: https://gist.github.com/sdegutis/1a3e4558515b94c1cda6 |
| 12:27 | sdegutis | kovrik_: btw there is an IRC channel for Hydra: #mjolnir |
| 12:28 | sdegutis | kovrik_: You're welcome any time. |
| 12:28 | tmciver | TimMc: o/ |
| 12:28 | TimMc | tmciver: I think nDuff is the only other person I've heard talk about OSGi in here. |
| 12:28 | kovrik_ | sdegutis: Cool, thanks! I'll join it! |
| 12:28 | TimMc | Hey, you coming to the meetup tonight? |
| 12:29 | tmciver | TimMc: nDuff, I'll have to track him down too. Thanks. No, playing some video games with a friend. Gotta have priorities, ya know? |
| 12:29 | AlwaysBCoding | how would I go from [[1 2 3] [4 5 6] [7 8 9]] => [1 2 3] [4 5 6] [7 8 9] ... i.e. go from one data structure to multiple data structures? |
| 12:29 | TEttinger | AlwaysBCoding, apply ? |
| 12:30 | TEttinger | (doc apply) |
| 12:30 | clojurebot | "([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args." |
| 12:30 | AlwaysBCoding | yeah but what do you apply to it? |
| 12:30 | TEttinger | what are you using multiple data structures in? you can also argument destructure in let or arg lists |
| 12:30 | atyz | AlwaysBCoding: depending on your need you could jus destructure |
| 12:31 | tanzoniteblack | AlwaysBCoding: if you're trying to call a function which expects multiple args, then apply is what you probably want; if you're trying to just get them in different variables in a let, then check on destructuring |
| 12:31 | tanzoniteblack | i.e. it depends on why you want them separated, and how you're planning on using them |
| 12:31 | atyz | so (let [[a b c]] [[1 2 3] ...]) |
| 12:32 | TEttinger | ,(let [[[a b c]] [[1 2 3] [4 5 6] [7 8 9]]] (reduce + a)) |
| 12:32 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 12:32 | TEttinger | ,(let [[a b c] [[1 2 3] [4 5 6] [7 8 9]]] (reduce + a)) |
| 12:32 | clojurebot | 6 |
| 12:33 | AlwaysBCoding | hm. I'm rendering HTML from a data structure. and I want to generate multiple dom nodes. so if I have a data structure like [{:team-name "wizards", :player-name "john wall"}, {:team-name "wizards", :player-name "bradley "beal"}] and I want to map over it and generate [:p.team-name (-> item :team-name)] [:p.player-name (-> item :player-name)] for each item |
| 12:33 | AlwaysBCoding | it doesn't work since map only returns the last item |
| 12:33 | AlwaysBCoding | so I'm wondering if there's a way to go straight from like [[1 2 3] [4 5 6] [7 8 9]] => [1 2 3] [4 5 6] [7 8 9] because that's what the html renderer requires |
| 12:34 | TEttinger | all as args to a function? |
| 12:34 | TEttinger | you can apply with the renderer and your nested collection |
| 12:35 | kovrik_ | or use destructuring? |
| 12:35 | hiredman | "map only returns the last item" <-- someone don't leave that hanging please |
| 12:36 | clgv | hiredman: :P |
| 12:37 | clgv | AlwaysBCoding: I guess I know what you try to describe. you just need to `concat` the result of that `map` with the other lists to create the desired output |
| 12:39 | sdegutis | Why cannot (def) take multiple pairs? |
| 12:39 | sdegutis | ,(def a 1 b 2) |
| 12:39 | clojurebot | #<CompilerException java.lang.RuntimeException: Too many arguments to def, compiling:(NO_SOURCE_PATH:0:0)> |
| 12:40 | tanzoniteblack | sdegutis: it would make parsing things like metadata and docstrings signifcantly more complicated, if not impossible |
| 12:40 | sdegutis | Oh. Thank you for your succinct, correct, and prompt answer. |
| 12:42 | AlwaysBCoding | clgv: cool, just realized that's what mapcat is for |
| 12:44 | AlwaysBCoding | yup, mapcat did the trick. so cool, thanks guys |
| 12:46 | clgv | sdegutis: and plainly wrong. there is no such thing as an extra metadata map you could specify. but there is the option to add a docstring which conflicts with multiple definitions |
| 12:47 | clgv | sdegutis: or at least makes it difficult to read |
| 12:50 | martinklepsch | anyone experience using nth-child selectors with garden? I can't require garden.selectors that contains some nth-child related things |
| 12:50 | martinklepsch | Maybe someone has a snippet laying around? |
| 12:51 | TimMc | sdegutis: For a simple use-case, it should be easy enough to whip up a macro that does what you want... but good luck getting various tools to recognize your new multi-def. |
| 12:52 | sdegutis | :) |
| 13:01 | TimMc | tmciver: Yup. I missed the last few meetups, so I should show up again. Someone's gotta be on hand to be a good influence and teach people Swearjure! |
| 13:02 | TEttinger | ,(#(`[~@%] (`[~@%&] (+))) (#(`[[~@%&]] (+)) :! :* :>) (+ (*) (*))) |
| 13:02 | clojurebot | :> |
| 13:06 | tmciver | TimMc: absolutely. Have fun. I've been doing enough swearing with OSGi lately. |
| 13:13 | TimMc | tmciver: Do a talk on it! :-D |
| 13:13 | TimMc | I'd like to know more about it. |
| 13:15 | TimMc | Bronsa: Speaking of syntax-quote and Swearjure, what are your thoughts on the correct behavior of `{~@[a b]} ? |
| 13:15 | TimMc | Bronsa: Err,`{~@[:a :b]} |
| 13:16 | tmciver | TimMc: that's a good idea; I just have to figure it out first! |
| 13:17 | cbp | ,`{~@[:a :b]} |
| 13:17 | clojurebot | #<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms> |
| 13:17 | TimMc | ,`{~@[:a :b] ~@[]} |
| 13:17 | clojurebot | {:a :b} |
| 13:18 | TimMc | I ask because you were (I think) recently in the guts of the reader. |
| 13:21 | llasram | How Bronsa is like a good book. |
| 13:26 | Bronsa | TimMc: it should be possible and not hard to make `{~@foo} work |
| 13:31 | bbloom | Bronsa: what would it do? ... |
| 13:32 | Bronsa | bbloom: compile to (apply hash-map foo) |
| 13:32 | bbloom | Bronsa: no, that's wrong |
| 13:32 | bbloom | (class `{:x ~@[:y]}) |
| 13:32 | bbloom | ,(class `{:x ~@[:y]}) |
| 13:32 | clojurebot | clojure.lang.PersistentHashMap |
| 13:32 | bbloom | ,(class `(apply hash-map :x ~@[:y])) |
| 13:32 | clojurebot | clojure.lang.Cons |
| 13:33 | Bronsa | '`{~@[] []} |
| 13:33 | Bronsa | ,'`{~@[] []} |
| 13:33 | clojurebot | (clojure.core/apply clojure.core/hash-map (clojure.core/seq (clojure.core/concat [] (clojure.core/list (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat))))))) |
| 13:33 | Bronsa | ,(read-string "`{~@[] []}") |
| 13:33 | clojurebot | (clojure.core/apply clojure.core/hash-map (clojure.core/seq (clojure.core/concat [] (clojure.core/list (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat))))))) |
| 13:33 | Bronsa | bbloom: ^ |
| 13:33 | bbloom | ooh duh, right |
| 13:33 | bbloom | sorry, ignore me |
| 13:33 | bbloom | i forget that syntax-quote assumes that you'll evaluate the result |
| 13:34 | bbloom | i mainly forget that b/c i've been experimenting with explicit evaluation :-P |
| 13:34 | martinklepsch | how can I compile cljx files of dependencies I'm using in another projecT? |
| 13:34 | bbloom | my design has an explicit partially-applied template type tag |
| 13:34 | martinklepsch | is "lein cljx once" aware of dependencies? |
| 13:34 | TimMc | Bronsa: So the notion of map literals having an even number of forms isn't baked in so deeply that this would be difficult? |
| 13:35 | bbloom | TimMc: i think it's only possible b/c sytnax quote is defined as part of the reader's behavior |
| 13:37 | martinklepsch | It doesn't seem that it is aware of cljx dependencie |
| 13:37 | Bronsa | TimMc: I'll try to hack a patch for tools.reader later, if I succed I'll try to backport to LispReader & open a ticket |
| 13:38 | TimMc | Bronsa: Ha, yeah? That would be neat. I was just idly curious; it's a weird enough use-case and there's an easy workaround, but of course I won't try to stop you... :-) |
| 13:45 | martinklepsch | any advice on compiling cljx dependencies? shouldn't these be compiled by leiningen automatically? do I have to care whether libraries I depend on use cljx? |
| 13:47 | tanzoniteblack | martinklepsch: my understanding of cljx is that it shouldn't have to be aware of whether dependencies were written using cljx, because when they were made into a jar to be put on clojars/maven/whatever, cljx worked on them as part of making the jar; so your code shouldn't actually be looking at the .cljx files, but the .clj file created by the cljx plugin |
| 13:51 | tanzoniteblack | I currently have code that looks like, `(try (f) (catch ErrorType1 e (fn-call e)) (catch ErrorType2 e (fn-call e)))` where I'm calling the same function when catching both ErrorType1 and ErrorType2, anyone know if there's a way I can collapse this code to catch *either* error type and then do the exact same body to the error (i.e. similar to `catch (ErrorType1 | ErrorType2 e)` in Java 1.7+) |
| 13:53 | martinklepsch | tanzoniteblack: well, thats how I'd expect it to work as well but it seems as if this compilation process isn't happening for garden... I'll take a look at clojars |
| 13:56 | tanzoniteblack | martinklepsch: I use prismatic's schema (which is made with cljx) regularly in projects which don't even have cljx as a plugin...so it might just be something wrong with garden's build? |
| 13:57 | verma | causing side effects in the function passed to core/map is idiomatically alright? |
| 13:57 | amalloy | tanzoniteblack: no, there is no way to do that except by writing a macro that expands to the code you have now |
| 13:58 | amalloy | verma: it's not strictly forbidden, but it should make you uneasy |
| 13:58 | arohner | tanzoniteblack: slingshot has macros that sound similar to what you want |
| 13:58 | martinklepsch | verma: I think it'd more idiomatic to use doseq or doall or something like this |
| 13:59 | tanzoniteblack | arohner: I'll look into that, thanks |
| 13:59 | arohner | slingshot lets you do all kinds of fun things, like (catch my-pred? e) |
| 13:59 | arohner | where my-pred is a fn that takes an exception |
| 14:00 | technomancy | I wish we had proper pattern matching for it though |
| 14:00 | martinklepsch | verma: map is lazy so if you want to apply f to all elements it might not do what you expect |
| 14:00 | arohner | technomancy: core.match matching? |
| 14:00 | mdrogalis | tanzoniteblack: Dire supports predicate matching on exception handlers. |
| 14:00 | verma | martinklepsch, yes, I am using it with doall |
| 14:00 | technomancy | arohner: sure |
| 14:01 | tanzoniteblack | seems like this functionality which would be nice in a future version of clojure, but I'll take a look at both dire and slingshot for now |
| 14:01 | arrdem | bbloom: Mike and I were comparing notes on a static Clojure variant |
| 14:02 | bbloom | arrdem: ah ok |
| 14:02 | bbloom | i favor the exact opposite approach, but i'm a crazy person ;-) |
| 14:02 | verma | amalloy, martinklepsch doseq and doall don't return the result of applying f though, do they? e.g. I want to map a set of commands, run them and capture the return value |
| 14:02 | arrdem | bbloom: that's fine with me, I just want to see people exploring the design space. |
| 14:02 | bbloom | arrdem: absolutely |
| 14:03 | bbloom | arrdem: languages that have a better dynamic/static range are welcome by me |
| 14:03 | martinklepsch | verma: doall returns the seq |
| 14:03 | martinklepsch | verma: doseq doesn't |
| 14:03 | tanzoniteblack | verma: you can do something like `(doall (map ...))` which immediately forces the map not to be lazily evaluated to have the side effects occur now and then returns the value of the original call to map |
| 14:03 | verma | martinklepsch, tanzoniteblack ooh sweet, thanks! :) |
| 14:06 | Bronsa | TimMc: http://sprunge.us/WGIY?diff |
| 14:07 | Bronsa | porting that to LispReader should be trivial |
| 14:10 | amalloy | Bronsa: where is gensym-env ever set? i only see it being bound to nil, and then being read numerous times |
| 14:10 | starlord | Hi. |
| 14:10 | starlord | I am trying to reduce the number of java.lang.NullPointerException I find in my program. Please advice. |
| 14:10 | Bronsa | amalloy: https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader.clj#L598 |
| 14:10 | bbloom | Bronsa: you're also changing set to avoid the duplicate check for splices? |
| 14:10 | Bronsa | bbloom: yep |
| 14:10 | bbloom | s/to/too |
| 14:11 | bbloom | Bronsa: i never really liked those checks... |
| 14:12 | bbloom | Bronsa: good stuff, that's bit me once with {~@[...]} |
| 14:12 | acagle1 | exit |
| 14:12 | acagle1 | exit |
| 14:16 | emacsnw | starlord: I have a similar problem. it complains about Exception in thread "main" java.lang.NullPointerException, but does not give any useful stacktrace. |
| 14:16 | technomancy | starlord: port it to ocaml |
| 14:16 | technomancy | boom |
| 14:17 | aperiodic | starlord: put (try ... (catch Throwable _)) around your program's entry point. bonus: you won't find any other errors, either! |
| 14:21 | starlord | technomancy, aperiodic: thank you I may try these both. |
| 14:25 | TimMc | Bronsa: Oh man, ++ on fixiing the set uniqueness thing! |
| 14:26 | amalloy | it's weird, i don't think i've ever used #{~@(...)} |
| 14:27 | TimMc | ,(let [a 5] #{a 5}) |
| 14:27 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: 5> |
| 14:27 | bobwilliams | has anyone here created a clojure script to wrap cleverbot? |
| 14:28 | TimMc | Bronsa: Oh, it actually doesn't fix the thing I've run into ^ |
| 14:28 | bobwilliams | anyone know of any documentation for cleverbot? |
| 14:28 | arrdem | $google cleaverbot http API |
| 14:28 | lazybot | [chatter-bot-api - A Mono/.NET, JAVA, Python and PHP chatter bot ...] http://code.google.com/p/chatter-bot-api/ |
| 14:29 | bobwilliams | arrdem: yea, looking for one in clojure already..I think i'm hitting a case where i need to enforce query param order and not seeing it really detailed anywhere |
| 14:30 | Bronsa | TimMc: that's not a reader issue |
| 14:31 | bobwilliams | arrdem: thanks |
| 14:32 | TimMc | Bronsa: Ah, OK. :-( |
| 14:33 | Bronsa | TimMc: #{1 1} won't work either |
| 14:33 | TimMc | Well, one step closer, then. |
| 14:33 | Bronsa | nor will #{(gensym) (gensym)} |
| 14:33 | Bronsa | this only affects syntax-quoted literals |
| 14:33 | TimMc | lolwut |
| 14:34 | Bronsa | TimMc: to make #{(gensym) (gensym)} work, the compiler should use a different reader |
| 14:35 | TimMc | Oh... I get it, now. Before it's evaluated, it would be invalid... |
| 14:35 | Bronsa | TimMc: what should (read-string "#{(gensym) (gensym)}") return? |
| 14:35 | Bronsa | TimMc: yeah |
| 14:35 | TimMc | That's incredibly ugly. |
| 14:35 | TimMc | I'd never considered that aspect of set literals before! |
| 14:35 | arrdem | Bronsa: couldn't you just add a let block and bind two gensym calls? |
| 14:36 | Bronsa | even though the two gensym calls result in different values at runtime, they have the same value at read-time |
| 14:36 | Bronsa | arrdem: sure |
| 14:36 | Bronsa | TimMc: that's the same for keys in map literals btw |
| 14:36 | TimMc | Mmm, that I can deal with. |
| 14:37 | Bronsa | I believe #{1 1} used to work and return #{1} some time in the past BTW |
| 14:37 | Bronsa | maybe amalloy remembers? |
| 14:37 | zackzackzack | Is there a good way to hash data structures into a string? |
| 14:38 | amalloy | zackzackzack: nothing easy. it's a harder problem than it sounds like |
| 14:39 | bbloom | Bronsa: TimMc: it's not a unique problem to set literals, just generally an extremely minor flaw of the clojure/edn syntax design |
| 14:39 | zackzackzack | amalloy: Yeah I sort of figured as much. Does it help if the data structures are restricted to vectors, strings and keywords? |
| 14:39 | arohner | Bronsa: yes, #{1 1} used to work |
| 14:39 | bbloom | there's no runtime representation of various unevaluated reader forms |
| 14:39 | arohner | in 1.5 and earlier? |
| 14:39 | bbloom | tagged literals are the one that annoy me... i want a generic tagged-literal fallback type |
| 14:39 | amalloy | Bronsa: i don't think #{1 1} ever made it past the reader. there was definitely some kerfuffle about the difference between (set [1 1]), (hash-set 1 1), and #{1 1} but i don't remember the details |
| 14:40 | Bronsa | uhm ok |
| 14:40 | amalloy | just tried on 1.4, #{1 1} doesn't read |
| 14:40 | zackzackzack | I'd like to be able to make an index in datomic that allows you to look up attributes via a datastructure. |
| 14:41 | amalloy | same on 1.2.1 |
| 14:41 | arohner | https://github.com/clojure/clojure/commit/c733148ba0fb3ff7bbab133f5375422972e62d08 |
| 14:43 | TimMc | It seems so unnecessary. |
| 14:43 | wei_ | has anyone used both om and reagent and can describe the main differences between the two? |
| 14:44 | arohner | wei_: I've used Om but not reagent. reading reagents docs, it looks higher level, with the good and bad that implies |
| 14:47 | wei_ | arohner: thanks. I’ve primarily used reagent and like it so far. just wondering what I’m missing in om |
| 14:47 | arohner | om is little more than protocols over react primtives |
| 15:02 | amalloy | i just realized the one-arity case of apply isn't defined: (apply f) doesn't mean anything. would it be totally crazy for (apply [f x y]) to mean (f x y)? |
| 15:02 | amalloy | then apply would kinda be like funcall, or maybe (partial apply funcall) |
| 15:03 | TEttinger | amalloy: |
| 15:04 | hyPiRion | amalloy: in what case would you have a need for (apply f)? |
| 15:04 | hyPiRion | If you have the form, evaluate it already. |
| 15:05 | llasram | To avoid special-handling the case when doing (apply apply f) |
| 15:05 | hyPiRion | Although there are problably some very special use cases for it. |
| 15:05 | amalloy | hyPiRion: i thought of it in regard to http://stackoverflow.com/q/25303068/625403 |
| 15:06 | TimMc | amalloy: Obviously it can be used for transducers. :-) |
| 15:06 | amalloy | though it turns out i totally misunderstood what he was asking for |
| 15:08 | amalloy | basically i wrote #(apply % %&) and was like "wait a minute this is a stupid thing to have to write" |
| 15:08 | TimMc | (def apply [f] ((f))) |
| 15:13 | bbloom | amalloy: if your input is a seq, isn't that just eval? :-) |
| 15:13 | amalloy | bbloom: er, actually not at all |
| 15:13 | bbloom | ,((comp eval seq) [+ 5 10]) |
| 15:13 | clojurebot | #<ExceptionInInitializerError java.lang.ExceptionInInitializerError> |
| 15:13 | hyPiRion | ,(eval '(name 'a)) |
| 15:13 | clojurebot | "a" |
| 15:13 | amalloy | even if you pretend that functions evaluate to themselves |
| 15:13 | bbloom | &((comp eval seq) [+ 5 10]) |
| 15:13 | lazybot | java.lang.SecurityException: You tripped the alarm! eval is bad! |
| 15:13 | bbloom | blah |
| 15:13 | TimMc | modulo some environment stuff... |
| 15:13 | bbloom | that clearly works in my repl |
| 15:14 | amalloy | there's still the problem of ((comp eval seq) [first '(x y z)]) |
| 15:14 | hyPiRion | oh derp |
| 15:15 | hyPiRion | ,(eval (list 'name 'a)) |
| 15:15 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:20 | Bronsa | TimMc: gah, metadata gets dorked with my patch |
| 15:22 | bbloom | dorked? is there a formal definition of that term in the literature? |
| 15:23 | TimMc | borked? |
| 15:23 | Bronsa | yes. typo |
| 15:24 | bbloom | don't admit the typo. just say that all the cool kids have moved from borked to dorked |
| 15:27 | TimMc | Poor metadata, everyone always forgets it. |
| 15:31 | Bronsa | TimMc: I mean, it works fine in tools.reader, for LispReader I'm using a class rather than a record for SyntaxQuoted[Map,Set] and that breaks everything. |
| 15:33 | bbloom | Bronsa: just gotta implement IMeta and IObj, right? |
| 15:33 | bbloom | those are easy enough |
| 15:34 | TEttinger | Bronsa: scala syntax? SyntaxQuoted[Map,Set] |
| 15:34 | Bronsa | bbloom: no, it also needs to be an IPersistentMap |
| 15:34 | bbloom | ... why? |
| 15:35 | Bronsa | bbloom: `^{:foo 1} {:bar 1}, {:foo 1} will be read as a SyntaxQuotedMap aswell |
| 15:36 | Bronsa | I can probably get away with just implementing IPM without actually providing any implementation though |
| 15:36 | Bronsa | TEttinger no, was just a shortrand for SyntaxQuotedMap, SyntaxQuotedSet :P |
| 15:36 | bbloom | oooh, i see, the actually metadata itself must be an IPM |
| 15:36 | Bronsa | yeah |
| 15:37 | bbloom | well then |
| 15:37 | bbloom | stupid static typing :-P |
| 15:37 | bbloom | hehe |
| 15:37 | bbloom | i enjoy that clojure will just provide a bunch of bodies that throw NotImplemetnedException |
| 15:37 | TEttinger | scala's static typing with inference I don't mind, but java's static typing really is stupid |
| 15:38 | bbloom | TEttinger: in this case inference wouldn't help |
| 15:38 | TEttinger | I just mean while coding |
| 15:38 | TEttinger | in general |
| 15:39 | TEttinger | I asked a question in #scala about how to port a CLOS-style pattern match, never heard back |
| 15:39 | jareddba | Anyone know how I would inspect what data this Java object contains using clojure? #<Object[] [Ljava.lang.Object;@54d36076> |
| 15:40 | jareddba | I'm using fressian pulling that it is a Tagged Object |
| 15:40 | jareddba | (fress/tag (first (:data (fress/read (:val mmaps4))))) which returns "datum" |
| 15:40 | jareddba | (fress/tagged-value (first (:data (fress/read (:val mmaps4 |
| 15:40 | jareddba | ))))) which returns #<Object[] [Ljava.lang.Object;@54d36076> |
| 15:40 | jumblemuddle | Can someone explain this to me: http://sprunge.us/UafD particularly the doseq part. I'm not really sure how they got the player entity out of the entities using this. |
| 15:40 | llasram | jareddba: That's a JVM array of `Object`s. Calling `seq` on it will get you at least one layer in, printing-wise |
| 15:41 | arrdem | jareddba: try seqing it |
| 15:42 | arrdem | jumblemuddle: that shouldn't work. http://grimoire.arrdem.com/1.6.0/clojure.core/doseq/ |
| 15:42 | llasram | arrdem: weird indentation and mutation |
| 15:43 | llasram | `entities` is actually after the `doseq`, not inside it |
| 15:43 | arrdem | llasram: good catch. |
| 15:43 | Bronsa | bbloom: fuck I can't not provide an implementation for interface methods in java ;_; |
| 15:43 | jareddba | llasram: and arrdem: worked perfect!! |
| 15:44 | jareddba | Thanks! |
| 15:44 | jumblemuddle | arrdem: interesting... It seems to be working, it's from the play-clj examples. |
| 15:44 | jumblemuddle | arrdem: thanks for the link, I'll look into that. |
| 15:44 | arrdem | jumblemuddle: llasram got it right. your indentation threw me off. |
| 15:45 | jumblemuddle | Ah, ok. |
| 15:45 | llasram | jumblemuddle: Looks like each entry `entities` is a triple, where the third member indicates if the entity is a player. They just walk that linearly, and then do something mutating with `position!` if the entity is a player |
| 15:45 | arrdem | jumblemuddle: all that snippet does is update each player entity in the entities collection, and then return the entities collection again. |
| 15:45 | llasram | er, not a triple. A map |
| 15:46 | llasram | I'm not even sure if it does that. It just `position!`s at `x` and `y` on `screen`. So who knows. |
| 15:46 | jumblemuddle | Ok, so the {:keys [x y z]} is just supposed to find the entities with those keys? |
| 15:46 | llasram | jumblemuddle: No. It extracts those keys from each entity, which must be a map |
| 15:46 | arrdem | jumblemuddle: https://gist.github.com/john2x/e1dca953548bfdfb9844 |
| 15:46 | llasram | so `entities` is a sequential collection of map(like)s |
| 15:47 | jumblemuddle | Ok, I think I understand now. I wasn't thinking of the 'entities' as maps. |
| 15:47 | jumblemuddle | Still trying to wrap my head around this functional programming things... Thanks guys! |
| 15:48 | jumblemuddle | arrdem: Thanks, I'll read that. I never quite got my head around the destructuring stuff. |
| 15:49 | arrdem | jumblemuddle: I just liked it because that {:keys []} is destructuring notation and john2x's writeup is pretty good. |
| 15:50 | jumblemuddle | It looks very well written. Most of the other stuff I've found on destructuring was very confusing. |
| 15:51 | llasram | jumblemuddle: Well, that function is about as non-functional as you can get :-) |
| 15:52 | jumblemuddle | Ya, with the 'position!' being inside a doseq. Play-clj is built on top of libgdx, so there I'd imagine it's pretty difficult to do it completely functionally. |
| 15:54 | arrdem | eh... state monad... anything's possible, the question is if it buys you anything since you're building atop a mutable java framework.. |
| 15:55 | jumblemuddle | On a side note: Is it even a good idea to try making games in clojure? Would it be better to go with a more established language (for game-dev), and try to adopt some of the functional design principals? |
| 15:56 | TEttinger | jumblemuddle: kinda. |
| 15:56 | TEttinger | I've written a small roguelike in an older version of clojure |
| 15:56 | awwaiid | jumblemuddle: I'm sure you will get a very unbiased answer here in #clojure. But yes -- it's a great idea to make a game in clojure! |
| 15:56 | TEttinger | some of clojure's features are mind-blowing for games |
| 15:56 | llasram | I don't think there's anything about Clojure to particularly recommend for or against it for writing games in particular |
| 15:56 | TEttinger | I had save/load done in half an hour, like 20 lines (needed to look up some stuff) |
| 15:57 | arrdem | llasram: well it's on the JVM which is typically an "against".. |
| 15:57 | llasram | If you're planning on writing a "serious" game, I'm not sure I'd recommend it, but for a hobby project -- sure! |
| 15:57 | jumblemuddle | awwaiid: Well, to be honest I'm looking to be convinced. I would love to use clojure. |
| 15:57 | TEttinger | I needed multithreaded level gen, so futures helped a ton |
| 15:57 | TEttinger | play-clj rocks |
| 15:57 | awwaiid | ahh |
| 15:57 | TEttinger | but clojure is not that fast |
| 15:57 | llasram | arrdem: People do do "serious" games on the JVM. I mean, minecraft, right? |
| 15:57 | TEttinger | it is getting better! |
| 15:57 | TEttinger | reducers came into the language after I had coded my game |
| 15:58 | awwaiid | I think there are quite a few "indie" jvm games |
| 15:58 | jumblemuddle | TEttinger: Ya, I was reading John Carmack's stuff on functional programming for game dev, and it sounds amazing. |
| 15:58 | arrdem | llasram: minecraft is famous for being a steaming pile of [REDACTED] in terms of its software architecture and engine performance. |
| 15:58 | TEttinger | jumblemuddle, I'm currently using scala because long story short, it's closer to C# and I was porting 5K lines of C# with functional style |
| 15:58 | arrdem | llasram: it can totally be done, it's just a question of what you consider a "serious" game. |
| 15:58 | awwaiid | so I wonder if performance is the only issue? |
| 15:58 | jumblemuddle | I'm definitely not at the point of 'serious' game dev, so I guess I'll go for it. |
| 15:58 | awwaiid | in which case it might depend on what sort of game it is |
| 15:59 | TEttinger | scala does work on android and seems to have decent performance when I'm not starting the game up |
| 15:59 | willgorm- | cwxvpn |
| 15:59 | TEttinger | but my scala code is much longer than my clojure code |
| 15:59 | jumblemuddle | I haven't looked into scala much. Most of the other game-dev stuff I've done, was in c#/monogame. |
| 16:00 | jumblemuddle | Granted my c# code was very very ugly... |
| 16:00 | TEttinger | jumblemuddle, look into play-clj |
| 16:00 | TEttinger | oakes is amazing |
| 16:00 | TEttinger | (the author) |
| 16:01 | jumblemuddle | TEttinger: Ya, that's why I'm looking into atm. (That's where the destructuring question came from, I'm walking through the examples, and trying to understand them) |
| 16:01 | TEttinger | jumblemuddle, I have an old, messy, heavily-ugly-due-to-opts version of my clojure game on github |
| 16:02 | TEttinger | most important stuff is here https://github.com/tommyettinger/Ravager/tree/master/ravager/desktop/src-common/gaunt/ravager |
| 16:02 | zenoli | So, I'm playing around with writing a BASIC interpreter, and am looking for some thoughts on program and execution representation. |
| 16:02 | TEttinger | it looks like https://dl.dropboxusercontent.com/u/11914692/Ravager-thin-walls.PNG btw |
| 16:02 | zenoli | Building an AST is no prob, nor is executing single statements, storing variables, and so on. |
| 16:03 | TEttinger | zenoli, BASIC with the clojure seq abstraction -- get the VB types on our team! |
| 16:03 | justin_smith | TEttinger: reminds me of that nethack frontend, falconseye |
| 16:03 | zenoli | But I'm bogging down trying to come up with a good representation for an execution pointer. |
| 16:03 | justin_smith | (though they may have a common root unknown to me) |
| 16:03 | TEttinger | justin_smith, yes, this uses nethack sprites from a japanese port |
| 16:03 | jumblemuddle | TEttinger: Thanks, that looks really cool! The more example I can find the better. That's one of the reasons I was thinking of going with a different langauge. (more examples) |
| 16:04 | zenoli | TEttinger: At the moment, the target is old-school David H. Ahl-period classic games. Later for world conquest. |
| 16:04 | TEttinger | technically it uses Steve Aoki's SLASHEM tiles, which are mostly the same as his Nethack tiles |
| 16:04 | TEttinger | unfortunately they're NHPL licensed, which is an outdated GPL 1.0 fork |
| 16:04 | Bronsa | TimMc: http://dev.clojure.org/jira/browse/CLJ-1503 |
| 16:05 | Bronsa | TimMc: no idea if it's going to make it, but I pushed the fix to tools.reader in the meantime. |
| 16:06 | zenoli | Consider typing in "10 A=1 : B=1 \n 30 IF A+B > 3 THEN GOTO 10 \n 20 A=A+1" |
| 16:06 | TEttinger | which clojure version are we on now? |
| 16:06 | llasram | ,*clojure-version* |
| 16:06 | clojurebot | {:interim true, :major 1, :minor 7, :incremental 0, :qualifier "master"} |
| 16:07 | zenoli | Line 10 has two separate statements, one without a label. Line 20 goes before line 30 during execution. |
| 16:07 | TEttinger | I'm also in #libgdx and we're having some fun talk about upgrading to the very recent 1.3.0, so I was confused |
| 16:09 | zenoli | A sorted map {10 [statement1 statement2] 20 [statement3]} would order the code, and line labels can be looked up. |
| 16:10 | zenoli | But GOSUB and FOR need to potentially be able to jump back to non-labelling execution points. |
| 16:11 | zenoli | And after a GOTO 20, I don't think there's a way to get the next label without stepping through all the integers. |
| 16:11 | hiredman | zenoli: you need to do a pass over the ast that generates labels for those statements |
| 16:12 | mdrogalis | From http://bendyworks.com/transducers-clojures-next-big-idea/?utm_source=dlvr.it&utm_medium=twitter, "As core.async becomes more and more popular with Clojure, reducers are left behind." Is that at all true? |
| 16:12 | zenoli | hiredman: For the B=1, you mean, which doesn't have a label of its own? |
| 16:12 | hiredman | zenoli: sure |
| 16:12 | llasram | mdrogalis: That is a weird statement. |
| 16:13 | hiredman | zenoli: I would likely do a sort of desugaring pass that rewrites FOR in terms of GOTO |
| 16:13 | llasram | mdrogalis: "Additionally, reducers use macros to perform their magic instead of using function composition, which means we have to repeat our logic to handle different abstractions." Um, not true at all |
| 16:13 | mdrogalis | llasram: Yeah. I don't claim to -really- understand Reducers, but those 2 things seemed orthogonal |
| 16:13 | llasram | What an odd article |
| 16:13 | hiredman | I actually have a start of a basic compiler targeting the beaglebone's prus in clojure https://github.com/hiredman/prubasic |
| 16:13 | mdrogalis | Yeah but points for his picture |
| 16:14 | mdrogalis | I thought they were acorns at first |
| 16:15 | zenoli | I've been mulling whether a zipper might be usable as an instruction pointer. |
| 16:15 | arrdem | what would that buy you besides complexity? |
| 16:15 | zenoli | hiredman: Ah, cool. |
| 16:17 | zenoli | zipper would be able to step to the next statement in the AST from anywhere, without trying to enumerate labels. |
| 16:17 | zenoli | I'm not saying it's a good idea, just *an* idea. |
| 16:18 | arrdem | but you _have_ labels, and basic is _designed_ in terms of addressed program points. |
| 16:18 | hiredman | zenoli: I think your best bet is a normalizing pass that gives every statement a label, and then using a map to represent ebbs {label code} like you mentioned |
| 16:19 | hiredman | if you have a normalizing pass then everything is more regular and easier to interpret or compile |
| 16:19 | arrdem | if you really insist on not addressing each individual statement as hiredman is suggesting, you could do a basic block transform, and then sequentially evaluate all the terms in a basic block and only handle the jump conditions. |
| 16:20 | hiredman | you can build an abstract machine that executes that pretty easily |
| 16:20 | zenoli | No, hiredman's suggestion makes sense. Just trying to figure out the design tradeoffs. |
| 16:21 | zenoli | Thanks, that reduces the complexity that I was getting bogged down in. |
| 16:35 | iris_ | Can I use extend-protocol in a separate namespace and count on the extended type / class implementing that protocol in another namespace inside the same lein project / jar? |
| 16:36 | amalloy | iris_: as long as you require the namespace doing the extending |
| 16:37 | tanzoniteblack | iris_: will work as long as you've required/run the code doing the extending before relying on it |
| 16:37 | iris_ | thanks! |
| 16:54 | cbp | ,1 |
| 16:54 | clojurebot | 1 |
| 16:55 | shriphani | hi everyone, I am a bit of a java noob. I was wondering if I place a shell script in my resources dir, can I execute (via clojure.shell say) it after pulling this jar from clojars ? |
| 16:57 | technomancy | shriphani: yes, provided you've thought through the security implic--aw who am I kidding; that's totally optional. |
| 16:59 | shriphani | technomancy, so if I have foo.sh in my resources dir, I can do (sh "foo.sh") and I can expect it to work fine ? |
| 16:59 | shriphani | well with the io/resource thing i.e. |
| 16:59 | technomancy | shriphani: oh, no you'd have to do (io/copy (io/resource ...) temp-file) first |
| 16:59 | technomancy | bash can't look inside jars like that |
| 16:59 | shriphani | ah. got it |
| 17:00 | technomancy | or you could feed it to bash via stdio |
| 17:01 | shriphani | technomancy, IIRC the first time we run lein, it wgets a whole bunch of stuff. That could be a possibility too (as opposed to bundling the binary as a resource). But I think it would be better to copy the binaries to a location in the user's homedir. |
| 17:02 | zanes | Hmm. |
| 17:11 | zanes | If I want to use clojure.core.async/map< with a function that returns a single value on a channel what’s the right way to do that? Do I want to comp the function with <!!? |
| 17:11 | zanes | Hope that made sense. |
| 17:12 | bbloom | zanes: map< and related are being deprecated in favor of the transducers stuff just announced |
| 17:12 | zanes | bbloom: I know, but isn’t that only in the latest alpha? |
| 17:13 | bbloom | zanes: yeah, but part of that is b/c rich realized he had to re-implement map/filter/mapcat/etc for lazy seqs, reducers, channels, etc etc and the channel based ones were particularly awkward |
| 17:13 | zanes | Yeah, I recognize this is all going to be easier with transducers. I’m just figuring out what to do if I’m stuck on 1.6.0 for now. |
| 17:14 | bbloom | zanes: just write your own goroutine for your particular |
| 17:14 | bbloom | ...need |
| 17:14 | zanes | So you’d advise against map< usage in general? |
| 17:15 | amalloy | gfredericks: the answer to http://math.stackexchange.com/questions/87436/the-tuesday-birthday-problem-why-does-the-probability-change-when-the-father-s nicely sums up the objection i was trying to make about the tuesday birthday problem months ago |
| 17:16 | bbloom | zanes: only b/c i advise core.async usage like my kindergarden teacher advised paste usage: a little dab will do ya |
| 17:17 | zanes | bbloom: Hmm. Maybe you’re right and I’ve overdone it here. I’ve been trying to propagate core.async and channel usage throughout this program. |
| 17:17 | bbloom | zanes: yeah, not a great plan |
| 17:17 | zanes | The program is basically all about making a lot of asynchronous HTTP requests, so it seemed unnatural to mix async paradigms. |
| 17:20 | bbloom | zanes: jvm only? |
| 17:20 | zanes | JVM only. |
| 17:22 | gfredericks | amalloy: aaaahm |
| 17:22 | bbloom | zanes: use <!! and real threads except in the few spots you genuinely need asynchronous operations |
| 17:23 | gfredericks | the stuff I remember you saying seems to have been poked at in the question, but I don't see it in the answer |
| 17:23 | bbloom | you can blend threaded and evented styles on a per-need basis |
| 17:23 | zanes | Okay, I’ll give that a shot. Thanks! |
| 17:28 | amalloy | gfredericks: the objection i was trying to make is that it depends on how you found the guy who's saying he has a son born on a tuesday |
| 17:29 | gfredericks | ooh yes right |
| 17:30 | amalloy | <amalloy> in contrast, suppose we sent out a survey to all parents in the US, and selected only those who have a son born on tuesday |
| 17:32 | gfredericks | I feel like there's a pretty obvious default meaning though |
| 17:32 | gfredericks | i.e., randomly selected from among all men who have two children with one a tuesday-boy |
| 17:34 | carrumba | is there a simple way to assign a Byte a value > 127? |
| 17:35 | amalloy | gfredericks: i don't agree. maybe i walked through central park with a sign reading "If you have two children, I'll give you $5 to tell me the sex of one and the day of the week it was born" |
| 17:35 | bbloom_ | carrumba: bytes are signed on the jvm |
| 17:36 | amalloy | now someone telling me tuesday doesn't mean anything interesting |
| 17:38 | bbloom_ | ,(unchecked-byte 255) ; carrumba |
| 17:38 | clojurebot | -1 |
| 17:38 | bbloom_ | ,(unchecked-byte 128) ; carrumba |
| 17:38 | clojurebot | -128 |
| 17:40 | gfredericks | amalloy: so if you do that, and the filter for the ones with a tuesday-boy, what proprotion would you expect to have two boys? |
| 17:41 | amalloy | 13/27, or whatever the weird number is |
| 17:42 | amalloy | because the filtering reduces it to exactly what you claim is the "default scenario" |
| 17:42 | gfredericks | doesn't the problem statement entail exactly such a filtering? |
| 17:42 | amalloy | no |
| 17:42 | gfredericks | "A man has two sons one of which is a boy born on tuesday..." |
| 17:43 | gfredericks | I don't know how to argue this any further; I think we must be speaking a different dialect of english? |
| 17:44 | amalloy | gfredericks: like the SO answer says, it depends on what pool of people he came from |
| 17:44 | TimMc | Oh, are we doing this again? |
| 17:44 | amalloy | did he come from a pool of people with two children and at least one boy, and the tuesday is just a coincidence? or did they select only people who answered tuesday and throw out everyone else? |
| 17:44 | aperiodic | gfredericks: not the only problem statement; the one in the linked article states "you meet a man on the street..." which doesn't imply any filtering |
| 17:46 | amalloy | TimMc: yes, i happened upon an SO question/answer that i thought better explained the position i was trying to take last time, so i resurrected the topic |
| 17:46 | carrumba | bbloom_: thanks for the hint! |
| 17:46 | amalloy | but it doesn't seem to be any clearer to gfredericks what i mean |
| 17:46 | amalloy | (or at least he doesn't think i'm any more right) |
| 17:47 | gfredericks | aperiodic: so does my phrasing imply the filtering then? |
| 17:47 | gfredericks | I'm not really interested in defending more ambiguous wordings |
| 17:48 | amalloy | gfredericks: i think yours is just as ambiguous. if it were worded instead as "you go on a journey to find a man who can tell you he has two children, one of whom is a boy born on tuesday", then it would be clear enough. just being told "there is such a man" is no good |
| 17:49 | gfredericks | but wandering through the park with five dollar bills is just another way of finding such a man |
| 17:49 | aperiodic | gfredericks: I should have said "implies no filtering." your intended phrasing doesn't give any information about how the man was found, so doesn't imply filtering or imply no filtering |
| 17:49 | gfredericks | once I've found him the probabilities are the same |
| 17:49 | amalloy | gfredericks: but the sign didn't ask for only tuesday-boys, it asked for children |
| 17:51 | gfredericks | oh okay your point is that if I in the park first run into a thursday-girl, then that's what the problem ends up using |
| 17:51 | gfredericks | and therefore we have 1/3 or 1/2 or something |
| 17:52 | amalloy | right |
| 17:52 | amalloy | whereas if you doggedly wait for tuesday-boy, you get the weird 13/27 |
| 17:53 | gfredericks | this interpretation is so unnatural that it took you this long to explain it to me :P |
| 17:54 | gfredericks | therefore the length of this discussion is evidence that I'm correct |
| 17:54 | amalloy | it seems pretty natural to me. if someone tells me "i have a boy born on a tuesday", i don't immediately assume "well he wouldn't have talked to me at all if his son were born on wednesday" |
| 17:54 | amalloy | i assume he would have said something similar but not identical |
| 17:55 | aperiodic | "i found it hard to understand your interpretation so it must be unnatural" |
| 17:55 | amalloy | aperiodic: works for lisp |
| 17:55 | amalloy | parens confuse me, thus they are confusing |
| 17:56 | metellus | considering we're talking about natural language |
| 17:56 | metellus | it's a valid claim to make |
| 17:56 | metellus | the response "no, I'm pretty sure you're the one with the unnatural interpretation" is also valid |
| 17:56 | gfredericks | amalloy: that was interesting, thanks |
| 17:56 | amalloy | i'm glad we finally got it ironed out enough to both be wrong |
| 17:56 | amalloy | you more than me, of course |
| 17:57 | gfredericks | naturally |
| 18:00 | aperiodic | that was easy; who wants to tackle the sleeping beauty problem? ;) |
| 18:00 | zanes | bbloom_: Is the guideline you’d use basically that if you are only going to need a well-known, fixed number of threads you should just use real threads? |
| 18:01 | bbloom_ | zanes: if you can use real threads, you should use real threads |
| 18:01 | zanes | That feels a bit strong. |
| 18:03 | bbloom_ | zanes: events etc add substantial complexity for very limited gain |
| 18:04 | gfredericks | aperiodic: hey nice I haven't seen this |
| 18:08 | amalloy | yeah, me either. it's neat |
| 18:09 | amalloy | probably the first time i've ever seen the words "Extreme Sleeping Beauty" all lined up, as well |
| 18:18 | gfredericks | the phenominalist bit makes sense to me |
| 18:18 | gfredericks | i.e., it's objectively the most natural |
| 18:18 | gfredericks | hey look at my statements all lining up |
| 18:18 | amalloy | haha |
| 18:19 | gfredericks | how long can I keep this up? it's tough |
| 18:20 | technomancy | one of my co-workers wrote a script to add garbage to the end of his commit message till it hashed to a sha starting with "cafe" for like three months before anyone caught on |
| 18:20 | amalloy | gfredericks: those of us with variable-width fonts are not impressed |
| 18:21 | gfredericks | amalloy: those of you with variable-width fonts don't matter |
| 18:22 | amalloy | technomancy: i remember someone writing something like that where you could specify a prefix you wanted, so that your commits could go like 0000001adf4d, 0000002fa21c... |
| 18:24 | arrdem | technomancy: got a minute? |
| 18:25 | amalloy | gfredericks: but i got you to break your streak. i'd say that counts as mattering |
| 18:25 | technomancy | arrdem: what's up? |
| 18:26 | arrdem | technomancy: I'd appreciate some help with having different compile time deps vs runtime deps. |
| 18:27 | arrdem | technomancy: basically I've gotten my summer compiler project to emit clojure/core, which means I don't want to have clojure.lang.RT bootstrapping it. So I built a version of RT that doesn't do so. Because the compiler is written in Clojure, I have to have clojure around when the compiler builds the source code, but for running the emitted classes I just want to use my lib-clojure rather than all of clojure 1.6 |
| 18:28 | arrdem | the only way I can think of doing this is having some `lein-oxcart` plugin that handles the compiler and compile time deps, then have user code depend on lib-clojure rather than clojure. I was wondering if there's something cleaner to be done. |
| 18:29 | technomancy | arrdem: this might be a good fit for the :provided profile |
| 18:30 | technomancy | for stuff that needs to be around during development but not included in the downstream jar |
| 18:30 | arrdem | herm... |
| 18:30 | technomancy | arrdem: are you intending to use this just for applications, or also for libraries? |
| 18:30 | arrdem | right now this is targeted only at final applications. |
| 18:31 | arrdem | this entire "lib-clojure" thing is me bored trying stuff, turning this into real infrastructure isn't in sight atm. |
| 18:31 | technomancy | yeah I'd go with making org.clojure/clojure :provided for starters |
| 18:32 | technomancy | maybe llasram could comment on whether that makes sense since he wrote it |
| 18:34 | arrdem | hum... so if I have [org.clojure/clojure "1.6.0"] :provided, then when I do "lein compile" or whatever it'll be on the classpath but for "lein run" it won't be. |
| 18:35 | technomancy | no, it's more like it'll be around during development but not deployment |
| 18:35 | arrdem | just trying to understand what it does, I'm only seeing the lein 2.0.0-PREVIEW ann as documentation. |
| 18:35 | technomancy | so that's actually not great; easy to accidentally depend on it |
| 18:36 | technomancy | maybe if you aliased compile to ["with-profiles" "+clj" "compile"]? |
| 18:36 | arrdem | that could work. |
| 18:37 | arrdem | or I could just build a plugin that deals with all this.. |
| 18:38 | technomancy | I think all the primitives are there |
| 18:38 | arrdem | rather than trying to have a per-project configuration, just add some lein tasks. |
| 18:38 | arrdem | I'll dig some. thanks technomancy |
| 18:48 | tsantos | Anyone know if dommy can be used with node js? |
| 19:36 | Anceps_ | Hi :) |
| 19:42 | canweriotnow | Any advice on starting points with dataviz/graphing in cljs? I’ve been looking at strokes for d3 interop, and c2 for pure cljs goodness, but having trouble making a call. |
| 20:55 | sritchie | technomancy: looks like the :hooks I’ve set in my :dev profile are running when I call “lein uberjar" |
| 20:55 | sritchie | is there a way to stop this? |
| 20:57 | llasram | sritchie: lein with-profile -dev uberjar ? |
| 20:57 | llasram | or: lein with-profile production uberjar (I believe is the idiom) |
| 20:58 | sritchie | llasram: I had thought it used the uberjar profile by default if present |
| 20:58 | sritchie | and it is, it’ sjust merging it with dev |
| 20:58 | llasram | It adds it, but doesn't use it exclusively |
| 20:58 | llasram | You you probably also ^:replace the hooks |
| 20:58 | llasram | (in the uberjar profile) |
| 20:58 | llasram | So many options! |
| 20:59 | sritchie | llasram: :hooks ^:replace [] doesn’t work |
| 20:59 | llasram | (Which is sarcasm directed at unintended complexity from combinations of useful features -- not intended as condescension) |
| 20:59 | llasram | Ah |
| 20:59 | sritchie | :) don’t worry, I understand and relate |
| 20:59 | sritchie | llasram: trying an alias thing now |
| 20:59 | llasram | Cool |
| 21:05 | russ_ | hello, how do I access the nth element of a native javascript array in clojurescript? |
| 21:06 | llasram | russ_: I think just `(nth array n)` |
| 21:07 | russ_ | llasram: I got an error doing that last time, maybe I messed something up... will try again, thanks |
| 21:07 | llasram | russ_: I honestly have only played around with cljs, so may be completely off base |
| 21:11 | russ_ | just tried it again, it's a js function with array elements, nth gives: nth not supported on this type function HTMLCollection() { [native code] } |
| 21:11 | sritchie | I think you use aget |
| 21:11 | sritchie | https://himera.herokuapp.com/index.html |
| 21:11 | sritchie | nth should work too |
| 21:11 | llasram | russ_: It's both a function and an array? |
| 21:12 | sritchie | (aget (array 1 2 3) 1) => 2 |
| 21:13 | jgdavey | You'll need to coerce an HTMLCollection to something seq-able to be able to use nth |
| 21:13 | russ_ | yes, a function with array elements.. returned by document.getElementsByTagName |
| 21:14 | russ_ | is there any way I could read the property "0" or "1" of the object? I tried (.-0 obj) but that didn't work |
| 21:14 | jgdavey | (aget #<HTMLCollection> 0) |
| 21:15 | jgdavey | That is, to get the first "p" tag in a document, you would do: (aget (.getElementsByTagName js/document "p") 0) |
| 21:16 | russ_ | yes, that works, thank you! |
| 21:46 | sritchie | anyone know how to get lein cljsbuild to ONLY do the test clojurescript build when I run “lein cljsbuild test" |
| 21:46 | sritchie | it always runs them all |
| 21:56 | nicholasf | Hi, what's the convention for keeping data files (in this case a bunch of .txt files) in the structure of a lein program? |
| 21:56 | nicholasf | I suppose resources? |
| 22:00 | llasram | nicholasf: Yeah. If they actually should ship with your program (aren't deployment configuration), then the `resources` directory is the way to go |
| 22:01 | llasram | That will cause them to end up in your final JAR file |
| 22:01 | llasram | And be accessible via `clojure.java.io/resource` function, or other mechanism which searches the classpath |
| 22:05 | nicholasf | llasram: thanks mate |
| 23:02 | lukecossey | I have a question about defrecords. Is there a nicer way to pass in a map to a defrecord than the following? |
| 23:02 | lukecossey | (defrecord Person [name age height]) |
| 23:02 | lukecossey | (def data {:height 5.11 :name "Steve" :age 27}) |
| 23:02 | lukecossey | (Person. (:name data) (:age data) (:height data)) |
| 23:03 | kristof | Isn't that a nice way? |
| 23:05 | lukecossey | Well I was hoping there would be something like (Person. (said-function data)) |
| 23:07 | luxbock | try map->Person |
| 23:08 | luxbock | ,(defrecord Person [name age height]) |
| 23:08 | clojurebot | sandbox.Person |
| 23:09 | luxbock | ,(map->Person {:name "Steve" :age 27 :height 5.11}) |
| 23:09 | clojurebot | #sandbox.Person{:name "Steve", :age 27, :height 5.11} |
| 23:11 | lukecossey | Perfect! Thank you very much, that's exactly what I wanted :) |
| 23:19 | sritchie | ugh, here’s another Q - |
| 23:19 | sritchie | technomancy: if you’re around, is there a way to specify dependencies that make it inot the uberjar, |
| 23:19 | sritchie | but are NOT bundled with a jar on a deploy to clojars? |
| 23:19 | sritchie | I’ve got a library with an accompanying example project I’m deploying to heroku, |
| 23:20 | sritchie | and lein with-profile -dev,-uberjar jar doesn’t seem to get rid of them |
| 23:20 | sritchie | dnolen_: boom, finally got this up: http://om-bootstrap.herokuapp.com/ |
| 23:21 | sritchie | dnolen_: getting close to having examples for all of the components I’ve written so far. All of these have little show/hide toggles for the code to build to UI elements that are showing |
| 23:21 | dnolen_ | sritchie: wow this is cool, you going to do a post about this or anything? |
| 23:22 | sritchie | dnolen_: yeah, definitely |
| 23:22 | dnolen_ | sritchie: cool, let me know will def help get the word out |
| 23:22 | sritchie | awesome, thanks |
| 23:22 | sritchie | dnolen_: once I get the the fade and dropdown mixins done I’ll be able to bang out the final important components; |
| 23:22 | sritchie | the nav bars, modals, etc |
| 23:23 | sritchie | here’s the backing lib: https://github.com/racehub/om-bootstrap |