2016-01-13
| 00:16 | neoncontrails | I think the part I don't get is how this database connection object relates to the DOM. Is the db connected to the application? To the user? At what point in the user signup process would you invoke this function? |
| 00:17 | neoncontrails | I'm assuming you wouldn't call it directly from the DOM, but via some HTTP post transaction that contains the relevant data |
| 00:38 | neoncontrails | Phew, figured it out. Heroku's explanation is a lot easier to follow https://devcenter.heroku.com/articles/clojure-web-application |
| 01:05 | Raynes | Sup brodudes |
| 01:06 | Raynes | How's Clojureland |
| 02:29 | TEttinger | Raynes! |
| 02:29 | TEttinger | how's refheap? |
| 02:30 | Raynes | TEttinger! |
| 02:30 | TEttinger | paste still works it seems |
| 02:30 | Raynes | TEttinger as expected, my announcement induced sheer terror despite that honestly it's a shitty pastebin. |
| 02:31 | TEttinger | well, to be perfectly fair, yes. |
| 02:31 | TEttinger | I tried to paste a large text in there |
| 02:31 | Raynes | I removed the paste in question and worked with Namecheap support and citibank has yet to file lawsuits, so I think I'm okay. |
| 02:31 | TEttinger | it froze my browser |
| 02:31 | Raynes | But I think it's time to let it go. I don't have a legal time. |
| 02:31 | Raynes | Because ancient version of codemirror. |
| 02:31 | Raynes | Let's just use gist, guys. |
| 02:31 | Raynes | Seriously, I'm not offended. |
| 02:32 | ianhedoesit | wait, what about refheap? |
| 02:32 | Raynes | I'm gonna make the site read only or static. |
| 02:32 | TEttinger | I believe it was https://gist.githubusercontent.com/tommyettinger/9079f8f882db658f301f/raw/eb452cd90915c558cd9ece03ee30af829dda059e/layer-dungeon.txt |
| 02:32 | Raynes | I've got spamming issues and malicious pastes. |
| 02:32 | TEttinger | ok. can you maybe update lazybot? :) |
| 02:32 | TEttinger | so it doesn't paste to refheap? |
| 02:32 | ianhedoesit | Raynes: ah |
| 02:32 | Raynes | If you'd like to take this current sprint I'm in. |
| 02:33 | TEttinger | so it would need to use a Gist API of some sort? |
| 02:33 | Raynes | I wrote one lol |
| 02:33 | Raynes | tentacles |
| 02:33 | TEttinger | great! |
| 02:33 | Raynes | I think there's even still code there for it. |
| 02:34 | TEttinger | to the lapserver on the floor underneath a piece of furniture! |
| 02:34 | Raynes | Anyways, the refheap plan is currently to either make it read only and deal with webservers or make it static. |
| 02:34 | Raynes | I'm at a standing desk bro |
| 02:34 | Raynes | Get with it |
| 02:35 | TEttinger | Raynes: do you even bend, bro? http://i.imgur.com/47RoA.jpg |
| 02:35 | ianhedoesit | but who took the picture |
| 02:36 | Raynes | TEttinger: Nah but I peace sign like a god https://scontent-lax3-1.xx.fbcdn.net/hphotos-xpf1/v/t1.0-9/12400609_10207883430106765_1579825192028990593_n.jpg?oh=fe824f9d65624447590ee61f21527945&oe=5709185D |
| 02:36 | TEttinger3 | ianhedoesit: also me, with my chin |
| 02:37 | ianhedoesit | hm, I was more hoping your answer would be "timer" |
| 02:37 | TEttinger3 | it was still pretty difficult |
| 05:08 | noncom | was just coding java and writing a lambda. i did not care for the paramerter, so i used _, but the IDE said that it is not allowed and commented that in versions of Java after Java 8, the _ for lambda names will not be supported |
| 05:08 | noncom | why so? |
| 05:10 | noncom | ah, https://bugs.openjdk.java.net/browse/JDK-8061549 |
| 05:11 | noncom | still no clue as to why |
| 05:11 | noncom | they say they reserv the identifier... |
| 05:12 | noncom | what for could they reserve it? |
| 05:12 | noncom | that's weird |
| 05:29 | amalloy | noncom: look at how scala uses _ |
| 05:30 | amalloy | (_ + 1) is scala's #(+ % 1) |
| 06:21 | lokien | do we use multidimensional arrays (vectors) in clojure? |
| 06:25 | MJB47 | lokien: yes for both vectors and arrays |
| 06:26 | lokien | MJB47: can you show me an example? |
| 06:26 | MJB47 | ,[[1 2] [3 4]] |
| 06:26 | clojurebot | [[1 2] [3 4]] |
| 06:27 | MJB47 | ,(map first [[1 2] [3 4]]) |
| 06:27 | clojurebot | (1 3) |
| 06:27 | lokien | oh, well, it's that easy. thanks |
| 07:19 | visof | ,(Integer/parseInt "ff726867" 16) |
| 07:19 | clojurebot | #error {\n :cause "For input string: \"ff726867\""\n :via\n [{:type java.lang.NumberFormatException\n :message "For input string: \"ff726867\""\n :at [java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]}]\n :trace\n [[java.lang.NumberFormatException forInputString "NumberFormatException.java" 65]\n [java.lang.Integer parseInt "Integer.java" 495]\n [sandbox$eval25 ... |
| 07:19 | visof | hi guys |
| 07:19 | visof | how can i fix this? |
| 07:27 | visof | ,(Long/parseLong "ff726867" 16) |
| 07:27 | clojurebot | 4285687911 |
| 07:27 | visof | good! |
| 09:03 | gerold | Hi. I’m wondering if clojure has any means to import a set of objects into the namespace at runtime |
| 09:04 | gerold | The use case is that I want to generate a bunch of closures, based on a function that I supply at runtime |
| 09:05 | gerold | these closures should be available without explicitly passing the to-be-closed upon function object each time |
| 09:05 | gerold | scala has a nifty feature called ‘implicit arguments’ for that use case |
| 09:07 | gerold | to illustrate: |
| 09:07 | gerold | (defn generate-set-of-functions [foo] |
| 09:07 | gerold | { :function1 (fn [x] (do-something-with foo x)), :function2 (fn [x] (do-something-with foo x)) }) |
| 09:07 | gerold | how would i import function1 and function2 into my namespace, after calling generate-set-of-functions |
| 09:23 | gerold | ..an ugly solution to my problem is to just call def within the function generate-set-of-functions. |
| 09:26 | jonathanj | not quite the same thing, but perhaps you want a protocol? |
| 09:37 | gerold | jonathanj: |
| 09:38 | gerold | that certaily looks useful, but its not quite what i wanted |
| 09:39 | gerold | a solution for my case would be equivalent to creating a type - or a class - to contain the functions i need. instead of the closure object foo, I would then have to pass an instance of this class |
| 09:40 | jonathanj | yes, i think that generally you should prefer explicitness to implicitness |
| 09:40 | jonathanj | you could probably use ^:dynamic and rebind things, but that will rebind them globally |
| 09:42 | gerold | jonathanj: is there no way to ‘import’ a bunch of symbols into the *current* namespace? I’m inspired here by python’s ability to simply “add” any dictionary (a hash map of strings to values), into the local namespace |
| 09:43 | gerold | In python, one could do locals().add({“function1”: …, “function2”: ...}) |
| 09:43 | jonathanj | and most people would tell you that's basically an awful idea |
| 09:43 | opqdonut | gerold: you can use intern to add a single var to a ns: https://clojuredocs.org/clojure.core/intern |
| 09:44 | opqdonut | but I'd go for an object with methods or equivalent too |
| 09:44 | gerold | opqdonut: ah. how is that different from calling def/defn, btw? |
| 09:45 | gerold | it feels really strange to me that I can even use nested def expressions |
| 09:45 | opqdonut | well it's dynamic |
| 09:45 | opqdonut | you can use code to generate the symbol or something |
| 10:08 | jonathanj | how do the clojure.java.jdbc `db-spec` maps work? |
| 10:10 | jonathanj | if you use (with-db-connection) you get a map that looks like `db-spec` but contains `:connection`, it would appear that when trying to reuse that map for other database actions the `:connection` value is preferred over creating a new connection, right? |
| 10:12 | jonathanj | i have a scheduled event (that may happen a week later) and by that point in time, the connection has been closed and the connection instance is invalid, is there a way to turn a "connection" back into a "db-spec"? |
| 10:12 | jonathanj | or is the way to do that just to dissoc `:connection`? |
| 10:40 | lunk | hello, im struggling to create an array if length n,with a tyle defined in java code as static |
| 10:41 | lunk | (into-array Object (repeatedly 5 pkg.class/staticobj)) |
| 10:41 | lunk | any suggestions would be greatly appreciated |
| 10:42 | lunk | api i dont own needs an arbitrary length array as input |
| 10:43 | jonathanj | what's the actual problem? |
| 10:45 | jonathanj | it's not quite clear what pkg.class/staticobj is, but i don't think you can pass that macro as f to repeatedly |
| 10:45 | lunk | jonathanj: that question for me? |
| 10:46 | lunk | ah |
| 10:46 | jonathanj | i think you might need to do: #(pkg.class/staticobj) |
| 10:47 | lunk | its a java api i dobt own,needs two arrays as input, a Strig array of hosts, and a final static objrct array to enable each host |
| 10:47 | lunk | sry, on my phone, silly corp firewalls |
| 10:48 | lunk | that was it |
| 10:48 | lunk | ty so much |
| 10:50 | lunk | (inc jonathanj) |
| 11:26 | _pr0t0type_ | Hey guys, is it a common pattern, or something feasible to integrate clojurescript into a broader, es6/React project? Say if I want to implement a specific widget withing React in clojurescript, is this easy? I guess what I"m asking is it easy to compose clojurescript? |
| 11:26 | _pr0t0type_ | I recently started using clojure, and I really want to start using clojurescript at work if possible, but I can't start from scratch unfortunately, so I was thinking how easy it would be to integrate clojurescript |
| 11:36 | matthavener | _pr0t0type_: imho, its certainly possible, but not very easy |
| 11:36 | matthavener | _pr0t0type_: i migrated a project to cljs once and did it a page-at-a-time (though i never finished :)) |
| 11:40 | neoncontrails | matthavener: which parts of the migration did you find most challenging? |
| 11:47 | matthavener | writing my frontend to deal with the same backend weirdness the legacy frontend dealt with |
| 11:47 | matthavener | and trying to share CSS |
| 11:47 | matthavener | but I was going YUI3 -> Om |
| 11:47 | matthavener | so.. it was essentially a per-page rewrite. I didn't try to share code |
| 12:02 | neoncontrails | matthavener: I've built some simple SPAs in clojurescript, that's about it. It seems like clojurescript is more restrictive than clj, like it might be easier to go cljs -> clj than vice versa. True or no? |
| 12:31 | justin_smith | _pr0t0type_: between the js->clj and clj->js functions, and declaring exports / externs, you should be able to bootstrap more and more of a frontend codebase to cljs from js |
| 12:33 | j-pb | Am I the only one feeling that crossclj.info is really not helping? It's pretty useless info but because it contains a bazillion crosslinking references to clojure functions it's always clogging up google results... |
| 12:34 | domgetter | j-pb: you can filter results in google with the minus operator |
| 12:34 | domgetter | some-func -crossclj |
| 12:35 | j-pb | domgetter: yeah but It's really annoying one has to include that into every query, just because the side is a search engines crawlers wet dream |
| 13:10 | matthavener | neoncontrails: hrm, I dont know |
| 13:15 | sdegutis | It seems like extend-protocol and defmethod aren't really suitable for a reloadable workflow, right? |
| 13:19 | TimMc | right |
| 13:20 | sdegutis | Hmm. |
| 13:20 | sdegutis | But on the other hand, I like the idea of extending compojure.response/Renderable rather than replacing Compojure. |
| 13:21 | sdegutis | I'm so conflicted. |
| 13:22 | TimMc | defoncerecord ;-) |
| 13:24 | sdegutis | haha! |
| 13:24 | sdegutis | (inc TimMc) |
| 13:24 | sdegutis | um, where's the bot? |
| 13:26 | allenj12 | ,(inc 1) |
| 13:26 | clojurebot | 2 |
| 13:26 | allenj12 | ^ |
| 13:27 | sdegutis | ,(def TimMC 100) |
| 13:27 | clojurebot | #'sandbox/TimMC |
| 13:27 | sdegutis | ,(inc TimMC) |
| 13:27 | clojurebot | 101 |
| 13:27 | sdegutis | Yay. |
| 13:30 | sdegutis | Also, TIL you can return a function from a Compojure route, and it'll call the function for you and use that as the return value. |
| 13:31 | sdegutis | So returning (fn[req](fn[req)(fn[req]"foo")) is the same as returning "foo" |
| 13:32 | lxsameer | hey folks, how clojurescript take advantage of core.async? does it use web workers? |
| 13:33 | Glenjamin | sdegutis: there's quite a lot of implementations of the Renderable protocol shipped with compojure, I was pleasantly surprised when i found them |
| 13:33 | sdegutis | inorite |
| 13:34 | sdegutis | I always wondered where the magic was that let you return just a string instead of a map. |
| 13:35 | Glenjamin | https://github.com/weavejester/compojure/blob/master/src/compojure/response.clj#L21 IDeref, MultiFn & URL are some fun ones there |
| 13:36 | hiredman | no it doesn't use webworkers |
| 13:37 | neoncontrails | Interesting data structures problem: say you have a giant map of English words to their respective pronunciation(s). Strings on keys, lists of lists of keywords on vals. |
| 13:37 | hiredman | the way you implement csp in a single threaded environment is channel operations hand off control between different logical threads |
| 13:38 | neoncontrails | Your time complexity largely depends on how quickly you can take the set union of words whose values have a common element (i.e., words that are phonetically similar) |
| 13:38 | hiredman | I am pretty sure that is how core.async does it in clojurescript, but I haven't actually looked at it |
| 13:39 | hiredman | neoncontrails: inverted index |
| 13:39 | neoncontrails | You have mappings for about 100k English words, and the phoneme lists are comprised of ~42 possible phonemes |
| 13:40 | neoncontrails | hiredman: that rings a bell, but I'm not sure I learned that one. *goes to wikipedia* |
| 13:40 | Glenjamin | i was about to say the same, datastructure should model the problem, rather than the data |
| 13:41 | amalloy | well, you start with a data structure that models the data, and then process it into one that models the problem |
| 13:42 | cap10morgan | lxsameer: If I understand it correctly, the async operations that would have run in another thread on the JVM are instead run in a subsequent trip through the JS engine's event loop. So your code looks linear, but it macro-expands into events and callbacks in JS. |
| 13:42 | lxsameer | cap10morgan: thanks |
| 13:43 | hiredman | infact, even on the jvm the execution of go blocks can be interleaved on a thread |
| 13:43 | neoncontrails | hiredman: nice, this was the solution I was imagining before I knew what it was called. Thanks |
| 13:45 | domgetter | neoncontrails: are you using the Carnagie Mellon Pronouncing Dictionary? http://www.speech.cs.cmu.edu/cgi-bin/cmudict |
| 13:47 | neoncontrails | hiredman: should I be concerned about memory overflows if I go this route? 42 phonemes on keys, 42 potentially large hashsets on vals. |
| 13:47 | neoncontrails | domgetter: that's the one |
| 13:47 | hiredman | use lucene |
| 13:48 | hiredman | I mean, I don't know, it depends how much memory you have and what all you are doing |
| 13:49 | hiredman | I think lucene may have the most highly tuned inverted index implementation |
| 13:53 | neoncontrails | This is just a pet project of mine, no need to use Lucene. (I hear it's a steep learning curve) |
| 14:03 | xemdetia | neoncontrails, its not really that bad at all. It's just a big component so it has big component learning curve instead of a small component learning curve |
| 14:03 | xemdetia | aka you just can't fumble your way through it without reading at least SOME of the docs |
| 14:04 | domgetter | neoncontrails: https://github.com/weavejester/clucy |
| 14:07 | neoncontrails | Interesting. Is Lucene just a database that happens to be optimized for this type of problem? |
| 14:09 | elvis4526 | Is there a thing like admix and mix but in reverse ? |
| 14:09 | neoncontrails | I know it's conventionally called a search engine, but this looks like plain ol' database syntax |
| 14:09 | xemdetia | It's more a specialized datastore |
| 14:09 | elvis4526 | (a mix of outputs instead of inputs) |
| 14:10 | xemdetia | they do provide a nice grammar/syntax to call into it, but it just provides an optimized way to store/retrieve a certain category of data (for search) |
| 14:10 | justin_smith | elvis4526: you mean fan out rather than fan in? |
| 14:11 | justin_smith | that would be pub and sub |
| 14:11 | Kamuela | i’ve been playing with clojure here and there for a bit, for those using it now full-time, what applications does it seem to fit well with? |
| 14:26 | hiredman | with some care, I think the index of phonemes to words could be an array of about 42 longs, which should not overly tax anything |
| 14:26 | sdegutis | Hi. |
| 14:27 | lukaszk | Hi all! I'm looking for an equivalent of Ruby's timecop for clojure - I have some time-sensitive tests and I want to validate that timestamps got correctly updated in a map. I could stub the function which returns timestamps, but I'm wondering if there's a better way |
| 14:33 | justin_smith | lukaszk: there might be something in clj-time, if not clj-time has the tools you would use to build it |
| 14:33 | lukaszk | justin_smith: thanks! I'll have a look |
| 14:35 | justin_smith | lukaszk: I think it would likely involve using the clj-time functions, plus using with-redefs to wrap your code and override the function that actually provides "current time" |
| 14:36 | lukaszk | justin_smith: I'm doing something similar, I'm using with-redefs-fn to mock internal function which returns the timestamp. Looks like I'm on the right track. Thanks again |
| 14:52 | neoncontrails | Is there a way to cast a vector of lists as a map without using flatten? i.e., (into #{} (flatten [(:T :AH0 :M :EY1 :T :OW2) (:T :AH0 :M :AA1 :T :OW2)])) |
| 14:52 | neoncontrails | ,(into #{} (flatten [(:T :AH0 :M :EY1 :T :OW2) (:T :AH0 :M :AA1 :T :OW2)])) |
| 14:52 | clojurebot | #error {\n :cause "Wrong number of args passed to keyword: :T"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Wrong number of args passed to keyword: :T"\n :at [clojure.lang.Keyword throwArity "Keyword.java" 97]}]\n :trace\n [[clojure.lang.Keyword throwArity "Keyword.java" 97]\n [clojure.lang.Keyword invoke "Keyword.java" 158]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" ... |
| 14:53 | justin_smith | wait, what are you trying to do? that's a set not a map |
| 14:54 | justin_smith | neoncontrails: also, we don't have casts, that's a javac thing |
| 14:54 | neoncontrails | justin_smith: set, my bad |
| 14:54 | neoncontrails | (into #{} (flatten ['(:T :AH0 :M :EY1 :T :OW2) '(:T :AH0 :M :AA1 :T :OW2)])) |
| 14:56 | justin_smith | ,(reduce into #{} ['(:T :AH0 :M :EY1 :T :OW2) '(:T :AH0 :M :AA1 :T :OW2)]) |
| 14:56 | clojurebot | #{:M :AA1 :OW2 :T :AH0 ...} |
| 14:58 | neoncontrails | justin_smith: brilliant. I suspected reduce would be my friend here |
| 15:01 | neoncontrails | justin_smith: just out of curiosity are type conversions in Clojure handled differently than they are in Java? |
| 15:02 | justin_smith | neoncontrails: a cast is not the same as a type conversion |
| 15:02 | justin_smith | a cast is "compile code as if you were dealing with this type", clojure kind of does this with type hints, but kind of not. Converting types is not casting. |
| 15:02 | neoncontrails | true, right. Inheritance plays a roll |
| 15:02 | neoncontrails | *role |
| 15:08 | justin_smith | neoncontrails: clojure's actually kind of sloppy about it - where javac wants to know the type of your argument (and you might want to cast to an interface or supertype), clojure just accepts that it will have to look the class up at runtime (but will happily check a specific class first if you provide a hint) |
| 15:13 | neoncontrails | justin_smith: my Java's a little rusty, but that sounds similar to the way JVM treats generics. Is that what Clojure symbols are? |
| 15:14 | justin_smith | neoncontrails: the jvm doesn't treat generics. Generics exist only in javac, there is no presence of generics in the bytecode or vm. |
| 15:15 | justin_smith | on the other hand, a clojure type hint actually leads to byte code that checks a certain class before doing reflection on the class of an unknown argument |
| 15:17 | neoncontrails | Huh. I didn't know that, but it makes sense. Even generics that implement a Java library class? |
| 15:17 | justin_smith | generics don't implement anything |
| 15:18 | justin_smith | you just have a value of type Object, or a collection of Object |
| 15:19 | justin_smith | and then javac makes you be more strict about how it is treated in your source code, but none of the info about that is present in the resulting class file byte code. They call this "type erasure". |
| 15:19 | TimMc | well |
| 15:19 | TimMc | ArrayList<String> is still really an ArrayList, not an instance of Object |
| 15:20 | TimMc | but it doesn't know about the String part |
| 15:20 | justin_smith | TimMc: oh, right, that's the thing I called "a collection of Object" |
| 15:20 | TimMc | ah, yeah |
| 15:20 | justin_smith | sorry if I was sloppy there |
| 15:20 | TimMc | It's an ArrayList of Object, yes |
| 15:23 | neoncontrails | Interesting. Right, can't implement but they do... extend, correct? A generic T that extends Comparable<T> is more specific than just a value of type object, no? |
| 15:23 | justin_smith | neoncontrails: there is no spoon |
| 15:23 | neoncontrails | justin_smith: aaah |
| 15:23 | justin_smith | neoncontrails: a "generic T" is a thing that javac has some concept of, but has no existence in the bytecode |
| 15:24 | justin_smith | as far as clojure is concerned you don't interact with generics at all |
| 15:24 | justin_smith | just the objects, without that whole "generic" aspect |
| 15:25 | sdegutis | Generics have to do with static typing at compile-time. Clojure is dynamic. |
| 15:25 | sdegutis | It's as if every type is "Any". Clojure arrays aren't Array<String>, they're Array<Any> |
| 15:26 | justin_smith | sdegutis: umm... |
| 15:26 | justin_smith | sdegutis: arrays actually have types |
| 15:26 | justin_smith | sdegutis: it's only generics that don't exist, some things really are typed |
| 15:27 | neoncontrails | fascinating. Now I want to take compilers :-\ |
| 15:27 | noncom|2 | sdegutis: justin_smith: it's that you can handle them as if they're of <Any>, but in the bytecode they're specific |
| 15:27 | justin_smith | sdegutis: ArrayList - yeah, that's Object, no types, array - array can be typed (at least for primitives but I think for Classes also) |
| 15:28 | sdegutis | justin_smith: not in Clojure they don't |
| 15:28 | noncom|2 | iirc there's some clojure function to make typed arrays |
| 15:28 | sdegutis | (doc make-array) |
| 15:28 | clojurebot | "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE." |
| 15:28 | sdegutis | And it's only for primitive types. |
| 15:28 | justin_smith | ,(aset (into-array ["a" "b"]) 1 2) ; no, it is typed |
| 15:29 | clojurebot | #error {\n :cause "java.lang.Long"\n :via\n [{:type java.lang.ArrayStoreException\n :message "java.lang.Long"\n :at [clojure.lang.RT aset "RT.java" 2340]}]\n :trace\n [[clojure.lang.RT aset "RT.java" 2340]\n [sun.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]\n [sun.reflect.NativeMethodAccessorImpl invoke "NativeMethodAccessorImpl.java" 57]\n [sun.reflect.Deleg... |
| 15:29 | noncom|2 | ? not only ? |
| 15:29 | justin_smith | see, it can't put a long into a string array - the array is actually typed |
| 15:29 | justin_smith | sdegutis: so you are wrong, even arrays of non-primitive types are typed |
| 15:29 | noncom|2 | but all this stuff is simply because arrays are special to JVM, it's just that |
| 15:29 | sdegutis | No sir. |
| 15:30 | justin_smith | sdegutis: generics are fictional, types of arrays are actual byte code fact |
| 15:30 | sdegutis | :) |
| 15:31 | lokien | how to force time function not to print results of the function? just the time of evaluation |
| 15:31 | justin_smith | lokien: (time (do (f) nil)) |
| 15:32 | justin_smith | or (time (do (with-out-str (f)) nil)) |
| 15:33 | noncom|2 | neoncontrails: i'm actually doing a thing with clojure + clojurescreept + threejs now. a neat setup if you're into some threejs |
| 15:34 | TimMc | justin_smith: Interestingly, java.lang.Class does provide support for talking about parameterized types, but I'm not clear what it buys you. |
| 15:34 | justin_smith | TimMc: is this something that's actually used? |
| 15:34 | noncom|2 | TimMc: maybe it's only compile time? |
| 15:34 | neoncontrails | noncoml2: no way. I was just working with three.js for the better part of last month! |
| 15:34 | neoncontrails | I'd love to see what you got. |
| 15:35 | lokien | justin_smith: thanks |
| 15:36 | noncom|2 | neoncontrails: well, currently i got a scene with two cubes :D - a result of a couple of days of work. but not simply a scene with cubes - everything is clojure way and i am implemeting an entity-component system to build games with it |
| 15:36 | noncom|2 | i'm not a pro in js and web, but done much opengl in java/cojure |
| 15:36 | noncom|2 | so now simply want to try out the browser multiplayer thing |
| 15:37 | TimMc | justin_smith: Dunno! |
| 15:38 | lokien | justin_smith: is there a memory limit for slurping? |
| 15:38 | justin_smith | hrm - there's a max string size limit, right? |
| 15:39 | noncom|2 | planning to opensource the basic project when i polish it a little so that if someone is interested, can pick it up. |
| 15:39 | lokien | is it? |
| 15:39 | justin_smith | when you get near that, you should probably be doing reads in a loop from an input source rather than a slurp |
| 15:39 | noncom|2 | lokien: there is |
| 15:39 | justin_smith | yes, there's a max string size |
| 15:39 | lokien | :( I wanted to slurp it |
| 15:40 | lokien | haskell had no problems with loading 2gig file, I can't load 800mb here |
| 15:40 | justin_smith | lokien: what about line-seq instead? |
| 15:40 | justin_smith | lokien: but did haskell turn it into a single 2gig string? |
| 15:40 | noncom|2 | iirc there was an option to use a custom reqder with slurp also? |
| 15:40 | justin_smith | lokien: we can load that much data, but you can't put it all in a single string object |
| 15:40 | noncom|2 | lokien: for sure haskell was just creating another kind of object. JVM has limitation on string length |
| 15:41 | lokien | welp. what do I do now? |
| 15:41 | lokien | can I load it line by line? |
| 15:41 | justin_smith | lokien: yes - line-seq |
| 15:41 | justin_smith | that gives you a lazy-seq of the lines |
| 15:42 | lokien | justin_smith: thanks, I'll try that |
| 15:42 | neoncontrails | nomcoml2: I feel your pain, three.js is one of the more unapologetically difficult libraries I've worked with |
| 15:42 | amalloy | justin_smith: well, haskell *did* turn it into single 2-gig string, but haskell has a different idea of what strings are than java does |
| 15:42 | noncom|2 | lokien: justin_smith: a bunch of replacements https://crossclj.info/docs.html?q=slurp |
| 15:43 | justin_smith | ,(line-seq (java.io.BufferedReader. (java.io.StringReader. "a\nb\nc\n"))) |
| 15:43 | clojurebot | ("a" "b" "c") |
| 15:43 | noncom|2 | btw, will line-seq choke if there are no new lines in the whole file? |
| 15:43 | amalloy | well it will return one large string |
| 15:43 | amalloy | and if that doesn't fit in memory, you will have problems |
| 15:44 | justin_smith | right, that's why I asked if it made sense to split by lines |
| 15:44 | noncom|2 | neoncontrails: heheh, well, yeah, but most of my pain goes for the JS particularities... other than that I am fairly familiar with 3d engines and opengl stuff |
| 15:44 | noncom|2 | lokien: so beware of the newlines requirement too |
| 15:45 | noncom|2 | lokien: look, another solution: https://books.google.ru/books?id=H9tOCwAAQBAJ&pg=PA151&lpg=PA151&dq=slurp+custom+reader&source=bl&ots=BEi-1HY2jO&sig=hkXf-BkMTFlLjgFRmYe8uWdq4ds&hl=ru&sa=X&ved=0ahUKEwj694f50qfKAhUiAXMKHeM5Ct0Q6AEILjAC#v=onepage&q=slurp%20custom%20reader&f=false |
| 15:45 | noncom|2 | lokien: bottom of the page |
| 15:46 | neoncontrails | noncomj2: my most successful tweet of 2015 compared graphics programming to pulling a fitted sheet over a thousand-dimensional mattress, heh |
| 15:47 | noncom|2 | neoncontrails: :D oh I understand that :D |
| 15:48 | lokien | java is broken :( |
| 15:48 | lokien | noncom|2: thanks, I'll read that |
| 15:49 | noncom|2 | lokien: well, you see, java is very pragmatic. having a multi-gig string is an antipattern |
| 15:49 | noncom|2 | lokien: so the String concept in JVM is fitted for performance ond optimization needs |
| 15:49 | noncom|2 | lokien: and for other cases you can just read the data as bytes. which is dead easy to do either |
| 15:50 | lokien | noncom|2: yeah, but it's late, and I'm getting buffer errors from java, it's annoying |
| 15:50 | noncom|2 | ah i see |
| 15:51 | justin_smith | ,(line-seq (java.io.BufferedReader. (java.io.StringReader. "a\nb\nc\n"))) |
| 15:51 | clojurebot | ("a" "b" "c") |
| 15:51 | justin_smith | lokien: buffer errors, or errors that say you have the wrong class that mention buffer in it somewhere? |
| 15:52 | l1x | hi guys |
| 15:52 | lokien | justin_smith: I'll try that code you've just written |
| 15:52 | noncom|2 | l1x: hi! |
| 15:52 | l1x | what does it mean when java guys do this -> Class OrcFile.WriterOptions it seems it behaves differently from normal java classes |
| 15:52 | l1x | hi noncom|2 |
| 15:53 | justin_smith | lokien: well don't do the StringReader part - that was just an easy way for me to make an input source |
| 15:53 | justin_smith | so replace (java.io.StringReader. "") with your actual input source |
| 15:53 | lokien | "path/to/file"? |
| 15:53 | justin_smith | (java.io.File. "path/to/file") |
| 15:54 | justin_smith | so (line-seq (java.io.BufferedReader. (java.io.File. "path/to/file"))) |
| 15:54 | lokien | now, how to prevent 800mb printing in the repl? |
| 15:54 | justin_smith | lokien: (def lines (line-seq ...)) |
| 15:54 | amalloy | urgh |
| 15:54 | justin_smith | then you can use lines - it's a seq |
| 15:54 | amalloy | def-ing an 800mb lazy seq... |
| 15:55 | lokien | but.. well, that works, so it's good. |
| 15:55 | justin_smith | amalloy: there is that, yeah |
| 15:55 | amalloy | you really don't ever want that tied to a var |
| 15:55 | lokien | amalloy: sorry :( |
| 15:55 | amalloy | you want it let-bound to a local or a function arg |
| 15:55 | justin_smith | lokien: in your final code it can be in a let binding |
| 15:55 | noncom|2 | l1x: you mean you see "Class OrcFile.WriterOptions" in a java source? |
| 15:55 | lokien | justin_smith: it will be |
| 15:55 | justin_smith | I think for quick repl experiments it should be OK |
| 15:55 | justin_smith | lokien: makes sense, yeha |
| 15:55 | l1x | noncom|2: well i am trying to call new on that but it does not work |
| 15:55 | l1x | for some weird reason |
| 15:56 | noncom|2 | l1x: can you post it into refheap and show? |
| 15:56 | noncom|2 | or pastebin or something |
| 15:57 | lokien | justin_smith: CompilerException java.lang.ClassCastException: Cannot cast java.io.File to java.io.Reader |
| 15:57 | noncom|2 | wrap the file in a reader |
| 15:59 | justin_smith | (-> "project.clj" java.io.File. clojure.java.io/reader java.io.BufferedReader. line-seq) |
| 15:59 | justin_smith | yeah, it's a lot of silly conversions |
| 15:59 | noncom|2 | actually it's very logical and gives a lot of flexibility |
| 15:59 | noncom|2 | i used to hate it too |
| 16:00 | justin_smith | scratch that - this suffices (-> "project.clj" clojure.java.io/reader line-seq) |
| 16:00 | noncom|2 | until i understood it |
| 16:00 | ridcully | l1x: are you looking for OrcFile$WriterOptions ? |
| 16:01 | lokien | noncom|2: that's why I'm hating it now |
| 16:01 | justin_smith | lokien: you saw my simpler version above right? just io/reader lin-seq |
| 16:02 | justin_smith | there was a detour on the way to finding that again |
| 16:02 | noncom|2 | lokien: it's very unixy, you like pipe output of one subprogram into another. each subprogram allows for a specific conversion |
| 16:02 | lokien | justin_smith: I thought "scratch that" meant something else |
| 16:02 | lokien | noncom|2: only linux! |
| 16:03 | noncom|2 | well, linuxy then :D they're not too different in this aspect afaik |
| 16:03 | lokien | ugh, why are you all so smart :^( |
| 16:04 | justin_smith | lokien: in my case it comes from a lot of time being stumped, and a lot of wrong answers corrected |
| 16:06 | noncom|2 | i rather often feel rather stupid btw |
| 16:06 | lokien | justin_smith: "I decided to use pull it out your ass driven development, where you just pull the answer out of your ass." |
| 16:06 | justin_smith | heh |
| 16:07 | noncom|2 | lokien: so, you really want a string in the end, but why? why you need a giga string? |
| 16:07 | lokien | I use it every time, and often have to rewrite /: |
| 16:07 | lokien | noncom|2: I'm curious about the performance on big things |
| 16:08 | noncom|2 | lokien: you benchmark clojure/jvm or do you simply work with big data? |
| 16:08 | lokien | noncom|2: I want to check how fast is clojure here compared to perl, and maybe haskell |
| 16:09 | l1x | noncom|2: i figured out public static OrcFile.WriterOptions orc_options = OrcFile.writerOptions(conf); |
| 16:09 | l1x | OrcFile.WriterOptions is the type |
| 16:09 | l1x | ridcully: yes :) |
| 16:10 | justin_smith | in clojure that would be OrcFile$WriterOptions - not that $ is not an operator, it's part of the name |
| 16:10 | justin_smith | *note |
| 16:13 | lokien | justin_smith: java reached 2gigs of memory and stopped, funny |
| 16:13 | justin_smith | lokien: that's why amalloy was saying not to put it in the var |
| 16:14 | justin_smith | lokien: also, you can tell java to use more RAM |
| 16:14 | lokien | justin_smith: I forgot, I'm so bad |
| 16:15 | l1x | lokien: are you trying to read a file lazyly? |
| 16:15 | justin_smith | l1x: it's too big to go in a string |
| 16:15 | lokien | l1x: I'm doing it :^) |
| 16:16 | noncom|2 | lokien: is your jvm 32bit or 64bit |
| 16:16 | noncom|2 | ? |
| 16:16 | l1x | justin_smith: ofc |
| 16:16 | lokien | noncom|2: 64 |
| 16:19 | sohail | hey guys, are there any good lein templates for http-kit based apps |
| 16:21 | justin_smith | sohail: changing from any other server in a ring app to http-kit should mean changing at most 4 lines (between project.clj and the namespace where you are loading and starting your http handler) |
| 16:21 | noncom|2 | sohail: luminus +http-kit for example |
| 16:21 | noncom|2 | +cljs also maybe |
| 16:21 | sohail | oh I'm just trying to find a template that lets me get started quickly, doing a lot of prototype work |
| 16:21 | noncom|2 | if you need it |
| 16:22 | sohail | what is luminus? |
| 16:22 | noncom|2 | sohail: http://www.luminusweb.net/docs/profiles.md |
| 16:22 | justin_smith | sohail: yeah, what I'm saying is, use any web template, and then when you need your web server to be http-kit, it's a question of changing like 4 lines |
| 16:22 | sohail | gotcha |
| 16:23 | domgetter | I'm trying to use compojure to make a defresource macro to make resources sort of like rails does. Any feedback on the macro is welcome: https://gist.github.com/domgetter/ce5a2d59b4e1817cd782 |
| 16:23 | sohail | luminus looks good, thanks noncom|2 |
| 16:23 | noncom|2 | lokien: regarding your tasks, if you are not sure that the file will have new lines, i.e. it's some binary data, I'd use https://www.refheap.com/113632 |
| 16:24 | noncom|2 | sohail: also, as justin says, you can just use it without http-kit, which will imply immutant 2 which is afaik better |
| 16:24 | noncom|2 | sohail: here's a good summary of all the options by the luminus creator: https://www.reddit.com/r/Clojure/comments/3dpjpf/jetty_vs_http_kit_vs_aleph_vs_immutant_luminus_app/ |
| 16:25 | lokien | noncom|2: bookmarked |
| 16:25 | sohail | noncom|2: right, I used http-kit last time because sente seemed to work well with it |
| 16:26 | noncom|2 | sohail: it now fully works with immutant 2 which is thought to be currently better maintained than http-kit |
| 16:26 | sohail | cool, I'll give it a shot |
| 16:37 | noncom|2 | lokien: i apologize it's too late for me too. feeling a bit dizzy :) the previous example deals with chars which are two bytes, but the file size is determined in bytes, so the array is made two times bigger than needed. besides, chars are not comfortable if you work with binary |
| 16:37 | noncom|2 | lokien: this one fixes this: https://www.refheap.com/113633 |
| 16:38 | noncom|2 | had to come back to it, since i felt that what i posted had hidden catches and was not very correct |
| 16:39 | lokien | noncom|2: well, bookmark out, bookmark in |
| 16:39 | lokien | thanks that you care |
| 16:40 | noncom|2 | :) |
| 16:47 | lokien | anyway, do you know some simple library for graphics? I wanted to mess around with a static game (it's played on paper normally) and I don't know if quil is a good choice |
| 16:48 | j-pb | lokien: I do all ui stuff in cljs |
| 16:48 | j-pb | reagent is great |
| 16:48 | j-pb | and it's so easy to get interactive stuff going |
| 16:49 | j-pb | especially for something like board games :) |
| 16:49 | lokien | j-pb: foreign grounds again, great |
| 16:49 | j-pb | :D |
| 16:50 | lokien | "read a book", they said. "you'll be a coder in 6 months", they said. and I'm still wandering in the dark |
| 16:50 | j-pb | haha well starting with clojure is a good thing |
| 16:50 | j-pb | what did you do before? |
| 16:51 | TimMc | lokien: Sounds like you're a coder. ;-) |
| 16:51 | TimMc | wandering in the dark is the human condition |
| 16:51 | futuro | lokien: yeah, I wouldn't expect that to change any time soon |
| 16:51 | j-pb | yeah |
| 16:51 | lokien | mainly python and haskell. some scala, go, perl, little bit of c and ocaml (very little) |
| 16:51 | j-pb | without google I wouldn't get shit done and I'm writing clojure for 3 years and have done CS for 10 years |
| 16:51 | ridcully | yet, if you don't know html/css this can be quite some adventure too |
| 16:52 | slester | I know it's probably not what you want to hear, but I've been struggling with Clojure for a year or so. Some things click, but just getting into the 'groove' (how things are done in clojure and not JavaScript/C/etc) |
| 16:52 | lokien | j-pb: hello, I'll interview you for your dream job, please write code on that whiteboard |
| 16:52 | slester | I just learned that (map f coll1 coll2) was a thing |
| 16:52 | lokien | TimMc: I'm trying D: |
| 16:52 | slester | etc. |
| 16:53 | lokien | ridcully: what kind of "adventure"? |
| 16:53 | j-pb | lokien: well I could do _that_^^, but "hey write a library that does xyz on that whiteboard" I would have some googling to do :D |
| 16:53 | lokien | slester: I get functional things cause I was writing haskell, but I don't get java at all :( |
| 16:54 | slester | I still don't know how to structure my clojure projects. Haha. :( |
| 16:54 | slester | lokien: that's a good situation to be in, wrapping my head around functional programming was quite the doozy of a first step! |
| 16:54 | slester | I came from C/PHP/JavaScript |
| 16:54 | j-pb | lokien: yeah, java is just weird, don't feel bad. It's the functional part that's hard and important ^^ |
| 16:54 | lokien | j-pb: fast trip to the toilet would do |
| 16:55 | j-pb | toilets are like the muse behind every great algorithm |
| 16:55 | noncom|2 | lokien: confirming, quil is perfect for that. it is based on https://processing.org/ |
| 16:55 | lokien | noncom|2: clj or cljs? |
| 16:55 | noncom|2 | lokien: both |
| 16:55 | j-pb | noncom|2: how so. If you want to do a board game thing you need interactivity |
| 16:56 | noncom|2 | theres processing and there's processing js |
| 16:56 | j-pb | noncom|2: in the sense, that you want to click stuff |
| 16:56 | ridcully | lokien: maybe an unpleasent one. or an rabbitholish one. |
| 16:56 | lokien | noncom|2: I mean, what'd be better |
| 16:56 | elvis4526 | Is there any good documentation about laziness in clojure ? |
| 16:56 | lokien | I'm dreaming of client-server or p2p, but it's too ambitious for now |
| 16:56 | elvis4526 | I'm still not sure how its implemented. |
| 16:56 | futuro | elvis4526: we keep meaning to get around to it, but something always comes up... |
| 16:56 | noncom|2 | lokien: depends. the cljs will require hosting with a web server, which you could quickly set up with, e.g. luminus |
| 16:56 | j-pb | noncom|2: which is super easy with drawing svg but impossibly difficult with quil |
| 16:57 | j-pb | elvis4526: before 1.8 it was just a bunch of nested anonymous functions |
| 16:57 | lokien | ridcully: uh, why aren't there good tools in this world :^( |
| 16:57 | noncom|2 | lokien: i'd try simple clj first, then, if you want to show your friends or make a multiplayer, then you can easily lift it to cljs |
| 16:57 | ridcully | lokien: in the browser there is html/css, webgl, svg, canvas (maybe more) to chose to render to |
| 16:57 | elvis4526 | j-pb: post clojure 1.8, what is it ? |
| 16:57 | lokien | noncom|2: I'll do that |
| 16:58 | slester | noncom|2: how do you suggest organizing code to have a CLJ + CLJS version live side-by-side? |
| 16:58 | j-pb | elvis4526: magic |
| 16:58 | slester | all of my functions are so intertwined and such, not sure how to organize it (even still) |
| 16:58 | j-pb | elvis4526: depends on the arity of map filter e.t.c. |
| 16:58 | noncom|2 | j-pb: um? don't really get what you mean. processing is just great at interactivity, both clj and cljs. they draw vector graphics too |
| 16:58 | elvis4526 | j-pb: right - ok |
| 16:59 | j-pb | noncom|2: yeah but say you have a board game with a bunch of figures, and you want to be able to click or drag them, how would you register that |
| 16:59 | noncom|2 | slester: well, first you have to have a clean code. with processing/quil, the code will be shared up to 100% if you use only the prefactored API, and no java/javascript platform specific things |
| 16:59 | noncom|2 | j-pb: in quil/processing? |
| 16:59 | j-pb | noncom|2: yeah |
| 17:00 | noncom|2 | noncom|2: i'd track the mouse position and mouse button events, like mouse pressed, mouse released. this will give me all the info i need about the mouse, so i can do anything within the game |
| 17:00 | slester | if anyone wants to give me tips for https://github.com/slester/amiss/blob/master/src/amiss/core.clj I'm definitely up for it haha. |
| 17:00 | j-pb | elvis4526: the arity 3 or more still use the nested fn's but the other 2 arity ones create transducers, which are agnostic to lazyness (can be defined over lazy seqs, arbitrary collections and even channels) |
| 17:00 | slester | reorganizing so I can end up making two versions |
| 17:00 | noncom|2 | j-pb: ^ that was for you :D |
| 17:00 | j-pb | noncom|2: yeah I know ^^ |
| 17:01 | lokien_ | it would be generating a hexagonal grid and marking fields with colours (basically that's entire game) |
| 17:01 | j-pb | noncom|2: yeah so you need to write your own event handling engine |
| 17:01 | j-pb | noncom|2: which to say it noncharlantly, sucks monkey balls :D |
| 17:01 | lokien_ | based on player's moves |
| 17:01 | lokien_ | something like battleships |
| 17:01 | j-pb | noncom|2: there is soooooo much stuff involved in this. What if figures overlap? what if you want click propagation |
| 17:01 | noncom|2 | j-pb: well, idk, i'm fine with all that kind of stuff. been doing games for ages |
| 17:02 | noncom|2 | http://www.openprocessing.org/sketch/17259 |
| 17:02 | domgetter | elvis4526: are you wondering how it works, or are you trying to figure out what it does for you so you can wield laziness? |
| 17:02 | j-pb | noncom|2: I'm not saying that it cant be done ^^ or that it's a bad approach for soething that requires continuous rendering (you would have to do the same in say canvas) |
| 17:03 | j-pb | noncom|2: but it's a lot easier for a board game to just throw a reagent svg context on a page which brings all the event handling as part of the browser |
| 17:03 | neoncontrails | I feel like Clojure's map utility functions (assoc-in, update-in, etc.) are not-so-subtly hinting I should use keywords for keys, not strings. Does it make an efficiency difference? |
| 17:03 | elvis4526 | domgetter: the latter |
| 17:04 | amalloy | neoncontrails: what makes you think they give you that hint? |
| 17:04 | noncom|2 | j-pb: ah, well, maybe, but then you get into all that html stuff. and speaking of games, html stuff is farther from it than writing some input processing. YMMW however |
| 17:04 | noncom|2 | j-pb: if you come from web dev and like it, i think then surely the web way will be far more pleasant |
| 17:04 | j-pb | noncom|2: yeah well it depends, I wouldn't want to do it in html ^^ but pure svg is bliss |
| 17:05 | lokien_ | hey guise, maybe my description would help in your argument |
| 17:05 | sohail | ok, so I've got this thing in core.clj after creating a luminus app: http://pastebin.com/raw/n8ErvU2y but it seems like if I use cider-jack-in from emacs, things will be wonky... I'm still shaky on my repl dev.. should I be starting the repl and then calling (start-app)? |
| 17:05 | j-pb | lokien_: clickable hexagons a la battleship? |
| 17:05 | lokien_ | j-pb: yeah |
| 17:05 | neoncontrails | amalloy: ooh I just noticed I can alternatively use list indices with assoc-in, etc. |
| 17:06 | j-pb | lokien_: I'd go with reagent and svg. I wouldnt want to write the logic that checks which hexagon the click is in |
| 17:06 | noncom|2 | slester: so what's the problem with your code? which parts break in clj<->cljs transition? |
| 17:06 | amalloy | use keywords (or other literals, like int if you're indexing non-string stuff) for your list keys when they are known at compile time and you type them in as source code literals; use strings instead of keywords when you're reading them in at runtime |
| 17:07 | neoncontrails | amalloy: I haven't found an example yet in the docs to change the value to which a string key is bound, though |
| 17:07 | domgetter | elvis4526: ah okay. try this in a repl: https://gist.github.com/domgetter/2f7fc4b085e58c092f7e |
| 17:07 | amalloy | ??? it's exactly the same as everything else |
| 17:07 | lokien_ | j-pb: would it be possible to make a map builder of some sort? that you'd create your own maps (there are two types of hexagons) |
| 17:07 | noncom|2 | sohail: yes, first start repl, go to the namespace where the function is and call (start-app []) - please note it requires 1 arg |
| 17:07 | amalloy | keywords are not special in any way to maps |
| 17:07 | amalloy | (get m k) (assoc m k v) and so on all work for any object k |
| 17:07 | domgetter | elvis4526: clojure will "actualize" chunks of 32 of a sequence at at time |
| 17:08 | neoncontrails | Well, that's good to know. I must just be syntactically off then |
| 17:08 | noncom|2 | sohail: also you should know that the IDE experience editing clj and cljs files will vary greatly. clj will be far more comfortable (likely) |
| 17:08 | j-pb | lokien_: yeah, I don't see why not |
| 17:09 | lokien_ | j-pb: so I'll be asking more silly questions here, yay |
| 17:09 | j-pb | lokien_: if you get stuck don't hesitate to pm :) |
| 17:09 | noncom|2 | j-pb: lokien_: it's just that with web gui you'll have to organize all that transport between the browser and your backend (if you want to save your edited maps, you'll need a backend, yes) |
| 17:09 | sohail | noncom|2: actually I have had better experience editing cljs files! |
| 17:10 | noncom|2 | sohail: wow! :D that's unusual |
| 17:10 | lokien_ | j-pb: I'll remember that :) |
| 17:10 | sohail | noncom|2 probably pebkac |
| 17:10 | domgetter | elvis4526: so even if that was (range 1000000), clojure would only make what it needs to do whatever work you asked of it (in 32 element chunks) |
| 17:10 | j-pb | noncom|2: you can go with local storage if you really want to, most of the time I do "p2p" between browsers |
| 17:10 | lokien_ | noncom|2: yeah, I'll see what floats my boat |
| 17:11 | noncom|2 | j-pb: i also think that doing cljs/web is more commercial-correct, since it lets you do the web things which are more apt today - the bowser things. but yeah, it involves js, frontend, backend and stuff... |
| 17:11 | lokien_ | anyway, if I make a game based on a board game.. do I need a licence to make it public? |
| 17:11 | noncom|2 | lokien_: technically you need to pack a license with everything |
| 17:11 | ridcully | lokien_: if in doubt, yes |
| 17:12 | lokien_ | I mean, do I have to mail guys who made it |
| 17:12 | j-pb | lokien_: hint: if you want to have an empty map and fill it with hexagons. Just draw all the hexagons already but make them invisible (theres an option to make invisible elements clickable). Then when you press in "empty" space. You automagically click a hexagon click area :) |
| 17:12 | lokien_ | j-pb: that's a good idea, actually. I need to read about hexagonal grids though |
| 17:13 | ridcully | lokien_: also you might _need_ a server side. you can store stuff in the browser, you can multiplay with webrtc etc (but the more complex things get, the more likely you need a server that goes beyond just serving files) |
| 17:13 | domgetter | lokien_: bookmark this sucker: http://www.redblobgames.com/grids/hexagons/ |
| 17:13 | lokien_ | ridcully: if I finish it till 2017, I will call it a great success |
| 17:13 | noncom|2 | lokien_: just do a server from the start if you go cljs. it'll save much. thankfully, there are templates, like luminus, which can help you do it in a few seconds |
| 17:13 | j-pb | noncom|2: yeah somewhat. I found that you can work with cljs quite nicely without a server. And if you need cross browser communication say for multiplayer, I created a websocket library that automatically sets up a ring websocket that broadcasts to all connected clients |
| 17:13 | ridcully | gamasutra has some nice article about them. something like 10 facts you didn know about hexgrids |
| 17:14 | lokien_ | domgetter: love you |
| 17:14 | noncom|2 | j-pb: idk, i always felt waaaaaaay safer with a backend |
| 17:14 | j-pb | noncom|2: why though? putting one in takes like 5 seconds, and it's code you don't immediately need but have to maintain. |
| 17:14 | noncom|2 | lokien_: https://help.github.com/articles/open-source-licensing/ |
| 17:14 | j-pb | lokien_: I'd probaly start with a figwheel cljs template |
| 17:14 | lokien_ | I don't know how I lived without irc |
| 17:15 | domgetter | lokien_: all the examples are interactive on there |
| 17:15 | j-pb | lokien_: lein new figwheel MYAWESOMEPROJECT -- --reagent |
| 17:15 | noncom|2 | j-pb: robustness and the ability to interface with a db and other services.. |
| 17:15 | j-pb | noncom|2: yeah but while prototyping a game ^^ |
| 17:16 | lokien_ | noncom|2: so, no monies for me from ideas I stole? eh :( |
| 17:16 | noncom|2 | j-pb: well, i actually was doing the whole thing at once. did not really seem to demanding or hard or something. it's only that js, css and html were at times getting me mad. but otherwise it's a breeze |
| 17:16 | noncom|2 | got pretty used to all that stuff before |
| 17:17 | noncom|2 | and when you do it right, a good infrastructure pays off really quickly, giving much comfort and freedom |
| 17:17 | j-pb | yeah I wouldn't want to do it in anything but reagent |
| 17:17 | j-pb | html is madness |
| 17:17 | j-pb | svg is nice though |
| 17:17 | noncom|2 | i was doing in in reagent :D |
| 17:18 | ridcully | that was what i meant with the "advententure" - the ones doing that web stuff for a decade or two now, don't remember all them madness that can arise |
| 17:18 | noncom|2 | lokien_: oh that's a hard question. if the game is like chess or battleships, surely, there's no patent for the idea |
| 17:18 | j-pb | game mechanics arent patentable |
| 17:18 | j-pb | nor trademakable |
| 17:18 | domgetter | j-pb I made a nice little typing game with reagent using core.async to do event logic: http://domgetter.github.io/typerooni/ |
| 17:18 | j-pb | trademarks are trademarkable so don't calle it battleship |
| 17:19 | j-pb | domgetter: cool |
| 17:19 | lokien_ | but story and universe is, I think |
| 17:20 | lokien_ | s/is/are |
| 17:20 | noncom|2 | lokien_: yes, artwork... you can read the stack exchange law site, there are some very good answers about such things |
| 17:20 | j-pb | domgetter: total words: 77correct words: 71incorrect words: 6wpm: 76.6 |
| 17:20 | ridcully | yet there is always the question of: how much money are you willing to pay laywers |
| 17:21 | noncom|2 | ridcully: yeah, funny, but in the end - money is all. often. |
| 17:21 | lokien_ | ridcully: I have like, 50 dollars |
| 17:21 | ridcully | many table top games g[eo]t ported to mobile etc. maybe you just piss off the wrong crowd |
| 17:21 | domgetter | j-pb: the average ms column is how many millisecds it takes you on average to type the wordlet on the left |
| 17:21 | j-pb | cool |
| 17:22 | j-pb | wow I suck a le |
| 17:22 | lokien_ | there is this dilemma now - do I mail them or not. if I don't mail them, maybe they'll never know |
| 17:22 | ridcully | you suck ale? |
| 17:22 | j-pb | 317ms ^^ |
| 17:22 | j-pb | at |
| 17:22 | j-pb | ^^ |
| 17:22 | lokien_ | noncom|2: I will |
| 17:23 | noncom|2 | lokien_: actually, if you do all the pictures yourself (or hire someone), and give your own names to all the stuff and things, then there's nothing to worry |
| 17:23 | noncom|2 | some minor tweaks to game mechanics also won't hurt |
| 17:25 | lokien_ | noncom|2: there are not so many pictures, I can do them by myself. but now I'll have to pay this irc for being real devs behind that |
| 17:25 | noncom|2 | :D |
| 17:29 | lokien_ | also, I don't give you name of that game, I know you, clojure hacks. justin_smith would instantly make all the logic |
| 17:29 | lokien_ | in one line |
| 17:30 | justin_smith | (win-game) |
| 17:30 | j-pb | (def wingame (constantly true)) |
| 17:30 | lokien_ | :( |
| 17:30 | lokien_ | knew that |
| 17:30 | elvis4526 | Would core.async be a good way to implement a stream ? |
| 17:31 | elvis4526 | Or there's something more idiomatic in clojure |
| 17:31 | justin_smith | elvis4526: what kind of stream? |
| 17:31 | j-pb | (def wingame (comp not #{:lokien_} get-user)) |
| 17:31 | noncom|2 | slester: amiss in its current form does not seem to have problems with being shared by clj/cljs.. idk.. maybe i am missing something |
| 17:32 | j-pb | elvis4526: depends on your kind of stream, seqs are also kinda streams :) |
| 17:32 | lokien_ | j-pb: thanks, man |
| 17:32 | elvis4526 | justin_smith: I'm trying to abstract the paginated results of a REST API. |
| 17:32 | domgetter | elvis4526: core.async is good for coordinating several different asynchronous operations. |
| 17:32 | j-pb | lokien_: most welcome ;P |
| 17:32 | j-pb | elvis4526: a seq it is |
| 17:32 | elvis4526 | j-pb: thats what i was trying to wrap my head around (hence the question about laziness), but I'm not sure I understand |
| 17:32 | slester | noncom|2: basically my concern is that I'm not setting up a good project structure so that I can expand it in the future |
| 17:32 | elvis4526 | correctly. |
| 17:33 | j-pb | elvis4526: flochart is like this. Does it have an end, or goes on infinitely without significant blocking. -> seq |
| 17:33 | j-pb | elvis4526: is that thing a bitch and might stall your thread when no item is available for an unbounded unknown amount of time? -> channel |
| 17:33 | justin_smith | elvis4526: you could do that with a lazy-seq (defn get-results [url cursor] (cons (slurp (make-url cursor)) (lazy-seq (get-results url (inc cursor)))) - something like this |
| 17:34 | noncom|2 | slester: well, clojure is not too different in project structuring than most of the other languages... it's just namespaces are more resembling abstract java classes full with static members.. vaguely... |
| 17:34 | lokien_ | j-pb: I'll annoy the heck out of you |
| 17:34 | j-pb | lokien_: please do :D |
| 17:34 | slester | I guess it's mostly having to do a bunch of (declare x) |
| 17:35 | j-pb | lokien_: I really really want to write a cljs board game library but I have a different project on my plate right now |
| 17:35 | j-pb | but it will be a part of it :D |
| 17:35 | lokien_ | j-pb: oh. |
| 17:35 | noncom|2 | slester: looking at your code i can say, that it's ok now, i've seen such an example of code many times. if you are wondering about organizing it - try splitting it logically into namespaces |
| 17:36 | j-pb | lokien_: heres some hacking music : https://www.youtube.com/watch?v=BhsTmiK7Q2M |
| 17:36 | noncom|2 | slester: well, declares are not too god, but sometimes they are inevitable or very handy. i do not see any particular problem with your code. try eliminating declares by placing the functions in the correct order, *when possible* |
| 17:36 | sdegutis | oh man |
| 17:36 | sdegutis | deadly |
| 17:37 | justin_smith | sdegutis: watch it, I'm wearing the glove |
| 17:38 | elvis4526 | j-pb: ok i see |
| 17:38 | noncom|2 | noncom|2: and split the code in namespaces.. for example, if you have any global state, it's better to reside in a separate namespace... just take a look at some existing good clojure libraries to get some inspiration |
| 17:38 | sdegutis | what if there was a ->>> macro? |
| 17:38 | sdegutis | that would be crazy |
| 17:38 | elvis4526 | justin_smith: im guessing its a "stream" because of lazy-seq ? |
| 17:38 | lokien_ | j-pb: why not the sound of silence? |
| 17:38 | noncom|2 | slester: then you can submit your code for a review, for example, here and if somebody's around, they could take a look |
| 17:38 | elvis4526 | if i do (lazy-seq [1 2 3]), do I get back something lazy ? |
| 17:38 | j-pb | lokien_: hahaha lol |
| 17:39 | j-pb | lokien_: hello darkness my old friend |
| 17:39 | justin_smith | elvis4526: it has the property that you can load elements one at a time as needed - lazy-seqs are "pull driven" unlike core.async which is "push driven" |
| 17:39 | justin_smith | elvis4526: if that makes sense |
| 17:39 | slester | noncom|2: they have circular dependencies which is why I had to declare |
| 17:39 | slester | is there a specific way to submit for a review? or just ask? haha |
| 17:39 | domgetter | ,(type (lazy-seq [1 2 3])) |
| 17:39 | justin_smith | elvis4526: yes, that is lazy, but also all the items are realized. A lazy thing remains lazy even when all the work has been done. |
| 17:40 | clojurebot | clojure.lang.LazySeq |
| 17:40 | justin_smith | slester: the standard solution is to make a third namespace, that uses things from the other two |
| 17:40 | lokien_ | j-pb: by the way, my dream is to make a retro platformer with this soundtrack https://youtu.be/q9HzqxwKfiM |
| 17:40 | j-pb | lokien_: hahahahah lol |
| 17:40 | domgetter | ,(realized? (lazy-seq [1 2 3])) |
| 17:40 | clojurebot | false |
| 17:41 | slester | justin_smith: thanks, I'll see if that's feasible with my code heh |
| 17:41 | slester | I just feel like it's really messy and I've already lost a handle on what's going on |
| 17:42 | noncom|2 | slester: yeah, try factoring thing in a side namespace |
| 17:42 | noncom|2 | maybe a rewrite would do... |
| 17:42 | noncom|2 | start with a ns to hold state |
| 17:42 | noncom|2 | another ns for simple queries on the state |
| 17:43 | noncom|2 | another ns for decisions |
| 17:43 | noncom|2 | and so on |
| 17:43 | noncom|2 | (as an example) |
| 17:43 | slester | that's probably smart |
| 17:43 | slester | this was my first clojure project so I was kind of feeling around in the dark :D |
| 17:44 | noncom|2 | slester: no procedure for a review, just ask.. if someone feels like having some time, i think they take a look |
| 17:44 | noncom|2 | oh my, my first clojure projects were terrible! |
| 17:44 | lokien_ | my first clojure project was fizzbuzz :^( |
| 17:46 | domgetter | lokien_: mine was basically fizzbuzz too, since ProjectEuler #1 is the same thing |
| 17:47 | lokien_ | domgetter: I have bad memories with project euler and haskell |
| 17:48 | domgetter | haskell's not well-suited to do math :P |
| 17:48 | lokien_ | like "yeah, I can't write a hello world, but I know what a functor is, I'll do that" |
| 17:48 | slester | project euler isn't the best for programming |
| 17:48 | lokien_ | *7 hours later* |
| 17:48 | slester | in my experience |
| 17:48 | lokien_ | slester: advent of code all the way! |
| 17:49 | slester | lokien_: hey I got on the leaderboard 5-6 of the days with clojure |
| 17:49 | slester | https://github.com/slester/amiss/blob/master/src/amiss/core.clj if people want to tear it apart :D |
| 17:49 | slester | (my game, not advent of code) |
| 17:49 | benjyz1 | hi. I'm working with channels and wondering about buffering. the standard (chan) means each put requires 1 take? |
| 17:50 | domgetter | benjyz1: technically (chan) has no buffer. that's why a put waits for the take |
| 17:50 | domgetter | if there was a buffer of one, then the put could put and the next put would then experience a waiting period |
| 17:51 | benjyz1 | I see. I've seen some examples about simple use of channels, but wondering about complex use cases |
| 17:51 | lokien_ | slester: I've done one problem with go, and it was.. gross. but I was so happy when it finally worked |
| 17:51 | noncom|2 | slester: well, the first advice still holds: make a ns for state, then a ns for functions that query state, then a ns for functions that write state, then a ns for functions that do higher-order logic. |
| 17:51 | slester | lokien_: go is fun |
| 17:51 | domgetter | some of the more complex uses are done through using the other core.async functions (mult-ing, alt-ing, fan-ing, pubsub, etc) |
| 17:51 | slester | noncom|2: yep, that'll be incorporated into the rewrite |
| 17:52 | lokien_ | slester: perl is fun, go is savage |
| 17:52 | slester | perl... |
| 17:52 | slester | haha |
| 17:52 | slester | I just can't do Perl |
| 17:53 | lokien_ | because you're no fun! |
| 17:54 | benjyz1 | domgetter: yes, I'm looking at those. I'm trying to understand the basic use of blocking and non-blocking |
| 17:54 | benjyz1 | often it is mentioned one can get rid of callback hell |
| 17:54 | noncom|2 | benjyz1: give an example of a complex use of channels |
| 17:55 | benjyz1 | e.g. I have an API I'm writing against. it only has polling. so I want to write a callback on the client via channels |
| 17:56 | domgetter | benjyz1: I'm an audiovisual learner, and if you're the same, I urge you to watch this entire video: https://www.youtube.com/watch?v=AhxcGGeh5ho |
| 17:56 | benjyz1 | request every few milli seconds, then if there is a change put that event on a channel. i.e. something like Event stream processing |
| 17:57 | noncom|2 | benjyz1: good, seems like a good task for c.a. |
| 17:57 | benjyz1 | thx, I think I know this one. for UI and clojurescript it async is awesome |
| 17:58 | benjyz1 | https://yobriefca.se/blog/2014/06/01/combining-and-controlling-channels-with-core-dot-asyncs-merge-and-mix/ |
| 17:58 | benjyz1 | this is quite a nice article on merge and mix |
| 17:58 | sdegutis | Remember when Clojure was a Common Lisp spin-off? |
| 18:00 | domgetter | sdegutis: remember when some lispweeines thought it was an abomination? http://www.loper-os.org/?p=42 |
| 18:01 | lokien_ | when I mentioned on #lisp that I use clojure, they called me a troll |
| 18:01 | noncom|2 | well, #lisp is for common lisp only. #lisp-cafe is for lisps in general |
| 18:01 | sdegutis | LOL "I don’t care if everybody really is more productive in Clojure than in Common Lisp." |
| 18:01 | sdegutis | I hope one day to finish implementing my very own Lisp! |
| 18:02 | lokien_ | noncom|2: I was asking about cl, just mentioned I'm familiar with clojure |
| 18:02 | sdegutis | Once it has its own IRC channel, it will be officially a real language! |
| 18:02 | lokien_ | sdegutis: me too |
| 18:03 | noncom|2 | lokien_: yeah, they don't perceive clojure serious.. but some of them use it though |
| 18:04 | noncom|2 | nice one: https://github.com/Habstinat/ParentheticLisp |
| 18:04 | sdegutis | Common Lisp and Haskell have very similar communities. |
| 18:04 | noncom|2 | yeah. and C |
| 18:04 | sdegutis | I think it comes from the purism that both languages seem to aim for. |
| 18:04 | sdegutis | C is awesome. |
| 18:05 | noncom|2 | yeah, just as haskell and common lisp |
| 18:05 | sdegutis | Haskell is neat. |
| 18:05 | lokien_ | noncom|2: it's sad they're so closed and think their tools have no flaws |
| 18:05 | noncom|2 | well, common lisp may seem obscure to some, but i know it's cool |
| 18:05 | sdegutis | CL is weird and boring. |
| 18:05 | lokien_ | sdegutis: some haskell people are nice |
| 18:05 | sdegutis | I bet. |
| 18:06 | noncom|2 | lokien_: just a flavor of the general variety |
| 18:06 | noncom|2 | well, cl was there always |
| 18:06 | noncom|2 | it's what kept lisp on for years |
| 18:06 | noncom|2 | there also was scheme, but it's umm.. a funny one, although not bad |
| 18:07 | lokien_ | and racket, duh |
| 18:07 | noncom|2 | yeah |
| 18:07 | noncom|2 | racket |
| 18:08 | benjyz1 | has anyone attempt writing a webserver in pure clojure? |
| 18:08 | noncom|2 | benjyz1: waht do you mean? you'd have to at least reach for java sockets |
| 18:08 | justin_smith | benjyz1: by "pure" do you mean no interop? if yes, then it's impossible |
| 18:08 | justin_smith | if no, then http-kit is pure clojure |
| 18:09 | noncom|2 | benjyz1: clojure is not about eliminating interop. it's about embracing interop easily when it is needed |
| 18:09 | lokien_ | but where is my c interop? sdegutis? |
| 18:09 | benjyz1 | I mean several projects use netty |
| 18:09 | justin_smith | I take that back, http-kit has a bunch of java code |
| 18:10 | sdegutis | easy |
| 18:10 | sdegutis | noncom|2: what about guile? |
| 18:10 | lokien_ | justin_smith: delete it and it will be pure clojure :) |
| 18:10 | sdegutis | why everyone forgot about guile tho? |
| 18:10 | benjyz1 | netty has some kind of channel semantics. I wonder what would happen if one would use clojure async. |
| 18:10 | lokien_ | isn't it a scheme? |
| 18:10 | lokien_ | guile scheme? |
| 18:10 | justin_smith | benjyz1: see aleph with manifold, it's intended for that sort of thing |
| 18:11 | noncom|2 | benjyz1: there's no point in writing a server in pure clojure. the fact is that most of the concepts underlying a netwrorking interface are better expressed in imperative manner which just works better with how CPUs are made. that's why the roots are always imperative. |
| 18:11 | noncom|2 | aleph also uses a load of java inside afaik |
| 18:11 | sdegutis | Oh man I forgot that CL is a Lisp 2. |
| 18:11 | sdegutis | How stupid. |
| 18:12 | noncom|2 | sdegutis: well, guile is scheme... |
| 18:12 | lokien_ | what about chicken though? |
| 18:12 | noncom|2 | scheme |
| 18:12 | sdegutis | lol nobody uses that anymore |
| 18:12 | lokien_ | I used it! |
| 18:12 | lokien_ | for like 14 minutes |
| 18:12 | noncom|2 | there's also picolisp - a rather neat thing |
| 18:13 | justin_smith | I should make a "c interop" lib that consists solely of the ability to tell the computer to execute a byte array as if it were machine code |
| 18:13 | justin_smith | and just let the user deal with the consequences |
| 18:13 | lokien_ | oh, and pixie!! |
| 18:13 | domgetter | hey look, Ruby is a lisp too! [:+, 1, 2, 3] |
| 18:13 | benjyz1 | noncom|2 : I'm not entirely sure. sockets is in the end a streaming protocol. Actors e.g. is semantics on top of streaming |
| 18:14 | lokien_ | justin_smith: do it please |
| 18:14 | noncom|2 | justin_smith: :D and attribute it like "unsafe" or "unmanaged" functions |
| 18:14 | noncom|2 | benjyz1: not sure about what? |
| 18:14 | benjyz1 | async is not a distributed protocol like Erlang actors |
| 18:14 | sdegutis | pixie looks cool but PyPy freaks me out |
| 18:14 | benjyz1 | about your statement. |
| 18:14 | justin_smith | well even "function" is a few levels of fancy abstraction higher than what I was describing... |
| 18:14 | lokien_ | "pretty safe" is a better attribute |
| 18:15 | noncom|2 | benjyz1: you mean that in erlang networking can be realized solely in terms of erlangian paradigms, without going C ? |
| 18:15 | justin_smith | noncom|2: (def ^:suicidal frob [] (execute-byte-array-as-machine-code b)) |
| 18:15 | noncom|2 | rrrriiiiiight! :D |
| 18:15 | nutnutnutnut | what's a good way of turning [1 2 3] in to [1 :a 2 :a 3 :a]? |
| 18:15 | noncom|2 | interpose + conj ? |
| 18:16 | justin_smith | ,(mapcat #(list % :a) [1 2 3]) |
| 18:16 | clojurebot | (1 :a 2 :a 3 ...) |
| 18:16 | noncom|2 | wow |
| 18:16 | benjyz1 | noncom|2: Erlang, AFAIK, implements pure actors, which means that process on one machine is identical to process on distributed machine |
| 18:16 | lokien_ | justin_smith: why didn't you use c interop for that |
| 18:16 | nutnutnutnut | ! that works well |
| 18:16 | justin_smith | noncom|2: interpose doesn't get you that last :a |
| 18:16 | lokien_ | it'd fit perfectly |
| 18:16 | justin_smith | heh |
| 18:16 | noncom|2 | justin_smith: that's why i put conj there also :D but it looked hacky. i like your way\ |
| 18:16 | benjyz1 | here Hickey wrote a bit about downsides of actors clojure.org/agents |
| 18:17 | lokien_ | also, BEAM is slow |
| 18:17 | domgetter | ,(into [] (interleave [1 2 3] (repeat :a))) |
| 18:17 | clojurebot | [1 :a 2 :a 3 ...] |
| 18:17 | noncom|2 | benjyz1: yeah, sure, but in erlang you have no big freedom over low-level. you're just stuck into acting in its limits. while it's great for it's tasks, it can be slow and stuff |
| 18:17 | sdegutis | nutnutnutnut: I'd like join them with two maps or something |
| 18:17 | nutnutnutnut | yeah i was trying that too... |
| 18:17 | nutnutnutnut | did a repeat of :a and zipmap'd them |
| 18:18 | sdegutis | ,(flatten (map list [1 2 3] (repeat :a))) |
| 18:18 | clojurebot | (1 :a 2 :a 3 ...) |
| 18:18 | sdegutis | ,(pr-str (flatten (map list [1 2 3] (repeat :a)))) |
| 18:18 | clojurebot | "(1 :a 2 :a 3 ...)" |
| 18:18 | sdegutis | clojurebot: WTF ITS NOT THAT LONG A THING JUST PRINT THE WHOLE THING PLZ |
| 18:18 | clojurebot | It's greek to me. |
| 18:18 | sdegutis | clojurebot: dont make me sense a pull request mf |
| 18:18 | clojurebot | Cool story bro. |
| 18:18 | noncom|2 | benjyz1: so when i was saying that there's no point in writing a server in pure clojure, i meant that it cannot be done because clojure does not abstract from JVM like erlang abstracts from C |
| 18:18 | sdegutis | oh man the arrogance of that little bot |
| 18:19 | domgetter | I'm sensing a pull request in the near future... |
| 18:19 | nutnutnutnut | (vec (map (fn [xs] (vec (mapcat #(vector % :a) xs))) a)) |
| 18:19 | nutnutnutnut | any way to get rid of all the vec calls? |
| 18:19 | noncom|2 | noncom|2: clojure actually likes JVM. it just thinks it could use a lispy makeup. but erlang is faaaar from C |
| 18:20 | nutnutnutnut | a is [[0 1 2] [3 4 5] [6 7 8] [0 3 6] [1 4 7] [2 5 8] [0 4 8] [2 4 6]] btw |
| 18:20 | lokien_ | mapv? |
| 18:20 | nutnutnutnut | oo |
| 18:20 | nutnutnutnut | i take it there's no mapcatv as well |
| 18:21 | lokien_ | OH MY GOD WAS I ACTUALLY USEFUL FOR SOMEONE |
| 18:21 | nutnutnutnut | lol |
| 18:21 | justin_smith | nutnutnutnut: why do you need these things to be vectors? |
| 18:21 | nutnutnutnut | yeah you're probably right |
| 18:21 | lokien_ | noncom|2: why are you talking to yourself |
| 18:21 | nutnutnutnut | hopefully they dont need to be |
| 18:21 | amalloy | i agree, you usually don't need vectors. but if you do, you probably use (into []) with a concat transducer or something |
| 18:22 | justin_smith | well I was asking an honest question - if they do need to be vectors then you can figure it out, but maybe they don't need to be |
| 18:22 | nutnutnutnut | everything else is a vector of vectors right now so i was trying to keep it uniform |
| 18:22 | noncom|2 | lokien_: damn, was talking to benjyz1. i keep pressing on my nick. happens for the second time. gotta sleep :D |
| 18:22 | sdegutis | Oh duh |
| 18:22 | nutnutnutnut | might still work though if they're different |
| 18:22 | sdegutis | Why did I miss this |
| 18:22 | lokien_ | noncom|2: I wanted to sleep, but irc is too much fun |
| 18:23 | sdegutis | ,(apply concat (for [a [1 2 3] b [:a]] [a b])) |
| 18:23 | clojurebot | (1 :a 2 :a 3 ...) |
| 18:23 | noncom|2 | lokien_: yeah :D |
| 18:23 | justin_smith | ,(= '(1 2 3) [1 2 3]) |
| 18:23 | clojurebot | true |
| 18:23 | sdegutis | hahaha stupid `for`, you rock |
| 18:25 | amalloy | nutnutnutnut: usually you can just work with a more abstract collection type: "anything sequential" is often good enough |
| 18:25 | nutnutnutnut | lokien_: if you're looking for fun you can try to do https://www.4clojure.com/problem/73#prob-title |
| 18:25 | nutnutnutnut | thats what im working on right now.. i have a really good idea for a solution |
| 18:25 | lokien_ | noncom|2: "I want to be an engineer, dad, I'll build wonderful things and help people" |
| 18:26 | lokien_ | noncom|2: but in reality, I just want to talk on irc |
| 18:26 | noncom|2 | :D well, communication is a wonderful thing actually! |
| 18:26 | lokien_ | nutnutnutnut: what makes me look like a good partner for it? |
| 18:26 | nutnutnutnut | no no not partner |
| 18:26 | nutnutnutnut | race! |
| 18:26 | noncom|2 | everything commutes |
| 18:27 | noncom|2 | except that which does not of course |
| 18:27 | lokien_ | man, I'm in bed for two hours now :( |
| 18:27 | domgetter | like matrix multiplication? That doesn't commute |
| 18:27 | lokien_ | noncom|2: what if world runs on erlang, and we're just actors |
| 18:28 | noncom|2 | next day at work: "man what's up with you? you look like a junkie" ... "mrhh.. i'm on #irc.. " |
| 18:28 | lokien_ | nutnutnutnut: github.com/youarebeautiful/tictactoe |
| 18:28 | lokien_ | nutnutnutnut: I won |
| 18:28 | noncom|2 | heh, yeah, :) |
| 18:28 | nutnutnutnut | boo |
| 18:28 | lokien_ | noncom|2: "I'm a professional hacker" |
| 18:29 | noncom|2 | esp if you irc from emacs |
| 18:29 | noncom|2 | or at least vim :) |
| 18:29 | lokien_ | nutnutnutnut: I hacked back in time to do that and ashame you |
| 18:29 | nutnutnutnut | gasp! |
| 18:30 | lokien_ | noncom|2: tty3, be a man |
| 18:30 | lokien_ | I hand craft my connections in c |
| 18:30 | lokien_ | every time |
| 18:31 | noncom|2 | ahahh :D |
| 18:31 | noncom|2 | and use a repl to send messages |
| 18:31 | noncom|2 | with a lisp written byself in c |
| 18:32 | lokien_ | and lint messages on the fly with perl, to not make grammar mistakes |
| 18:33 | lokien_ | anyway, I'm going to sleep, you addicting group of nice people |
| 18:33 | noncom|2 | good night! |
| 18:33 | lokien_ | kind is a better word, actually |
| 18:33 | noncom|2 | class |
| 18:33 | lokien_ | g'night, beautiful clojuristas |
| 18:37 | nutnutnutnut | hmmmmmmmmmmmmmmmmmmmmmmmmmmmm |
| 18:37 | nutnutnutnut | not sure how to do this |
| 18:37 | nutnutnutnut | is it possible to.. |
| 18:37 | nutnutnutnut | so im doing something like this: (mapcat #(vector % p) xs) |
| 18:38 | nutnutnutnut | for p i want to be able to pass in :o, :x, or (z %) |
| 18:38 | nutnutnutnut | for the last case it should actually evaluate it |
| 18:38 | nutnutnutnut | is there a consise way of doing that? |
| 18:38 | domgetter | nutnutnutnut: you don't like (mapv #(vec (interleave % (repeat :a))) a) ? |
| 18:39 | nutnutnutnut | i mean that works fine but in either case i have that problem |
| 18:39 | nutnutnutnut | z is a local variable btw |
| 18:39 | nutnutnutnut | in context of the outer function it's in |
| 18:39 | justin_smith | ,(mapcat #(list % (%2 %)) [1 2 3] [(constantly :b) (constantly :c) identity]) |
| 18:39 | clojurebot | (1 :b 2 :c 3 ...) |
| 18:41 | nutnutnutnut | o |
| 18:41 | nutnutnutnut | constantly.. hmm ok |
| 18:41 | justin_smith | that way it's consistent - you call the second item every time |
| 18:41 | justin_smith | sometimes it uses the arg, sometimes not |
| 18:41 | nutnutnutnut | very clever! |
| 18:51 | souterrain | So, constantly rather than evaluating argument many times just returns a function that gives the same result? |
| 18:52 | souterrain | So, very useful for functions that have side effects you only want to trigger once? |
| 18:52 | justin_smith | that's one use for it |
| 18:52 | justin_smith | see also memoize |
| 18:53 | justin_smith | or even delay |
| 18:53 | nutnutnutnut | does anyone know if you can use eval in 4clojure? |
| 18:53 | justin_smith | ~eval |
| 18:53 | clojurebot | eval is sometimes useful - but only sometimes |
| 18:53 | blake__ | nutnutnutnut: I don't think so. I think it's verboten. |
| 18:53 | souterrain | ok, looking... sorry, total clojure noob here, but this is the most excited I've been about writing code in about 15 years :) |
| 18:54 | nutnutnutnut | damn |
| 18:54 | justin_smith | heh |
| 18:54 | nutnutnutnut | justin how do i do this without eval :? |
| 18:54 | justin_smith | one moment, setting up a migration (day job) |
| 18:54 | nutnutnutnut | okie dokie |
| 18:55 | sdegutis | setting up? |
| 18:55 | sdegutis | oh right you're not using datomic |
| 18:55 | justin_smith | :P |
| 18:55 | sdegutis | :D |
| 18:56 | souterrain | justin_smith: ok, so there are many ways to deal with, say, network side effects. (HTTP GETs, PUTs, etc.) |
| 18:56 | souterrain | wow, POSTs, not PUTs. |
| 18:57 | nutnutnutnut | hmmmm |
| 18:57 | souterrain | who uses PUT |
| 18:57 | nutnutnutnut | idk if clojure understands what im trying to do |
| 18:58 | sdegutis | compojure does afaik |
| 18:58 | sdegutis | compojure also respects the "_method" param |
| 18:58 | sdegutis | its super magic |
| 18:59 | nutnutnutnut | is it possible to send a list like this '(z %) to inside an anonymous shorthand function and then eval it? |
| 18:59 | nutnutnutnut | clojure keeps saying he doesnt know what % is |
| 18:59 | nutnutnutnut | z is a local binding |
| 18:59 | sdegutis | probably not |
| 18:59 | nutnutnutnut | grr |
| 18:59 | nutnutnutnut | theres gotta be a way to do this lol |
| 18:59 | sdegutis | ,((fn [a] (eval 'a)) 2) |
| 18:59 | clojurebot | #error {\n :cause "Unable to resolve symbol: a in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: a in this context"\n ... |
| 19:00 | nutnutnutnut | ok so clojure cant do that then |
| 19:00 | sdegutis | anyway look |
| 19:00 | sdegutis | https://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#L17-L18 |
| 19:00 | nutnutnutnut | is there any alternative? |
| 19:00 | nutnutnutnut | i cant use eval anyway i guess |
| 19:00 | nutnutnutnut | because of 4clojure |
| 19:00 | sdegutis | just run it in lein repl |
| 19:00 | justin_smith | nutnutnutnut: if you do it the way I did before, just pass in z, and let the function inside call z on the arg |
| 19:01 | nutnutnutnut | hmm ok ill take another look |
| 19:06 | nutnutnutnut | hooray it worked! |
| 19:06 | nutnutnutnut | ok almost done ...! |
| 19:06 | nutnutnutnut | this is gonna be the best solution |
| 19:08 | nutnutnutnut | hmm |
| 19:09 | nutnutnutnut | for some reason doing (pos? (count (intersection set1 set2))) works |
| 19:09 | nutnutnutnut | but just calling subset? doesnt work |
| 19:09 | nutnutnutnut | arent those statements equivalent? |
| 19:09 | nutnutnutnut | tried both superset and subset. neither worked |
| 19:17 | justin_smith | nutnutnutnut: depends, are the args both sets? |
| 19:18 | nutnutnutnut | yeah |
| 19:19 | domgetter | nutnutnutnut they are not equivalent |
| 19:19 | domgetter | a set may share elements with another but not be a subset |
| 19:19 | justin_smith | ahh, right |
| 19:19 | justin_smith | (inc domgetter) |
| 19:19 | justin_smith | d'oh |
| 19:20 | domgetter | consider #{1 2 3} and #{2 3 4}. the count of their intersection is 2, since their intersection is #{2 3}, but neither is a subset of the other |
| 19:20 | justin_smith | domgetter is a witch |
| 19:20 | nutnutnutnut | oh right |
| 19:20 | nutnutnutnut | in that case.. is there a more concise way of writing this? (pos? (count (clojure.set/intersection (set list1) (set list2)))) |
| 19:21 | justin_smith | ,(boolean (filter (set list1) list2)) |
| 19:21 | justin_smith | err, sorry |
| 19:21 | clojurebot | #error {\n :cause "Unable to resolve symbol: list1 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: list1 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: list1 in this... |
| 19:21 | nutnutnutnut | ahh poor clojurebot |
| 19:21 | nutnutnutnut | ! |
| 19:21 | domgetter | (not (empty? (intersection s1 s2))) perhaps |
| 19:21 | justin_smith | ,(boolean (filter #{1 2 3} [3 4 5])) |
| 19:21 | clojurebot | true |
| 19:22 | justin_smith | domgetter: I think filter might be cheaper than intersection... |
| 19:22 | nutnutnutnut | ,(filter #{1 2 3} [3 4 5]) |
| 19:22 | clojurebot | (3) |
| 19:22 | nutnutnutnut | ah |
| 19:22 | justin_smith | ,(boolean (some #{1 2 3} [3 4 5])) |
| 19:22 | clojurebot | true |
| 19:22 | justin_smith | even better |
| 19:22 | justin_smith | only needs one result |
| 19:22 | justin_smith | nutnutnutnut: a set acts as a function which looks its arg up in itself |
| 19:23 | justin_smith | that sentence looks weird... |
| 19:23 | nutnutnutnut | yeah i always forget that |
| 19:24 | justin_smith | ,(defn kanye [x] (= kanye x)) |
| 19:24 | clojurebot | #'sandbox/kanye |
| 19:24 | justin_smith | ,(kanye kanye) |
| 19:24 | clojurebot | true |
| 19:24 | justin_smith | ,(kanye :anything-else) |
| 19:24 | clojurebot | false |
| 19:24 | justin_smith | that's probably got a name in the lambda calculus |
| 19:24 | justin_smith | but I'll just call it the kanye function |
| 19:24 | nutnutnutnut | omg this solution is gonna be soooooooo good |
| 19:25 | nutnutnutnut | im so excited lol. i keep looking at how clever that 'constantly' use is |
| 19:25 | nutnutnutnut | never would have thought of that |
| 19:53 | nutnutnutnut | !!!!!! done! |
| 19:53 | nutnutnutnut | omg this is so good |
| 19:56 | nutnutnutnut | ok here's the code. i think there may be some ways to get rid of the vec calls but not sure.. http://pastebin.com/8Di5ykEW |
| 19:56 | nutnutnutnut | spoilers 4clojure level 73 |
| 19:56 | nutnutnutnut | can anyone see any more ways to shorten it? |
| 19:57 | nutnutnutnut | besides things like variables names, etc. |
| 19:58 | justin_smith | (vec (flatten board)) could be (reduce into [] board) |
| 19:59 | nutnutnutnut | flatten is actually a character shorter :p |
| 19:59 | justin_smith | flatten is terrible |
| 19:59 | justin_smith | and with reduce into it's a vector from the get-go, no need for vec |
| 19:59 | nutnutnutnut | yeah i just mean (vec (flatten board)) is 21 characters and (reduce into [] board) is 22 characters |
| 20:00 | nutnutnutnut | my friend and i both did this problem and we're seeing who can beat it in less characters |
| 20:00 | justin_smith | OK, but the latter is doing less work, but if character count is the thing (apply concat board) |
| 20:01 | nutnutnutnut | haha nice 1 character savings |
| 20:01 | nutnutnutnut | oh wait |
| 20:01 | nutnutnutnut | i only use z in one place |
| 20:01 | nutnutnutnut | i can just inline that |
| 20:02 | nutnutnutnut | same with w |
| 20:03 | domgetter | (let [r reduce i into b board] (r i [] b)) |
| 20:04 | justin_smith | haha |
| 20:04 | nutnutnutnut | updated: http://pastebin.com/iiL6M4af |
| 20:04 | nutnutnutnut | domgetter: not sure what you mean by that |
| 20:05 | domgetter | just bein silly |
| 20:06 | nutnutnutnut | i wish the word constantly wasnt so long haha |
| 20:07 | justin_smith | #(do % x) is the shortest version of (constantly x) (if you know it gets one arg) |
| 20:07 | domgetter | nutnutnutnut: you *can* def anything you want |
| 20:07 | domgetter | (def con constantly) |
| 20:07 | justin_smith | (fn [_] x) ? |
| 20:07 | nutnutnutnut | yeah not sure if it would be worth it though |
| 20:08 | nutnutnutnut | i think it'd be around the same amount of characterrs |
| 20:08 | domgetter | I just wanted to write def con |
| 20:08 | justin_smith | (fn [_] x) isn't so bad, and saves chars |
| 20:08 | nutnutnutnut | also i dont think 4clojure allows def |
| 20:08 | justin_smith | (fn[_]x) saves chars the messy way |
| 20:08 | nutnutnutnut | why that over do? |
| 20:11 | justin_smith | ,(map count ["#(do x)" "(fn[_]x)"]) |
| 20:11 | clojurebot | (7 8) |
| 20:11 | justin_smith | hmm |
| 20:12 | justin_smith | oh, wait |
| 20:12 | justin_smith | ,(map count ["#(do % x)" "(fn[_]x)"]) |
| 20:12 | clojurebot | (9 8) |
| 20:12 | justin_smith | it needs the % |
| 20:12 | nutnutnutnut | see anything else justin_smith? http://pastebin.com/3A0meCny |
| 20:13 | nutnutnutnut | lol so gross |
| 20:13 | justin_smith | list is shorter than vector |
| 20:13 | justin_smith | and I bet a list would be as good as a vector where you are calling it |
| 20:14 | nutnutnutnut | yeah changing that vector to list worked |
| 20:14 | justin_smith | and I don't think you need the (vec ...) call at all |
| 20:14 | nutnutnutnut | oh nice i could get rid of the other vector call too |
| 20:14 | justin_smith | you can probably take that out |
| 20:14 | nutnutnutnut | wasnt working earlier |
| 20:14 | justin_smith | yeah |
| 20:14 | nutnutnutnut | oh wait |
| 20:14 | nutnutnutnut | hold on |
| 20:14 | nutnutnutnut | maybe not |
| 20:14 | nutnutnutnut | forgot to redef it |
| 20:15 | justin_smith | and I think mapv could be map |
| 20:17 | nutnutnutnut | yeah whoops ive been running the wrong version |
| 20:17 | nutnutnutnut | i dont think the apply concat trick from earlier worked |
| 20:17 | nutnutnutnut | when i do that some of the code is lists and some of it is vectors |
| 20:17 | nutnutnutnut | and it stops giving correct output |
| 20:18 | nutnutnutnut | it'd be nice if this could work just on sequences because all the vector calls take up space |
| 20:19 | justin_smith | well (reduce into s) is the same as (reduce into [] s) if the first element of s is a vector |
| 20:23 | justin_smith | oh I see you are using p as a function, and p is each element of w |
| 20:24 | nutnutnutnut | yea? |
| 20:24 | justin_smith | no, wait... |
| 20:24 | justin_smith | you are calling get |
| 20:24 | justin_smith | if you changed get to nth it would work without vectors |
| 20:25 | nutnutnutnut | also are you sure that (fn [_] :x) trick works? |
| 20:25 | nutnutnutnut | i tried changing constantly to it and am getting errors |
| 20:25 | justin_smith | how many args do you provide? the count has to match |
| 20:26 | justin_smith | with two args it is (fn[_ _]x) |
| 20:26 | justin_smith | etc. |
| 20:26 | nutnutnutnut | ah |
| 20:26 | justin_smith | oh (fn[&_]x) - this accepts any number of args |
| 20:27 | nutnutnutnut | like this? (set (f (fn [&_] :x))) :x |
| 20:27 | nutnutnutnut | maybe ill just stick to constantly. only an extra couple characaters |
| 20:28 | justin_smith | ,(map (partial apply (fn[&_]42)) [[][1][1 2][1 2 3]]) |
| 20:28 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox/eval25/fn--26> |
| 20:28 | justin_smith | ,(map (partial apply (fn[& _]42)) [[][1][1 2][1 2 3]]) |
| 20:28 | clojurebot | (42 42 42 42) |
| 20:29 | justin_smith | aha! |
| 20:29 | nutnutnutnut | ohhh |
| 20:29 | justin_smith | [&_] is not the same as [& _], my bad |
| 20:29 | nutnutnutnut | (fn[& _]:x)) is 12 and (constantly :x) is 15 |
| 20:29 | nutnutnutnut | ill probably just use constantly for clarity |
| 20:31 | justin_smith | makes sense |
| 20:31 | nutnutnutnut | ok justin_smith updated version: http://pastebin.com/MPturzBX |
| 20:31 | nutnutnutnut | and this one works i triple checked |
| 20:32 | nutnutnutnut | oh right i can change mapv to map.. another character |
| 20:32 | nutnutnutnut | unless you see something else i think that might be it |
| 20:33 | nutnutnutnut | o the reduce thing |
| 20:33 | nutnutnutnut | ill try that |
| 20:33 | nutnutnutnut | yeah that worked |
| 20:34 | nutnutnutnut | justin_smith: version 5 http://pastebin.com/rruNSdsz |
| 20:35 | nutnutnutnut | i cant wait to see everyone else's solutions when i submit |
| 20:36 | justin_smith | nutnutnutnut: neat |
| 20:36 | nutnutnutnut | do you see anything else or do you think that about covers it? |
| 20:38 | justin_smith | (juggling) |
| 20:41 | justin_smith | that vector of numbers.... |
| 20:41 | nutnutnutnut | what about it? |
| 20:41 | justin_smith | ((juxt identity #(apply map list %&)) (partition 3 (range 9))) |
| 20:42 | nutnutnutnut | what! |
| 20:42 | nutnutnutnut | black magic! |
| 20:42 | nutnutnutnut | how'd you do that |
| 20:42 | justin_smith | that's not quite it |
| 20:42 | nutnutnutnut | yeah you're missing diagonals right? |
| 20:42 | nutnutnutnut | knew it was too good to be true :p |
| 20:43 | justin_smith | ,(apply into ((juxt vec #(apply map list %)) (partition 3 (range 9)))) |
| 20:43 | clojurebot | [(0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) ...] |
| 20:44 | justin_smith | oh yeah, it's missing diagonals... |
| 20:45 | justin_smith | any matrix geniuses know a concise way to add the diagonals to that? |
| 20:45 | justin_smith | heh |
| 20:45 | nutnutnutnut | lol |
| 20:49 | justin_smith | ,(reduce into ((juxt vec #(apply map list %) (comp list (partial map-indexed #(nth %2 %)))) (partition 3 (range 9)))) |
| 20:49 | clojurebot | [(0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) ...] |
| 20:49 | justin_smith | missing one of the diagonals |
| 20:50 | justin_smith | but it has the other one (in a totally stupi way) |
| 20:50 | nutnutnutnut | justin_smith: newer version: http://pastebin.com/M5gt42Yy |
| 20:50 | turbofail | could just be #(map nth % [0 1 2]) |
| 20:50 | justin_smith | turbofail: good point, that could give both diagonals mutatis mutandis |
| 20:51 | nutnutnutnut | that's a phrase i've never heard before |
| 20:54 | justin_smith | nutnutnutnut: if you google it the def. is the top hit |
| 20:54 | nutnutnutnut | yeah i read it |
| 20:54 | nutnutnutnut | neato |
| 20:54 | justin_smith | nutnutnutnut: basically it means "we all know the difference, so changing those parts..." |
| 20:54 | justin_smith | heh |
| 20:54 | justin_smith | useful when someone is goalpost moving in an argument :) |
| 20:59 | turbofail | i wouldn't be surprised if the literal sequence still ends up being shorter |
| 20:59 | justin_smith | turbofail: fair |
| 20:59 | turbofail | the code is a little nicer to look at though |
| 20:59 | turbofail | for some reason |
| 21:00 | turbofail | i feel like my brain turns off when i see too much literal data |
| 21:00 | neoncontrails | Still having some syntax trouble. The goal is easy peasy: there's a big map, has strings on keys, vals are vectors of lists of keywords. Want hashsets of the keywords. I've written that component. |
| 21:00 | justin_smith | some people's brains turn off when they see (juxt comp apply partial comp into) |
| 21:00 | turbofail | haha |
| 21:00 | turbofail | true |
| 21:01 | neoncontrails | Update-in seems like the ideal method for this, but I can't quite figure out how to use it on a map that isn't an atom, and has no special keywords |
| 21:02 | rhg135 | does that have any practical use? |
| 21:02 | justin_smith | ,(reduce into #{} ({"a" [[:a :b] [:c :d]]} "a")) ; neoncontrails - like this? |
| 21:02 | clojurebot | #{:c :b :d :a} |
| 21:03 | justin_smith | neoncontrails: oh, you want it still in a hash-map, but sets instead of vectors of lists? |
| 21:03 | justin_smith | ,(into {} (map (fn [[k v]] [k (reduce into #{} v)]) { |
| 21:03 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 21:03 | neoncontrails | justin_smith: hash-map of strings to hash sets I think, yeah |
| 21:04 | justin_smith | ,(into {} (map (fn [[k v]] [k (reduce into #{} v)]) {"a" [[1 2 3][4 5 6]] "b" [[1 2][5 6][6 7]]})) |
| 21:04 | clojurebot | {"a" #{1 4 6 3 2 ...}, "b" #{7 1 6 2 5}} |
| 21:04 | justin_smith | that should do what you want? or close to it |
| 21:05 | justin_smith | you don't need update-in, since you know you want to operate on every key |
| 21:07 | neoncontrails | justin_smith: very close to it, give me onnne sec this is quite helpful |
| 21:17 | neoncontrails | justin_smith: I'm noticing a theme in my errors, it's nesting depth related. Kludging nested sequences over the head with into/reduce/merge/flatten, but not familiar enough to predict the nesting structure of the output |
| 21:17 | neoncontrails | Seen any good practice resources? In scheme we had these handy things called box and pointer diagrams that helped me a lot |
| 21:18 | neoncontrails | Clojure's not so easily diagrammed though I fear |
| 21:24 | turbofail | any approach you'd use to understand that with scheme would also work in clojure |
| 21:59 | justin_smith | clojure just has more shapes of boxes |
| 22:12 | akabander | Is anyone else having trouble getting to http://clojure.org? |
| 22:13 | justin_smith | yup |
| 22:13 | kenrestivo | akabander: http://www.isup.me/ |
| 22:13 | kenrestivo | er, http://downforeveryoneorjustme.com/clojure.org |
| 22:18 | turbofail | huh. i get connection refused from home, but from my brother's server i get 302 found, but it appears to lead to some sort of infinite redirect loop |
| 22:18 | akabander | Weird, bummer... Thanks though. |
| 22:40 | neoncontrails | What's a good rule of thumb, ballpark figure for the memory footprint of a typical clojure vector? |
| 22:41 | neoncontrails | You can assume it doesn't contain any floats or long strings :) |
| 22:44 | TimMc | neoncontrails: A vector less than 32 elements would just be an Object[32] with not much else, I think... |
| 22:45 | neoncontrails | How many bytes would typically get allocated per cell? |
| 22:46 | TimMc | "per call"? |
| 22:46 | justin_smith | for a one element vector, enough to hold 64 Object pointers |
| 22:46 | justin_smith | cell |
| 22:46 | TimMc | 64... because of the tail? |
| 22:46 | justin_smith | err, 32 64 bit, of course |
| 22:46 | TimMc | ok |
| 22:46 | justin_smith | with some small overhead for the tail yeah |
| 22:46 | TimMc | plus there are ~8 supporting instance fields |
| 22:47 | justin_smith | if you actually look at one in the inspector, it's kind of weird |
| 22:47 | justin_smith | yeah |
| 22:47 | neoncontrails | justin_smith: awesome thank you |
| 22:47 | TimMc | neoncontrails: Try allocating a bunch and see what happens. :-) |
| 22:47 | justin_smith | neoncontrails: but note that a 31 element vector is exactly the same size |
| 22:48 | justin_smith | and then a 32 element one would be big enough to hold 64 objects, etc. |
| 22:49 | neoncontrails | TimMc: I'll report back, just trying to make sure my aspirations are within what I pay for on my cloud server heh |
| 23:22 | turbofail | nutnutnutnut: here's my version of the whole problem http://sprunge.us/EjHb |
| 23:22 | nutnutnutnut | ! |
| 23:23 | nutnutnutnut | does it work? |
| 23:23 | turbofail | yeah |
| 23:24 | nutnutnutnut | gives nil when i run it |
| 23:24 | turbofail | we're doing this one right? https://www.4clojure.com/problem/73 |
| 23:24 | nutnutnutnut | yea |
| 23:25 | nutnutnutnut | oh wait i got it |
| 23:26 | turbofail | you can't use defn in 4clojure i suppose |
| 23:26 | turbofail | so it'd just be (fn win? ...) |
| 23:28 | turbofail | http://imgur.com/bQyMVRu |
| 23:28 | nutnutnutnut | trying to understand it now |
| 23:29 | turbofail | the board input already gives you a sequence of rows |
| 23:29 | turbofail | (apply map list b) gives you a sequence of columns |
| 23:30 | turbofail | and the other two bits are to get the diagonals |
| 23:30 | turbofail | then i just look for any row, column, or diagonal that has either all :x or all :o |
| 23:30 | nutnutnutnut | clever! |
| 23:31 | nutnutnutnut | simple too |