#clojure logs

2015-05-30

00:02randomcharhereOne issue yeh will run into is if you change yer game object you will have change all the fuctions would create an itermediate function that talks to all the other functions that way yeh end only having to modify one fuction?
00:19escherizeThe best approach I've seen for managing a big-ass-state-map is re-frame, It's a clojurescript library that's got a simple idea that wouldn't be hard to implement in clojure.
00:27dumptruckmanescherize: thanks, i'll look into it
00:27dumptruckmanescherize: otherwise i basically have to deal with the big-ass-state-map yeah?
00:58ambrosebswhere does lein repl call complete.core/completions?
00:59ambrosebsah I think this is the code that gets injected https://github.com/trptcolin/reply/blob/69c4c6ffe0c8903a193c1e127337832e225335b0/src/clj/reply/reader/jline/completion.clj#L6-L7
02:32escherizedumptruckman: you might want to take a look at spectre for maintaining a big map if swap reset and update-in feel like not enough
03:26elvis4526I'm trying to use httpkit and websocket and with-channel isn't working.
03:26elvis4526within (with-channel req channel), channel is always nil.
07:28ionthas_dumptruckma: "It's better to have 100 functions operate in one datset insted of having 10 functions operating in 10 differents datasets." You should check atoms, they will allow to change the state of your big object. Maybe there is a better way to do it, but I'm also a principant.
07:34irctcwhat is the super class of map list String seq ...?
07:37oddcullyObject?
09:16franklnrsjoin #bouncetest
09:20gfredericksirctc: "map list String seq ..." isn't a class?
10:34virmundihello. Is there anyone active in here?
10:35virmundiI’ll give it a shot. I need to get a File from the tests/ dir of the project. I cannot figure out how to get that without handing a full path. I need a File and not a stream.
10:38luxbockvirmundi: might (java.io.File. (.getCanonicalPath (java.io.File. ".")) "/tests/") work?
10:39virmundilet me see.
10:39luxbock(java.io.File. (str (.getCanonicalPath (java.io.File. ".")) "/tests/file.thing"))
10:40virmundiyes, yes it did. now I wonder why (io/file didn’t)
10:41luxbockreplacing java.io.File. with io/file should work exactly the same
10:41justin_smithluxbock: isn't that the same as (java.io.File. "./tests/") - it should be
10:41virmundiI added a new resources directory under test and updated the lein profiles.clj to work.
10:42luxbockjustin_smith: oh right!
10:42virmundiyou’re right. tempfile2 (io/file "./test/resources/20150429_102332.jpg")
10:42virmundithanks
10:43justin_smithvirmundi: here's another neat trick --
10:43justin_smith,(java.io.File. "foo" "bar")
10:43clojurebot#object[java.io.File 0x1a442294 "foo/bar"]
10:43justin_smithno need to use str either :)
10:44virmundi:)
10:48gfredericks,(java.io.File. "foo/bar" "baz/kabling")
10:48clojurebot#object[java.io.File 0x3bd2c1b4 "foo/bar/baz/kabling"]
10:58drivercacheShould i learn java before learning clojure?
10:58drivercacheI am new.
10:58SagiCZdrivercache: not super necessary i would say
10:58virmundino. As a guy who literally has a Java ring on as I type this, you don’t need it.
10:58virmundihttp://s.hswstatic.com/gif/digital-jewelry-javaring.jpg
10:58SagiCZdrivercache: may help to read up about the very basics.. but you dont need to dive deep into inheritence, oop etc
10:59justin_smithdrivercache: it suffices to know just enough so that javadoc is readable - you really don't need to get the syntax, but the semantics are helpful
11:00virmundidrivercache: the viewpoints are different. you can write clean code in java with out concern for much mutation (final for all vars), but clojure makes the same easier.
11:00SagiCZvirmundi: not entirely true.. its not as simple as slapping final on attributes.. clojure goes a long way towards immutability
11:00virmundiI agree. I was just saying.
11:00justin_smithvirmundi: well... a final collection is still mutable, even if its field is final - so you do need immutable collections
11:01SagiCZi think there are some java libraries for immutable collections.. probably not as efficient as in clojure
11:01justin_smithSagiCZ: clojure is a good java lib for immutable collections :)
11:02virmundijustin_smith: I’m saying you can do it in Java, but you’re going to get into some niche corners of Java development. Heck, using final is so odd for most developer I’ve been actually told to remove them because they make the code harder to read.
11:02SagiCZjustin_smith: interesting point! maybe some java coders could only use that part of clojure
11:02SagiCZvirmundi: seriously? thats just non-sensical, who told you that? final is appropriate in many cases and it may make the code way faster
11:03virmundisagicz: a very poor programmer during a code review. I ignored her and then had a 20 minute conversation about code quality with the project manager.
11:04SagiCZvirmundi: i see!
11:04SagiCZanyways whats up with clojure lately? is it still being developed? where is 1.7.0? is clojure losing momentum?
11:04virmundisagicz: in the end, I got to keep the finals.
11:05justin_smithSagiCZ: 1.7 has a release cantidate, and might be the most feature rich addition we've had in a long while
11:05justin_smithmight be comparable to the 1.2 -> 1.3 update
11:06SagiCZjustin_smith: and would you call clojure's future bright? i understand it will never become mainstream engine, but it needs to have a solid community so it wont die out. I hate to start a big project only to find that the tools I use get deprecated in the next year
11:06SagiCZs/engine/language
11:06justin_smithI don't see any signs of that myself
11:07SagiCZthis is interesting though https://www.google.cz/trends/explore#q=clojure%2C%20golang&cmpt=q&tz=
11:07SagiCZkeyword trend comparison
11:08SagiCZjustin_smith: anyways, thanks.. thats mostly what i wanted to hear
11:08justin_smithclearly, if we want it to succeed, cognitect has to hand clojure over to bing
11:09justin_smithSagiCZ: I think the mailing list (available on google groups) gives a good idea of the state of development (both for the language and libs) - things tend to get announced or decided there
11:10SagiCZjustin_smith: i see.. well being quite young and from a Windows background I always found mailing-list bizzare and unproductive communication of the past.. almost like using mailing pidgeons.. so I guess thats why I didnt catch the latest development. thanks
11:11justin_smithSagiCZ: the UI on google groups makes it more like a web forum
11:11SagiCZbtw cognitect? is clojure developed by private company now<
11:11SagiCZ?
11:11justin_smithSagiCZ: always has been
11:11justin_smithit accepts contributions
11:12SagiCZdidn't know that
11:12justin_smiththat's why you have to sign the super official agreement and use jira if you want to submit code for clojure
11:13SagiCZwell I don't think it's a bad idea at all..
11:13SagiCZseems like clojure's development is fueled by Datomic and other cognitect products
11:13justin_smiththey also offer clojure consulting
11:20drivercacheSagiCZ: I have working knowledge of python, will it be enough to begin?
11:21SagiCZdrivercache: nothing is enough to begin
11:21SagiCZif you learned python, you can learn clojure
11:21SagiCZjust note that functional programming is very different from imperative (python) and the transition might be difficult at first
11:25gfrederickshello
11:30virmundihi
11:31luxbockI have a debug-printing helper library that currently just formats text nicely and prints it to the REPL
11:32luxbockI thought it might be a good idea to offer alternative output targets
11:32justin_smithluxbock: you should check out aviso/pretty and aviso/tracker
11:32justin_smithfor prior art
11:32luxbocki.e. you could print to a file, create a HTML page or an org document
11:32luxbockjustin_smith: this is mine: https://github.com/luxbock/pr-foobar
11:32luxbockI think they do different things
11:33justin_smithpretty is for things like column alignment and colors
11:33justin_smithtracker is for being able to show a context for errors that makes sense for clojure code
11:33luxbockmy goal is that switching from the core-function to the pr-equivalent should be as painless as possible
11:33justin_smithOK
11:34luxbockso to switch the output function, I was thinking of making a dynamic variable that holds it
11:34luxbockand then just use alter-var-root to change it
11:34luxbockis this a good idea?
11:34justin_smithif you are using alter-var-root, why make the var dynamic?
11:34luxbockah yeah I guess I wouldn't need to
11:43virmundiwhat am I doing wrong here: (io/copy (:tempfile file) dest-file)
11:43virmundi(:tempfile is a valid file). dest-file is a new file.
11:44SagiCZ:tempfile cant be a valid file, it is a keyword
11:44virmundifile is a map
11:44virmundi(:key m) == value?
11:44SagiCZyes that is correct
11:45virmundidest-file is new. But I’m getting a error actual: java.io.FileNotFoundException: /Users/jdavenpo/Pictures/tours/usa/fl/palatak/uuid/newfile.jpg
11:46SagiCZwell.. seems like the fild is not on that path
11:49virmundi(is (.exists tempfile))
11:49virmundiwhere tempfile is the value in the map :tempfile
11:49SagiCZthat returns true?
11:49virmundiyep
11:49SagiCZyou can lose the "is" btw
11:50virmundithe temp file is classpath relative.
11:50virmundiI can in a test?
11:50SagiCZno no.. not in a test
11:50SagiCZsorry
11:50virmundinp.
11:50SagiCZtahts really weird.. because the jvm can access the file but then says its not found? strange
11:50virmundiThe error is the new file.
11:51SagiCZoh..
11:51virmundi(defmethod move :tour-list [file]
11:51virmundi (let [dest (create-dest file)
11:51virmundi dest-file (io/file dest)]
11:51virmundi (io/copy (:tempfile file)
11:51virmundi (io/file dest))
11:51virmundi dest))
11:51SagiCZthen maybe then you dont have write acces on the path
11:51justin_smithvirmundi: don't do that please
11:51virmundisorry, best way to do that?
11:51SagiCZwww.refheap.com
11:51justin_smithuse a site like refheap
11:51justin_smithyeah
11:51virmundihttps://www.refheap.com/101885
11:53virmundithe blow out is on line 5, as per the refheap
11:53virmundithe declaration at line 3 is for debugging.
11:53SagiCZvirmundi: would like to help you but i rly dont know whats wrong there
11:54Chousukedoes the directory structure exist+
11:54Chousuke?
11:54virmundi:(
11:54ChousukeFile won't automatically create you directories.
11:54SagiCZyeah all the folders must exist before creating a new file
11:55justin_smiththere's a method that creates all the nested folders you need for a given path though iirc
11:56virmundi.mkdir executes without creating the paths.
11:56justin_smith.mkdirs
11:57justin_smith"Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories."
11:57justin_smithyou were missing the plural s
11:57justin_smith.mkdir only creates a single directory, where the parent must already exist
11:58justin_smith.mkdirs creates all the directories needed fora given file
11:58virmundi:O
12:04virmundiso then maybe a bit of Java is required for Clojure?
12:04justin_smithvirmundi: like I said, you should at least know how to read the javadoc
12:05justin_smithbut that's not java - you're not using java syntax. But we use the same vm and the same methods, so that ends up being something you should at least know how to look up.
12:06virmundi;)
12:06virmundiThat was it.
12:06virmundiI had to get the parent dir of the new file, but worked fine.
12:06virmundithanks
12:07justin_smithvirmundi: I find the "javadoc search pane" browser plugin really useful
12:08justin_smithit detects when you are looking at a javadoc page, and makes a pane with real-time completion and search
12:08SagiCZi would rather see the javadoc in my IDE than having to switch to browser
12:09justin_smithSagiCZ: I don't want to read javadoc in emacs myself
12:09SagiCZi understand..
12:10SagiCZi am very sensitive to my tool chain and i understand others may be as well so that can be left for personal preference
13:13luxbockone thing I've started doing lately with destructuring is to always use :as even when it's not strictly needed
13:13luxbockbut I think it makes it easier to read the code, because the name can give a hint to what the argument/local is supposed to do
13:13luxbockanyone else do this?
13:21gfredericksI don't because it looks like a mistake
13:22gfredericksbut I appreciate the desire for documentation
13:22gfredericksclojure currently conflates the local names of args with documentation for the args
13:22justin_smithsee also using prismatic/schema but not running the checks
13:22justin_smithbut using the declarations as a form of docs
13:23gfredericksI wish there were a standard way to add arg documentation
13:23justin_smithyeah, exactly
13:23justin_smithmetadata on args?
13:23gfredericksthe drawback is
13:23luxbockgfredericks: ditto
13:23gfredericksyou sometimes have multiple arglists
13:23gfrederickswhich might be irrelevant to the documentation
13:23gfredericks,(doc +)
13:23clojurebot"([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0. Does not auto-promote longs, will throw on overflow. See also: +'"
13:24justin_smithgfredericks: first class code accessible arglist objects, with first class code accessible arg objects
13:24gfrederickswhat
13:24justin_smithso you could do like (-> #'+ :arglists first :args first :doc)
13:24justin_smithnever mind that's crazy
13:25gfredericksI would suggest :doc/args metadata on the var
13:25gfredericksrelated, you could also add examples as metadata
13:25gfredericksi.e., as first-class code rather than in a docstring
13:25gfrederickswhich could additionally be subject to automatic validation
13:25justin_smithtests can already be specified this way
13:26gfredericksyeah
13:26gfrederickswell
13:26gfrederickssort of
13:26gfredericks,(doc test)
13:26clojurebot"([v]); test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception"
13:26gfredericks^ it looks for a fn, not a form
13:26justin_smithahh
13:26justin_smithyeah that is different
13:27gfredericksand you have to throw exceptions :/
14:11gfredericksdoes anybody know an elisp way to check if the current buffer is a file that is in the project that the default cider connection is a part of?
14:11gfredericksI assume any solution has to be super hacky
14:12clojerI have a (let .... form containing 2 non-nested (for ... comprehensions. Only the last one seems to execute even if I wrap them both in a (do ... block which shouldn't be necessary in a (let ... form.
14:17justin_smith~for
14:17clojurebotfor is a beautiful person
14:18justin_smithclojer: sorry, I wanted a different factoid. for is lazy
14:18justin_smithuse doseq if you are not consuming the result
14:18justin_smithit's almost identical, but returns nil and is not lazy
14:18justin_smith,(do (for [a (range 10)] (println a)) nil)
14:18clojurebotnil
14:19clojerjustin_smith: Why does only the last for comp execute?
14:19justin_smith,(do (doseq [a (range 10)] (println a)) nil)
14:19clojurebot0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n
14:19justin_smithclojer: laziness
14:19justin_smithnotice the difference between what for and doseq did above
16:05fourqI'm reading up on persistent vectors and their inner workings. If someone could speak to this image, specifically what it means when it says "path copying". The way I interpret this is that the new vec, the blue one, created 3 new internal nodes, 1 new leaf node, and then pointed the left internal node to the existing, old, vector. Where does "path copying" come into play here? http://screencast.com/t/ZG4igyaPHS7
16:25bmorphismIs output-stream with lazy-seq the solution if I want to output the results of a computation into a file and not keep them in memory?
17:21underplankSo I have this (def scripts-path (str (io/resource "test/scripts") "/"))
17:21underplankwhich gives me "file:/Users/mlakewood/Projects/orochi/resources/test/scripts/"
17:21underplankhoe do I get just the string representation without the file: on there
17:22underplank*how
17:28justin_smithunderplank: (.getPath (io/resource "test/scripts"))
17:28justin_smithyou don't need to add the / yourself
17:29underplankOh great! I’d worked out that I needed to get a java url and then do getPath on it.. but didnt realise that I could just call getPath on the return. Makes sens.
17:29underplankthanks justin_smith helpful as always!
17:42jtmarmonhey guys
17:43jtmarmoni have a fairly large threaded macro that fails macro expansion whenever I add "..." to one of the forms...if i remove it it succeeds. the compilation error is "CompilerException java.lang.StringIndexOutOfBoundsException: String index out of range: 0"
17:43jtmarmonjust having ... anywhere in the macro makes it fail with that error. it's quoted just fine as far as i can tell. super weird
17:44justin_smithwait, what does 'add "..." to one of the forms' mean exactly?
17:44justin_smithlike one of the forms has "..." in it?
17:44justin_smiththe string?
17:44jtmarmonyep
17:44jtmarmonno
17:44jtmarmonthe characters ...
17:44jtmarmonnot in a string
17:44jtmarmonthe form is quoted
17:45justin_smitheven if quoted, I don't think ... is valid - it's not a valid symbol or symbol constituent. There may be contexts where it works accidentally.
17:45justin_smith,'...
17:45clojurebot...
17:46jtmarmonit's for a datomic collection binding
17:46justin_smithOK
17:46justin_smithfunny, ... actually works as a symbol, but I didn't expect it to
17:47jtmarmonhttp://puu.sh/i6pA9/97aa45aa3f.png
17:50TEttinger,(let [... "wat"] ...)
17:50clojurebot#error {\n :cause "Illegal field name \"...\" in class sandbox$eval49"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassFormatError: Illegal field name \"...\" in class sandbox$eval49, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.ClassFormatError\n :message "Illegal field name \"...\" in ...
17:50TEttingerhm
17:50justin_smith,(def ... "this works")
17:50clojurebot#'sandbox/...
17:51justin_smith,...
17:51clojurebot"this works"
17:51TEttingerwhaaaaat
17:51justin_smithTEttinger: yeah, I know, right?
17:51justin_smiththat's why my first instinct was that it only worked accidentally
17:51TEttinger(inc wat)
17:51lazybot⇒ 3
17:51TEttingerhow doe sthat have 3
17:51justin_smithTEttinger: I think it's because vars are not used as method or field names
17:52justin_smithTEttinger: if only our incs left metadata we could look up on the karma :)
17:52TEttingerhaha
17:52TEttingerlazybot could even dump to refheap
17:56justin_smith,(def watset (hash-set Double/NaN Double/NaN Double/NaN))
17:56clojurebot#'sandbox/watset
17:56justin_smith,watset
17:56clojurebot#{NaN NaN NaN}
17:56justin_smith,(get watset Double/NaN)
17:56clojurebotnil
17:56justin_smith,(get watset (first watset))
17:56clojurebotNaN
17:56justin_smithroflmao
18:02justin_smith,(= watset (hash-set Double/NaN Double/NaN Double/NaN))
18:02clojurebotfalse
18:02justin_smith,(= watset (apply hash-set watset))
18:02clojurebottrue
18:02TEttingerhaha
18:02TEttinger,(count watset)
18:02clojurebot3
18:03TEttinger,(distinct watset)
18:03clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: PersistentHashSet>
18:03TEttingeroh?
18:03justin_smith,(distinct (seq watset))
18:03clojurebot(NaN NaN NaN)
18:03TEttinger,(distinct (seq watset))
18:03clojurebot(NaN NaN NaN)
18:03TEttingerhaha
18:03justin_smithTEttinger: it's like we found the weirdest insect ever under a rock, and now we just can't stop poking it
18:03TEttingerhaha
18:04justin_smithlet's see what it does if we put it in a jar with a spider
18:04TEttingerI was going to link to a solifugid, but oh god those things are terrifying
18:05justin_smithis that the same as a camel spider?
18:05TEttingerhere's a better weird bug, it's nice https://flic.kr/p/cu62MQ
18:05TEttingernot sure
18:06TEttingerI think sun spiders
18:06justin_smith$google solifugid
18:06TEttingerI don't like house centipedes for totally different reasons
18:06lazybot[Solifugae - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Solifugae
18:06justin_smith"known variously as camel spiders, wind scorpions, sun spiders, or solifuges"
18:06TEttinger(as in, if you hit a house centipede with, say, your shoe, its legs fly off and KEEP MOVING)
18:06justin_smithheh
18:07justin_smithvery similar in nature to a set full of multiple NaNs
18:07TEttingeryes
18:07TEttingerit is what should not be
18:55sdegutisIs there anything Clojure can't do that Haskell can, aside from the restrictions and type-checking errors Haskell provides?
18:56gfredericksit's probably easier to call C code in haskell?
18:57sdegutisOkay but any algorithmic type things?
18:57sdegutisLike, can Clojure implement monads?
19:01justin_smiththere are monadic libraries for clojure, but since we don't have easy type inference or strong type requirements they usually don't end up being especially useful
19:05sdegutisAh I see.
19:06sdegutisThanks guys.
19:06sdegutisWelp, back to cleaning up the mess I made in our codebase at work.
19:06gfrederickssdegutis: actually yeah monads are a good point -- you can't straightforwardly write polymorphic 0-arg functions that monads in haskell depend on
19:07gfredericksI think this is the main reason why trying to write a monad library in clojure is pretty awkward
19:08justin_smithgfredericks: even using one is a bit weird
19:08gfredericksI've never tried
19:09sdegutisgfredericks: Oooh, that explains it.
19:09sdegutisBecause in Clojure, polymorphism requires at least one argument.
19:09gfredericksyep
19:09sdegutisIn Haskell, it can be based on type, which is like an implicit argument almost.
19:09gfrederickscan't write (return x) or (pure x) or whatever
19:09sdegutisGot it.
19:09gfredericksso you could A) require everybody to pass "the monad" around, in which case nobody will want to use your library
19:10gfredericksB) do something magical with macros or dynamic vars or something, in which case nobody will want to use your library
19:10gfredericksC) don't bother writing a monads library, in which case nobody will want to use your library
19:11gfredericksif bbloom were here he would argue that monads aren't very useful anyhow
19:11bbloomjust use a lazy seq and write an interpreter for that seq w/ reduce
19:12sdegutisOooh, of course!
19:12sdegutisbbloom: why not transducers?
19:12gfrederickshe didn't say not transducers
19:12sdegutisbbloom: I was under the impression that transdocers completely obsolete your solution.
19:12sdegutisgfredericks: I thought transducers and lazy seqs were incompatible?
19:13gfredericksnot at all
19:13bblooms/lazy seq/whatever-ducable/
19:13gfredericks,(doc sequence)
19:13clojurebot"([coll] [xform coll] [xform coll & colls]); Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence nil) yields (), When a transducer is supplied, returns a lazy sequence of applications of the transform to the items in coll(s), i.e. to the set of first items of each coll, followed by the set of second items in each coll, until any one of the co...
19:14gfrederickshmm
19:14gfredericks,(sequence (map inc) [1 2 3])
19:14clojurebot(2 3 4)
19:14gfredericks,(type (sequence (map inc) [1 2 3]))
19:14clojurebotclojure.lang.LazySeq
19:14gfredericks,(sequence (map inc) (range 5))
19:14clojurebot(1 2 3 4 5)
19:14gfredericks^ lazy seq in, lazy seq out, w/ transducers
19:15gfredericksdid refinements ever make it to ruby 2?
19:20sdegutisI think I prefer objects, classes, and dot-notation.
19:20gfredericksyou've been saying that for weeks now I think
19:20sdegutisI have? I thought this was the first time.
19:20gfredericksokay I'll stop conversing I guess
19:21sdegutiswat
19:22sdegutisI don't see the connection from everything before that to that.
19:23gfredericksI assumed you were trolling because most of your conversation lately has been about OOP
19:28gfredericksI was tripped up by the difficulty of telling intentions via text; my apologies
19:29sdegutis:|
19:34sdegutisI guess I'm just coming to this same conclusion over and over because I've made a mess of my codebase by trying to design our system with just pure functions, which has a lot of drawbacks.
19:39gfrederickshow much legacy ruby have you dealt with?
19:40sdegutisgfredericks: plenty
19:40sdegutisgfredericks: I'd say this is worse.
19:43sdegutisNeat how in Datomic a bool value can be true false or nil.
19:44sdegutisI am taking advantage of that right now in my code.
23:35dumptruckmanhow do i join together lists into one list?
23:35justin_smithdumptruckman: concat
23:35dumptruckmanah, thanks
23:36justin_smith,(concat (range 3) (range 3))
23:36clojurebot(0 1 2 0 1 ...)
23:38dumptruckmanis there some way to do this with destructuring?
23:38dumptruckman(concat (for [player (:players entites)] (:segments player)))
23:38justin_smithno
23:39justin_smithI mean there is apply concat
23:39dumptruckmanactually i'm not even sure that's right >.>
23:39justin_smithor mapcat
23:39justin_smith,(apply concat (for [a {:a [0 1]} {:a [:b :c]}] (:a a)))
23:39clojurebot#error {\n :cause "for requires an even number of forms in binding vector in sandbox:"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: for requires an even number of forms in binding vector in sandbox:, compiling:(NO_SOURCE_FILE:0:0)"\n :at [clojure.lang.Compiler macroexpand1 "Compiler.java" 6644]}\n {:type java.lang.IllegalArgumentExce...
23:39justin_smitherr
23:39clojurebotI don't understand.
23:40justin_smith,(apply concat (for [a [{:a [0 1]} {:a [:b :c]}]] (:a a)))
23:40clojurebot(0 1 :b :c)
23:40justin_smith(mapcat :a [{:a [0 1]} {:a [:a :b]}])
23:40justin_smith,(mapcat :a [{:a [0 1]} {:a [:a :b]}])
23:40clojurebot(0 1 :a :b)
23:40dumptruckmanwait
23:40dumptruckmanapply concat?
23:40justin_smithmapcat is likely the one you want
23:40dumptruckmani see
23:41justin_smithbut apply concat works too
23:41justin_smithmapcat is just apply concat map ...
23:41justin_smith$source mapcat
23:41lazybotmapcat is http://is.gd/HgriSd
23:41dumptruckmani see
23:45dumptruckmanwhen i'm defining a map is it possible to refer to the values i've defined ahead of another?
23:46justin_smithsounds like something where a let block plus a few calls to assoc would help
23:46TEttingerdumptruckman: you can use ##(declare)
23:46lazybot⇒ nil
23:46TEttingerdumptruckman: you can use ##(doc declare)
23:46lazybot⇒ "Macro ([& names]); defs the supplied var names with no bindings, useful for making forward declarations."
23:46dumptruckmanO.o
23:46dumptruckmanfor instance
23:46TEttinger,(declare foo)
23:46clojurebot#'sandbox/foo
23:47TEttinger,{:bar foo :a 1}
23:47clojurebot{:bar #object[clojure.lang.Var$Unbound 0x7c02c5a4 "Unbound: #'sandbox/foo"], :a 1}
23:47TEttinger,(def mapperz {:bar foo :a 1})
23:47clojurebot#'sandbox/mapperz
23:47TEttinger,(def foo "yay")
23:47clojurebot#'sandbox/foo
23:47TEttinger,mapperz
23:47clojurebot{:bar #object[clojure.lang.Var$Unbound 0x7c02c5a4 "Unbound: #'sandbox/foo"], :a 1}
23:47TEttingerhm
23:47dumptruckman{:a a :b b :c :a} where the value for c is the value for :a
23:47TEttingeroh
23:47justin_smithyeah, use assoc for that
23:48justin_smith,((fn [m] (assoc m :c (:a m))) {:a 0})
23:48clojurebot{:a 0, :c 0}
23:49dumptruckmanmeh
23:49dumptruckmani think that's probably more complicated than juts putting the value again
23:49justin_smithdumptruckman: if you already knew the value, do that
23:49TEttingeror you could have it be a key into a different table
23:49justin_smithI thought you were talking about a situation where the caller could specify any :a they please, and you need to map :c to that too
23:50dumptruckmannah
23:50dumptruckmani'm defining a player object which has a color key
23:50dumptruckmanand also needs to define a shape in the same map using that color
23:50dumptruckmanit might be useful later
23:50dumptruckmanwhen i get to having more than 1 player
23:50TEttinger,(let [inner {:a 10 :b 20} outer {:a :a :b :b :c :a}] (inner (outer :c)))
23:50clojurebot10
23:51dumptruckmanwat
23:54dumptruckmani can't wrap my mind around that
23:56dumptruckmanhmm
23:56dumptruckmanthis doesn't seem to be doing what i'm going for
23:56dumptruckman(apply concat (for [player (:players entities)] (:segments player)))
23:57justin_smithdumptruckman: equivalent is (mapcat :segments (:players entities))
23:57justin_smithand I think that version is a bit nicer
23:57dumptruckmanwell
23:57dumptruckmanit produces an empty lits
23:57dumptruckmanbut there's definitely something in the segments part that i'm trying to retrieve
23:58dumptruckmanso entities is a map that has a seq of :players and each element of that seq has a seq of :segments
23:59justin_smithso (-> entities :players first :segments) will always give you a seq
23:59justin_smithif so, that for comprehension should work