2013-12-27
| 00:00 | rhg135 | i get what js is but it doesn't actually send it |
| 00:01 | rhg135 | i'm stumped |
| 00:02 | rhg135 | it's actually logging everything, just not sending it or blocking a second request works fine |
| 00:02 | rhg135 | well not fine but it does log for it |
| 00:11 | rhg135 | any ideas why that .write call isn't writing to the client? |
| 00:26 | jebberjeb | ls |
| 00:26 | lazybot | bin data lib lost+found media proc sbin swap sys var |
| 00:46 | ianeslick | Has anyone dealt with using macros in a file used in both clojure and clojurescript? |
| 00:46 | ianeslick | i.e. ^:shared ns |
| 00:47 | ianeslick | I'm guessing that unless I use something like cljx, there is no way to conditionally use :require-macros only in the clojurescript case? |
| 01:46 | ddellacosta | bitemyapp: ping |
| 02:28 | v4n | If I want to set a local variable within a defn (e.g. system time), would using let be my best choice? |
| 02:29 | rhg135 | Yup |
| 02:30 | v4n | Any way to avoid having to wrap my entire function body with let for just setting the local time variable? |
| 02:30 | rhg135 | Well not variable as it doesn't vary usually |
| 02:30 | v4n | *Scope |
| 02:31 | rhg135 | Not that I know |
| 03:34 | sveri | hi, i trying to figure out whats the best way to convert a vector like this [1 2 3 4 5 6] into a string like this: "1,2 3,4 5,6"? should i just use loop/recur or one of the helper functions? |
| 03:38 | sm0ke | ,(clojure.string/join "," [1 2 3 4 5 6]) |
| 03:38 | clojurebot | "1,2,3,4,5,6" |
| 03:39 | TEttinger | sveri, with every other pair having a comma separating them? |
| 03:41 | sveri | sm0ke: i only need commas between pairs |
| 03:41 | TEttinger | &(clojure.string/join " " (mapv #(clojure.string/join "," %) (partition-all 2 [1 2 3 4 5 6]))) |
| 03:41 | lazybot | ⇒ "1,2 3,4 5,6" |
| 03:42 | sveri | TEttinger: ah, thats nice, thank you :-) |
| 03:42 | TEttinger | np |
| 03:46 | rhg135 | Any reason for mapv? |
| 03:47 | rhg135 | As opposed to just map |
| 03:49 | ddellacosta | rhg135: lazy sequence vs. vector? |
| 03:50 | rhg135 | It doesn't affect join? |
| 03:50 | rhg135 | Or does it |
| 03:50 | ddellacosta | rhg135: I assume join is going to realize the sequence, so doesn't really matter in that context I suppose |
| 03:51 | rhg135 | I guess not |
| 03:51 | ddellacosta | or rather, join *does* realize it, to be clear |
| 03:54 | TEttinger | rhg135, I used mapv to make clear that it wasn't going to produce lazy output |
| 03:55 | TEttinger | they're very similar on performance, right? |
| 04:25 | sm0ke | java sucks |
| 04:26 | sm0ke | cant seem to find an equivalent of promise for last 2 hours |
| 04:36 | Raynes | $google java.util.concurrent.FutureTask |
| 04:36 | lazybot | [FutureTask (Java Platform SE 7 ) - Oracle Documentation] http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/FutureTask.html |
| 04:36 | Raynes | sm0ke: ^ |
| 04:36 | Raynes | Oh, promise. |
| 04:36 | Raynes | Wow. Somehow I managed to see 'future' |
| 04:36 | Raynes | Apologies. |
| 04:38 | sm0ke | hmm i guess |
| 04:38 | sm0ke | Future can be used very much to copy promise |
| 04:39 | sm0ke | in some ways |
| 04:39 | sm0ke | it infact has set and get which would behave the same i guess |
| 04:40 | sm0ke | only clojure makes distinction between future and promise |
| 04:41 | sm0ke | hmm sensible developers should have named methods for Promise as kept, broken etc. Seems like a very sensitive api to have |
| 04:41 | sm0ke | explains why its not there |
| 06:05 | nones | ,t |
| 06:05 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: t in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 06:05 | nones | ,foo |
| 06:05 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 06:32 | daGrevis | Hello! I'm doing Clojure koans |
| 06:32 | daGrevis | http://vpaste.net/qRWeT What's wrong with this? |
| 06:33 | hyPiRion | daGrevis: What is (+ 1 2 3) in Clojure? |
| 06:34 | daGrevis | hyPiRion, lazy expr? |
| 06:34 | nones | daGrevis: you need to compare lists, (0 1 2 3 4 5) not list |
| 06:34 | hyPiRion | daGrevis: It's an expression, where the function `+` is evaluated on the arguments 1, 2 and 3 |
| 06:34 | hyPiRion | with the arguments, rather |
| 06:36 | daGrevis | so I guess the correct answer is http://vpaste.net/MikBn |
| 06:36 | daGrevis | or at least I pass ;D |
| 06:36 | ddima | no |
| 06:36 | ddima | what hyPiRion tries to say: by default the first element of a list is interpreted as the function to be invoked with the rest being arguments |
| 06:37 | nones | ,(0 1) |
| 06:37 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 06:37 | ddima | so you need to make clojure look at it as a "pure" list and not invoke anything |
| 06:37 | nones | ,(list 0 1) |
| 06:37 | clojurebot | (0 1) |
| 06:37 | ddima | sorry, pure is a bad word, "simple" |
| 06:37 | ddima | ,`(0 1) |
| 06:37 | clojurebot | (0 1) |
| 06:37 | hyPiRion | daGrevis: Unless you explicitly tell a lisp to not evaluate the list, it will be evaluated |
| 06:37 | daGrevis | to tell it not to eval it, I say '(something) ? |
| 06:38 | ddima | ` is shorthand for quote |
| 06:38 | ddima | ,(quote (1 2 3)) |
| 06:38 | clojurebot | (1 2 3) |
| 06:38 | hyPiRion | daGrevis: Exactly! quote, or ', will avoid evaluation |
| 06:39 | ddima | or, as nones pasted before, you can use the "list" function |
| 06:39 | ddima | ,(= `(0 1 2 3) (for [x (range 4)] x)) |
| 06:39 | clojurebot | true |
| 06:39 | daGrevis | hyPiRion, I learned Haskell a bit before. everything is lazy in it by default. so in Clojure everything is NOT lazy unless you say it to be lazy? mm? |
| 06:39 | hyPiRion | `, or backquote, will do something similar, but that's not neccessary to know before you go into macros |
| 06:39 | Raynes | &'(0 1) |
| 06:39 | lazybot | ⇒ (0 1) |
| 06:40 | daGrevis | ,(= '(1) `(1)) |
| 06:40 | clojurebot | true |
| 06:40 | hyPiRion | daGrevis: evaluation of code is not lazy, but generally, list operations will be |
| 06:40 | daGrevis | thank you, guys :) |
| 06:40 | ddima | hf |
| 06:40 | hyPiRion | daGrevis: so (foo a b) will always be called, but e.g. (map + '(1 2 3) '(4 5 6)) will produce a so-called lazy sequence |
| 06:40 | ddima | hyPiRion: you're a natural teacher ;) |
| 06:41 | hyPiRion | ddima: oh what, that's a first |
| 06:41 | daGrevis | hyPiRion, I think I got it, thanks :) |
| 06:41 | hyPiRion | thanks I guess =) / :p |
| 06:41 | nones | but remember: |
| 06:41 | nones | ,(= `(0 1 (+ 1 1) 3) (for [x (range 4)] x)) |
| 06:41 | clojurebot | false |
| 06:41 | nones | ,(= (list 0 1 (+ 1 1) 3) (for [x (range 4)] x)) |
| 06:41 | clojurebot | true |
| 06:42 | ddima | well, i liked how you tried to help him find his own answer while explaining the the mechanics |
| 06:42 | ddima | instead of "quote/list, neext" ;) |
| 06:43 | daGrevis | many ways to do a thing, pretty weird for a python dev ;d |
| 06:43 | ddima | not really |
| 06:43 | ddima | prefer list for that |
| 06:43 | hyPiRion | ddima: oh yeah, it's a good way of learning stuff I think. |
| 06:44 | daGrevis | ,(= list(1 2) '(1 2)) |
| 06:44 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 06:44 | daGrevis | yelp! :D |
| 06:44 | deadghost | idk feels like clojure gives some guidance |
| 06:44 | deadghost | by making some things more difficult |
| 06:44 | daGrevis | woah sorry |
| 06:45 | daGrevis | ,(= (list 1 2) '(1 2)) |
| 06:45 | clojurebot | true |
| 06:45 | daGrevis | there :) |
| 06:46 | ddima | used to happen to me all the time, $functionname($args) thing in clojure ;) |
| 06:46 | ddima | muscle memory |
| 06:50 | logic_prog | does keyword destructuring i.e. (let [{:keys [foo bar]} {:foo 20}] ... ) provide a way to provide a _default_ value |
| 06:51 | logic_prog | i.e. I want bar to be bound to "0" rather than "nil" when there is no key for bar |
| 06:52 | hyPiRion | logic_prog: yes, you can use the :or keyword. For instance, ##(let [{:keys [foo bar] :or {bar 0}} {:foo 20}] {:foo foo :bar bar}) |
| 06:52 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: in this context |
| 06:52 | hyPiRion | ,##(let [{:keys [foo bar] :or {bar 0}} {:foo 20}] {:foo foo :bar bar}) |
| 06:52 | lazybot | ⇒ {:foo 20, :bar 0} |
| 06:52 | clojurebot | #<RuntimeException java.lang.RuntimeException: Reader tag must be a symbol> |
| 06:52 | hyPiRion | heh, whoops |
| 06:53 | logic_prog | hyPiRion: nice, thanks! |
| 06:55 | logic_prog | hyPiRion: do you have any cool clojure projects on github? |
| 06:57 | hyPiRion | logic_prog: depends on what you mean by cool. I mostly contribute to Leiningen either directly or indirectly through plugins |
| 06:58 | logic_prog | ah, I just remember seeing you here quite a bit |
| 06:58 | logic_prog | and was curious if there were any projects whose code I could learn from |
| 06:58 | logic_prog | (the other day, I learned "lein pdo" and it changed the way I use lein) |
| 07:02 | hyPiRion | logic_prog: well, Leiningen isn't a good place to learn idiomatic Clojure, because it's not your usual Clojure program. |
| 07:08 | hyPiRion | To be fair, I'm not sure what a good library to learn from is. Perhaps starting with https://github.com/weavejester/medley or https://github.com/flatland/useful, as they are rather easy to read. |
| 07:12 | hyPiRion | but the best is to code much, and when you need to use a library, attempt to understand what's going on behind the covers if you got time |
| 07:12 | logic_prog | hyPiRion: oh, by "learn from", I didn't mean learn clojure |
| 07:12 | logic_prog | but rather "a nice library I can pull in that may be useful" |
| 07:12 | logic_prog | for example, my current project.clj has 22 dependencies |
| 07:12 | logic_prog | but always looking for cool clojure _libraries_ to learn to use, |
| 07:12 | logic_prog | not actually learn how to write clojure code :-) |
| 07:13 | hyPiRion | aha |
| 07:13 | logic_prog | so for example, learning core.logic was awesome |
| 07:13 | logic_prog | as was match / ring / compojure |
| 07:14 | hyPiRion | instaparse is good |
| 07:15 | logic_prog | i found it really slow at parsec to be better |
| 07:15 | logic_prog | i never understood why anyone wanted _all parses_ rather than make the grammar unambigious |
| 07:15 | logic_prog | it goes against a fundamental principle of CS |
| 07:15 | logic_prog | don't be ambigious |
| 07:16 | arrdem | ... wat |
| 07:16 | arrdem | you can totally define an ambiguous grammar that has meaning in multiple parse trees |
| 07:16 | logic_prog | yeah |
| 07:16 | logic_prog | but when is this iseful in practice? |
| 07:16 | arrdem | now will a sane grammar be unambiguous? sure, but that's a performance tweak usually. |
| 07:17 | logic_prog | no, see packrat parsing |
| 07:17 | arrdem | logic_prog: natural language :/ |
| 07:17 | logic_prog | you take a CFG, then specify precedence |
| 07:17 | logic_prog | and boom, no ambiguity |
| 07:17 | hyPiRion | environ is also nice to know of, although I tend to use edn for environment vars these days |
| 07:17 | logic_prog | arrdem: for that, you need probabilistic techniques |
| 07:18 | arrdem | logic_prog: I mean to do it "right" sure, but how is probabalistic analysis any different from having multiple ambiguous yielded trees? |
| 07:18 | logic_prog | they have probabilites associated with them |
| 07:18 | hyPiRion | logic_prog: the instaparse perf isn't good, true, but I find it useful for mocking up parsers |
| 07:18 | logic_prog | and generally, you can prune stuff |
| 07:19 | hyPiRion | (Okay when you have deadlines and stuff) |
| 07:20 | arrdem | hyPiRion: instaparse is amazing when you want a parser yesterday for a well defined language. |
| 07:20 | arrdem | Eg. Pascal or Scheme or something else you just want to plug and chug with a BNF on |
| 07:20 | arrdem | s/on/for/ |
| 07:45 | bitemyapp | bwahahaha...plans are made...another soul gets converted tonight... |
| 07:47 | bitemyapp | arrdem: hey I'm not the one making snake-oil in code form >:D |
| 07:48 | arrdem | bitemyapp: dogecoin is totally legit I don't know what you're talking about |
| 07:48 | bitemyapp | arrdem: I actually meant snake oil => anticipating the sine wave |
| 07:48 | bitemyapp | arrdem: but I'm VERY curious to see how the returns, even if not large in magnitude, come out quantitatively |
| 07:49 | bitemyapp | WRT alpha, overall risk, etc. |
| 07:49 | arrdem | bitemyapp: haha yeah I'm still trying to get a handle on the problem so I can throw a neural network at it :P |
| 07:49 | bitemyapp | wat |
| 07:51 | arrdem | bitemyapp: it's like throwing a brick at something, except that when iterated the brick eventually figures it's stuff out and hits its mark |
| 07:58 | arrdem | bitemyapp: sillyness asside I'm working on slapping togehter a logging system so that I can do some testing and answer those questions before going live. |
| 08:15 | pepijndevos | So persistent datastructures in JS, nothing stops silly JS libs from setting modifiying them, right? |
| 08:15 | pandeiro | anybody working with datomic-console? i'm trying to get it set up for datomic-free; no luck so far |
| 08:16 | daGrevis | ,(map + (1 2)) |
| 08:16 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 08:16 | daGrevis | why it doesn't work? |
| 08:17 | arrdem | daGrevis: you want to use [] for a sequence literal. |
| 08:17 | daGrevis | in short, I want to get sum of list |
| 08:17 | hyPiRion | daGrevis: (list 1 2) vs. (1 2) |
| 08:17 | arrdem | daGrevis: by writing (1 2) you are saying (apply 1 2) which makes no sense |
| 08:17 | daGrevis | ,(map + (list 1 2)) |
| 08:17 | clojurebot | (1 2) |
| 08:17 | daGrevis | :/ |
| 08:17 | daGrevis | okay, i got rid of error |
| 08:17 | daGrevis | thought exepected result was 3 |
| 08:17 | arrdem | daGrevis: check out reduce |
| 08:17 | nones | ,(reduce + (list 1 2)) |
| 08:17 | clojurebot | 3 |
| 08:18 | daGrevis | right! i knew about reduce, just didn't thought to use it :) |
| 08:18 | daGrevis | i present to u my first code in clojure |
| 08:18 | daGrevis | ,(reduce + (filter #(zero? (mod % 3)) (filter #(zero? (mod % 5)) (range 1 999)))) |
| 08:18 | clojurebot | 33165 |
| 08:19 | daGrevis | do u like it? :D |
| 08:21 | hyPiRion | daGrevis: Good start :) |
| 08:22 | gilles | hi can anybody answer a basic core.logic question ? |
| 08:22 | hyPiRion | Just fyi, (range a b) would return all elements from a up to, but not including b. |
| 08:23 | hyPiRion | ,(last (range 1 100)) |
| 08:23 | clojurebot | 99 |
| 08:23 | hyPiRion | ~anybody |
| 08:23 | clojurebot | Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..." |
| 08:25 | nones | ,anybody |
| 08:25 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: anybody in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 08:25 | gilles | I declare a "parent" defrel and then some facts about joe is parent of suzy etc... how can i find pairs of persons which are not in a parent relationship ? |
| 08:25 | nones | ~anybody |
| 08:25 | clojurebot | anybody is anyone |
| 08:26 | arrdem | nones: ~ invokes an inference and pattern matching system |
| 08:26 | arrdem | nones: , evals code |
| 08:26 | daGrevis | hyPiRion, how is it related to my code? |
| 08:28 | hyPiRion | daGrevis: If you want to find the sum of all the multiples of 3 or 5 below 1000, you should do (range 1 1000) instead. Just have a suspicion that's what you wanted to do. |
| 08:30 | daGrevis | hyPiRion, imo below 1000 means 999 and NOT 1000 |
| 08:31 | daGrevis | hyPiRion, but you are right about me currently finding sum of numbers that are mod 3 and mod 5. i need OR conditional |
| 08:31 | hyPiRion | daGrevis: (range 1 1000) returns (1 2 3 ... 997 998 999) |
| 08:31 | hyPiRion | and yeah, I was about to mention that, but I guess you figured =) |
| 08:31 | daGrevis | hyPiRion, imo I could fix it by creating two lazy lists, then filtering both. one my mod 3 and other by mod 5. the I merge em and get sum like before. |
| 08:32 | hyPiRion | daGrevis: yep, that's a good idea. Just remember to remove duplicates |
| 08:32 | daGrevis | hyPiRion, so the question is: is 0 a natural number because wikipedia isn't super sure :D |
| 08:32 | daGrevis | hyPiRion, good point about removing duplicates |
| 08:34 | hyPiRion | daGrevis: Whether 0 is a natural number or not isn't that important in this case. 0 + x = x, so it wouldn't change your result |
| 08:34 | daGrevis | you are right |
| 08:35 | daGrevis | yes, set up lein exec. much better :) |
| 08:40 | daGrevis | hyPiRion, thanks, just understand what you meant |
| 08:40 | daGrevis | if I write (range 999), it really gives me 998 as last elem |
| 08:41 | hyPiRion | yup |
| 08:41 | daGrevis | so I present the solution to you :) |
| 08:41 | daGrevis | http://vpaste.net/6d24h |
| 08:41 | daGrevis | dunno if I get how to indent corretly thought |
| 08:41 | hyPiRion | daGrevis: yup, that looks correct :) |
| 08:41 | instilled | does someone have a working clojure/nrepl/emacs debugging setup and would be willing to share some insights? i'm currently bbatsov's excellent prelude. is ritz-* still the way to go? i can debug with eclipse or intellij but that's not really what I want. |
| 08:45 | hyPiRion | daGrevis: most editors support some sort of autoindentation, but I wouldn't worry too much about it right now |
| 08:47 | daGrevis | I guess this indentation looks more decent http://vpaste.net/Sp8lv |
| 08:47 | daGrevis | hyPiRion, ye, I guess. I'm using Vim with Vim-clojure |
| 08:48 | daGrevis | hyPiRion, http://i.imgur.com/hMa8UZD.jpg |
| 08:50 | hyPiRion | daGrevis: not a guru on vim, but I think `filetype plugin indent on` should help you on the autoindentation |
| 08:51 | daGrevis | hyPiRion, u r correct and ft is on. i got niceties like autocomplete from standard lib. this doesn't change the fact that indentation doesn't work. ;D maybe it's turned off by default because Lisp and parens and something. gotta google |
| 08:52 | gphilippart | here |
| 08:52 | gphilippart | can anyone answer a core.logic question on relations ? |
| 08:53 | AimHere | We don't know. The best way to ask a question on IRC is to blurt it out and wait |
| 08:54 | AimHere | Unless all you wanted to know if anyone could answer a core.logic question on relations, in which case, we don't know. Depends on the question. |
| 08:54 | gphilippart | how do you find answers which do not satisfy a relation in core logic ? |
| 08:57 | AimHere | Not sure that's in general possible - this is some old musings on the subject, David Nolen being the guy who should know everything to know about core.logic: https://groups.google.com/forum/#!topic/clojure/hz63yeQfiQE |
| 08:59 | gphilippart | thanks for the heads up, that's the topic i was looking for |
| 09:05 | gphilippart | so, the answer is : it's possible since David added nafc in core logic to support Negation as a failure. |
| 09:11 | AimHere | gphilippart, well you'll have to refer to the current state of core.logic for that; last time I looked at core.logic, tthere were sweeping changes that broke all the tutorials! |
| 09:17 | turbopape | Hi people, |
| 09:17 | turbopape | did anyone write something real-time in clojure ? |
| 09:18 | turbopape | I mean, tiny servers that do content transformation on the fly, namely... ? |
| 09:18 | turbopape | any pointers that can help ? |
| 09:30 | broquaint | turbopape: Something like this? https://github.com/schani/clojurec |
| 09:32 | turbopape | broquaint maybe, but is this ready for production yet ? |
| 09:39 | broquaint | No idea I'm afraid. |
| 09:48 | pepijndevos | Why doesn't this work in clojurescript? (.indexOf [1 2 3] 2) |
| 09:49 | hyPiRion | turbopape, broquaint: No, not production ready. |
| 09:49 | pepijndevos | Intended result: 1, like [1,2,3].indexOf(2) |
| 09:50 | turbopape | ok... |
| 09:51 | BobSchack | pepijndevos [1 2 3] is a clojurescript vector not a javascript array |
| 09:51 | glosoli | pepijndevos: Isn't indexOf meant for String type ? |
| 09:51 | glosoli | ah sorry :) |
| 09:51 | pepijndevos | BobSchack, but it doesn't give an exception, just nil. |
| 09:52 | pepijndevos | Which suggests indeOf is defined to do *something* |
| 09:52 | justin_smith | pepijndevos: I think that is becuase [1 2 3] is not a javascript array |
| 09:53 | justin_smith | it is a clojurescript immutible vector |
| 09:53 | hyPiRion | Doesn't explain why .indexOf is prototyped though. |
| 09:53 | pepijndevos | I know that. Question is, how do I get the index of an element from it |
| 09:54 | BobSchack | pepijndevos: http://clojuredocs.org/clojure_core/clojure.core/nth |
| 09:54 | pepijndevos | And if Clojurescript is anything like Clojure, its collections implement the native interfaces. |
| 09:54 | pepijndevos | BobSchack, that's the other way around. I HAVE an item, I WANT its index. |
| 09:54 | BobSchack | oh my mistake |
| 09:56 | pepijndevos | Maybe I should hack an implementation using keep-indexed |
| 09:57 | justin_smith | pepijndevos: I don't know why they don't implement .indexOf, but clearly they don't. Doing it with native clojure functions is possible I guess. |
| 09:58 | hyPiRion | (ffirst (keep-indexed #(if (= item %2) %1) coll)) -- poor man's indexOf |
| 09:59 | hyPiRion | ur, an f too much there |
| 09:59 | pepijndevos | yea |
| 09:59 | pepijndevos | I was wondering.. do you return a seq? |
| 09:59 | justin_smith | (first (keep-indexed #(if (= %2 2) %1) [1 2 3])) works in cljs-fiddle |
| 09:59 | pepijndevos | yea, I independently arrived at the exact same code :) |
| 10:00 | pepijndevos | though I'm curious what the .indexOf is doing... |
| 10:01 | justin_smith | I think under the hood in most javascript an "array" is really a hash-map from index to value with numeric keys |
| 10:02 | justin_smith | likely something very similar to the code above actually |
| 10:16 | Wild_Cat | justin_smith: really? Interesting, that sounds... Baroque. |
| 10:16 | hyPiRion | sounds efficient |
| 10:16 | justin_smith | http://stackoverflow.com/questions/365975/how-are-javascript-arrays-implemented |
| 10:18 | Wild_Cat | thanks for the info |
| 10:18 | Wild_Cat | hyPiRion: efficient? Sounds more like wasteful of memory and slower to iterate over to me. |
| 10:19 | Wild_Cat | ...although I just now realized that Javascript doesn't have foreach-type iteration. |
| 10:19 | hyPiRion | Wild_Cat: Sorry, it's hard to convey sarcasm over the Internet :p |
| 10:19 | Wild_Cat | hyPiRion: ooh. Also note that I haven't had my morning coffee yet, which makes it harder for me to sense it :D |
| 10:19 | justin_smith | arrays are defined to behaviors of "objects" AKA hash-maps with magic attached |
| 10:20 | justin_smith | (defined by the js spec that is) |
| 10:24 | rovar | whatevs: https://developer.mozilla.org/en-US/docs/Web/API/Int32Array?redirectlocale=en-US&redirectslug=Web%2FJavaScript%2FTyped_arrays%2FInt32Array |
| 10:27 | justin_smith | rovar: I am unfamiliar with mdn formatting - if there are no compatibility notes does that imply only mozilla based browsers, or all browsers? |
| 10:30 | rovar | justin_smith: it's any browser that supports WebGL, as those extensions were added to support that. |
| 10:30 | justin_smith | oh, OK, I missed that, thanks |
| 11:05 | daGrevis | hi again |
| 11:05 | daGrevis | Why isn't this working as expected? http://vpaste.net/Yl5Sb The result is wrong. |
| 11:06 | ghadishayban | daGrevis: the # symbols need to wrap the 'or' itself instead of the inner clauses |
| 11:07 | daGrevis | ghadishayban, woah, thanks. I wonder why it didn't blow up :( |
| 11:08 | ghadishayban | or checks for truthiness, and functions are truthy (only nil and false are falsey) so it was being filtered only by the first # fn |
| 11:11 | daGrevis | ghadishayban, thanks :) |
| 11:17 | gfredericks | should I infer from the fact that clojure/west hasn't been announced yet that its existence is questionable? |
| 11:18 | sritchie | cemerick: first step toward the liberator + friend integration I wanted to write about: https://github.com/clojure-liberator/liberator/pull/95 |
| 11:21 | cemerick | sritchie: yup, got it in a tab now; keeping an eye on it :-) |
| 11:29 | mdrogalis | I guess as a Lisp programmer, one could describe him/herself as a data entry professional. |
| 11:32 | cjfrisz | mdrogalis: -_- |
| 11:32 | dabd | I was comparing ghci with clojure in a simple example: ,(->> (filter odd? (map #(* % %) (iterate inc 1))) (take-while #(< % 10000000000)) (reduce +)) |
| 11:33 | dabd | takes a long time with clojure and is almost instantaneous with haskel: sum (takeWhile (<10000000000) (filter odd (map (^2) [1..]))) |
| 11:33 | dabd | l. Anyone knows why? |
| 11:34 | mdrogalis | cjfrisz: Yeah, everyone at my office just did that to me after I said it out loud lol |
| 11:38 | jcromartie | so you want the sum of the square of all odd numbers under 10000000000 |
| 11:39 | dabd | nvm it was the gc... |
| 11:39 | dabd | pls ignore my question |
| 11:40 | dabd | and i suppose clojure version will be faster with a type hint |
| 11:40 | jcromartie | yeah I was going to say I get 200ms |
| 11:41 | jcromartie | and there are certainly faster ways to write it in Clojure |
| 11:41 | mdrogalis | cjfrisz: Two SQL tables walk into a bar. |
| 11:41 | mdrogalis | Going for broke there. ;[ |
| 11:49 | cjfrisz | mdrogalis: You need to make sure there's a stand-up comedy spot in the lightning talks at next year's Conj |
| 11:58 | mdrogalis | cjfrisz: Rich, Stu, and Chouser walk into a bar. |
| 11:58 | mdrogalis | It's a great way for me to offend everyone in a single pass. |
| 11:58 | jcromartie | and only one of them will emerge victorious |
| 11:59 | otfrom | sritchie: I like the friend/liberator stuff you are working on. I'm going to be using that PR when it happens |
| 12:00 | sritchie | yeah, it's been really good |
| 12:01 | gfredericks | A man at a bar orders a rich stew chowder |
| 12:02 | mdrogalis | Does the man end up complaining about the meal not being composable? |
| 12:02 | technomancy | otfrom: I have to ask... your nick? is there a story? |
| 12:04 | technomancy | or at least a pronunciation guide? |
| 12:04 | gfredericks | obviously hir name is Obvious Tfrom? |
| 12:04 | otfrom | technomancy: to goes <- way and from goes -> way |
| 12:04 | otfrom | is was *really* clever in 1999 |
| 12:05 | otfrom | s/is/it |
| 12:05 | gfredericks | (defn clever? [nick year] ...) |
| 12:05 | otfrom | every time I write that function it *always* returns false |
| 12:05 | otfrom | weird |
| 12:07 | otfrom | technomancy: and it is only 6 letters and available as a .com |
| 12:08 | gfredericks | technomancy.com is in a holding pattern |
| 12:09 | technomancy | otfrom: ah, not bad |
| 12:11 | gfredericks | technomancy bar jokes: repeatability is important for beer |
| 12:13 | nenorbot | is there a min function that accepts a function for value comparison? |
| 12:13 | gfredericks | dabd: I'm surprised that didn't crash from numeric overflow |
| 12:14 | gfredericks | nenorbot: min-key could work if you can map your items to appropriate numbers |
| 12:14 | nenorbot | sounds good! thanks |
| 12:20 | hyPiRion | Otherwise just use compare |
| 12:21 | hyPiRion | ,(reduce #(if (neg? (compare %1 %2)) %1 %2) [1 2 -2 4 -3 -10 10 1023]) |
| 12:21 | clojurebot | -10 |
| 12:22 | daGrevis | i love that you can do (source func). |
| 12:26 | gfredericks | I have typed (use 'clojure.repl) 5838 times so far |
| 12:26 | gfredericks | does anybody know cider well enough to tell me how to bind that to a key? :) |
| 12:28 | justin_smith | gfredericks: you could make that an :injection in you :develop profile |
| 12:28 | justin_smith | or are you one to switch to project namespaces in the repl |
| 12:29 | gfredericks | yes I am |
| 12:29 | gfredericks | user is usually well-equipped I think |
| 12:29 | gfredericks | alternatively I could try learning to automate the process of making user useful for everything |
| 12:30 | justin_smith | I just stay in the user ns and never have that problem, I guess that is just a different strokes for different folks thing |
| 12:30 | gfredericks | I don't want to assume my jvm process is always running locally with the :user profile though |
| 12:30 | gfredericks | so e.g. :user dependencies wouldn't always be around |
| 12:30 | justin_smith | right |
| 12:31 | gfredericks | so ideally this would be in elisp I guess |
| 12:31 | justin_smith | for me I am in the user ns for the repl, but test namespaces don't have user |
| 12:31 | justin_smith | gfredericks: yeah, there is definitely an elisp function that evaluates some string in the current repl. I only have nrepl still though, so can't help you with that part |
| 12:32 | justin_smith | but the ielm elisp repl + (apropos "thing") work wonders with elisp |
| 12:32 | justin_smith | also C-h f "name" |
| 12:32 | justin_smith | once you figure out a few basics, emacs self-documents really well and very deeply |
| 12:33 | justin_smith | I like ielm rather than M-: because it reminds me of using a real lisp |
| 12:33 | justin_smith | warm fuzzys |
| 12:33 | gfredericks | C-h is backspace for me :) |
| 12:34 | gfredericks | gotta figure out how to bind help to something else |
| 12:34 | gfredericks | #thingsyoushouldhavedonealongtimeago |
| 12:40 | justin_smith | gfredericks: M-x describe-function |
| 12:41 | dabd | gfredericks: indeed, it should overflow ints |
| 12:42 | gfredericks | dabd: and longs I'd think |
| 12:42 | gfredericks | ,(#(* % %) 10000000000) |
| 12:42 | clojurebot | #<ArithmeticException java.lang.ArithmeticException: integer overflow> |
| 12:42 | gfredericks | assuming ten billion is what you were dealing with; I might've misread |
| 12:42 | justin_smith | ,(#(*' % %) 10000000000) |
| 12:42 | clojurebot | 100000000000000000000N |
| 12:43 | gfredericks | ,'''*''' |
| 12:43 | clojurebot | (quote (quote *''')) |
| 12:44 | justin_smith | ,*' |
| 12:44 | clojurebot | #<core$_STAR__SINGLEQUOTE_ clojure.core$_STAR__SINGLEQUOTE_@1a9aa17> |
| 12:44 | gfredericks | ,(fn $_STAR__SINGLEQUOTE_ [x] "you're a star, singlequote!") |
| 12:44 | clojurebot | #<sandbox$eval125$$_STAR__SINGLEQUOTE___126 sandbox$eval125$$_STAR__SINGLEQUOTE___126@1c4b127> |
| 12:45 | justin_smith | ,(-> #'*' meta :doc) |
| 12:45 | clojurebot | "Returns the product of nums. (*) returns 1. Supports arbitrary precision.\n See also: *" |
| 12:45 | gfredericks | justin_smith and I alternate between providing useful information about obscure clojure functions and making stupid repl jokes |
| 12:46 | justin_smith | as I see |
| 12:46 | clojurebot | It's greek to me. |
| 12:46 | gfredericks | ~greek |
| 12:46 | clojurebot | Pardon? |
| 12:46 | justin_smith | ~foo |
| 12:46 | clojurebot | foo is bar |
| 12:46 | gfredericks | clojurebot: greek is it to me |
| 12:46 | clojurebot | Roger. |
| 12:46 | justin_smith | ~greek |
| 12:46 | clojurebot | greek is it to me |
| 12:47 | justin_smith | transitive equality, nice |
| 12:47 | justin_smith | clojurebot: it is greek to me |
| 12:47 | clojurebot | You don't have to tell me twice. |
| 12:47 | justin_smith | ~it |
| 12:47 | clojurebot | it is a lie |
| 12:47 | justin_smith | :( |
| 12:47 | gfredericks | it is a lot of things |
| 12:47 | gfredericks | ~it |
| 12:47 | clojurebot | it is a lie |
| 12:48 | gfredericks | ~it |
| 12:48 | clojurebot | it is greek to me |
| 12:48 | gfredericks | or two things at least |
| 12:48 | justin_smith | ~it |
| 12:48 | clojurebot | it is for clojure.pprint/cl-format :) |
| 12:48 | [1]brian | i'm doing clojure koans |
| 12:48 | [1]brian | http://pastebin.com/37tD7QD9 |
| 12:49 | [1]brian | can someone tell me why looping backwards instead of forwards is preferable? |
| 12:49 | justin_smith | [1]brian: for one thing, many things stop at 0 |
| 12:50 | justin_smith | conventions speed comprehension |
| 12:50 | AimHere | The given solution probably should use 'zero?' for the zero comparison |
| 12:50 | [1]brian | well my version didn't work with bigger numbers |
| 12:50 | [1]brian | i'm wondering why looping forward would fail |
| 12:50 | AimHere | Neither version will |
| 12:50 | daGrevis | is this the correct way to solve the koan? seems unusally too hard http://stackoverflow.com/a/8395229/458610 |
| 12:51 | justin_smith | [1]brian: replacing * with *' will fix that issue |
| 12:51 | AimHere | Use *' and +' instead of * and + to promote large integers to bigints when necessary |
| 12:51 | daGrevis | [1]brian, hi, im doing koans as well ;) |
| 12:51 | [1]brian | daGrevis: :) |
| 12:51 | daGrevis | haha, im almost there |
| 12:51 | daGrevis | how did u solve last one? |
| 12:51 | daGrevis | recursive-reverse |
| 12:51 | AimHere | Because I'm a paranoid sort, I'd use <= or >= instead of '=' so the function will at least terminate when fed a non-integer |
| 12:53 | [1]brian | *' and +' duly noted |
| 12:53 | [1]brian | but the solution doesn't use *' and +' and passes for larger N than mine can, simply because it loops backwards? |
| 12:53 | [1]brian | or am i missing something? |
| 12:54 | daGrevis | [1]brian, u r missing on answer to me :D |
| 12:54 | daGrevis | <daGrevis> how did u solve last one? |
| 12:54 | daGrevis | <daGrevis> recursive-reverse |
| 12:54 | [1]brian | daGrevis: i conjoined the first of coll to the reverse of the rest of coll, making sure the base case returns a vector |
| 12:54 | [1]brian | slow to type |
| 12:54 | [1]brian | :( |
| 12:55 | daGrevis | thanks! :) |
| 12:55 | AimHere | [1]brian, they both ArithmeticException at the same time for me |
| 12:55 | daGrevis | [1]brian, like this? http://stackoverflow.com/a/16345932/458610 |
| 12:55 | [1]brian | daGrevis: yep |
| 12:56 | gfredericks | I like clojure's impl of reverse |
| 12:56 | gfredericks | (reduce conj () coll) |
| 12:58 | gfredericks | ,((reduce conj () coll) [:a :b :c 42 :d]) |
| 12:58 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: coll in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 12:58 | gfredericks | ,(#(reduce conj () %) [:a :b :c 42 :d]) |
| 12:58 | clojurebot | (:d 42 :c :b :a) |
| 13:09 | [1]brian | how does destructuring a map with :keys work exactly? |
| 13:10 | [1]brian | does it just take the variable name, turn it into a keyword and take the value in the map? |
| 13:11 | justin_smith | [1]brian: pretty much, but remember it is not a variable, it is a symbol |
| 13:11 | justin_smith | a var is a specific thing, often when we use a symbol it is not pointing at a var |
| 13:11 | justin_smith | a symbol even works as an implicit map lookup |
| 13:12 | justin_smith | ,('a '{a 0 b 1}) |
| 13:12 | clojurebot | 0 |
| 13:12 | justin_smith | no vars to be seen |
| 13:12 | justin_smith | in a let binding a symbol points to the innermost visible binding, rather than a var |
| 13:13 | justin_smith | ,(let [foo "hello"] foo) |
| 13:13 | clojurebot | "hello" |
| 13:13 | [1]brian | does the compiler just see :keys and be like this is this 2nd way of destructuring map |
| 13:13 | [1]brian | ? |
| 13:13 | justin_smith | ,(let [foo "hello"] #'foo) |
| 13:13 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: foo in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 13:13 | justin_smith | as you can see it is not a var |
| 13:13 | justin_smith | [1]brian: yeah, you can also destructure a map more explicitly |
| 13:13 | [1]brian | what is #'foo |
| 13:14 | [1]brian | ,(let [foo "hello"] 'foo) |
| 13:14 | clojurebot | foo |
| 13:14 | justin_smith | ,(let [{a "hello" b "world"} {"hello" 0 "world" 42}] [a b]) |
| 13:14 | clojurebot | [0 42] |
| 13:14 | justin_smith | ,(type #'+) |
| 13:14 | clojurebot | clojure.lang.Var |
| 13:15 | justin_smith | #' references a var by the symbol that would point at it |
| 13:15 | justin_smith | just being pedantic about your usage of the word "variable" |
| 13:15 | [1]brian | i know |
| 13:15 | [1]brian | i'm trying to understand but I never fully grokked symbols in Scheme |
| 13:16 | justin_smith | so more to the point of your original question, :keys is just a shortcut, you can do a more flexible destructuring (as you see in my above destructuring example, I hope) |
| 13:16 | [1]brian | ,(#'+ 3 5) |
| 13:16 | clojurebot | 8 |
| 13:16 | justin_smith | another difference: |
| 13:16 | justin_smith | ,[(meta +) (meta #'+)] |
| 13:16 | clojurebot | [nil {:arglists ([] [x] [x y] [x y & more]), :ns #<Namespace clojure.core>, :name +, :column 1, :added "1.2", ...}] |
| 13:17 | justin_smith | the first is resolved (and thus metadata is no longer there) before meta is called |
| 13:17 | raiskailija | justin_smith, |
| 13:17 | justin_smith | the quoting ensures that we can see the metadata on the var for the second |
| 13:17 | [1]brian | i see |
| 13:17 | raiskailija | I am here to inform you of a great cause |
| 13:17 | raiskailija | His Shadow must be worshipped. |
| 13:17 | [1]brian | when would be a good time to use #'symbol vs symbol |
| 13:18 | justin_smith | [1]brian: for example when you have a handler for a server, and want to be able to redefine the function it uses at runtime |
| 13:18 | justin_smith | have the handler point to the var |
| 13:18 | justin_smith | so redefinitions will be resolved |
| 13:18 | justin_smith | a var is a mutable object, so you use a var when you want mutation to happen |
| 13:19 | justin_smith | or like above if you want to reference the metadata that is on a var but not in the value it points to |
| 13:20 | [1]brian | a <-- resolved var 'a <-- symbol #'a <--- yet unresolved var reference using a symbol |
| 13:20 | [1]brian | is that right? |
| 13:20 | justin_smith | yes |
| 13:20 | justin_smith | exactly |
| 13:21 | [1]brian | was there something else? |
| 13:21 | justin_smith | a symbol is looked up first as a closure binding (let / function arg), then as a var |
| 13:21 | justin_smith | oh wait, it can also be a java class - that goes somewhere in that list |
| 13:22 | justin_smith | the nested bindings thing should be very familiar, coming from scheme |
| 13:22 | Glenjamin | Hi guys, i'm having a strange problem with ring, ring-codec in particular. The param middleware is unable to find ring.util.codec/assoc-conj |
| 13:23 | [1]brian | i don't know what you mean by nested bindings, and i only used Scheme for 1 class |
| 13:23 | Glenjamin | i've tried clearing my m2 repository, and checked the clj source inside the ring codec jar - the function *is* defined in that namespace |
| 13:23 | justin_smith | Glenjamin: have you checked that the version of ring you are using has that function? try looking in the jar and seeing what is actually defined in there / the actual version |
| 13:23 | Glenjamin | can anyone suggest what i should try next? |
| 13:23 | justin_smith | oh, you already tried what I suggested |
| 13:24 | justin_smith | [1]brian: I just mean that ##(let [a 0] (let [a 1] a)) |
| 13:24 | lazybot | ⇒ 1 |
| 13:24 | justin_smith | the innermost value assigned to the symbol is used |
| 13:25 | [1]brian | so do vars exist only at the global scope? |
| 13:25 | justin_smith | you can create one in a let, but there is usually no reason for it |
| 13:26 | [1]brian | how would you do that |
| 13:26 | [1]brian | thanks for bearing with me, this symbol stuff is just different from the usual imperative languages |
| 13:27 | Glenjamin | here's some repl output: https://www.refheap.com/22250 |
| 13:27 | justin_smith | [1]brian: np, working on an example of using a var directly - doesn't come up often so I don't have it off the top of my head |
| 13:27 | Glenjamin | I can call the function by switching namespace, but not form outside |
| 13:27 | Glenjamin | but it's not private |
| 13:27 | justin_smith | Glenjamin: (meta #'assoc-conj) |
| 13:28 | Glenjamin | oh |
| 13:28 | justin_smith | the value does not have the metadata, the var does, as I was just explaing to [1]brian :) |
| 13:28 | Glenjamin | that rings a bell |
| 13:28 | Glenjamin | just coming back to a project after a few months and trying to upgrade all deps |
| 13:29 | Glenjamin | right, that's more like it |
| 13:29 | Glenjamin | but it's still not private or anything weird afaict https://www.refheap.com/22250 |
| 13:30 | Glenjamin | although, the :file key is odd |
| 13:32 | justin_smith | maybe it is defined in ring.util.data and ring.util.codec :use s it |
| 13:32 | justin_smith | another reason to hate use! |
| 13:32 | daGrevis | guys, I have a problem |
| 13:32 | daGrevis | I'm doing clojure-koans |
| 13:32 | daGrevis | and Im at recursion |
| 13:32 | daGrevis | writing function for factorial |
| 13:33 | daGrevis | writing a function that calculates factorial for 1 and 2, nothing else |
| 13:33 | Glenjamin | codec should be this: https://github.com/ring-clojure/ring-codec/blob/master/src/ring/util/codec.clj |
| 13:33 | [1]brian | so, both var and symbols can have values, but while a var is mutable, a symbol value is not, it can only be overshadowed by another scope, an unquoted symbol looks up either a symbol value or var value of the same name, a quoted symbol is a literal that can be used to only resolve var value by prefixing it with # or can be used as a key for maps |
| 13:33 | justin_smith | [1]brian: not quite |
| 13:33 | [1]brian | darn |
| 13:33 | justin_smith | a symbol is just a symbol, but in many contexts is implicitly resolved |
| 13:33 | daGrevis | i wrote a function and it passed all other koans that checked factorial where factorial is a really big number. |
| 13:33 | justin_smith | [1]brian: sometimes a symbol is resolved to a let binding, sometimes to a var |
| 13:34 | daGrevis | http://vpaste.net/FUrly |
| 13:34 | daGrevis | where's my stack overflow? |
| 13:34 | justin_smith | sometimes as a java class, sometimes it stands as a symbol, unresolved |
| 13:34 | [1]brian | ,(let [a 5] #'a) |
| 13:34 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: a in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 13:34 | Glenjamin | daGrevis: you're getting a stack overflow when running this? |
| 13:35 | justin_smith | maybe with a negative n you would get a heap overflow |
| 13:35 | daGrevis | Glenjamin, no. I expected one |
| 13:35 | justin_smith | daGrevis: recur does not use the stack |
| 13:35 | Glenjamin | daGrevis: ah, (loop..recur) is magiv |
| 13:35 | Glenjamin | magic even |
| 13:35 | daGrevis | because you know, if we follow koans, i should have written some shitty function that fails on big nums and then get enlighten |
| 13:35 | [1]brian | justin_smith: what is the term for a vs 'a |
| 13:36 | [1]brian | -is +are -term +terms |
| 13:36 | justin_smith | daGrevis: the new binding replaces the old one, the old one is immediately destroyed |
| 13:36 | daGrevis | Glenjamin, justin_smith: how would look that simple function? |
| 13:36 | justin_smith | so there is no buildup of context |
| 13:36 | Glenjamin | daGrevis: just call your function by name, no loop |
| 13:36 | Glenjamin | (defn fact [n] (* n (fact (dec n))) |
| 13:37 | [1]brian | ,(let [{'a a} {'a 'a}] #a) |
| 13:37 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 13:37 | justin_smith | [1]brian: symbol vs. quoted sybol |
| 13:37 | justin_smith | [1]brian: a let block creates no vars |
| 13:37 | justin_smith | so #' makes no sense in that context |
| 13:37 | daGrevis | ahh, okay |
| 13:37 | justin_smith | still working on the creating a var in a let block example (it is possible, just weird) |
| 13:38 | daGrevis | so I wrote better version at 1st |
| 13:38 | [1]brian | ,(let [{'a a} {'a 'a}] a) |
| 13:38 | clojurebot | #<Exception java.lang.Exception: Unsupported binding form: (quote a)> |
| 13:38 | daGrevis | [1]brian, did u solve all of recursion? |
| 13:38 | [1]brian | yes |
| 13:38 | daGrevis | kewl, me too ;) |
| 13:38 | jjttjj | am I the only one who has an impossible time writing unit tests the second I stop copying a screencast and writing my own code? And yet I get the feeling that extensive tests would have saved more than one of the little side projects I eventually abandoned |
| 13:39 | justin_smith | [1]brian: ##'a |
| 13:39 | lazybot | ⇒ a |
| 13:39 | justin_smith | err... |
| 13:39 | justin_smith | ##''a |
| 13:39 | lazybot | ⇒ (quote a) |
| 13:39 | justin_smith | that is what 'a expands to |
| 13:39 | justin_smith | you can't use that as the lhs of a binding |
| 13:39 | justin_smith | ,(type ''a) |
| 13:39 | clojurebot | clojure.lang.PersistentList |
| 13:39 | [1]brian | oh right |
| 13:40 | justin_smith | it is a list of two elements |
| 13:40 | Glenjamin | jjttjj: what are you using, and what are you used to? |
| 13:40 | [1]brian | ,(let [{a 'a} {'a 'a}] a) |
| 13:40 | clojurebot | a |
| 13:40 | Glenjamin | what is #' shorthand for? |
| 13:40 | justin_smith | var |
| 13:41 | [1]brian | ,(let [{a 'a} {'a 'a}] a) |
| 13:41 | clojurebot | a |
| 13:41 | [1]brian | why is that a vs 'a |
| 13:41 | justin_smith | levels of quotation |
| 13:41 | Glenjamin | aha, thanks |
| 13:41 | [1]brian | ,(let [{a 'a} {'a 'a}] (type a)) |
| 13:41 | clojurebot | clojure.lang.Symbol |
| 13:41 | [1]brian | ,(type 'a) |
| 13:41 | clojurebot | clojure.lang.Symbol |
| 13:42 | [1]brian | ,'a |
| 13:42 | clojurebot | a |
| 13:42 | [1]brian | ,''a |
| 13:42 | clojurebot | (quote a) |
| 13:42 | jjttjj | Glenjamin: as a testing framework or language? I'm actually more experienced with clojure than any other language and am very comfortable with it, I'm just more of a hobbiest type programmer and never properly learned testing. I've played arround with clojure.test and expectations and like the latter a little better, but really have almost no experience testing in general |
| 13:42 | justin_smith | Glenjamin: ##(macroexpand-1 '#'+) |
| 13:42 | lazybot | ⇒ (var +) |
| 13:42 | [1]brian | ,(type ''a) |
| 13:42 | clojurebot | clojure.lang.PersistentList |
| 13:43 | Glenjamin | jjttjj: ah, I see |
| 13:43 | [1]brian | ,(quote a b c) |
| 13:43 | clojurebot | a |
| 13:43 | [1]brian | ,(= ''a 'a) |
| 13:43 | clojurebot | false |
| 13:43 | Glenjamin | imo the trick with tests is writing them to test expected behaviour, not implementation |
| 13:44 | justin_smith | yeah, a functional mindset makes testing much more straightforward |
| 13:44 | Glenjamin | you think "i want to do X", so you write a test for X, and then implement something to pass |
| 13:44 | justin_smith | if the input values are right, the thing is a function and the output values are right, then there is nothing else left to worry about |
| 13:44 | jjttjj | Glenjamin: so you mean basically testing example usage of the functions, etc, as they would tend to appear in your program |
| 13:44 | Glenjamin | yes |
| 13:44 | [1]brian | justin_smith: i think i almost learned something then everything fell out of reach :( |
| 13:45 | Glenjamin | the trick is to use your functions before you write them |
| 13:45 | justin_smith | jjttjj: I think an important aspect of this is avoiding side effects (or limiting them to very specific places in your code) |
| 13:45 | jjttjj | Ok cool def a good start |
| 13:45 | Glenjamin | i often find it tricky to do this when starting an app |
| 13:46 | justin_smith | because of course if the "functions" have some kind of state tied to them, testing will be much harder |
| 13:46 | jjttjj | yeah that's where I'm at now |
| 13:46 | Glenjamin | but once you have a skeleton, try writing a test before implementing any helper function |
| 13:46 | justin_smith | but then again state makes everything harder |
| 13:46 | Glenjamin | or if you're extracting a helper function, write the tests before you do so |
| 13:47 | jjttjj | ok cool |
| 13:47 | jjttjj | trying to make a little twilio SMS bot |
| 13:48 | jjttjj | so I was just at a loss of where to really start test-wise, (= (process-incoming-messages) ?) |
| 13:48 | justin_smith | now I have a question (that comes up in trying to answer [1]brian's question) |
| 13:48 | Glenjamin | testing remote http calls can be tricky (but doable), i'd start with testing the helper functions |
| 13:48 | justin_smith | can I create a var in a local binding, or vars by definition only attached to namespaces? |
| 13:48 | Glenjamin | bah |
| 13:49 | Glenjamin | my function not found issue was due to not running lein clean |
| 13:49 | Glenjamin | managed to find it via lein classpath |
| 13:49 | [1]brian | ,'a |
| 13:49 | clojurebot | a |
| 13:49 | justin_smith | Glenjamin: man, that is my voodoo answer of choice, sorry I did not mention it earlier |
| 13:49 | Glenjamin | [1]brian: think of it like this: when clojure sees "a", it unpacks the var. when you put the quote in front, it leaves it alone |
| 13:50 | [1]brian | this from the docs helped me greatly "Yields the unevaluated form." |
| 13:50 | [1]brian | for (quote form) |
| 13:52 | [1]brian | ,(do (def a 1) #'a) |
| 13:52 | clojurebot | #'sandbox/a |
| 13:52 | [1]brian | ,(do (def a 1) ##'a) |
| 13:52 | clojurebot | #<RuntimeException java.lang.RuntimeException: Reader tag must be a symbol> |
| 13:52 | lazybot | ⇒ a |
| 13:52 | justin_smith | [1]brian: ##(with-local-vars [a 0 b 1] (dotimes [_ 10] (var-set a (+ @a @b)) (var-set b (+ @a @b))) (mapv (juxt identity deref) [a b])) |
| 13:52 | lazybot | java.lang.SecurityException: You tripped the alarm! class clojure.lang.Var is bad! |
| 13:52 | justin_smith | :( |
| 13:52 | justin_smith | ,(with-local-vars [a 0 b 1] (dotimes [_ 10] (var-set a (+ @a @b)) (var-set b (+ @a @b))) (mapv (juxt identity deref) [a b])) |
| 13:52 | clojurebot | [[#<Var: --unnamed--> 6765] [#<Var: --unnamed--> 10946]] |
| 13:52 | [1]brian | ## is just a way to run lazybot right? |
| 13:53 | justin_smith | so you can use vars locally, as a mutable type |
| 13:53 | justin_smith | right |
| 13:53 | justin_smith | and , runs clojurebot |
| 13:53 | [1]brian | how do i get a value from a var? |
| 13:53 | justin_smith | @, which is shorthand for #(deref %) |
| 13:53 | [1]brian | ,(do (def a 1) @#'a) |
| 13:53 | clojurebot | 1 |
| 13:54 | justin_smith | right |
| 13:54 | justin_smith | just like my above example, though the above was using local vars, and def creates a global one |
| 13:54 | justin_smith | but both have the same mutable semantics |
| 13:55 | [1]brian | ,(do (def a 1) @(var a)) |
| 13:55 | clojurebot | 1 |
| 13:55 | justin_smith | ,(do (def a 1) (deref (var a))) |
| 13:55 | clojurebot | 1 |
| 13:55 | justin_smith | @ is just a reader macro for deref |
| 13:55 | justin_smith | just as #' is a reader macro for var |
| 13:55 | [1]brian | is (var ___) just a special form such that the ___ doesn't get implictly dereferenced? |
| 13:56 | justin_smith | no |
| 13:56 | justin_smith | it is a function that asks for a var object |
| 13:56 | justin_smith | by that name, using a specific lookup strategy |
| 13:56 | [1]brian | why doesn't a dereference to 1 and it become (var 1) |
| 13:57 | justin_smith | sorry, it is a macro, not a function |
| 13:57 | [1]brian | i see |
| 13:57 | justin_smith | OOPS |
| 13:57 | justin_smith | not a macro, a special form |
| 13:57 | justin_smith | one of the select few |
| 13:58 | justin_smith | so funny enough, since it is a special form, var is not a var :) |
| 13:58 | justin_smith | whereas normal functions / macros are a var with some metadata attached to the value we use |
| 13:59 | [1]brian | i think i got most of it |
| 13:59 | [1]brian | ,(let [a 1] @'a) |
| 13:59 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.util.concurrent.Future> |
| 13:59 | [1]brian | how do you unquote a quoted symbol |
| 14:00 | justin_smith | let bindings are not vars |
| 14:00 | justin_smith | [1]brian: by evaluating it |
| 14:00 | justin_smith | the default action on a symbol is evaluation |
| 14:00 | [1]brian | ,(let [a 1] (do 'a)) |
| 14:00 | clojurebot | a |
| 14:00 | justin_smith | you can use resolve |
| 14:00 | [1]brian | ,(let [a 1] (resolve 'a)) |
| 14:00 | clojurebot | nil |
| 14:01 | justin_smith | ,((juxt resolve identity) '+) |
| 14:01 | clojurebot | [#'clojure.core/+ +] |
| 14:01 | justin_smith | resolve is for vars though |
| 14:02 | [1]brian | ,(let [a 1] (eval 'a)) |
| 14:02 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 14:02 | [1]brian | ,(do (def a 1) (eval 'a)) |
| 14:02 | clojurebot | 1 |
| 14:03 | justin_smith | the kinds of resolutions are more limited with let bindings |
| 14:03 | justin_smith | also do note that a var is a mutible container type, a let binding is not |
| 14:04 | justin_smith | so resolving is a weaker / more limited thing in the let binding case |
| 14:06 | [1]brian | ok enough rabbit hole fun |
| 14:06 | [1]brian | back to koans |
| 14:06 | [1]brian | thanks justin_smith :) |
| 14:07 | justin_smith | some folks on #emacs were joking about the clojure emacs in the browser project |
| 14:07 | justin_smith | calling it bromacs |
| 14:07 | justin_smith | dude, do you even lambda lift? |
| 14:07 | justin_smith | lol |
| 14:07 | [1]brian | link? |
| 14:08 | [1]brian | or is this clojure emacs in the browser project not a real thing? :( |
| 14:08 | justin_smith | it is one of many started but not yet usable attempts to re-implement emacs in $foo |
| 14:09 | justin_smith | https://github.com/hraberg/deuce |
| 14:09 | justin_smith | "Note: Almost NOTHING works yet. 0.1.0 developer preview ETA: when it's done." |
| 14:09 | justin_smith | it is so common as to be a running joke (see emacs in common lisp, emacs in haskell, emacs in ocaml, emacs in scheme...) |
| 14:10 | TimMc | Not to mention implementing a browser in emacs, of course. |
| 14:10 | [1]brian | emacs in emacs lisp |
| 14:11 | [1]brian | why can't emacs run emacs yet? this is a travesty |
| 14:11 | justin_smith | that one almost works, to be fair :) |
| 14:11 | justin_smith | try running emacs without any elisp code - you would not get much, if anything, usable I don't think |
| 14:13 | justin_smith | the vast majority of emacs is elisp, just running emacs without elisp code gets you something that is basically unusable |
| 14:19 | Glenjamin | i'm getting an NPE from a third-party lib i'm using - is therea == |
| 14:19 | justin_smith | (-> #'== meta :doc) |
| 14:19 | justin_smith | ,(-> #'== meta :doc) |
| 14:19 | clojurebot | "Returns non-nil if nums all have the equivalent\n value (type-independent), otherwise false" |
| 14:19 | justin_smith | only for numbers |
| 14:19 | Glenjamin | i'm getting an NPE from a third-party lib i'm using - is there a better approach to debug than moving it to a lein checkout and adding some statements into it? |
| 14:20 | justin_smith | Glenjamin: you can open it's jar and evaluate redefinitions in a repl |
| 14:20 | justin_smith | without needing to check anything out |
| 14:20 | Glenjamin | hrm, lets see if i can reproduce in a repl |
| 14:20 | justin_smith | this is of course much easier if you are using an editor with repl integration, but it can be done even in a naked repl |
| 14:21 | justin_smith | Glenjamin: if you are running a server, start an nrepl server in the same code that runs the server, and connect to that |
| 14:21 | justin_smith | it makes debugging so much nicer |
| 14:21 | Glenjamin | in the main server process? |
| 14:21 | justin_smith | yeah |
| 14:22 | justin_smith | then you can connect to that repl |
| 14:22 | Glenjamin | do i need to use drawbridge or something like that? |
| 14:22 | justin_smith | why would you? |
| 14:22 | justin_smith | just use tools.nrepl to start a server |
| 14:22 | Glenjamin | ah, right |
| 14:22 | Glenjamin | i see |
| 14:22 | justin_smith | if the server process is running on localhost at least |
| 14:23 | Glenjamin | mm |
| 14:23 | justin_smith | and even if the server is on a remote host, an ssh tunnel is easy enough to make |
| 14:24 | Glenjamin | ok, so i might as well have it always do this |
| 14:24 | justin_smith | Glenjamin: anyway, using clojure.tools.nrepl to open a repl port inside my server, then defining some atoms I can conj some interesting data onto, helps me solve things much faster than I would otherwise |
| 14:24 | Glenjamin | sounds like a good plan |
| 14:24 | Glenjamin | cheers |
| 14:24 | Glenjamin | bbiab |
| 14:25 | justin_smith | of course you can use environment config to not open a repl port in production, etc. |
| 14:25 | Glenjamin | was about to do that, but if its localhost only, i'm not too bothered |
| 14:28 | [1]brian | ,(do (def a 3) (dosync (ref-set #'a 4)) a) |
| 14:28 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to clojure.lang.Ref> |
| 14:28 | justin_smith | [1]brian: you have your mutable types mixed up |
| 14:29 | [1]brian | what is the difference between a ref and a var |
| 14:29 | [1]brian | ,(do (def a 3) (dosync (set! #'a 4)) a) |
| 14:29 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Invalid assignment target, compiling:(NO_SOURCE_PATH:0:0)> |
| 14:30 | justin_smith | ,(do (def a 3) (alter-var-root #'a (constantly 4)) a) |
| 14:30 | clojurebot | 4 |
| 14:30 | justin_smith | or |
| 14:30 | nDuff | [1]brian: vars aren't even intended to be used as reference types -- they do locking rather than the retry semantics used by atoms and refs. |
| 14:30 | justin_smith | ,(do (def a 3) (alter-var-root #'a inc) a) |
| 14:30 | clojurebot | 4 |
| 14:33 | nDuff | [1]brian: ...anyow, the big distinguishing thing between refs and atoms is that update of multiple refs can be done in a single transaction, whereas other reference types' updates are individually atomic but uncoordinated. (That's a little bit of a simplification, inasmuch as there's some transactional awareness for sends to agents, but not much of one). |
| 14:34 | nDuff | [1]brian: ...anyhow, in general, alter-var-root (which is the var equivalent to ref-set) is something you shouldn't be using absent a fairly specific reason. |
| 14:37 | deniska | http://pastebin.com/uqCQNNRr hello, is it correct ns syntax? |
| 14:37 | justin_smith | nDuff: yeah, absolutely, this is more being done to demonstrate what vars are as opposed to let bindings etc. - I hope that remains clear |
| 14:38 | justin_smith | deniska: no |
| 14:38 | justin_smith | deniska: I think you want an extra closing ] on the second line |
| 14:38 | justin_smith | and an opening [ at the beginning of the third |
| 14:39 | deniska | oh, thank you, it works |
| 14:39 | deniska | all my previous attempts on adding and removing brackets in different places resulted either in not working silently or not compiling at all |
| 14:44 | [1]brian | omg i'm finally to the macros koan |
| 14:46 | nDuff | deniska: ...by the way, you might consider using a pastebin with fewer ads. We're fans of refheap.com here (since it's written by one of our own), but gist.github.com is also an improvement on pastebin.com. |
| 14:47 | nDuff | deniska: ...pastebin.com is something of an eyesore to anyone not running adblock. |
| 14:47 | gfredericks | ~paste |
| 14:47 | clojurebot | paste is https://refheap.com/ |
| 14:47 | deniska | heh, as a fan of adblock I was not aware of it, sorry =) |
| 14:48 | nDuff | deniska: yup, that's probably my biggest beef with adblock -- allows sites that make customer-unfriendly decisions about advertising to thrive despite those decisions. |
| 15:21 | bitemyapp | arrdem: don't overtrain against historical data :) |
| 15:27 | jcromartie | the logging output from clj-http is driving me nuts |
| 15:28 | dakrone | jcromartie: which logging output? apache's? |
| 15:28 | jcromartie | the full Apache HTTPClient wire log is going to my log4j output |
| 15:28 | jcromartie | yeah |
| 15:28 | dakrone | jcromartie: you should definitely turn off DEBUG/TRACE for org.apache.http :D |
| 15:28 | jcromartie | any experience in turning that off? I know it's just because I set my own root logging level to DEBUG |
| 15:28 | dakrone | it is pretty insane |
| 15:28 | jcromartie | I don't understand log4j config :) |
| 15:28 | dakrone | jcromartie: log4j.logger.org.apache.http = INFO |
| 15:29 | dakrone | in your log4j.properties |
| 15:29 | gfredericks | (inc dakrone) ;; guy just swept in and fixed everything in 30 seconds |
| 15:29 | lazybot | ⇒ 1 |
| 15:29 | jcromartie | indeed |
| 15:29 | dakrone | :) |
| 15:29 | jcromartie | (doall (take 1000 (repeatedly #(inc dakrone)))) :) |
| 15:30 | jcromartie | nothing quite like complaining on IRC and getting the library's author within seconds ;) |
| 15:30 | dakrone | haha, I get notifications whenever someone mentions "clj-http" or "cheshire" :D |
| 15:31 | deniska | http://storage7.static.itmages.ru/i/13/1227/h_1388176119_3947209_3b72676298.png does this code look terribly bad? =) |
| 15:31 | gfredericks | I wonder if he'll fix arbitrary things as long as you preface it with a clj-http complaint |
| 15:31 | gfredericks | clj-http is a clojure library and americans don't research political candidates before they vote |
| 15:31 | dakrone | gfredericks: it guarentees I see it anyway ;) |
| 15:32 | mercwithamouth | o_O |
| 15:33 | dakrone | CHANGELOG for clj-http: clj-http now sends poll data when used for increasing research on voter uptake |
| 15:33 | gfredericks | phew |
| 15:34 | mocker | Dang, wanted to read up on speclj the site is down. |
| 15:35 | bitemyapp | mocker: speclj is a bad idea anyway |
| 15:42 | wink | meh, there was supposed to be a table of lisp hackers at 30c3, either I don't find it or they're gone :( |
| 15:43 | Leonidas | wink: hi :-) |
| 15:43 | wink | hehe \o/ |
| 15:43 | Leonidas | i remember there was a meeting in berlin, not all that impressiv |
| 15:44 | Leonidas | *impressive |
| 15:48 | corecode | wink: i'm here :) |
| 15:48 | corecode | not at a specific table |
| 15:50 | grzm | I have a vector of functions and a value. I want to apply each function to the value, returning the first non-nil result. |
| 15:50 | gfredericks | ,((apply some-fn [first rest]) [nil nil nil]) |
| 15:50 | clojurebot | (nil nil) |
| 15:51 | grzm | crikey |
| 15:51 | gfredericks | maybe a confusing example but I think that does what you want :) |
| 15:51 | gfredericks | ,((apply some-fn [first rest]) [false nil nil]) |
| 15:51 | clojurebot | (nil nil) |
| 15:51 | gfredericks | as long as you can tolerate falses being skipped too |
| 15:51 | grzm | no, I've been banging my fingers against the repl for trying some combination of some-fn, or, map, filter, first that would work |
| 15:51 | gfredericks | ,((apply some-fn [first rest]) [:truthy nil nil]) |
| 15:51 | clojurebot | :truthy |
| 15:51 | grzm | yup |
| 15:52 | grzm | thanks, gfredericks |
| 15:52 | gfredericks | np |
| 16:05 | mrhanky | (fn [& ds]) <- what does the & mean? optional argument? |
| 16:06 | gfredericks | varargs |
| 16:06 | gfredericks | can be called with any number of arguments |
| 16:06 | gfredericks | ds is bound to a list of the args |
| 16:06 | gfredericks | ,((fn [& ds] ["my args are" ds])) |
| 16:06 | clojurebot | ["my args are" nil] |
| 16:06 | gfredericks | ,((fn [& ds] ["my args are" ds]) 1 2 3) |
| 16:06 | clojurebot | ["my args are" (1 2 3)] |
| 16:08 | justin_smith | works nicely with destructuring |
| 16:08 | justin_smith | ,((fn [& [a b c & z]] [a b c z]) (range 10)) |
| 16:08 | clojurebot | [(0 1 2 3 4 ...) nil nil nil] |
| 16:08 | gfredericks | apply |
| 16:09 | justin_smith | oops |
| 16:10 | justin_smith | ,(apply (fn [& [a b c & z]] [a b c z]) (range 10)) |
| 16:10 | clojurebot | [0 1 2 (3 4 5 6 7 ...)] |
| 16:10 | justin_smith | much better |
| 16:10 | mrhanky | okay, thanks |
| 16:11 | grzm | gfredericks: ((apply some-fn [first rest]) [:truthy nil nil]) ends up evaluating the non-nil returning function twice, doesn't it? |
| 16:11 | gfredericks | no? |
| 16:11 | clojurebot | no is tufflax: there was a question somewhere in there, the answer |
| 16:11 | gfredericks | grzm: having a hard time figuring out why you would think that |
| 16:12 | grzm | gfredericks: 'cause I'm naive and learning? let me think some more |
| 16:12 | gfredericks | naive and learning is fine :) |
| 16:12 | gfredericks | just couldn't figure out how to help |
| 16:15 | logic_prog | hiredman: I have a complaint. In https://gist.github.com/hiredman/5167534 , on line 17, what is "storage" ? |
| 16:15 | [1]brian | ,(let [a 1] ~'a) |
| 16:15 | clojurebot | #<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/unquote> |
| 16:15 | amogh_ | Any clojure guys around who have worked with pdf generation using iText ? |
| 16:15 | mrhanky | logic_prog, maybe the js localStorage? |
| 16:16 | justin_smith | [1]brian: ~ is special, and used inside ` |
| 16:16 | logic_prog | mrhanky: it's not defined though. There is no (let [storage ...]) anywhere |
| 16:16 | amogh_ | hey anyone with itext experience ? |
| 16:16 | logic_prog | mrhanky: more importantly, how do I fix this? I'll figure out what is wrong later. |
| 16:16 | logic_prog | amogh_: I have used itext. It's not bad. |
| 16:16 | logic_prog | ApachePdfBox is also pretty good. |
| 16:16 | amogh_ | i am using |
| 16:16 | amogh_ | clj-pdf |
| 16:17 | amogh_ | which is a DSL over i text |
| 16:17 | amogh_ | itext* |
| 16:17 | amogh_ | I wanted to know.. how do we place some text on the right of an image |
| 16:17 | mercwithamouth | i can't seem to get ecstatic to work...or more so lein-bin. I've added lein-bin to my profile and I definitely saw it get pulled however it keeps saying 'bin' isn't a task |
| 16:17 | amogh_ | everything i give comes one below another |
| 16:18 | amogh_ | @logic_prog do u have any idea about such layout? |
| 16:18 | logic_prog | amogh_ : not off the top of my head |
| 16:18 | logic_prog | itext has nice documentation ... |
| 16:19 | justin_smith | did you ever think to yourself "in a conversation, why would you deref the person you are talking to?" |
| 16:19 | amogh_ | lemme check.. |
| 16:20 | amogh_ | I needed something like float:left in css... |
| 16:20 | logic_prog | justin_smith: you mean hashtag_irc_is_not_twitter ? |
| 16:21 | gfredericks | twitter people sure do mention lots of different IRC channels |
| 16:21 | justin_smith | well, reader-macros for popular topics make sense |
| 16:21 | gfredericks | most of them aren't worth visiting though |
| 16:21 | justin_smith | lol |
| 16:21 | logic_prog | #beiber_forever |
| 16:23 | logic_prog | this is a dumbass and off topic question, but perhspa someone here knows: (1) Given: I can read pdfs in chrome (i.e. visit blahblah.pdf). (2) Question: Is there a way to for me to read render a svg as a DOM node in Chrome? |
| 16:23 | logic_prog | it doesn't have to work in IE/Firefox; pure Chrome is fine. |
| 16:23 | justin_smith | read render? |
| 16:23 | logic_prog | ? |
| 16:23 | logic_prog | I want a webpage, where one my of my DOM nodes is showing a pdf |
| 16:24 | justin_smith | "is there a way to for me to read render" - I did not parse that |
| 16:24 | justin_smith | ahh |
| 16:24 | bitemyapp | logic_prog: how are you getting from PDF to svg? |
| 16:24 | deniska | I saw examples of manipulating SVG through JS |
| 16:24 | deniska | Not sure if it's DOM |
| 16:24 | bitemyapp | also yes you can render SVG but that's not the part that confuses me |
| 16:24 | justin_smith | you can use the dom to manipulate an svg yeah |
| 16:25 | justin_smith | animated svg etc. |
| 16:25 | logic_prog | bitemyapp: I don't have a svg yet. I just have a pdf right now. |
| 16:26 | logic_prog | Let me rewrite my question. (1) I Know that Chrome can render pdfs (I can view Pdfs inside of Chrome). (2) Question: is there a way in Chrome to render a pdf as a _dom node_ ? so I can have a webpage, with a bunch of CSS Menus, then one part of it which, bam, renders a pdf. |
| 16:27 | bitemyapp | logic_prog: this is no longer SVG and the answer is not without a plugin. |
| 16:28 | logic_prog | bitemyapp: noted, thanks for the clarification |
| 16:30 | logic_prog | wait |
| 16:30 | logic_prog | I can render the pdf in an iframe |
| 16:30 | logic_prog | and overlay a div over the iframe |
| 16:31 | Glenjamin | you can't guarantee the iframe will show it inline |
| 16:32 | Glenjamin | but if you use pdf.js you can get the PDF as a canvas element |
| 16:32 | Glenjamin | which is what firefox uses internally, but it should also work on a web page |
| 16:32 | Glenjamin | http://mozilla.github.io/pdf.js/ |
| 16:32 | grzm | gfredericks: What had me confused was reading the description of some-fn: http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/some-fn |
| 16:33 | logic_prog | Glenjamin: there's also http://pdfobject.com/ |
| 16:33 | gfredericks | grzm: some-fn is super weird once you start passing the returned function more than one arg |
| 16:33 | grzm | I read it as returning the *function* that returned the logical true value rather than retiring *a* function that returns the logical true value of the result of applying them |
| 16:34 | grzm | gfredericks: but super useful in this case :) |
| 16:34 | gfredericks | ah ha |
| 16:34 | gfredericks | grzm: well yeah because you're only passing one arg |
| 16:35 | grzm | gfredericks: i'll put a pin in that and work on it another day. thanks for helping me get around my issue |
| 16:35 | gfredericks | grzm: no problem |
| 16:37 | DerGuteMoritz | wink: look for the chicken scheme banner, we are in the first assembly hall right before the gate towards the large assembly hall |
| 17:00 | scottr | Has anyone spent much time playing with Om? I'm having some trouble figuring out how to structure my app to work with it. |
| 17:04 | bbloom | scottr: the conventions of how to structure such an app are still evolving. in fact, Om itself is just one stack at that idea dnolen put together |
| 17:04 | bbloom | s/stack/stab |
| 17:05 | bbloom | scottr: what issues are you running in to? |
| 17:05 | scottr | bbloom: I'm aware; he pretty clearly calls it pre-alpha in the readme, but I can't figure out how to get this one aspect working and it's sort of a dealbreaker. |
| 17:05 | bbloom | scottr: talk through it, i can probably help |
| 17:05 | scottr | bbloom: I can't get at data in the cursor unless in an om/update! call, and those are synchronous. |
| 17:06 | scottr | bbloom: this issue (https://github.com/swannodette/om/issues/14) describes getting data out of the cursor, but that seems... hacky and not the way it was envisioned. |
| 17:07 | scottr | bbloom: The root issue is that the update I need to perform is conditional on some data existing, but the data needs to be async fetched. |
| 17:07 | jtoy | are there any declaritive sql schema libraries that can auto update that actually work? |
| 17:07 | bbloom | scottr: hmm. i'd have to study what dnolen did here a bit. i'm not a big fan of the one-tree + metadata path-into-that-tree approach for a variety of reasons, but i was curious to see where he took it |
| 17:08 | jtoy | i looked through them and they dont seem to work, I will probably jsut end up using ruby for the schema management :( |
| 17:08 | jtoy | i would like to have it all in clojure if possible |
| 17:08 | scottr | bbloom: I spent the last hour looking through the cursor implementation to figure it out... and I cannot, for the life of me, understand their point. |
| 17:08 | scottr | Not the implementation, that's fairly trivial, but their purpose in the Om library as a whole. |
| 17:09 | bbloom | scottr: they were not reified as a data type last i looked, so give me a moment to study |
| 17:09 | scottr | bbloom: Happened yesterday, if the commit timestamp is to be trusted ;) |
| 17:10 | bbloom | dnolen: you there? |
| 17:12 | bbloom | scottr: hm, yeah dnolen seems to be running in to the problems that i was trying to warn him about :-) |
| 17:13 | bbloom | in short, having a single state tree is non tenable b/c you then need to have some sort of zipper that operates on that tree |
| 17:13 | bbloom | which is the cursor thing |
| 17:13 | bbloom | then those cursor things become both "modified" trees but also are values from the past |
| 17:14 | bbloom | if the cursor itself offers the ability to "dereference" it, then you have to bake in a pointer to the current root, or an indirection through a mutable root |
| 17:14 | scottr | bbloom: I... followed none of that. Why do you need a pointer to root? |
| 17:15 | bbloom | scottr: you'll see that MapCursor and VectorCursor both have value/state/path triples |
| 17:15 | bbloom | the value is the map or vector, the state is the root of the tree, and the path is the location of the current map or vector in the root tree |
| 17:16 | scottr | bbloom: AH. I wasn't really sure how value and state differed, but I needed so much state shared between my components that I just ended up passing the whole tree around... |
| 17:16 | bbloom | in effect, a cursor is a zipper. there are two types of zippers: 1) this kind, where you record the traversal path and 2) the huet kind where you invert pointers to be relative to the "current" spot |
| 17:17 | scottr | bbloom: Got it, I think. So (= value (get-in state path)), essentially, meaning `state` is always root? |
| 17:17 | bbloom | yeah, that's what it looks like |
| 17:17 | bbloom | the problem with the zipper approach is that you have multiple "components" and each component wants to think about the world concurrently. when you have concurrent zippers, you need to worry about isolation |
| 17:18 | scottr | bbloom: Because of updates? |
| 17:18 | bbloom | scottr: yup |
| 17:19 | bbloom | oleg talks about multiple zippers & isolation modes here: http://okmij.org/ftp/continuations/zipper.html#zipper-fs |
| 17:20 | bbloom | what dnolen has coded can be called a "Kiselyov Zipper" that is representing a zipper as a suspended walk: like a stack of call frames |
| 17:20 | bbloom | sorry, this rant is kinda more for observers than for you scottr :-P |
| 17:20 | scottr | bbloom: No problem. I'm not familiar enough with zippers to really understand it yet. |
| 17:22 | bbloom | scottr: in short, a zipper represents a tree viewed from a position other than the root |
| 17:23 | scottr | bbloom: Ah. That makes sense. |
| 17:23 | scottr | bbloom: I don't think this addresses the original problem though, unless I'm just not seeing it. |
| 17:23 | bbloom | scottr: like i said, there are two types: 1) huet zippers = interior node + pointers going out. 2) kiselyov zaippers = root + path |
| 17:24 | bbloom | scottr: it's a round about way of saying that i think the problem is a design flaw in om, one that i've been trying to find the words to explain to dnolen :-) |
| 17:26 | scottr | bbloom: Possibly. I'm trying to reconcile the very abstract "single tree cursor/zipper" description with the very concrete problem I have. |
| 17:26 | bbloom | scottr: anyway, avoid capturing cursors. they are temporary objects that should go away after a "frame" has been updated/rendered |
| 17:27 | scottr | bbloom: I don't know if that's necessarily the problem. I'm trying to inspect a cursor to find a specific value, then async fetch data if that data doesn't exist yet. I'd schedule an update to the current frame after the data returns. |
| 17:27 | bbloom | scottr: my recommendation: store data externally |
| 17:27 | bbloom | store only some token or ID in your tree, store that synchronously |
| 17:28 | scottr | bbloom: That's what I ended up doing for the top-level items. It just felt very awkward and I thought maybe I just didn't understand the library well enough. |
| 17:29 | bbloom | scottr: really, that's what you need to do & the library doesn't (yet) make that sort of thing easy for you |
| 17:30 | scottr | bbloom: Is it really necessary to store ALL of the data externally? A lot of the machinery of React itself presupposes having that data stored on the root component, much as is already done in Om. |
| 17:31 | bbloom | scottr: om is trying to make it easy to get to the data local to your "current" component, but generally that data should be small. ie just an id number or a setting or two |
| 17:32 | bbloom | scottr: all state MUST be external for react/om to work, but some state should *FEEL* local in order to be easy to reason about. which is what getState/setState provides in React |
| 17:32 | scottr | bbloom: I'm not sure I understand that. |
| 17:32 | scottr | bbloom: Shouldn't all of the data necessarily exist on the root component (assuming the whole page is React/Om controlled)? |
| 17:33 | bbloom | yeah, that's what i mean by external |
| 17:33 | bbloom | ie not within the view structure |
| 17:33 | bbloom | the view structure is an inert description of the view |
| 17:33 | bbloom | it doesn't have state, it's merely associated with state |
| 17:33 | scottr | Right. So if the root component updates its canonical data, and passes the whole thing to each component with the components' needed additional data (e.g. pointers into that tree), that would be sensible, yes? |
| 17:34 | bbloom | well what is a "pointer" in to that tree? is it a path? |
| 17:35 | bbloom | is it a composite object that is a path plus the tree root itself? |
| 17:35 | scottr | Or an ID. Anything to reasonably attempt to fetch data from the source. |
| 17:35 | bbloom | yeah, see that's the tricky part of this whole thing: you need a consistent way to obtain and dereference identifiers |
| 17:36 | bbloom | om is using "path in the view hierarchy" as a convenient identifier for many use cases |
| 17:36 | scottr | I think it's less of a problem for my particular use case, since the data is naturally tree-like anyway. |
| 17:36 | scottr | And shallow, and (relatively) unchanging. |
| 17:36 | bbloom | tree-like data is always nice to work with :-) |
| 17:37 | scottr | So, is that accurate, relative to how you've described "storing all data externally" (by which you meant on the root component)? |
| 17:38 | scottr | Components should get the data and some reasonable method to access the relevant data from the source itself? |
| 17:38 | scottr | And that was the purpose of cursors in the first place, to give components said "reasonable method to access the data"? |
| 17:38 | bbloom | scottr: on or next to the root component |
| 17:39 | bbloom | yeah, i don't like the cursor idea |
| 17:39 | scottr | "Next to" might make it tricky to coordinate re-rendering when the update itself doesn't cause the root component to see a change. |
| 17:39 | scottr | Though I suppose a watch on an atom, like Om does, is reasonable enough for that. |
| 17:39 | bbloom | oh sure, "on" the component from the react user perspective, but from the react internals perspective, that state is stored "next to" the root component :-) |
| 17:40 | scottr | Ah... totally unfamiliar with the internals yet. I haven't really poked around it much. |
| 17:40 | bbloom | the distinction is one of who holds the pointer |
| 17:40 | bbloom | the component itself does not contain a pointer to it's state |
| 17:40 | bbloom | the component only holds an ID which can be used to look up it's corresponding state |
| 17:40 | bbloom | s/it's/its |
| 17:41 | scottr | Ah, which is the `data-reactid` attribute on the DOM nodes? |
| 17:41 | bbloom | i believe so, yes |
| 17:41 | scottr | Interesting. I should go poke around a bit to get a better grasp of it. |
| 17:41 | bbloom | react "hydrates" components only when relevant |
| 17:42 | bbloom | the components' lifetimes are disjoint from the lifetimes of the objects which provide their behavior |
| 17:42 | scottr | That's interesting. It seems like you've looked into it a lot... |
| 17:43 | bbloom | I'm the guy who has been shouting at dnolen & a bunch of other folks in this channel to look at React since it came out. hell, i've been shouting about these ideas for much longer than that :-P |
| 17:44 | bbloom | however, since react is now available, i'm going to assume i can use it as a backend & am thinking about / working on something more ambitious one layer up :-) |
| 17:44 | bitemyapp | bbloom: do you teach people 1:1? |
| 17:44 | scottr | Hah. dnolen even mentions you by name in his benchmark post. |
| 17:44 | bitemyapp | bbloom: not in IRC, that is. |
| 17:45 | bbloom | bitemyapp: occasionally. why? |
| 17:45 | scottr | bbloom: Thanks for all your help. I'm not really sure how to reconcile the missing data still, but at least I feel better about maybe just accessing the data in the cursor and "just doing it". |
| 17:46 | bitemyapp | bbloom: any particular techniques, tools, you use? do you do it face-to-face or over the internet? what subjects typically? |
| 17:46 | bbloom | bitemyapp: pretty ad hoc |
| 17:52 | bbloom | bitemyapp: curious why you ask |
| 17:52 | devn | boot is starting to get pretty cool, you can now build tasks that rely on tasks, and they compose nicely, in boot.edn: :tasks {:run-development-env {:require [some.dep :as foo], :main [:do [foo/bar "argument"] [(fn [_] (println "hello world"))]]} |
| 17:55 | bitemyapp | bbloom: been teaching a lot of people lately, was looking to refine a few things. |
| 17:56 | bbloom | bitemyapp: selfishly, i mostly teach for my own edification & clarity, so my teaching methods may be tuned differently than you'd desire :-) |
| 17:56 | bitemyapp | bbloom: nah same here. |
| 17:56 | bitemyapp | bbloom: did you really expect anything selfless of me? >:) |
| 17:57 | bbloom | bitemyapp: when you switched from callen to the bitemyapp handle, it kinda rebooted most of the features my brain's personality classifiers depend on |
| 17:57 | bitemyapp | bbloom: working as intended. |
| 17:58 | bitemyapp | bbloom: Trying to set a better mold, but I'm not a martyr of my time. |
| 17:58 | bitemyapp | when I teach, it's as much for me as the student. |
| 17:58 | bitemyapp | students ask good questions :D |
| 17:58 | bbloom | btw, changing your handle screwing up my brain is similar to the identifier/state correspondence problem in UIs/OM discussed above :-P |
| 17:59 | justin_smith | today I finally figured out what the deal was with non-namespace vars, because of a question [1]brian asked |
| 17:59 | bbloom | human brains are bad at transferring attributes after rename, which you have capitalized on for the sake of your perception, but can hurt you if that's teh nature of the problem |
| 17:59 | justin_smith | and my struggle in answering it |
| 17:59 | bitemyapp | bbloom: rumor has it using values instead of references to mutable data helps clear up the identity/state problem :P |
| 17:59 | bbloom | greatly aids, but doesn't clear up completely :-P |
| 18:00 | bitemyapp | bbloom: especially if the values are really just broadcast proxies of something that is changing. |
| 18:00 | bitemyapp | then it's a mechanical advantage, but not as much of a design one. |
| 18:00 | bbloom | bitemyapp: computer science. it works bitches. |
| 18:00 | bitemyapp | bbloom: speaking of, my christmas haul was good this year. |
| 18:01 | bitemyapp | physical copy of the homotopy type theory book and machine learning for hackers. :D |
| 18:01 | bitemyapp | I might be getting the BCP Type Theory book as well, not sure yet. |
| 18:01 | bitemyapp | bbloom: you get any good books? |
| 18:01 | bbloom | bitemyapp: nah, my backlog of books is already crushing |
| 18:02 | bitemyapp | I have a decent backlog, but I'm not feeling any crushing sensations. |
| 18:02 | bitemyapp | http://liamoc.net/posts/2013-11-13-imperativereasoning.html |
| 18:07 | logic_prog | anyone here know how to use pdfjs with clojurescript ? |
| 18:08 | bitemyapp | logic_prog: probably have to write your own exports or something. |
| 18:08 | bitemyapp | logic_prog: or turn off optimization. |
| 18:09 | bitemyapp | logic_prog: when you're integrating arbitrary JS libraries into a CLJS app you have to "Closure-ize" the packages that aren't made for it to begin with. |
| 18:09 | bitemyapp | I highly recommend releasing the closure-ized versions for your fellow hackers. |
| 18:09 | logic_prog | I thought I just import and call them |
| 18:09 | logic_prog | like (. js/console log) |
| 18:09 | logic_prog | (. foreign-javascript-library shit) |
| 18:10 | bitemyapp | well if you turn off optimizations that might work. |
| 18:10 | bitemyapp | but I'm pretty sure the imports/require system is all based on Google Closure |
| 18:10 | bitemyapp | so if you don't have an exports file describing what to export from the package, then it probably doesn't know how to find it. |
| 18:10 | nDuff | logic_prog: the thing is that the Closure Compiler does name-mangling |
| 18:10 | bitemyapp | logic_prog: you should know that I'm working off memory here and I don't even use CLJS that much, and when I do, it's pure lein-cljsbuild and clojars. |
| 18:10 | logic_prog | oh right, becuase with optimizations, (. foreign-javascript-library shit) gets minimized to (. a23 a24) |
| 18:11 | bitemyapp | which is why I keep telling you to try shutting them off completely. |
| 18:11 | logic_prog | so I need to tell cljs "don't rename foreign-javascript-libarry/shit" |
| 18:11 | bitemyapp | but if optimizations none doesn't work, you'll need to make an exports file. |
| 18:11 | bitemyapp | it's not cljs...it's Google Closure... |
| 18:11 | seangrove | logic_prog: Yeah, just include the pdf.js as a foreign-lib or extern. |
| 18:11 | bitemyapp | logic_prog: cljs is built on top of the Google Closure compilation toolchain. |
| 18:11 | seangrove | The javascript file itself can double as its own extern file |
| 18:12 | [1]brian | logic_prog: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html |
| 18:12 | bitemyapp | seangrove: handy. Didn't know how to do that because I've only used clojars libraries. |
| 18:12 | logic_prog | nDuff , bitemyapp , seangrove , [1]brian : noted, this is enough, I will return to hacking |
| 18:12 | bitemyapp | logic_prog: are you sure? I'd like to waterboard you some more. |
| 18:12 | logic_prog | bitemyapp : stop making my stupid irc client beep |
| 18:13 | bitemyapp | sorry :( |
| 18:13 | logic_prog | :-) |
| 18:13 | bitemyapp | seangrove: how've you been? |
| 18:13 | seangrove | bitemyapp: Alive and kickin' |
| 18:14 | seangrove | Been rethinking vacation policy a bit |
| 18:14 | seangrove | Might make the last ~2 weeks and first few days of the new year mandatory time-off. |
| 18:15 | Bronsa | With only 8 lines of clojure we can use datomic's datalog to query valid tools.analyzer ASTs: https://github.com/Bronsa/tools.analyzer.jvm.index/blob/no-database/src/clojure/tools/analyzer/jvm/query.clj#L7-L14 |
| 18:16 | bitemyapp | seangrove: mandatory time off is a good idea. We've got one of those unlimited vacation policies at my company but it only works because the founders and executives take time off - thereby setting the tone for everybody else. |
| 18:16 | bitemyapp | seangrove: been doing a bunch of 1:1 tutoring lately and scoping out the lay of the land for finishing a release of Simonides. Talked to the founder of Heap recently. |
| 18:16 | seangrove | bitemyapp: Yeah, that's what I was thinking |
| 18:17 | seangrove | And it's valuable just to take time off and recharge for everyone |
| 18:17 | seangrove | How'd the talk go? |
| 18:19 | bitemyapp | seangrove: oh right the talk about Brambling. Fine I think. It's a good library to use as an excuse for explaining how Datomic works, limitations and all. |
| 18:20 | bitemyapp | I finished the night with my talk, spent most of it explaining why you even need Brambling because of how Datomic works. |
| 18:20 | seangrove | bitemyapp: Yeah, seems like a good way of approaching the subject |
| 18:20 | bitemyapp | seangrove: Heap founder seemed really nice btw. He represents his YC batch very well. |
| 18:21 | seangrove | Ah, great. Most of them are pretty helpful (if not nice), one of the things I like a lot |
| 18:21 | seangrove | bitemyapp: And is Simonides making progress? |
| 18:22 | bitemyapp | seangrove: definitely nowhere near shippable but I'm going to get traction soon. I expect to have something working by the time I return to work. |
| 18:22 | bitemyapp | seangrove: Matin was impressed we slapped Simonides together in a weekend :) |
| 18:23 | bitemyapp | I have books that should provide nice experiment ideas for Simonides and Keensweep. |
| 18:23 | bitemyapp | seangrove: where's a good place to get sencha in the city? |
| 18:23 | bitemyapp | I have an excellent supply of chinese teas but my sencha is wanting. |
| 18:24 | edw | ,(+ 41 1) |
| 18:24 | clojurebot | 42 |
| 18:24 | edw | bitemyapp: What city? |
| 18:24 | seangrove | I don't know, I always pick up mine annually when I visit Japan |
| 18:24 | bitemyapp | edw: San Francisco. |
| 18:24 | bitemyapp | seangrove: that is bloody cheating, hahahaha. |
| 18:24 | seangrove | bitemyapp: Sacha is going back on Sunday, I can ask him to send some from Osaka/Kyoto |
| 18:24 | edw | Ah. There is Japantown... |
| 18:25 | bitemyapp | edw: I know where to get a futon in JT, but not tea. I guess I could just close my eyes and see where I land on the dart board. |
| 18:25 | bitemyapp | I was hoping for a rec ;) |
| 18:26 | edw | bitemyapp: Meh. Opinions are like assholes. Spin the wheel! |
| 18:26 | justin_smith | ,(+ (*) (*) (* (+ (*) (*) (*) (*)) (+ (*) (*) (*) (*) (*)) (+ (*) (*)))) |
| 18:26 | clojurebot | 42 |
| 18:26 | seangrove | bitemyapp: Happy to have some sent here for you, probably take a week or so |
| 18:26 | seangrove | bitemyapp: In fact, consider it done |
| 18:26 | edw | justin_smith: Well played. |
| 18:27 | arrdem | justin_smith: ssssh we were trying to get hyPiRion to stop writing in that stuff. |
| 18:28 | gfredericks | ,(* (+ (*) (*)) (+ (*) (*) (*)) (+ (*) (*) (*) (*) (*) (*) (*))) ;; is my favorite |
| 18:28 | clojurebot | 42 |
| 18:28 | bitemyapp | seangrove: oh man, thank you! You'll have to give me Sacha's email so I can thank them as well. Also I'd like to get you dinner sometime, I'm on the wrong side of the balance sheet at the moment :) |
| 18:32 | justin_smith | ,(+ (#(* % % %) (+ (*) (*) (*))) (#(+ % % % % %) (+ (*) (*) (*)))) |
| 18:32 | clojurebot | 42 |
| 18:33 | bitemyapp | justin_smith: write a genetic algorithm for generating Swearjure that optimizes for brevity. |
| 18:33 | hyPiRion | ,(#(* % (+ % (*)) (+ % % % (*))) (+ (*) (*))) |
| 18:33 | clojurebot | 42 |
| 18:33 | justin_smith | heh |
| 18:33 | bitemyapp | justin_smith: or just clone hyPiRion. That too. |
| 18:34 | hyPiRion | I'm actually trying to implement that genetic algorithm you're speaking of. Not enough time for it yet though |
| 18:34 | hyPiRion2 | guys I figured out how to turn parentheses sideways |
| 18:34 | hyPiRion2 | somehow this lets me generate arbitrary keywords in swearjure |
| 18:34 | hyPiRion | oh dang |
| 18:34 | hyPiRion | I've ignored nickname changes, so I actually have no idea who that is. |
| 18:34 | bitemyapp | hyPiRion: I'll never tell! |
| 18:35 | wink | DerGuteMoritz: oh wow thanks :) |
| 18:35 | hyPiRion | bitemyapp: A secret kept by fellow IRCers |
| 18:37 | arrdem | (inc gfredericks) |
| 18:37 | lazybot | ⇒ 34 |
| 18:38 | justin_smith | sometimes a rename doesn't hide much, when people have distinctive favorite topics, conversation habits, or personalities |
| 18:38 | bitemyapp | case in point, me. |
| 18:38 | justin_smith | exactly |
| 18:39 | bitemyapp | always a little worried when something imports the IEEE-754 library. |
| 18:39 | arrdem | good. you should be. |
| 18:40 | bitemyapp | arrdem: written by bos though. Almost certainly fine. |
| 18:44 | danneu | How can I see a list of lein templates? |
| 18:44 | arrdem | bitemyapp: it's all fun and games until someone returns a -NaN with some top bits set |
| 18:46 | bitemyapp | hastache is spooky good. |
| 19:10 | logic_prog | is webworkers basically threads for javascript? |
| 19:11 | em-dash | working in cljs, where should I put protocol extensions to native types? eg., in what file, how to ensure the protocol extension is available everywhere? I'm trying to use this: http://keminglabs.com/blog/angular-cljs-weather-app/ |
| 19:12 | nmws | i have a question about modeling data which can change underneath you. For instance, how would we model a thermostat that reports the current temperature? |
| 19:13 | nmws | My current thinking is to have a map where the key is :temperature and the value is a function that returns the latest temperature |
| 19:13 | em-dash | right now I have the extend-type call in a util.cljs file that I'm :requiring in via the ns macro wherein I want to have access to the protocol extension |
| 19:15 | arrdem | nmws: just use an OOP style getter. So you have some map or other datastructure that defines _which_ thermometer you are interested in. An instance if you will. Then you have (poll :: Thermometer -> Float) or whatever. |
| 19:15 | arrdem | nmws: https://github.com/fredericksgary/qubits is hardly a typical library but uses that accessor pattern. |
| 19:18 | nmws | arrdem: hmm so then the poll function isn't really a pure function in this case, correct? |
| 19:18 | arrdem | nmws: right. it really can't be if it's dependant on an external data source. |
| 19:18 | nmws | arrdem: but the value returned by the poll function is immutable, since it is one snapshot of a continuously changing value? |
| 19:18 | arrdem | nmws: also correct. |
| 19:19 | Glenjamin | oo, there was a lib that might be handy for stuff like that i saw today |
| 19:19 | nmws | arrdem hmm thanks.. will chew on this |
| 19:19 | Glenjamin | the example from https://github.com/weavejester/reagi almost exactly describes that |
| 19:20 | nmws | glenjamin was that link for me? |
| 19:20 | Glenjamin | yes |
| 19:21 | nmws | glenjamin ok will take a look. |
| 19:22 | nmws | (my larger project is to actually develop a clojure api for the lego mindstorms ev3 robot) |
| 19:22 | arrdem | nice! |
| 19:23 | arrdem | herm... so I've built an assembler assembler... now how to test it without including a simulator for the target processor... |
| 19:24 | bitemyapp | arrdem: want to do it the hardware way? |
| 19:24 | bitemyapp | or double validation way? |
| 19:25 | bitemyapp | arrdem: you build a second assembler assembler - write a fuzzer-generator for the assembler...then crash whenever the two implementations disagree. |
| 19:25 | bitemyapp | arrdem: then you're doing it aerospace style! |
| 19:25 | bitemyapp | I'm quite serious :( |
| 19:25 | arrdem | I know you are |
| 19:25 | arrdem | and it's a reasonable approach |
| 19:25 | bitemyapp | arrdem: you could also just add manual "known correct" test-cases. |
| 19:26 | arrdem | yeah I think I'm gonna start with checking against some hand-assembled cases. |
| 19:26 | Glenjamin | arrdem: are you concerned with correct program result, or correct assembler? |
| 19:27 | arrdem | Glenjamin: eventually both. |
| 19:27 | bitemyapp | Glenjamin: oh you have a way of auto-validating program output without executing? |
| 19:27 | bitemyapp | I'd like to see this >:) |
| 19:27 | Glenjamin | presumably for anything non-trivial the latter is harder to distinguish |
| 19:27 | Glenjamin | i was going to say a simuator is probably a reasonable approach |
| 19:27 | Glenjamin | if you want it to generate a program than runs and produces the output, rather than generating the program you expect it to generate |
| 19:28 | Glenjamin | which implies you could have done it by hand |
| 19:28 | bitemyapp | arrdem: yeah actually, why is a simulator out of the question? |
| 19:28 | bitemyapp | arrdem: also I strongly encourage the use of fuzzers for program validation. |
| 19:28 | bitemyapp | they hammer out SO MANY bugs. |
| 19:28 | arrdem | $google github arrdem batbridge |
| 19:28 | lazybot | [arrdem/batbridge · GitHub] https://github.com/arrdem/batbridge |
| 19:29 | arrdem | bitemyapp: a bytecode simulator already exists. I'm just pondering if there's a better way. |
| 19:29 | Glenjamin | are your tests for validation, or a feedback mechanism? |
| 19:29 | Glenjamin | program validation is less useful for the latter |
| 19:29 | Glenjamin | imo, anyway |
| 19:32 | arrdem | mmkay. I'll probably do the dual input fuzzing once I've validated the processors against each-other. |
| 19:33 | arrdem | thanks for the feedback guys. |
| 19:33 | bitemyapp | arrdem: http://i.imgur.com/M56m4yl.gif |
| 19:34 | arrdem | bitemyapp: oh god why |
| 19:35 | nmws | bitemyapp: some of us aren't that far away from asking these kinds of questions in clojure. :( Spent many years writing Java, and I feel like I'm learning programming all over again.. |
| 19:35 | bitemyapp | arrdem: if you want more "oh god why" https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCsQFjAA&url=http%3A%2F%2Fivanych.net%2Fdoc%2FPessimalAlgorithmsAndSimplexityAnalysis.pdf&ei=UBy-UqaVAsXzoATHr4Ag&usg=AFQjCNFvMsu2RyJJeI-ous2xrHdwkifwog&sig2=LCil287uk5mofzgxJYobXw |
| 19:35 | bitemyapp | nmws: it's ,(+ 1 2) |
| 19:35 | arrdem | bitemyapp: I've got all the oh god why I need right here http://codegolf.stackexchange.com/questions/16226/trolling-homework-questions-sorting |
| 19:35 | bitemyapp | ,(+ 1 2) |
| 19:35 | clojurebot | 3 |
| 19:36 | nmws | bitemyapp: heh not quite that bad, but close.. :) |
| 19:36 | metellus | nmws: the question is the least objectionable thing on that page |
| 19:37 | nmws | metellus: good point. I've stopped being shy about asking basic questions.. |
| 19:38 | bitemyapp | nmws: I don't bite...much. Ask questions! |
| 19:38 | arrdem | bitemyapp: that paper is glorious. |
| 19:38 | bitemyapp | There was a study once where they found, neurologically speaking, the anticipation and fear of pain was more painful than pain itself. |
| 19:38 | bitemyapp | nmws: ^^ meditate on that ;) |
| 19:39 | nmws | bitemyapp :) |
| 19:39 | Glenjamin | i feel like i'm missing something obvious, if i've got an environ map, what's a neat way to either get nil, or cast the field to an int if present? |
| 19:40 | Glenjamin | oh wow, (int) does not do what i expected anyway |
| 19:40 | Glenjamin | i guess i need Integer/valueOf |
| 19:40 | Glenjamin | and a wrapper |
| 19:40 | bitemyapp | Glenjamin: I write value-type wrappers for my environ stuff. |
| 19:41 | arrdem | Glenjamin: yeah #(when %1 (Integer/valueOf %1)) |
| 19:41 | bitemyapp | benv, ienv, kenv, etc. |
| 19:41 | Glenjamin | i've got it all wrapped up in a config namespace |
| 19:41 | bitemyapp | zats what I do. |
| 19:42 | hyPiRion | maan |
| 19:42 | hyPiRion | ,(map #(some-> % Integer/valueOf) ["1" nil "3"]) |
| 19:42 | clojurebot | (1 nil 3) |
| 19:43 | Glenjamin | oo, neat |
| 19:44 | Glenjamin | gah |
| 19:45 | Glenjamin | is there a reason other than no-one has done it yet that (ns) errors are so cryptic? |
| 19:52 | technomancy | Glenjamin: two reasons: it's very difficult to get contributions accepted into clojure, and the core team doesn't place a high priority on usability |
| 19:52 | Glenjamin | both those reasons make me sad :( |
| 19:53 | Glenjamin | by difficult, do you mean the CLA, or the review process? |
| 19:55 | Glenjamin | hrm, which bit of the stack causes "lein repl" to write out the .nrepl-port file? |
| 19:55 | logic_prog | where can I read about how "lein cljsbuild auto" works with _multiple profiles_ -- for example, I have a dev profile with 'sourcemaps + no optimiations' and I have a release profile with "no source maps; advanced optimizations"; then, I weant "lein cljsbuild auto" to only auto rebuild the dev profile, and not touch the stable profile |
| 19:56 | Glenjamin | ah, it's leiningen since 2.3.2 - found it in the changelog |
| 20:01 | technomancy | Glenjamin: the CLA is annoying, but it's symptomatic of deeper issues |
| 20:02 | bbloom | technomancy: i sense some seriously negative connotation to your statements :-P |
| 20:08 | arrdem | bbloom: tiny bit |
| 20:34 | BAMbanda | if I fire "lein repl" it brings up a clojure repl, Im just curious, is it detecting the clojure install on my machine? |
| 20:34 | BAMbanda | i am not executing it with java |
| 20:40 | arrdem | BAMbanda: no. Lein packages the Clojure repl and runtime. You are running Lein's clojure from inside the Lein JVM instance. |
| 20:48 | mullr | In clojurescript, is there a preferred way to extend a protocol over both PersistentHashMap and PersistentArrayMap? |
| 20:49 | arrdem | does it need to be a protocol? seems like you could probably just have a type-agnostic function... |
| 20:49 | mullr | arrdem: well, the function is polymorphic |
| 20:50 | mullr | arrdem: it does different things for maps and vectors |
| 20:51 | mullr | https://gist.github.com/mullr/8155158 |
| 20:51 | gdev | arrdem, when do you start working on CinC? |
| 20:52 | arrdem | gdev: whenever I get motivated :/ |
| 20:52 | arrdem | gdev: that and I have another book or to on the JVM to track down and read |
| 20:53 | arrdem | gdev: what's up, got a special request or something? |
| 20:53 | gdev | arrdem, I have 125 bucks in amazon gift cards if there are any books you're missing =) |
| 20:55 | arrdem | gdev: thanks :P all I really need to do is track down a copy of "Inside the Java Virtual Machine, 2nd ed." and then stop letting bitemyapp and dogecoin distract me. |
| 20:57 | BAMbanda | im sorry, i asked this question before and I haven't had the time to configure it so I forgot, what is your recommended setup for emacs? |
| 20:57 | BAMbanda | slime? |
| 20:57 | arrdem | BAMbanda: slime is to be avoided at this point. |
| 20:57 | BAMbanda | ok, so cider and nrepl? |
| 20:57 | arrdem | BAMbanda: nrepl.el is the "old" emacs repl support, but stable and working |
| 20:57 | arrdem | BAMbanda: Cider is new, somewhat unstable nrepl support |
| 20:57 | BAMbanda | hmm, what do you personally use? |
| 20:57 | BAMbanda | arrdem |
| 20:57 | arrdem | cider |
| 20:57 | BAMbanda | ok |
| 21:00 | mullr | related question: is there a uniform way to map over both the [key value] tuples for each? For the vector, the key would be its index. |
| 21:01 | arrdem | (seq {:foo :bar :baz :bung} |
| 21:01 | mullr | (to map over both hashes and vectors) |
| 21:01 | arrdem | mullr: ... hashes too? you're gonna have to bring for into this. |
| 21:02 | mullr | arrdem: I can do (for [[key val] x] ....) when x is a map |
| 21:02 | gdev | BAMbanda, I just use the emacs live setup |
| 21:02 | mullr | arrdem: but if x is a vector, of course that doesn't work. Conceptually though, a vector is also associative with and index key and a value |
| 21:02 | gdev | clone the github repo as your emacs.d folder and you have everything you need to start whacking away |
| 21:03 | arrdem | mullr: barely, but I see what you're saying. I don't think of a nice way to achieve that withought implementing a wrapper function to manually handling seq-ing the parameter seqable. |
| 21:03 | BAMbanda | gdev, i just pasted in the script from the emacs-live page, it looks so promising, i installed it, but now what? |
| 21:03 | BAMbanda | "emacs-live" doesn't seem to be recognized as a command on my terminal |
| 21:04 | mullr | hmmmmm |
| 21:04 | gdev | BAMbanda, C-c A-j |
| 21:04 | arrdem | BAMbanda: just boot emacs |
| 21:04 | gdev | BAMbanda, in your project folder type emacs project.clj |
| 21:04 | BAMbanda | oh my |
| 21:04 | gdev | to get to other files C-f |
| 21:04 | BAMbanda | oh my, this is incredible |
| 21:05 | arrdem | HE HAS SEEN THE LIGHT. REJOICE BROTHERS. |
| 21:05 | BAMbanda | :) |
| 21:05 | BAMbanda | i think im in a dream |
| 21:05 | gdev | I'll burn the white smoke in the vatican so RMS will know there is a new member in the church of emacs |
| 21:05 | nonuby | is there any behaviour difference between (put! ch val) and (go (>! ch val)) when used in a response callback of say a http-kit request |
| 21:05 | Raynes | That seems quite unlikely |
| 21:06 | Raynes | :p |
| 21:06 | BAMbanda | gdev, how do i get the repl up in emacs |
| 21:06 | arrdem | BAMbanda: C-c M-j |
| 21:06 | gdev | ^ |
| 21:07 | BAMbanda | hmm, its undefined for me |
| 21:07 | gdev | gfredericks, are you watching the hawks game? |
| 21:07 | gdev | BAMbanda, A-x nrepl-jack-in |
| 21:07 | arrdem | BAMbanda: or M-x cider-jack-in |
| 21:07 | arrdem | gdev: what is this A- blaspehmy |
| 21:08 | gdev | Alt-x =p |
| 21:08 | BAMbanda | arrdem, cider-jack-in doesn't work but nrepl-jack-in works |
| 21:08 | arrdem | o. kay. |
| 21:08 | BAMbanda | damn, this is it |
| 21:08 | arrdem | BAMbanda: that's fine. just means that emacs-live still uses nrepl not cider. |
| 21:09 | arrdem | BAMbanda: this is a feature. do not touch until you feel brave enough to do so. |
| 21:09 | BAMbanda | arrdem, I will prostrate on the floor and thank God now |
| 21:09 | BAMbanda | this is nothing short of a gift |
| 21:09 | gdev | it's because sam hasn't updated the package |
| 21:09 | gdev | but when he does all you have to do is pull the changes from the hub |
| 21:10 | BAMbanda | alright |
| 21:12 | gdev | BAMbanda, you'll also want to know how to cancel an evaluation in case you accidentally evaluate (range) |
| 21:13 | BAMbanda | where do I type (range) into |
| 21:13 | BAMbanda | if the repl is busy evaluating |
| 21:13 | xeqi | nonuby: I'd use (put! ch val). (go ...) creates a new channel to return and the >! happens asynchronously |
| 21:14 | gdev | BAMbanda, no, I meant if you accidentally evaluate something like (range) which is an infinite sequence, you'll want to know how to cancel it |
| 21:14 | BAMbanda | gdev, ah how may that be |
| 21:14 | gdev | BAMbanda, https://github.com/clojure-emacs/cider study the keyboard shortcuts |
| 21:14 | arrdem | BAMbanda: C-c C-C |
| 21:14 | arrdem | BAMbanda: the usual EJECT EJECT EJECT EJECT keyboard mashing will work :D |
| 21:15 | BAMbanda | (range) automatically stops with 99 ... |
| 21:15 | BAMbanda | thats good security |
| 21:15 | arrdem | wat |
| 21:15 | arrdem | could not reproduce. |
| 21:15 | BAMbanda | (range) doesn't crash |
| 21:16 | BAMbanda | (range prints num from 1 - 99 and ends with ... |
| 21:16 | pjstadig | *print-length* in action |
| 21:16 | gdev | BAMbanda, probably because your print length is set |
| 21:16 | BAMbanda | gdev, ah, intellisence in emacs, this is superb |
| 21:17 | gdev | okay, if you accidentally evaluate (Thread/sleep Integer/MAX_INT) |
| 21:17 | mullr | ok, came up with something a bit nicer: https://gist.github.com/mullr/8155158 |
| 21:20 | gdev | arrdem, is it too early to show him nyan-mode? |
| 21:20 | arrdem | gdev: NEVAR. |
| 21:20 | arrdem | BAMbanda: M-x package-install RET nyan-mode RET M-x nyan-mode RET |
| 21:21 | BAMbanda | "Install package: nyan-mode (No matches) |
| 21:21 | BAMbanda | :( |
| 21:21 | BAMbanda | arrdem |
| 21:22 | arrdem | wat |
| 21:22 | arrdem | BAMbanda: do you have elpa/marmalade set up yet? |
| 21:22 | technomancy | make sure you've added marmalade to your archive sources, maybe run M-x package-refresh-contents |
| 21:23 | BAMbanda | i have elpa, let me take care of marmalde |
| 21:25 | gdev | mullr, what is that doing? |
| 21:27 | mullr | gdev: Just a depth-first search, giving back the path to each leaf of the tree. Given something like (all-paths {:a {:b [1 2]}}), gives back ((:a :b 0) (:a :b 1)) |
| 21:28 | BAMbanda | wow, cats and rainbows, thanks guys :) |
| 21:28 | BAMbanda | makes development a little more cheerful! |
| 21:28 | mullr | gdev: I'm trying to do two way synchronization between an atom in clojurescript and a https://www.firebase.com/ document |
| 21:28 | arrdem | BAMbanda: IS IT NOT GLORIOUS. |
| 21:29 | BAMbanda | arrdem, the internet age and cats. I would have never though |
| 21:29 | BAMbanda | thought* |
| 21:29 | arrdem | BAMbanda: yeah. it's silly but sometimes it's all that's needed to make a hard debugging session doable. |
| 21:29 | arrdem | I suppose I should build doge-mode... |
| 21:29 | BAMbanda | arrdem, yeah i got it. It reminds us to smile. very healthy indeed! |
| 21:31 | arrdem | anyone have a cute keyboard shortcut for M-x shell? |
| 21:32 | justin_smith | arrdem: now I am imagining doge themed stack traces |
| 21:32 | arrdem | justin_smith: first we need sane stack traces. then we can make them silly. |
| 21:32 | justin_smith | clojure.java.jdbc/with-connection* wow |
| 21:32 | justin_smith | much clojure.core/eval |
| 21:32 | gdev | arrdem, meta-! |
| 21:33 | arrdem | gdev: do like. very short. so stolen., |
| 21:33 | justin_smith | I think comic sans, primary colors, and a doge face are exactly what clojure stack traces need |
| 21:35 | gdev | or even better a text-to-speech service that will say your stack trace in speed reading lawyer voice |
| 21:35 | justin_smith | I wonder if the micro-machine guy is available |
| 21:35 | gdev | lol that's who I had in mine |
| 21:36 | gdev | s/mine/mind |
| 21:39 | arrdem | bitemyapp: lol made 14% so far in manual trading. wtf. |
| 21:50 | technomancy | arrdem: I use C-x m |
| 21:51 | technomancy | arrdem: but I have a secret plan to make an nrepl middleware that can render stack traces as terribly compressed jpegs with hell of artifacts |
| 21:52 | arrdem | technomancy: I have heard of this plan. I like that it will allow Clojure/nrepl to compete with drracket :P |
| 21:52 | jcromartie | I love it |
| 21:53 | gdev | technomancy, weren't you working on rich text format for nrepl output? |
| 21:54 | technomancy | rich media types, yeah |
| 21:54 | technomancy | necessarily |
| 21:55 | justin_smith | to fully embrace gigo, a stack trace could be replaced by a random image from a random /b/ thread |
| 21:56 | technomancy | at my last job there was a pool of gifs that would get posted to pull requests that resulted in build failures |
| 21:57 | gdev | and the price-is-right fail horn over the office PA system |
| 21:58 | arrdem | wasn't bitemyapp doing a gif a commit at some point? |
| 21:59 | gdev | I remember posted a picture of my pug on one of his pull requests and calling it a pug request |
| 21:59 | gdev | github lets you post images everywhere you can make comments, sometimes all you need is an image |
| 22:00 | TEttinger | technomancy, how bad do you want uour compressed jpegs? http://www.mspaintadventures.com/sweetbroandhellajeff/archive/011.jpg |
| 22:01 | technomancy | TEttinger: just point me in the direction of the java lib |
| 22:02 | TEttinger | haha |
| 22:02 | gdev | another good use of being able to post images on github comments, instead of ascii picard face palm, you can post the real thing https://github.com/mikejdoyle/Quiz/commit/e26496db754bd201ed7e2ecead8aeb760d10f195#diff-eb0cd5ad98766cffd6b8a54a7329f3d4 |
| 22:02 | justin_smith | technomancy: you can do it with java.awt.image.BufferedImage |
| 22:02 | justin_smith | + javax.imageio.plugins.jpeg.JPEGImageWriteParam for setting that compression as intense as it goes |
| 22:03 | jared314 | if you are going to use a meme, just use sad kitten or something |
| 22:04 | gdev | animated gif stack traces |
| 22:04 | TEttinger | jMeme for all meme-related image needs |
| 22:04 | technomancy | justin_smith: nice |
| 22:05 | ryanf | does anyone know of an open-source repo that is an example of building cljs to run on node with tests? |
| 22:06 | ryanf | it wasn't hard to get it building, but it's not clear to me how to simultaneously make a second build with tests in it |
| 22:06 | ryanf | (or whatever other approach would make sense) |
| 22:07 | jared314 | http://memegenerator.net/instance/44379725 |
| 22:09 | justin_smith | http://i.imgur.com/PXn2vPV.jpg |
| 22:09 | arrdem | yeah there'd better be an insanity wolf option :D |
| 22:16 | logic_prog_ | https://github.com/mozilla/pdf.js/blob/master/examples/helloworld/hello.js#L30-L33 <-- how do I write these lines in cljs? |
| 22:16 | bitemyapp | arrdem: lolwut |
| 22:17 | arrdem | bitemyapp: ?? |
| 22:17 | lazybot | arrdem: Definitely not. |
| 22:17 | arrdem | lazybot: did I ask for your oppinion? |
| 22:19 | bitemyapp | arrdem: 14% |
| 22:20 | arrdem | bitemyapp: yep. started playing with 12000 doge, now have 13686. 14% ROI. |
| 22:21 | arrdem | bitemyapp: mining's faster tho... |
| 22:46 | SirSkidmore | When using lein, I run lein new foo, enter that directory, run lein repl and then run (in-ns 'foo.core) when I try to run the placeholder function (foo 1) and it says it can't resolve the function |
| 22:47 | SirSkidmore | any ideas why? |
| 22:47 | amalloy | in-ns doesn't load anything |
| 22:47 | SirSkidmore | doesn't it switch the namespace? |
| 22:48 | justin_smith | sure, but it doesn't load the file |
| 22:48 | amalloy | sure, it switches you into a namespace, creating it if it doesn't exist |
| 22:48 | amalloy | but it doesn't compile anything or read any files |
| 22:48 | SirSkidmore | ohhh |
| 22:48 | SirSkidmore | how do I make lein load all of the project files when it starts? |
| 22:48 | justin_smith | SirSkidmore: make a namespace that requires all the others, and then require that from the repl |
| 22:48 | amalloy | you don't do that; you (require) them |
| 22:49 | SirSkidmore | oh |
| 22:49 | SirSkidmore | thank you :) |
| 22:55 | mullr | logic_prog: (.render page #js {:canvasContext context, :viewport viewport}) |
| 22:55 | mullr | err, logic_prog_: see above |
| 22:55 | logic_prog | mullr: I used js-obj |
| 22:55 | logic_prog | where is #js documented ? |
| 22:55 | logic_prog | this looks badass if it's a edn |
| 22:56 | mullr | I think it's rather new, I found it in an Om sample |
| 22:57 | mullr | logic_prog: https://groups.google.com/d/msg/clojurescript/mUVbtdnAvHA/LisdVWyAJKwJ |
| 23:02 | yedi | anyone have some resources for getting started with datomic pro starter with clojure? |
| 23:03 | yedi | the main site's tutorial is in java, and i've been googling around and haven't found anything to resourceful yet |
| 23:10 | bbloom | yedi: i can't imagine the interface is dramatically different as to be confusing for a clojure programmer |
| 23:19 | brainproxy | yedi_: have you looked at the "day of datomic" stuff? |
| 23:19 | yedi_ | yea im lookin at that stuff now, and workin through some of the examples |
| 23:19 | yedi_ | hopefully thatll be enough for me to get up to speed |
| 23:20 | logic_prog_ | yedi_: I also learned from day of datomic. |
| 23:20 | logic_prog_ | mullr: thanks! (re: google link for #js) |
| 23:49 | yedi_ | i guess in datomic, there's no schema type for edn? |
| 23:50 | yedi_ | i should just store the edn as a string and parse it everytime |