#clojure logs

2016-01-13

00:16neoncontrailsI 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:17neoncontrailsI'm assuming you wouldn't call it directly from the DOM, but via some HTTP post transaction that contains the relevant data
00:38neoncontrailsPhew, figured it out. Heroku's explanation is a lot easier to follow https://devcenter.heroku.com/articles/clojure-web-application
01:05RaynesSup brodudes
01:06RaynesHow's Clojureland
02:29TEttingerRaynes!
02:29TEttingerhow's refheap?
02:30RaynesTEttinger!
02:30TEttingerpaste still works it seems
02:30RaynesTEttinger as expected, my announcement induced sheer terror despite that honestly it's a shitty pastebin.
02:31TEttingerwell, to be perfectly fair, yes.
02:31TEttingerI tried to paste a large text in there
02:31RaynesI removed the paste in question and worked with Namecheap support and citibank has yet to file lawsuits, so I think I'm okay.
02:31TEttingerit froze my browser
02:31RaynesBut I think it's time to let it go. I don't have a legal time.
02:31RaynesBecause ancient version of codemirror.
02:31RaynesLet's just use gist, guys.
02:31RaynesSeriously, I'm not offended.
02:32ianhedoesitwait, what about refheap?
02:32RaynesI'm gonna make the site read only or static.
02:32TEttingerI believe it was https://gist.githubusercontent.com/tommyettinger/9079f8f882db658f301f/raw/eb452cd90915c558cd9ece03ee30af829dda059e/layer-dungeon.txt
02:32RaynesI've got spamming issues and malicious pastes.
02:32TEttingerok. can you maybe update lazybot? :)
02:32TEttingerso it doesn't paste to refheap?
02:32ianhedoesitRaynes: ah
02:32RaynesIf you'd like to take this current sprint I'm in.
02:33TEttingerso it would need to use a Gist API of some sort?
02:33RaynesI wrote one lol
02:33Raynestentacles
02:33TEttingergreat!
02:33RaynesI think there's even still code there for it.
02:34TEttingerto the lapserver on the floor underneath a piece of furniture!
02:34RaynesAnyways, the refheap plan is currently to either make it read only and deal with webservers or make it static.
02:34RaynesI'm at a standing desk bro
02:34RaynesGet with it
02:35TEttingerRaynes: do you even bend, bro? http://i.imgur.com/47RoA.jpg
02:35ianhedoesitbut who took the picture
02:36RaynesTEttinger: 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:36TEttinger3ianhedoesit: also me, with my chin
02:37ianhedoesithm, I was more hoping your answer would be "timer"
02:37TEttinger3it was still pretty difficult
05:08noncomwas 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:08noncomwhy so?
05:10noncomah, https://bugs.openjdk.java.net/browse/JDK-8061549
05:11noncomstill no clue as to why
05:11noncomthey say they reserv the identifier...
05:12noncomwhat for could they reserve it?
05:12noncomthat's weird
05:29amalloynoncom: look at how scala uses _
05:30amalloy(_ + 1) is scala's #(+ % 1)
06:21lokiendo we use multidimensional arrays (vectors) in clojure?
06:25MJB47lokien: yes for both vectors and arrays
06:26lokienMJB47: can you show me an example?
06:26MJB47,[[1 2] [3 4]]
06:26clojurebot[[1 2] [3 4]]
06:27MJB47,(map first [[1 2] [3 4]])
06:27clojurebot(1 3)
06:27lokienoh, well, it's that easy. thanks
07:19visof,(Integer/parseInt "ff726867" 16)
07:19clojurebot#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:19visofhi guys
07:19visofhow can i fix this?
07:27visof,(Long/parseLong "ff726867" 16)
07:27clojurebot4285687911
07:27visofgood!
09:03geroldHi. I’m wondering if clojure has any means to import a set of objects into the namespace at runtime
09:04geroldThe use case is that I want to generate a bunch of closures, based on a function that I supply at runtime
09:05geroldthese closures should be available without explicitly passing the to-be-closed upon function object each time
09:05geroldscala has a nifty feature called ‘implicit arguments’ for that use case
09:07geroldto illustrate:
09:07gerold(defn generate-set-of-functions [foo]
09:07gerold { :function1 (fn [x] (do-something-with foo x)), :function2 (fn [x] (do-something-with foo x)) })
09:07geroldhow would i import function1 and function2 into my namespace, after calling generate-set-of-functions
09:23gerold..an ugly solution to my problem is to just call def within the function generate-set-of-functions.
09:26jonathanjnot quite the same thing, but perhaps you want a protocol?
09:37geroldjonathanj:
09:38geroldthat certaily looks useful, but its not quite what i wanted
09:39gerolda 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:40jonathanjyes, i think that generally you should prefer explicitness to implicitness
09:40jonathanjyou could probably use ^:dynamic and rebind things, but that will rebind them globally
09:42geroldjonathanj: 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:43geroldIn python, one could do locals().add({“function1”: …, “function2”: ...})
09:43jonathanjand most people would tell you that's basically an awful idea
09:43opqdonutgerold: you can use intern to add a single var to a ns: https://clojuredocs.org/clojure.core/intern
09:44opqdonutbut I'd go for an object with methods or equivalent too
09:44geroldopqdonut: ah. how is that different from calling def/defn, btw?
09:45geroldit feels really strange to me that I can even use nested def expressions
09:45opqdonutwell it's dynamic
09:45opqdonutyou can use code to generate the symbol or something
10:08jonathanjhow do the clojure.java.jdbc `db-spec` maps work?
10:10jonathanjif 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:12jonathanji 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:12jonathanjor is the way to do that just to dissoc `:connection`?
10:40lunkhello, im struggling to create an array if length n,with a tyle defined in java code as static
10:41lunk(into-array Object (repeatedly 5 pkg.class/staticobj))
10:41lunkany suggestions would be greatly appreciated
10:42lunkapi i dont own needs an arbitrary length array as input
10:43jonathanjwhat's the actual problem?
10:45jonathanjit's not quite clear what pkg.class/staticobj is, but i don't think you can pass that macro as f to repeatedly
10:45lunkjonathanj: that question for me?
10:46lunkah
10:46jonathanji think you might need to do: #(pkg.class/staticobj)
10:47lunkits 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:47lunksry, on my phone, silly corp firewalls
10:48lunkthat was it
10:48lunkty so much
10:50lunk(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:36matthavener_pr0t0type_: imho, its certainly possible, but not very easy
11:36matthavener_pr0t0type_: i migrated a project to cljs once and did it a page-at-a-time (though i never finished :))
11:40neoncontrailsmatthavener: which parts of the migration did you find most challenging?
11:47matthavenerwriting my frontend to deal with the same backend weirdness the legacy frontend dealt with
11:47matthavenerand trying to share CSS
11:47matthavenerbut I was going YUI3 -> Om
11:47matthavenerso.. it was essentially a per-page rewrite. I didn't try to share code
12:02neoncontrailsmatthavener: 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:31justin_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:33j-pbAm 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:34domgetterj-pb: you can filter results in google with the minus operator
12:34domgettersome-func -crossclj
12:35j-pbdomgetter: 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:10matthavenerneoncontrails: hrm, I dont know
13:15sdegutisIt seems like extend-protocol and defmethod aren't really suitable for a reloadable workflow, right?
13:19TimMcright
13:20sdegutisHmm.
13:20sdegutisBut on the other hand, I like the idea of extending compojure.response/Renderable rather than replacing Compojure.
13:21sdegutisI'm so conflicted.
13:22TimMcdefoncerecord ;-)
13:24sdegutishaha!
13:24sdegutis(inc TimMc)
13:24sdegutisum, where's the bot?
13:26allenj12,(inc 1)
13:26clojurebot2
13:26allenj12^
13:27sdegutis,(def TimMC 100)
13:27clojurebot#'sandbox/TimMC
13:27sdegutis,(inc TimMC)
13:27clojurebot101
13:27sdegutisYay.
13:30sdegutisAlso, 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:31sdegutisSo returning (fn[req](fn[req)(fn[req]"foo")) is the same as returning "foo"
13:32lxsameerhey folks, how clojurescript take advantage of core.async? does it use web workers?
13:33Glenjaminsdegutis: there's quite a lot of implementations of the Renderable protocol shipped with compojure, I was pleasantly surprised when i found them
13:33sdegutisinorite
13:34sdegutisI always wondered where the magic was that let you return just a string instead of a map.
13:35Glenjaminhttps://github.com/weavejester/compojure/blob/master/src/compojure/response.clj#L21 IDeref, MultiFn & URL are some fun ones there
13:36hiredmanno it doesn't use webworkers
13:37neoncontrailsInteresting 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:37hiredmanthe way you implement csp in a single threaded environment is channel operations hand off control between different logical threads
13:38neoncontrailsYour 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:38hiredmanI am pretty sure that is how core.async does it in clojurescript, but I haven't actually looked at it
13:39hiredmanneoncontrails: inverted index
13:39neoncontrailsYou have mappings for about 100k English words, and the phoneme lists are comprised of ~42 possible phonemes
13:40neoncontrailshiredman: that rings a bell, but I'm not sure I learned that one. *goes to wikipedia*
13:40Glenjamini was about to say the same, datastructure should model the problem, rather than the data
13:41amalloywell, you start with a data structure that models the data, and then process it into one that models the problem
13:42cap10morganlxsameer: 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:42lxsameercap10morgan: thanks
13:43hiredmaninfact, even on the jvm the execution of go blocks can be interleaved on a thread
13:43neoncontrailshiredman: nice, this was the solution I was imagining before I knew what it was called. Thanks
13:45domgetterneoncontrails: are you using the Carnagie Mellon Pronouncing Dictionary? http://www.speech.cs.cmu.edu/cgi-bin/cmudict
13:47neoncontrailshiredman: should I be concerned about memory overflows if I go this route? 42 phonemes on keys, 42 potentially large hashsets on vals.
13:47neoncontrailsdomgetter: that's the one
13:47hiredmanuse lucene
13:48hiredmanI mean, I don't know, it depends how much memory you have and what all you are doing
13:49hiredmanI think lucene may have the most highly tuned inverted index implementation
13:53neoncontrailsThis is just a pet project of mine, no need to use Lucene. (I hear it's a steep learning curve)
14:03xemdetianeoncontrails, 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:03xemdetiaaka you just can't fumble your way through it without reading at least SOME of the docs
14:04domgetterneoncontrails: https://github.com/weavejester/clucy
14:07neoncontrailsInteresting. Is Lucene just a database that happens to be optimized for this type of problem?
14:09elvis4526Is there a thing like admix and mix but in reverse ?
14:09neoncontrailsI know it's conventionally called a search engine, but this looks like plain ol' database syntax
14:09xemdetiaIt's more a specialized datastore
14:09elvis4526(a mix of outputs instead of inputs)
14:10xemdetiathey 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:10justin_smithelvis4526: you mean fan out rather than fan in?
14:11justin_smiththat would be pub and sub
14:11Kamuelai’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:26hiredmanwith 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:26sdegutisHi.
14:27lukaszkHi 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:33justin_smithlukaszk: there might be something in clj-time, if not clj-time has the tools you would use to build it
14:33lukaszkjustin_smith: thanks! I'll have a look
14:35justin_smithlukaszk: 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:36lukaszkjustin_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:52neoncontrailsIs 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:52neoncontrails,(into #{} (flatten [(:T :AH0 :M :EY1 :T :OW2) (:T :AH0 :M :AA1 :T :OW2)]))
14:52clojurebot#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:53justin_smithwait, what are you trying to do? that's a set not a map
14:54justin_smithneoncontrails: also, we don't have casts, that's a javac thing
14:54neoncontrailsjustin_smith: set, my bad
14:54neoncontrails(into #{} (flatten ['(:T :AH0 :M :EY1 :T :OW2) '(:T :AH0 :M :AA1 :T :OW2)]))
14:56justin_smith,(reduce into #{} ['(:T :AH0 :M :EY1 :T :OW2) '(:T :AH0 :M :AA1 :T :OW2)])
14:56clojurebot#{:M :AA1 :OW2 :T :AH0 ...}
14:58neoncontrailsjustin_smith: brilliant. I suspected reduce would be my friend here
15:01neoncontrailsjustin_smith: just out of curiosity are type conversions in Clojure handled differently than they are in Java?
15:02justin_smithneoncontrails: a cast is not the same as a type conversion
15:02justin_smitha 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:02neoncontrailstrue, right. Inheritance plays a roll
15:02neoncontrails*role
15:08justin_smithneoncontrails: 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:13neoncontrailsjustin_smith: my Java's a little rusty, but that sounds similar to the way JVM treats generics. Is that what Clojure symbols are?
15:14justin_smithneoncontrails: the jvm doesn't treat generics. Generics exist only in javac, there is no presence of generics in the bytecode or vm.
15:15justin_smithon 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:17neoncontrailsHuh. I didn't know that, but it makes sense. Even generics that implement a Java library class?
15:17justin_smithgenerics don't implement anything
15:18justin_smithyou just have a value of type Object, or a collection of Object
15:19justin_smithand 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:19TimMcwell
15:19TimMcArrayList<String> is still really an ArrayList, not an instance of Object
15:20TimMcbut it doesn't know about the String part
15:20justin_smithTimMc: oh, right, that's the thing I called "a collection of Object"
15:20TimMcah, yeah
15:20justin_smithsorry if I was sloppy there
15:20TimMcIt's an ArrayList of Object, yes
15:23neoncontrailsInteresting. 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:23justin_smithneoncontrails: there is no spoon
15:23neoncontrailsjustin_smith: aaah
15:23justin_smithneoncontrails: a "generic T" is a thing that javac has some concept of, but has no existence in the bytecode
15:24justin_smithas far as clojure is concerned you don't interact with generics at all
15:24justin_smithjust the objects, without that whole "generic" aspect
15:25sdegutisGenerics have to do with static typing at compile-time. Clojure is dynamic.
15:25sdegutisIt's as if every type is "Any". Clojure arrays aren't Array<String>, they're Array<Any>
15:26justin_smithsdegutis: umm...
15:26justin_smithsdegutis: arrays actually have types
15:26justin_smithsdegutis: it's only generics that don't exist, some things really are typed
15:27neoncontrailsfascinating. Now I want to take compilers :-\
15:27noncom|2sdegutis: justin_smith: it's that you can handle them as if they're of <Any>, but in the bytecode they're specific
15:27justin_smithsdegutis: ArrayList - yeah, that's Object, no types, array - array can be typed (at least for primitives but I think for Classes also)
15:28sdegutisjustin_smith: not in Clojure they don't
15:28noncom|2iirc there's some clojure function to make typed arrays
15:28sdegutis(doc make-array)
15:28clojurebot"([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:28sdegutisAnd it's only for primitive types.
15:28justin_smith,(aset (into-array ["a" "b"]) 1 2) ; no, it is typed
15:29clojurebot#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:29noncom|2? not only ?
15:29justin_smithsee, it can't put a long into a string array - the array is actually typed
15:29justin_smithsdegutis: so you are wrong, even arrays of non-primitive types are typed
15:29noncom|2but all this stuff is simply because arrays are special to JVM, it's just that
15:29sdegutisNo sir.
15:30justin_smithsdegutis: generics are fictional, types of arrays are actual byte code fact
15:30sdegutis:)
15:31lokienhow to force time function not to print results of the function? just the time of evaluation
15:31justin_smithlokien: (time (do (f) nil))
15:32justin_smithor (time (do (with-out-str (f)) nil))
15:33noncom|2neoncontrails: i'm actually doing a thing with clojure + clojurescreept + threejs now. a neat setup if you're into some threejs
15:34TimMcjustin_smith: Interestingly, java.lang.Class does provide support for talking about parameterized types, but I'm not clear what it buys you.
15:34justin_smithTimMc: is this something that's actually used?
15:34noncom|2TimMc: maybe it's only compile time?
15:34neoncontrailsnoncoml2: no way. I was just working with three.js for the better part of last month!
15:34neoncontrailsI'd love to see what you got.
15:35lokienjustin_smith: thanks
15:36noncom|2neoncontrails: 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:36noncom|2i'm not a pro in js and web, but done much opengl in java/cojure
15:36noncom|2so now simply want to try out the browser multiplayer thing
15:37TimMcjustin_smith: Dunno!
15:38lokienjustin_smith: is there a memory limit for slurping?
15:38justin_smithhrm - there's a max string size limit, right?
15:39noncom|2planning to opensource the basic project when i polish it a little so that if someone is interested, can pick it up.
15:39lokienis it?
15:39justin_smithwhen you get near that, you should probably be doing reads in a loop from an input source rather than a slurp
15:39noncom|2lokien: there is
15:39justin_smithyes, there's a max string size
15:39lokien:( I wanted to slurp it
15:40lokienhaskell had no problems with loading 2gig file, I can't load 800mb here
15:40justin_smithlokien: what about line-seq instead?
15:40justin_smithlokien: but did haskell turn it into a single 2gig string?
15:40noncom|2iirc there was an option to use a custom reqder with slurp also?
15:40justin_smithlokien: we can load that much data, but you can't put it all in a single string object
15:40noncom|2lokien: for sure haskell was just creating another kind of object. JVM has limitation on string length
15:41lokienwelp. what do I do now?
15:41lokiencan I load it line by line?
15:41justin_smithlokien: yes - line-seq
15:41justin_smiththat gives you a lazy-seq of the lines
15:42lokienjustin_smith: thanks, I'll try that
15:42neoncontrailsnomcoml2: I feel your pain, three.js is one of the more unapologetically difficult libraries I've worked with
15:42amalloyjustin_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:42noncom|2lokien: justin_smith: a bunch of replacements https://crossclj.info/docs.html?q=slurp
15:43justin_smith,(line-seq (java.io.BufferedReader. (java.io.StringReader. "a\nb\nc\n")))
15:43clojurebot("a" "b" "c")
15:43noncom|2btw, will line-seq choke if there are no new lines in the whole file?
15:43amalloywell it will return one large string
15:43amalloyand if that doesn't fit in memory, you will have problems
15:44justin_smithright, that's why I asked if it made sense to split by lines
15:44noncom|2neoncontrails: 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:44noncom|2lokien: so beware of the newlines requirement too
15:45noncom|2lokien: look, another solution: https://books.google.ru/books?id=H9tOCwAAQBAJ&amp;pg=PA151&amp;lpg=PA151&amp;dq=slurp+custom+reader&amp;source=bl&amp;ots=BEi-1HY2jO&amp;sig=hkXf-BkMTFlLjgFRmYe8uWdq4ds&amp;hl=ru&amp;sa=X&amp;ved=0ahUKEwj694f50qfKAhUiAXMKHeM5Ct0Q6AEILjAC#v=onepage&amp;q=slurp%20custom%20reader&amp;f=false
15:45noncom|2lokien: bottom of the page
15:46neoncontrailsnoncomj2: my most successful tweet of 2015 compared graphics programming to pulling a fitted sheet over a thousand-dimensional mattress, heh
15:47noncom|2neoncontrails: :D oh I understand that :D
15:48lokienjava is broken :(
15:48lokiennoncom|2: thanks, I'll read that
15:49noncom|2lokien: well, you see, java is very pragmatic. having a multi-gig string is an antipattern
15:49noncom|2lokien: so the String concept in JVM is fitted for performance ond optimization needs
15:49noncom|2lokien: and for other cases you can just read the data as bytes. which is dead easy to do either
15:50lokiennoncom|2: yeah, but it's late, and I'm getting buffer errors from java, it's annoying
15:50noncom|2ah i see
15:51justin_smith,(line-seq (java.io.BufferedReader. (java.io.StringReader. "a\nb\nc\n")))
15:51clojurebot("a" "b" "c")
15:51justin_smithlokien: buffer errors, or errors that say you have the wrong class that mention buffer in it somewhere?
15:52l1xhi guys
15:52lokienjustin_smith: I'll try that code you've just written
15:52noncom|2l1x: hi!
15:52l1xwhat does it mean when java guys do this -> Class OrcFile.WriterOptions it seems it behaves differently from normal java classes
15:52l1xhi noncom|2
15:53justin_smithlokien: well don't do the StringReader part - that was just an easy way for me to make an input source
15:53justin_smithso replace (java.io.StringReader. "") with your actual input source
15:53lokien"path/to/file"?
15:53justin_smith(java.io.File. "path/to/file")
15:54justin_smithso (line-seq (java.io.BufferedReader. (java.io.File. "path/to/file")))
15:54lokiennow, how to prevent 800mb printing in the repl?
15:54justin_smithlokien: (def lines (line-seq ...))
15:54amalloyurgh
15:54justin_smiththen you can use lines - it's a seq
15:54amalloydef-ing an 800mb lazy seq...
15:55lokienbut.. well, that works, so it's good.
15:55justin_smithamalloy: there is that, yeah
15:55amalloyyou really don't ever want that tied to a var
15:55lokienamalloy: sorry :(
15:55amalloyyou want it let-bound to a local or a function arg
15:55justin_smithlokien: in your final code it can be in a let binding
15:55noncom|2l1x: you mean you see "Class OrcFile.WriterOptions" in a java source?
15:55lokienjustin_smith: it will be
15:55justin_smithI think for quick repl experiments it should be OK
15:55justin_smithlokien: makes sense, yeha
15:55l1xnoncom|2: well i am trying to call new on that but it does not work
15:55l1xfor some weird reason
15:56noncom|2l1x: can you post it into refheap and show?
15:56noncom|2or pastebin or something
15:57lokienjustin_smith: CompilerException java.lang.ClassCastException: Cannot cast java.io.File to java.io.Reader
15:57noncom|2wrap the file in a reader
15:59justin_smith(-> "project.clj" java.io.File. clojure.java.io/reader java.io.BufferedReader. line-seq)
15:59justin_smithyeah, it's a lot of silly conversions
15:59noncom|2actually it's very logical and gives a lot of flexibility
15:59noncom|2i used to hate it too
16:00justin_smithscratch that - this suffices (-> "project.clj" clojure.java.io/reader line-seq)
16:00noncom|2until i understood it
16:00ridcullyl1x: are you looking for OrcFile$WriterOptions ?
16:01lokiennoncom|2: that's why I'm hating it now
16:01justin_smithlokien: you saw my simpler version above right? just io/reader lin-seq
16:02justin_smiththere was a detour on the way to finding that again
16:02noncom|2lokien: it's very unixy, you like pipe output of one subprogram into another. each subprogram allows for a specific conversion
16:02lokienjustin_smith: I thought "scratch that" meant something else
16:02lokiennoncom|2: only linux!
16:03noncom|2well, linuxy then :D they're not too different in this aspect afaik
16:03lokienugh, why are you all so smart :^(
16:04justin_smithlokien: in my case it comes from a lot of time being stumped, and a lot of wrong answers corrected
16:06noncom|2i rather often feel rather stupid btw
16:06lokienjustin_smith: "I decided to use pull it out your ass driven development, where you just pull the answer out of your ass."
16:06justin_smithheh
16:07noncom|2lokien: so, you really want a string in the end, but why? why you need a giga string?
16:07lokienI use it every time, and often have to rewrite /:
16:07lokiennoncom|2: I'm curious about the performance on big things
16:08noncom|2lokien: you benchmark clojure/jvm or do you simply work with big data?
16:08lokiennoncom|2: I want to check how fast is clojure here compared to perl, and maybe haskell
16:09l1xnoncom|2: i figured out public static OrcFile.WriterOptions orc_options = OrcFile.writerOptions(conf);
16:09l1xOrcFile.WriterOptions is the type
16:09l1xridcully: yes :)
16:10justin_smithin clojure that would be OrcFile$WriterOptions - not that $ is not an operator, it's part of the name
16:10justin_smith*note
16:13lokienjustin_smith: java reached 2gigs of memory and stopped, funny
16:13justin_smithlokien: that's why amalloy was saying not to put it in the var
16:14justin_smithlokien: also, you can tell java to use more RAM
16:14lokienjustin_smith: I forgot, I'm so bad
16:15l1xlokien: are you trying to read a file lazyly?
16:15justin_smithl1x: it's too big to go in a string
16:15lokienl1x: I'm doing it :^)
16:16noncom|2lokien: is your jvm 32bit or 64bit
16:16noncom|2?
16:16l1xjustin_smith: ofc
16:16lokiennoncom|2: 64
16:19sohailhey guys, are there any good lein templates for http-kit based apps
16:21justin_smithsohail: 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:21noncom|2sohail: luminus +http-kit for example
16:21noncom|2+cljs also maybe
16:21sohailoh I'm just trying to find a template that lets me get started quickly, doing a lot of prototype work
16:21noncom|2if you need it
16:22sohailwhat is luminus?
16:22noncom|2sohail: http://www.luminusweb.net/docs/profiles.md
16:22justin_smithsohail: 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:22sohailgotcha
16:23domgetterI'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:23sohailluminus looks good, thanks noncom|2
16:23noncom|2lokien: 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:24noncom|2sohail: also, as justin says, you can just use it without http-kit, which will imply immutant 2 which is afaik better
16:24noncom|2sohail: 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:25lokiennoncom|2: bookmarked
16:25sohailnoncom|2: right, I used http-kit last time because sente seemed to work well with it
16:26noncom|2sohail: it now fully works with immutant 2 which is thought to be currently better maintained than http-kit
16:26sohailcool, I'll give it a shot
16:37noncom|2lokien: 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:37noncom|2lokien: this one fixes this: https://www.refheap.com/113633
16:38noncom|2had to come back to it, since i felt that what i posted had hidden catches and was not very correct
16:39lokiennoncom|2: well, bookmark out, bookmark in
16:39lokienthanks that you care
16:40noncom|2:)
16:47lokienanyway, 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:48j-pblokien: I do all ui stuff in cljs
16:48j-pbreagent is great
16:48j-pband it's so easy to get interactive stuff going
16:49j-pbespecially for something like board games :)
16:49lokienj-pb: foreign grounds again, great
16:49j-pb:D
16:50lokien"read a book", they said. "you'll be a coder in 6 months", they said. and I'm still wandering in the dark
16:50j-pbhaha well starting with clojure is a good thing
16:50j-pbwhat did you do before?
16:51TimMclokien: Sounds like you're a coder. ;-)
16:51TimMcwandering in the dark is the human condition
16:51futurolokien: yeah, I wouldn't expect that to change any time soon
16:51j-pbyeah
16:51lokienmainly python and haskell. some scala, go, perl, little bit of c and ocaml (very little)
16:51j-pbwithout google I wouldn't get shit done and I'm writing clojure for 3 years and have done CS for 10 years
16:51ridcullyyet, if you don't know html/css this can be quite some adventure too
16:52slesterI 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:52lokienj-pb: hello, I'll interview you for your dream job, please write code on that whiteboard
16:52slesterI just learned that (map f coll1 coll2) was a thing
16:52lokienTimMc: I'm trying D:
16:52slesteretc.
16:53lokienridcully: what kind of "adventure"?
16:53j-pblokien: 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:53lokienslester: I get functional things cause I was writing haskell, but I don't get java at all :(
16:54slesterI still don't know how to structure my clojure projects. Haha. :(
16:54slesterlokien: that's a good situation to be in, wrapping my head around functional programming was quite the doozy of a first step!
16:54slesterI came from C/PHP/JavaScript
16:54j-pblokien: yeah, java is just weird, don't feel bad. It's the functional part that's hard and important ^^
16:54lokienj-pb: fast trip to the toilet would do
16:55j-pbtoilets are like the muse behind every great algorithm
16:55noncom|2lokien: confirming, quil is perfect for that. it is based on https://processing.org/
16:55lokiennoncom|2: clj or cljs?
16:55noncom|2lokien: both
16:55j-pbnoncom|2: how so. If you want to do a board game thing you need interactivity
16:56noncom|2theres processing and there's processing js
16:56j-pbnoncom|2: in the sense, that you want to click stuff
16:56ridcullylokien: maybe an unpleasent one. or an rabbitholish one.
16:56lokiennoncom|2: I mean, what'd be better
16:56elvis4526Is there any good documentation about laziness in clojure ?
16:56lokienI'm dreaming of client-server or p2p, but it's too ambitious for now
16:56elvis4526I'm still not sure how its implemented.
16:56futuroelvis4526: we keep meaning to get around to it, but something always comes up...
16:56noncom|2lokien: depends. the cljs will require hosting with a web server, which you could quickly set up with, e.g. luminus
16:56j-pbnoncom|2: which is super easy with drawing svg but impossibly difficult with quil
16:57j-pbelvis4526: before 1.8 it was just a bunch of nested anonymous functions
16:57lokienridcully: uh, why aren't there good tools in this world :^(
16:57noncom|2lokien: 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:57ridcullylokien: in the browser there is html/css, webgl, svg, canvas (maybe more) to chose to render to
16:57elvis4526j-pb: post clojure 1.8, what is it ?
16:57lokiennoncom|2: I'll do that
16:58slesternoncom|2: how do you suggest organizing code to have a CLJ + CLJS version live side-by-side?
16:58j-pbelvis4526: magic
16:58slesterall of my functions are so intertwined and such, not sure how to organize it (even still)
16:58j-pbelvis4526: depends on the arity of map filter e.t.c.
16:58noncom|2j-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:58elvis4526j-pb: right - ok
16:59j-pbnoncom|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:59noncom|2slester: 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:59noncom|2j-pb: in quil/processing?
16:59j-pbnoncom|2: yeah
17:00noncom|2noncom|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:00slesterif 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:00j-pbelvis4526: 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:00slesterreorganizing so I can end up making two versions
17:00noncom|2j-pb: ^ that was for you :D
17:00j-pbnoncom|2: yeah I know ^^
17:01lokien_it would be generating a hexagonal grid and marking fields with colours (basically that's entire game)
17:01j-pbnoncom|2: yeah so you need to write your own event handling engine
17:01j-pbnoncom|2: which to say it noncharlantly, sucks monkey balls :D
17:01lokien_based on player's moves
17:01lokien_something like battleships
17:01j-pbnoncom|2: there is soooooo much stuff involved in this. What if figures overlap? what if you want click propagation
17:01noncom|2j-pb: well, idk, i'm fine with all that kind of stuff. been doing games for ages
17:02noncom|2http://www.openprocessing.org/sketch/17259
17:02domgetterelvis4526: are you wondering how it works, or are you trying to figure out what it does for you so you can wield laziness?
17:02j-pbnoncom|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:03j-pbnoncom|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:03neoncontrailsI 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:03elvis4526domgetter: the latter
17:04amalloyneoncontrails: what makes you think they give you that hint?
17:04noncom|2j-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:04noncom|2j-pb: if you come from web dev and like it, i think then surely the web way will be far more pleasant
17:04j-pbnoncom|2: yeah well it depends, I wouldn't want to do it in html ^^ but pure svg is bliss
17:05lokien_hey guise, maybe my description would help in your argument
17:05sohailok, 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:05j-pblokien_: clickable hexagons a la battleship?
17:05lokien_j-pb: yeah
17:05neoncontrailsamalloy: ooh I just noticed I can alternatively use list indices with assoc-in, etc.
17:06j-pblokien_: I'd go with reagent and svg. I wouldnt want to write the logic that checks which hexagon the click is in
17:06noncom|2slester: so what's the problem with your code? which parts break in clj<->cljs transition?
17:06amalloyuse 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:07neoncontrailsamalloy: I haven't found an example yet in the docs to change the value to which a string key is bound, though
17:07domgetterelvis4526: ah okay. try this in a repl: https://gist.github.com/domgetter/2f7fc4b085e58c092f7e
17:07amalloy??? it's exactly the same as everything else
17:07lokien_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:07noncom|2sohail: yes, first start repl, go to the namespace where the function is and call (start-app []) - please note it requires 1 arg
17:07amalloykeywords are not special in any way to maps
17:07amalloy(get m k) (assoc m k v) and so on all work for any object k
17:07domgetterelvis4526: clojure will "actualize" chunks of 32 of a sequence at at time
17:08neoncontrailsWell, that's good to know. I must just be syntactically off then
17:08noncom|2sohail: also you should know that the IDE experience editing clj and cljs files will vary greatly. clj will be far more comfortable (likely)
17:08j-pblokien_: yeah, I don't see why not
17:09lokien_j-pb: so I'll be asking more silly questions here, yay
17:09j-pblokien_: if you get stuck don't hesitate to pm :)
17:09noncom|2j-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:09sohailnoncom|2: actually I have had better experience editing cljs files!
17:10noncom|2sohail: wow! :D that's unusual
17:10lokien_j-pb: I'll remember that :)
17:10sohailnoncom|2 probably pebkac
17:10domgetterelvis4526: 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:10j-pbnoncom|2: you can go with local storage if you really want to, most of the time I do "p2p" between browsers
17:10lokien_noncom|2: yeah, I'll see what floats my boat
17:11noncom|2j-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:11lokien_anyway, if I make a game based on a board game.. do I need a licence to make it public?
17:11noncom|2lokien_: technically you need to pack a license with everything
17:11ridcullylokien_: if in doubt, yes
17:12lokien_I mean, do I have to mail guys who made it
17:12j-pblokien_: 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:12lokien_j-pb: that's a good idea, actually. I need to read about hexagonal grids though
17:13ridcullylokien_: 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:13domgetterlokien_: bookmark this sucker: http://www.redblobgames.com/grids/hexagons/
17:13lokien_ridcully: if I finish it till 2017, I will call it a great success
17:13noncom|2lokien_: 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:13j-pbnoncom|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:13ridcullygamasutra has some nice article about them. something like 10 facts you didn know about hexgrids
17:14lokien_domgetter: love you
17:14noncom|2j-pb: idk, i always felt waaaaaaay safer with a backend
17:14j-pbnoncom|2: why though? putting one in takes like 5 seconds, and it's code you don't immediately need but have to maintain.
17:14noncom|2lokien_: https://help.github.com/articles/open-source-licensing/
17:14j-pblokien_: I'd probaly start with a figwheel cljs template
17:14lokien_I don't know how I lived without irc
17:15domgetterlokien_: all the examples are interactive on there
17:15j-pblokien_: lein new figwheel MYAWESOMEPROJECT -- --reagent
17:15noncom|2j-pb: robustness and the ability to interface with a db and other services..
17:15j-pbnoncom|2: yeah but while prototyping a game ^^
17:16lokien_noncom|2: so, no monies for me from ideas I stole? eh :(
17:16noncom|2j-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:16noncom|2got pretty used to all that stuff before
17:17noncom|2and when you do it right, a good infrastructure pays off really quickly, giving much comfort and freedom
17:17j-pbyeah I wouldn't want to do it in anything but reagent
17:17j-pbhtml is madness
17:17j-pbsvg is nice though
17:17noncom|2i was doing in in reagent :D
17:18ridcullythat 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:18noncom|2lokien_: oh that's a hard question. if the game is like chess or battleships, surely, there's no patent for the idea
17:18j-pbgame mechanics arent patentable
17:18j-pbnor trademakable
17:18domgetterj-pb I made a nice little typing game with reagent using core.async to do event logic: http://domgetter.github.io/typerooni/
17:18j-pbtrademarks are trademarkable so don't calle it battleship
17:19j-pbdomgetter: cool
17:19lokien_but story and universe is, I think
17:20lokien_s/is/are
17:20noncom|2lokien_: yes, artwork... you can read the stack exchange law site, there are some very good answers about such things
17:20j-pbdomgetter: total words: 77correct words: 71incorrect words: 6wpm: 76.6
17:20ridcullyyet there is always the question of: how much money are you willing to pay laywers
17:21noncom|2ridcully: yeah, funny, but in the end - money is all. often.
17:21lokien_ridcully: I have like, 50 dollars
17:21ridcullymany table top games g[eo]t ported to mobile etc. maybe you just piss off the wrong crowd
17:21domgetterj-pb: the average ms column is how many millisecds it takes you on average to type the wordlet on the left
17:21j-pbcool
17:22j-pbwow I suck a le
17:22lokien_there is this dilemma now - do I mail them or not. if I don't mail them, maybe they'll never know
17:22ridcullyyou suck ale?
17:22j-pb317ms ^^
17:22j-pbat
17:22j-pb^^
17:22lokien_noncom|2: I will
17:23noncom|2lokien_: 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:23noncom|2some minor tweaks to game mechanics also won't hurt
17:25lokien_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:25noncom|2:D
17:29lokien_also, I don't give you name of that game, I know you, clojure hacks. justin_smith would instantly make all the logic
17:29lokien_in one line
17:30justin_smith(win-game)
17:30j-pb(def wingame (constantly true))
17:30lokien_:(
17:30lokien_knew that
17:30elvis4526Would core.async be a good way to implement a stream ?
17:31elvis4526Or there's something more idiomatic in clojure
17:31justin_smithelvis4526: what kind of stream?
17:31j-pb(def wingame (comp not #{:lokien_} get-user))
17:31noncom|2slester: amiss in its current form does not seem to have problems with being shared by clj/cljs.. idk.. maybe i am missing something
17:32j-pbelvis4526: depends on your kind of stream, seqs are also kinda streams :)
17:32lokien_j-pb: thanks, man
17:32elvis4526justin_smith: I'm trying to abstract the paginated results of a REST API.
17:32domgetterelvis4526: core.async is good for coordinating several different asynchronous operations.
17:32j-pblokien_: most welcome ;P
17:32j-pbelvis4526: a seq it is
17:32elvis4526j-pb: thats what i was trying to wrap my head around (hence the question about laziness), but I'm not sure I understand
17:32slesternoncom|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:32elvis4526correctly.
17:33j-pbelvis4526: flochart is like this. Does it have an end, or goes on infinitely without significant blocking. -> seq
17:33j-pbelvis4526: is that thing a bitch and might stall your thread when no item is available for an unbounded unknown amount of time? -> channel
17:33justin_smithelvis4526: 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:34noncom|2slester: 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:34lokien_j-pb: I'll annoy the heck out of you
17:34j-pblokien_: please do :D
17:34slesterI guess it's mostly having to do a bunch of (declare x)
17:35j-pblokien_: I really really want to write a cljs board game library but I have a different project on my plate right now
17:35j-pbbut it will be a part of it :D
17:35lokien_j-pb: oh.
17:35noncom|2slester: 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:36j-pblokien_: heres some hacking music : https://www.youtube.com/watch?v=BhsTmiK7Q2M
17:36noncom|2slester: 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:36sdegutisoh man
17:36sdegutisdeadly
17:37justin_smithsdegutis: watch it, I'm wearing the glove
17:38elvis4526j-pb: ok i see
17:38noncom|2noncom|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:38sdegutiswhat if there was a ->>> macro?
17:38sdegutisthat would be crazy
17:38elvis4526justin_smith: im guessing its a "stream" because of lazy-seq ?
17:38lokien_j-pb: why not the sound of silence?
17:38noncom|2slester: then you can submit your code for a review, for example, here and if somebody's around, they could take a look
17:38elvis4526if i do (lazy-seq [1 2 3]), do I get back something lazy ?
17:38j-pblokien_: hahaha lol
17:39j-pblokien_: hello darkness my old friend
17:39justin_smithelvis4526: 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:39justin_smithelvis4526: if that makes sense
17:39slesternoncom|2: they have circular dependencies which is why I had to declare
17:39slesteris there a specific way to submit for a review? or just ask? haha
17:39domgetter,(type (lazy-seq [1 2 3]))
17:39justin_smithelvis4526: 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:40clojurebotclojure.lang.LazySeq
17:40justin_smithslester: the standard solution is to make a third namespace, that uses things from the other two
17:40lokien_j-pb: by the way, my dream is to make a retro platformer with this soundtrack https://youtu.be/q9HzqxwKfiM
17:40j-pblokien_: hahahahah lol
17:40domgetter,(realized? (lazy-seq [1 2 3]))
17:40clojurebotfalse
17:41slesterjustin_smith: thanks, I'll see if that's feasible with my code heh
17:41slesterI just feel like it's really messy and I've already lost a handle on what's going on
17:42noncom|2slester: yeah, try factoring thing in a side namespace
17:42noncom|2maybe a rewrite would do...
17:42noncom|2start with a ns to hold state
17:42noncom|2another ns for simple queries on the state
17:43noncom|2another ns for decisions
17:43noncom|2and so on
17:43noncom|2(as an example)
17:43slesterthat's probably smart
17:43slesterthis was my first clojure project so I was kind of feeling around in the dark :D
17:44noncom|2slester: no procedure for a review, just ask.. if someone feels like having some time, i think they take a look
17:44noncom|2oh my, my first clojure projects were terrible!
17:44lokien_my first clojure project was fizzbuzz :^(
17:46domgetterlokien_: mine was basically fizzbuzz too, since ProjectEuler #1 is the same thing
17:47lokien_domgetter: I have bad memories with project euler and haskell
17:48domgetterhaskell's not well-suited to do math :P
17:48lokien_like "yeah, I can't write a hello world, but I know what a functor is, I'll do that"
17:48slesterproject euler isn't the best for programming
17:48lokien_*7 hours later*
17:48slesterin my experience
17:48lokien_slester: advent of code all the way!
17:49slesterlokien_: hey I got on the leaderboard 5-6 of the days with clojure
17:49slesterhttps://github.com/slester/amiss/blob/master/src/amiss/core.clj if people want to tear it apart :D
17:49slester(my game, not advent of code)
17:49benjyz1hi. I'm working with channels and wondering about buffering. the standard (chan) means each put requires 1 take?
17:50domgetterbenjyz1: technically (chan) has no buffer. that's why a put waits for the take
17:50domgetterif there was a buffer of one, then the put could put and the next put would then experience a waiting period
17:51benjyz1I see. I've seen some examples about simple use of channels, but wondering about complex use cases
17:51lokien_slester: I've done one problem with go, and it was.. gross. but I was so happy when it finally worked
17:51noncom|2slester: 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:51slesterlokien_: go is fun
17:51domgettersome of the more complex uses are done through using the other core.async functions (mult-ing, alt-ing, fan-ing, pubsub, etc)
17:51slesternoncom|2: yep, that'll be incorporated into the rewrite
17:52lokien_slester: perl is fun, go is savage
17:52slesterperl...
17:52slesterhaha
17:52slesterI just can't do Perl
17:53lokien_because you're no fun!
17:54benjyz1domgetter: yes, I'm looking at those. I'm trying to understand the basic use of blocking and non-blocking
17:54benjyz1often it is mentioned one can get rid of callback hell
17:54noncom|2benjyz1: give an example of a complex use of channels
17:55benjyz1e.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:56domgetterbenjyz1: 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:56benjyz1request every few milli seconds, then if there is a change put that event on a channel. i.e. something like Event stream processing
17:57noncom|2benjyz1: good, seems like a good task for c.a.
17:57benjyz1thx, I think I know this one. for UI and clojurescript it async is awesome
17:58benjyz1https://yobriefca.se/blog/2014/06/01/combining-and-controlling-channels-with-core-dot-asyncs-merge-and-mix/
17:58benjyz1this is quite a nice article on merge and mix
17:58sdegutisRemember when Clojure was a Common Lisp spin-off?
18:00domgettersdegutis: remember when some lispweeines thought it was an abomination? http://www.loper-os.org/?p=42
18:01lokien_when I mentioned on #lisp that I use clojure, they called me a troll
18:01noncom|2well, #lisp is for common lisp only. #lisp-cafe is for lisps in general
18:01sdegutisLOL "I don’t care if everybody really is more productive in Clojure than in Common Lisp."
18:01sdegutisI hope one day to finish implementing my very own Lisp!
18:02lokien_noncom|2: I was asking about cl, just mentioned I'm familiar with clojure
18:02sdegutisOnce it has its own IRC channel, it will be officially a real language!
18:02lokien_sdegutis: me too
18:03noncom|2lokien_: yeah, they don't perceive clojure serious.. but some of them use it though
18:04noncom|2nice one: https://github.com/Habstinat/ParentheticLisp
18:04sdegutisCommon Lisp and Haskell have very similar communities.
18:04noncom|2yeah. and C
18:04sdegutisI think it comes from the purism that both languages seem to aim for.
18:04sdegutisC is awesome.
18:05noncom|2yeah, just as haskell and common lisp
18:05sdegutisHaskell is neat.
18:05lokien_noncom|2: it's sad they're so closed and think their tools have no flaws
18:05noncom|2well, common lisp may seem obscure to some, but i know it's cool
18:05sdegutisCL is weird and boring.
18:05lokien_sdegutis: some haskell people are nice
18:05sdegutisI bet.
18:06noncom|2lokien_: just a flavor of the general variety
18:06noncom|2well, cl was there always
18:06noncom|2it's what kept lisp on for years
18:06noncom|2there also was scheme, but it's umm.. a funny one, although not bad
18:07lokien_and racket, duh
18:07noncom|2yeah
18:07noncom|2racket
18:08benjyz1has anyone attempt writing a webserver in pure clojure?
18:08noncom|2benjyz1: waht do you mean? you'd have to at least reach for java sockets
18:08justin_smithbenjyz1: by "pure" do you mean no interop? if yes, then it's impossible
18:08justin_smithif no, then http-kit is pure clojure
18:09noncom|2benjyz1: clojure is not about eliminating interop. it's about embracing interop easily when it is needed
18:09lokien_but where is my c interop? sdegutis?
18:09benjyz1I mean several projects use netty
18:09justin_smithI take that back, http-kit has a bunch of java code
18:10sdegutiseasy
18:10sdegutisnoncom|2: what about guile?
18:10lokien_justin_smith: delete it and it will be pure clojure :)
18:10sdegutiswhy everyone forgot about guile tho?
18:10benjyz1netty has some kind of channel semantics. I wonder what would happen if one would use clojure async.
18:10lokien_isn't it a scheme?
18:10lokien_guile scheme?
18:10justin_smithbenjyz1: see aleph with manifold, it's intended for that sort of thing
18:11noncom|2benjyz1: 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:11noncom|2aleph also uses a load of java inside afaik
18:11sdegutisOh man I forgot that CL is a Lisp 2.
18:11sdegutisHow stupid.
18:12noncom|2sdegutis: well, guile is scheme...
18:12lokien_what about chicken though?
18:12noncom|2scheme
18:12sdegutislol nobody uses that anymore
18:12lokien_I used it!
18:12lokien_for like 14 minutes
18:12noncom|2there's also picolisp - a rather neat thing
18:13justin_smithI 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:13justin_smithand just let the user deal with the consequences
18:13lokien_oh, and pixie!!
18:13domgetterhey look, Ruby is a lisp too! [:+, 1, 2, 3]
18:13benjyz1noncom|2 : I'm not entirely sure. sockets is in the end a streaming protocol. Actors e.g. is semantics on top of streaming
18:14lokien_justin_smith: do it please
18:14noncom|2justin_smith: :D and attribute it like "unsafe" or "unmanaged" functions
18:14noncom|2benjyz1: not sure about what?
18:14benjyz1async is not a distributed protocol like Erlang actors
18:14sdegutispixie looks cool but PyPy freaks me out
18:14benjyz1about your statement.
18:14justin_smithwell even "function" is a few levels of fancy abstraction higher than what I was describing...
18:14lokien_"pretty safe" is a better attribute
18:15noncom|2benjyz1: you mean that in erlang networking can be realized solely in terms of erlangian paradigms, without going C ?
18:15justin_smithnoncom|2: (def ^:suicidal frob [] (execute-byte-array-as-machine-code b))
18:15noncom|2rrrriiiiiight! :D
18:15nutnutnutnutwhat's a good way of turning [1 2 3] in to [1 :a 2 :a 3 :a]?
18:15noncom|2interpose + conj ?
18:16justin_smith,(mapcat #(list % :a) [1 2 3])
18:16clojurebot(1 :a 2 :a 3 ...)
18:16noncom|2wow
18:16benjyz1noncom|2: Erlang, AFAIK, implements pure actors, which means that process on one machine is identical to process on distributed machine
18:16lokien_justin_smith: why didn't you use c interop for that
18:16nutnutnutnut! that works well
18:16justin_smithnoncom|2: interpose doesn't get you that last :a
18:16lokien_it'd fit perfectly
18:16justin_smithheh
18:16noncom|2justin_smith: that's why i put conj there also :D but it looked hacky. i like your way\
18:16benjyz1here Hickey wrote a bit about downsides of actors clojure.org/agents
18:17lokien_also, BEAM is slow
18:17domgetter,(into [] (interleave [1 2 3] (repeat :a)))
18:17clojurebot[1 :a 2 :a 3 ...]
18:17noncom|2benjyz1: 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:17sdegutisnutnutnutnut: I'd like join them with two maps or something
18:17nutnutnutnutyeah i was trying that too...
18:17nutnutnutnutdid a repeat of :a and zipmap'd them
18:18sdegutis,(flatten (map list [1 2 3] (repeat :a)))
18:18clojurebot(1 :a 2 :a 3 ...)
18:18sdegutis,(pr-str (flatten (map list [1 2 3] (repeat :a))))
18:18clojurebot"(1 :a 2 :a 3 ...)"
18:18sdegutisclojurebot: WTF ITS NOT THAT LONG A THING JUST PRINT THE WHOLE THING PLZ
18:18clojurebotIt's greek to me.
18:18sdegutisclojurebot: dont make me sense a pull request mf
18:18clojurebotCool story bro.
18:18noncom|2benjyz1: 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:18sdegutisoh man the arrogance of that little bot
18:19domgetterI'm sensing a pull request in the near future...
18:19nutnutnutnut(vec (map (fn [xs] (vec (mapcat #(vector % :a) xs))) a))
18:19nutnutnutnutany way to get rid of all the vec calls?
18:19noncom|2noncom|2: clojure actually likes JVM. it just thinks it could use a lispy makeup. but erlang is faaaar from C
18:20nutnutnutnuta 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:20lokien_mapv?
18:20nutnutnutnutoo
18:20nutnutnutnuti take it there's no mapcatv as well
18:21lokien_OH MY GOD WAS I ACTUALLY USEFUL FOR SOMEONE
18:21nutnutnutnutlol
18:21justin_smithnutnutnutnut: why do you need these things to be vectors?
18:21nutnutnutnutyeah you're probably right
18:21lokien_noncom|2: why are you talking to yourself
18:21nutnutnutnuthopefully they dont need to be
18:21amalloyi agree, you usually don't need vectors. but if you do, you probably use (into []) with a concat transducer or something
18:22justin_smithwell 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:22nutnutnutnuteverything else is a vector of vectors right now so i was trying to keep it uniform
18:22noncom|2lokien_: damn, was talking to benjyz1. i keep pressing on my nick. happens for the second time. gotta sleep :D
18:22sdegutisOh duh
18:22nutnutnutnutmight still work though if they're different
18:22sdegutisWhy did I miss this
18:22lokien_noncom|2: I wanted to sleep, but irc is too much fun
18:23sdegutis,(apply concat (for [a [1 2 3] b [:a]] [a b]))
18:23clojurebot(1 :a 2 :a 3 ...)
18:23noncom|2lokien_: yeah :D
18:23justin_smith,(= '(1 2 3) [1 2 3])
18:23clojurebottrue
18:23sdegutishahaha stupid `for`, you rock
18:25amalloynutnutnutnut: usually you can just work with a more abstract collection type: "anything sequential" is often good enough
18:25nutnutnutnutlokien_: if you're looking for fun you can try to do https://www.4clojure.com/problem/73#prob-title
18:25nutnutnutnutthats what im working on right now.. i have a really good idea for a solution
18:25lokien_noncom|2: "I want to be an engineer, dad, I'll build wonderful things and help people"
18:26lokien_noncom|2: but in reality, I just want to talk on irc
18:26noncom|2:D well, communication is a wonderful thing actually!
18:26lokien_nutnutnutnut: what makes me look like a good partner for it?
18:26nutnutnutnutno no not partner
18:26nutnutnutnutrace!
18:26noncom|2everything commutes
18:27noncom|2except that which does not of course
18:27lokien_man, I'm in bed for two hours now :(
18:27domgetterlike matrix multiplication? That doesn't commute
18:27lokien_noncom|2: what if world runs on erlang, and we're just actors
18:28noncom|2next day at work: "man what's up with you? you look like a junkie" ... "mrhh.. i'm on #irc.. "
18:28lokien_nutnutnutnut: github.com/youarebeautiful/tictactoe
18:28lokien_nutnutnutnut: I won
18:28noncom|2heh, yeah, :)
18:28nutnutnutnutboo
18:28lokien_noncom|2: "I'm a professional hacker"
18:29noncom|2esp if you irc from emacs
18:29noncom|2or at least vim :)
18:29lokien_nutnutnutnut: I hacked back in time to do that and ashame you
18:29nutnutnutnutgasp!
18:30lokien_noncom|2: tty3, be a man
18:30lokien_I hand craft my connections in c
18:30lokien_every time
18:31noncom|2ahahh :D
18:31noncom|2and use a repl to send messages
18:31noncom|2with a lisp written byself in c
18:32lokien_and lint messages on the fly with perl, to not make grammar mistakes
18:33lokien_anyway, I'm going to sleep, you addicting group of nice people
18:33noncom|2good night!
18:33lokien_kind is a better word, actually
18:33noncom|2class
18:33lokien_g'night, beautiful clojuristas
18:37nutnutnutnuthmmmmmmmmmmmmmmmmmmmmmmmmmmmm
18:37nutnutnutnutnot sure how to do this
18:37nutnutnutnutis it possible to..
18:37nutnutnutnutso im doing something like this: (mapcat #(vector % p) xs)
18:38nutnutnutnutfor p i want to be able to pass in :o, :x, or (z %)
18:38nutnutnutnutfor the last case it should actually evaluate it
18:38nutnutnutnutis there a consise way of doing that?
18:38domgetternutnutnutnut: you don't like (mapv #(vec (interleave % (repeat :a))) a) ?
18:39nutnutnutnuti mean that works fine but in either case i have that problem
18:39nutnutnutnutz is a local variable btw
18:39nutnutnutnutin context of the outer function it's in
18:39justin_smith,(mapcat #(list % (%2 %)) [1 2 3] [(constantly :b) (constantly :c) identity])
18:39clojurebot(1 :b 2 :c 3 ...)
18:41nutnutnutnuto
18:41nutnutnutnutconstantly.. hmm ok
18:41justin_smiththat way it's consistent - you call the second item every time
18:41justin_smithsometimes it uses the arg, sometimes not
18:41nutnutnutnutvery clever!
18:51souterrainSo, constantly rather than evaluating argument many times just returns a function that gives the same result?
18:52souterrainSo, very useful for functions that have side effects you only want to trigger once?
18:52justin_smiththat's one use for it
18:52justin_smithsee also memoize
18:53justin_smithor even delay
18:53nutnutnutnutdoes anyone know if you can use eval in 4clojure?
18:53justin_smith~eval
18:53clojureboteval is sometimes useful - but only sometimes
18:53blake__nutnutnutnut: I don't think so. I think it's verboten.
18:53souterrainok, looking... sorry, total clojure noob here, but this is the most excited I've been about writing code in about 15 years :)
18:54nutnutnutnutdamn
18:54justin_smithheh
18:54nutnutnutnutjustin how do i do this without eval :?
18:54justin_smithone moment, setting up a migration (day job)
18:54nutnutnutnutokie dokie
18:55sdegutissetting up?
18:55sdegutisoh right you're not using datomic
18:55justin_smith:P
18:55sdegutis:D
18:56souterrainjustin_smith: ok, so there are many ways to deal with, say, network side effects. (HTTP GETs, PUTs, etc.)
18:56souterrainwow, POSTs, not PUTs.
18:57nutnutnutnuthmmmm
18:57souterrainwho uses PUT
18:57nutnutnutnutidk if clojure understands what im trying to do
18:58sdegutiscompojure does afaik
18:58sdegutiscompojure also respects the "_method" param
18:58sdegutisits super magic
18:59nutnutnutnutis it possible to send a list like this '(z %) to inside an anonymous shorthand function and then eval it?
18:59nutnutnutnutclojure keeps saying he doesnt know what % is
18:59nutnutnutnutz is a local binding
18:59sdegutisprobably not
18:59nutnutnutnutgrr
18:59nutnutnutnuttheres gotta be a way to do this lol
18:59sdegutis,((fn [a] (eval 'a)) 2)
18:59clojurebot#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:00nutnutnutnutok so clojure cant do that then
19:00sdegutisanyway look
19:00sdegutishttps://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#L17-L18
19:00nutnutnutnutis there any alternative?
19:00nutnutnutnuti cant use eval anyway i guess
19:00nutnutnutnutbecause of 4clojure
19:00sdegutisjust run it in lein repl
19:00justin_smithnutnutnutnut: if you do it the way I did before, just pass in z, and let the function inside call z on the arg
19:01nutnutnutnuthmm ok ill take another look
19:06nutnutnutnuthooray it worked!
19:06nutnutnutnutok almost done ...!
19:06nutnutnutnutthis is gonna be the best solution
19:08nutnutnutnuthmm
19:09nutnutnutnutfor some reason doing (pos? (count (intersection set1 set2))) works
19:09nutnutnutnutbut just calling subset? doesnt work
19:09nutnutnutnutarent those statements equivalent?
19:09nutnutnutnuttried both superset and subset. neither worked
19:17justin_smithnutnutnutnut: depends, are the args both sets?
19:18nutnutnutnutyeah
19:19domgetternutnutnutnut they are not equivalent
19:19domgettera set may share elements with another but not be a subset
19:19justin_smithahh, right
19:19justin_smith(inc domgetter)
19:19justin_smithd'oh
19:20domgetterconsider #{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:20justin_smithdomgetter is a witch
19:20nutnutnutnutoh right
19:20nutnutnutnutin that case.. is there a more concise way of writing this? (pos? (count (clojure.set/intersection (set list1) (set list2))))
19:21justin_smith,(boolean (filter (set list1) list2))
19:21justin_smitherr, sorry
19:21clojurebot#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:21nutnutnutnutahh poor clojurebot
19:21nutnutnutnut!
19:21domgetter(not (empty? (intersection s1 s2))) perhaps
19:21justin_smith,(boolean (filter #{1 2 3} [3 4 5]))
19:21clojurebottrue
19:22justin_smithdomgetter: I think filter might be cheaper than intersection...
19:22nutnutnutnut,(filter #{1 2 3} [3 4 5])
19:22clojurebot(3)
19:22nutnutnutnutah
19:22justin_smith,(boolean (some #{1 2 3} [3 4 5]))
19:22clojurebottrue
19:22justin_smitheven better
19:22justin_smithonly needs one result
19:22justin_smithnutnutnutnut: a set acts as a function which looks its arg up in itself
19:23justin_smiththat sentence looks weird...
19:23nutnutnutnutyeah i always forget that
19:24justin_smith,(defn kanye [x] (= kanye x))
19:24clojurebot#'sandbox/kanye
19:24justin_smith,(kanye kanye)
19:24clojurebottrue
19:24justin_smith,(kanye :anything-else)
19:24clojurebotfalse
19:24justin_smiththat's probably got a name in the lambda calculus
19:24justin_smithbut I'll just call it the kanye function
19:24nutnutnutnutomg this solution is gonna be soooooooo good
19:25nutnutnutnutim so excited lol. i keep looking at how clever that 'constantly' use is
19:25nutnutnutnutnever would have thought of that
19:53nutnutnutnut!!!!!! done!
19:53nutnutnutnutomg this is so good
19:56nutnutnutnutok 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:56nutnutnutnutspoilers 4clojure level 73
19:56nutnutnutnutcan anyone see any more ways to shorten it?
19:57nutnutnutnutbesides things like variables names, etc.
19:58justin_smith(vec (flatten board)) could be (reduce into [] board)
19:59nutnutnutnutflatten is actually a character shorter :p
19:59justin_smithflatten is terrible
19:59justin_smithand with reduce into it's a vector from the get-go, no need for vec
19:59nutnutnutnutyeah i just mean (vec (flatten board)) is 21 characters and (reduce into [] board) is 22 characters
20:00nutnutnutnutmy friend and i both did this problem and we're seeing who can beat it in less characters
20:00justin_smithOK, but the latter is doing less work, but if character count is the thing (apply concat board)
20:01nutnutnutnuthaha nice 1 character savings
20:01nutnutnutnutoh wait
20:01nutnutnutnuti only use z in one place
20:01nutnutnutnuti can just inline that
20:02nutnutnutnutsame with w
20:03domgetter(let [r reduce i into b board] (r i [] b))
20:04justin_smithhaha
20:04nutnutnutnutupdated: http://pastebin.com/iiL6M4af
20:04nutnutnutnutdomgetter: not sure what you mean by that
20:05domgetterjust bein silly
20:06nutnutnutnuti wish the word constantly wasnt so long haha
20:07justin_smith#(do % x) is the shortest version of (constantly x) (if you know it gets one arg)
20:07domgetternutnutnutnut: you *can* def anything you want
20:07domgetter(def con constantly)
20:07justin_smith(fn [_] x) ?
20:07nutnutnutnutyeah not sure if it would be worth it though
20:08nutnutnutnuti think it'd be around the same amount of characterrs
20:08domgetterI just wanted to write def con
20:08justin_smith(fn [_] x) isn't so bad, and saves chars
20:08nutnutnutnutalso i dont think 4clojure allows def
20:08justin_smith(fn[_]x) saves chars the messy way
20:08nutnutnutnutwhy that over do?
20:11justin_smith,(map count ["#(do x)" "(fn[_]x)"])
20:11clojurebot(7 8)
20:11justin_smithhmm
20:12justin_smithoh, wait
20:12justin_smith,(map count ["#(do % x)" "(fn[_]x)"])
20:12clojurebot(9 8)
20:12justin_smithit needs the %
20:12nutnutnutnutsee anything else justin_smith? http://pastebin.com/3A0meCny
20:13nutnutnutnutlol so gross
20:13justin_smithlist is shorter than vector
20:13justin_smithand I bet a list would be as good as a vector where you are calling it
20:14nutnutnutnutyeah changing that vector to list worked
20:14justin_smithand I don't think you need the (vec ...) call at all
20:14nutnutnutnutoh nice i could get rid of the other vector call too
20:14justin_smithyou can probably take that out
20:14nutnutnutnutwasnt working earlier
20:14justin_smithyeah
20:14nutnutnutnutoh wait
20:14nutnutnutnuthold on
20:14nutnutnutnutmaybe not
20:14nutnutnutnutforgot to redef it
20:15justin_smithand I think mapv could be map
20:17nutnutnutnutyeah whoops ive been running the wrong version
20:17nutnutnutnuti dont think the apply concat trick from earlier worked
20:17nutnutnutnutwhen i do that some of the code is lists and some of it is vectors
20:17nutnutnutnutand it stops giving correct output
20:18nutnutnutnutit'd be nice if this could work just on sequences because all the vector calls take up space
20:19justin_smithwell (reduce into s) is the same as (reduce into [] s) if the first element of s is a vector
20:23justin_smithoh I see you are using p as a function, and p is each element of w
20:24nutnutnutnutyea?
20:24justin_smithno, wait...
20:24justin_smithyou are calling get
20:24justin_smithif you changed get to nth it would work without vectors
20:25nutnutnutnutalso are you sure that (fn [_] :x) trick works?
20:25nutnutnutnuti tried changing constantly to it and am getting errors
20:25justin_smithhow many args do you provide? the count has to match
20:26justin_smithwith two args it is (fn[_ _]x)
20:26justin_smithetc.
20:26nutnutnutnutah
20:26justin_smithoh (fn[&_]x) - this accepts any number of args
20:27nutnutnutnutlike this? (set (f (fn [&_] :x))) :x
20:27nutnutnutnutmaybe ill just stick to constantly. only an extra couple characaters
20:28justin_smith,(map (partial apply (fn[&_]42)) [[][1][1 2][1 2 3]])
20:28clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox/eval25/fn--26>
20:28justin_smith,(map (partial apply (fn[& _]42)) [[][1][1 2][1 2 3]])
20:28clojurebot(42 42 42 42)
20:29justin_smithaha!
20:29nutnutnutnutohhh
20:29justin_smith[&_] is not the same as [& _], my bad
20:29nutnutnutnut(fn[& _]:x)) is 12 and (constantly :x) is 15
20:29nutnutnutnutill probably just use constantly for clarity
20:31justin_smithmakes sense
20:31nutnutnutnutok justin_smith updated version: http://pastebin.com/MPturzBX
20:31nutnutnutnutand this one works i triple checked
20:32nutnutnutnutoh right i can change mapv to map.. another character
20:32nutnutnutnutunless you see something else i think that might be it
20:33nutnutnutnuto the reduce thing
20:33nutnutnutnutill try that
20:33nutnutnutnutyeah that worked
20:34nutnutnutnutjustin_smith: version 5 http://pastebin.com/rruNSdsz
20:35nutnutnutnuti cant wait to see everyone else's solutions when i submit
20:36justin_smithnutnutnutnut: neat
20:36nutnutnutnutdo you see anything else or do you think that about covers it?
20:38justin_smith(juggling)
20:41justin_smiththat vector of numbers....
20:41nutnutnutnutwhat about it?
20:41justin_smith((juxt identity #(apply map list %&)) (partition 3 (range 9)))
20:42nutnutnutnutwhat!
20:42nutnutnutnutblack magic!
20:42nutnutnutnuthow'd you do that
20:42justin_smiththat's not quite it
20:42nutnutnutnutyeah you're missing diagonals right?
20:42nutnutnutnutknew it was too good to be true :p
20:43justin_smith,(apply into ((juxt vec #(apply map list %)) (partition 3 (range 9))))
20:43clojurebot[(0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) ...]
20:44justin_smithoh yeah, it's missing diagonals...
20:45justin_smithany matrix geniuses know a concise way to add the diagonals to that?
20:45justin_smithheh
20:45nutnutnutnutlol
20:49justin_smith,(reduce into ((juxt vec #(apply map list %) (comp list (partial map-indexed #(nth %2 %)))) (partition 3 (range 9))))
20:49clojurebot[(0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) ...]
20:49justin_smithmissing one of the diagonals
20:50justin_smithbut it has the other one (in a totally stupi way)
20:50nutnutnutnutjustin_smith: newer version: http://pastebin.com/M5gt42Yy
20:50turbofailcould just be #(map nth % [0 1 2])
20:50justin_smithturbofail: good point, that could give both diagonals mutatis mutandis
20:51nutnutnutnutthat's a phrase i've never heard before
20:54justin_smithnutnutnutnut: if you google it the def. is the top hit
20:54nutnutnutnutyeah i read it
20:54nutnutnutnutneato
20:54justin_smithnutnutnutnut: basically it means "we all know the difference, so changing those parts..."
20:54justin_smithheh
20:54justin_smithuseful when someone is goalpost moving in an argument :)
20:59turbofaili wouldn't be surprised if the literal sequence still ends up being shorter
20:59justin_smithturbofail: fair
20:59turbofailthe code is a little nicer to look at though
20:59turbofailfor some reason
21:00turbofaili feel like my brain turns off when i see too much literal data
21:00neoncontrailsStill 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:00justin_smithsome people's brains turn off when they see (juxt comp apply partial comp into)
21:00turbofailhaha
21:00turbofailtrue
21:01neoncontrailsUpdate-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:02rhg135does that have any practical use?
21:02justin_smith,(reduce into #{} ({"a" [[:a :b] [:c :d]]} "a")) ; neoncontrails - like this?
21:02clojurebot#{:c :b :d :a}
21:03justin_smithneoncontrails: oh, you want it still in a hash-map, but sets instead of vectors of lists?
21:03justin_smith,(into {} (map (fn [[k v]] [k (reduce into #{} v)]) {
21:03clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:03neoncontrailsjustin_smith: hash-map of strings to hash sets I think, yeah
21:04justin_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:04clojurebot{"a" #{1 4 6 3 2 ...}, "b" #{7 1 6 2 5}}
21:04justin_smiththat should do what you want? or close to it
21:05justin_smithyou don't need update-in, since you know you want to operate on every key
21:07neoncontrailsjustin_smith: very close to it, give me onnne sec this is quite helpful
21:17neoncontrailsjustin_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:17neoncontrailsSeen any good practice resources? In scheme we had these handy things called box and pointer diagrams that helped me a lot
21:18neoncontrailsClojure's not so easily diagrammed though I fear
21:24turbofailany approach you'd use to understand that with scheme would also work in clojure
21:59justin_smithclojure just has more shapes of boxes
22:12akabanderIs anyone else having trouble getting to http://clojure.org?
22:13justin_smithyup
22:13kenrestivoakabander: http://www.isup.me/
22:13kenrestivoer, http://downforeveryoneorjustme.com/clojure.org
22:18turbofailhuh. 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:18akabanderWeird, bummer... Thanks though.
22:40neoncontrailsWhat's a good rule of thumb, ballpark figure for the memory footprint of a typical clojure vector?
22:41neoncontrailsYou can assume it doesn't contain any floats or long strings :)
22:44TimMcneoncontrails: A vector less than 32 elements would just be an Object[32] with not much else, I think...
22:45neoncontrailsHow many bytes would typically get allocated per cell?
22:46TimMc"per call"?
22:46justin_smithfor a one element vector, enough to hold 64 Object pointers
22:46justin_smithcell
22:46TimMc64... because of the tail?
22:46justin_smitherr, 32 64 bit, of course
22:46TimMcok
22:46justin_smithwith some small overhead for the tail yeah
22:46TimMcplus there are ~8 supporting instance fields
22:47justin_smithif you actually look at one in the inspector, it's kind of weird
22:47justin_smithyeah
22:47neoncontrailsjustin_smith: awesome thank you
22:47TimMcneoncontrails: Try allocating a bunch and see what happens. :-)
22:47justin_smithneoncontrails: but note that a 31 element vector is exactly the same size
22:48justin_smithand then a 32 element one would be big enough to hold 64 objects, etc.
22:49neoncontrailsTimMc: I'll report back, just trying to make sure my aspirations are within what I pay for on my cloud server heh
23:22turbofailnutnutnutnut: here's my version of the whole problem http://sprunge.us/EjHb
23:22nutnutnutnut!
23:23nutnutnutnutdoes it work?
23:23turbofailyeah
23:24nutnutnutnutgives nil when i run it
23:24turbofailwe're doing this one right? https://www.4clojure.com/problem/73
23:24nutnutnutnutyea
23:25nutnutnutnutoh wait i got it
23:26turbofailyou can't use defn in 4clojure i suppose
23:26turbofailso it'd just be (fn win? ...)
23:28turbofailhttp://imgur.com/bQyMVRu
23:28nutnutnutnuttrying to understand it now
23:29turbofailthe board input already gives you a sequence of rows
23:29turbofail(apply map list b) gives you a sequence of columns
23:30turbofailand the other two bits are to get the diagonals
23:30turbofailthen i just look for any row, column, or diagonal that has either all :x or all :o
23:30nutnutnutnutclever!
23:31nutnutnutnutsimple too