#clojure logs

2014-07-09

00:06FrozenlockWant to learn Clojure? Hang in #clojure and you'll learn by osmosis :-p
00:13amalloyosmosis is okay, but you'll go a lot faster if you try to contribute
00:13amalloyotherwise it all just washes over you
00:33sm0kein project.clj i have something like (def profiles {:a {..} :b {...}}) (defproject.... :profiles profiles)
00:33sm0kebut this doesnt seem to work
00:34technomancysm0ke: defproject is a macro; it implicitly back-quotes.
00:34sm0kebut ~profiles also doesnt work
00:34technomancyhm; I know other people have gotten that working
00:35sm0ketechnomancy: i you remember the bug which we were discussing..seems like its already there https://github.com/technomancy/leiningen/pull/992
00:36sm0keonly that there is no doc for it at all
00:37sm0kealso it is nice that if i just put :classifier "xyz" in project.clj it is converted to an xml element in .pom file
00:37technomancyyeah, definitely needs docs
00:38sm0kebut the right way is to use :classifiers , as you would not want to install each one seperately
00:39sm0kei will add the same example to sample.project.clj
00:39sm0kei think everyone looks there first
00:41sm0keso my problem now is i want to have classifier for each profile which i have and do not want to replicate the profile map
00:41sm0kei mean rewrite
00:48technomancyyou can have composite profiles
00:49technomancy:profiles {:a {:x "y"} :b {:z 10} :aplusb [:a :b]}
00:49arrdemtechnomancy: it wasn't clear to me when I read the docs yesterday: can you have a composite profile with definitions?
00:49technomancyarrdem: definitions?
00:50arrdemso :profiles {:foo {:inherits [:a :b] :dependencies [[com.foo/shit "0.0.0-SNAPSHOT"]]}}
00:50technomancyarrdem: map keys are just map keys
00:50technomancythere's no magic keys with special meanings
00:51technomancyI mean, they all mean the same thing they mean inside defproject
00:51arrdemokay. so you have to have an "intermediary" profile that gets merged with whatever you are going to inherit from.
00:51technomancyI wouldn't use the term "inherit"
00:51technomancy"merged" is better
00:51arrdemsure
00:52technomancybut yeah
00:56sm0kehttps://github.com/nathanmarz/cascalog/blob/develop/cascalog-core/project.clj
00:56sm0keseems to be doing the same thing
00:57sm0kei am not sure why :profiles ~profiles wont work
01:28shanemhansenHow would you use the iterate macro if your function took multiple arguments?
01:30shanemhansenI want to generalize something like (apply foo (apply foo [arg1 arg2]))
01:33bbloomshanemhansen: iterate is a function, not a macro
01:33shanemhansenbbloom, sorry. I'm really new to clojure/lisp.
01:33bbloomshanemhansen: no worries
01:34bbloomit doesn't really make sense for iterate functions to take multiple arguments b/c it will use the same function on the result
01:34bbloomif you have a function that returns a vector or something like that, you can wrap the function to also take a vector
01:35bbloomhere's an example:
01:35bbloom,(take 5 (iterate (fn [[x y]] [(inc x) (dec x)]) [0 0]))
01:35clojurebot([0 0] [1 -1] [2 0] [3 1] [4 2])
01:35bbloomwhoosp
01:35bbloom,(take 5 (iterate (fn [[x y]] [(inc x) (dec y)]) [0 0]))
01:35clojurebot([0 0] [1 -1] [2 -2] [3 -3] [4 -4])
01:35bbloomthere
01:38shanemhansenThanks bbloom.
01:55hellofunkIn Om, I'm a bit confused on the role of the "owner" parameter. For example, line 9 of this: https://www.refheap.com/87993 clearly it is referring to the state of the "this" object currently being re-ified. But yet, "owner" is named as an argument to the function itself, suggesting it is referring to something passed in.
02:39shanemhansenI'm running a simulation that shows clojure.lang.RT.first() and clojure.lang.LazySeq.seq() as bottlenecks. Is there some idiom in clojure that's faster than (count (drop-while perdicate? (iterate f args))) ?
02:40shanemhansenI could write it in java, but I'm having fun with clojure.
02:44shanemhansenhttps://gist.github.com/shanemhansen/b237c8ebc747cc6e0ed2
02:48justin_smithshanemhansen: you could try a reduce or loop with a counter and a state argument
02:48shanemhansenThanks justin_smith
02:50justin_smith,(loop [i 0 t 0] (if (> i 10) t (recur (inc i) (+ i t))))
02:50clojurebot55
02:50justin_smithfor example
02:51justin_smithin bytecode that is equivalent to a java for loop
02:51justin_smith(or should be)
02:54amalloyshanemhansen: you're counting lazy sequences an awful lot of times. you can't use a data structure that's better at being counted?
02:55amalloylike, your tick function counts a bunch of lazy seqs and then makes them longer, and then in your next iteration you count them again...
02:55shanemhansenamalloy, I know the sequence of "ticks" is lazy. I'm counting it once.
02:55justin_smithamalloy: that's why I figured a raw loop, then no sequence even needs to exist, you just count iterations
02:56amalloyno, the rungs inside of tick
02:56shanemhansenI'm not familiar enough w/ clojure to know where I put my other lazy sequences ; ).
02:56amalloycounting the return value from period is no big deal
02:56amalloyand i misspoke a bit: in tick, the rungs aren't lazy, but they are singl-ylinked lists, which are expensive to count
02:57shanemhansenI asked because profiling didn't immediately make it look like counting was the problem. Even though I *know* count must be O(n).
02:57amalloywell, count doesn't have to be O(n) if you use a better data structure
02:58justin_smithwith vector / conj it would be O(1)
02:58amalloyand indeed your queue should be a vector
02:58amalloyyou always add to the right, and using concat for that is super expensive
02:58amalloywith vectors, it's practically free, and so is count
02:58shanemhansenamalloy, Maybe it's different for clojure. In golang I use a single linked list with an extra pointer to the tail.
02:59justin_smithyeah cons on a seq is cheap on the left, conj on a vec is cheap on the right
02:59shanemhansenappending onto a vector causes it to do lots of gc due to the amortized doubling of allocation.
02:59amalloyshanemhansen: that's fine, but pointers to the tail are ~impossible without mutation
02:59shanemhansenI know clojure has like some sort of tree-ish thing for vectors?
02:59justin_smithyes
02:59amalloyyeah, amortized doubling is a total red herring. are you talking about another language's vectors? clojure doesn't have those
03:00shanemhansenI'll try vectors. I am talking about another languages vectors. I'm doing this excersize to learn about clojure's data structures, so your feedback is really helpful amalloy.
03:01amalloyadding to the end of a vector is very cheap, and the way you're building queue right now is O(N^2). so if queue is large, i expect switching to vectors will fix your performance issues
03:02amalloyoh, but you're also using first/rest on it? you need a queue, not a vector
03:02amalloy,(peek (into clojure.lang.PersistentQueue/EMPTY) [1 2 3 4])
03:02clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/into>
03:02shanemhansenamalloy, the "queue" is double ended. So ideally appends and pushing are cheap.
03:02amalloy,(peek (into clojure.lang.PersistentQueue/EMPTY [1 2 3 4]))
03:02clojurebot1
03:03shanemhansenThe rungs can be pretty well represented with vectors I think.
03:03amalloyyou append onto both sides?
03:03amalloyit doesn't look that way to me
03:03amalloyyou always push onto the right, and pop from the left
03:03shanemhansenamalloy, sorry you're right. I mutate both sides, not append.
03:04amalloyeh, the rungs are probably fine as lists. they don't get large, and you seem to want to build them on the left and consume on the left, so lists are perfect
03:04amalloya clojure.lang.PersistentQueue looks like the structure you need for your queue
03:04amalloy(appropriately, since they're even both called queue)
03:46jein ClojureScript: (def my-atom (atom {})) in ns1 and :refer it from ns2. When I try to deref it: @my-atom I get: No protocol method IDeref.-deref defined for type undefined, anyone know why?
03:49scotty9my friend died in a car accident
03:50scotty9im trying to find clojure
03:50scotty9get it
03:50scotty9cause its like closure but no its clojure
03:55ddellacostaje: can you paste the code into a refheap or gist?
03:57hellofunkIn Om, I'm a bit confused on the role of the "owner" parameter. For example, line 9 of this: https://www.refheap.com/87993 clearly it is referring to the state of the "this" object currently being re-ified. But yet, "owner" is named as an argument to the function itself, suggesting it is referring to something passed in.
04:03expezWhen I do lein -U repl today I get a warning about 'no nREPL dependency detected' it then starts an nREPL server an appears to be working just fine. It also doesn't update any snapshots, even though I know for a fact cider-nrepl was updated yesterday. What gives?
04:16jeddellacosta: https://gist.github.com/jacobemcken/8b993ff43c4809bc954a
04:17Glenjaminhellofunk: i thought it was the parent component, but i may be wrong
04:17Glenjaminactually yeah, it does seem to be `this`
04:18ddellacostaje: are you calling @state directly in the file like that?
04:19jeddellacosta: from LightTable... trying see what's inside the atom :)
04:21ddellacostaje: I'm not familiar with LightTable. Are you talking about running it in a console or repl in some way?
04:22hellofunk what's the proper approach to have a single Om root that then builds various unconnected components, or is this not possible? Nolen's tutorials just use more than one Om/root for this. I've tried to have more than one om/build in a function but React provides an error
04:23ddellacostahellofunk: it's definitely possible, I do it a lot. If you post the code you're using and the error I can try to give you a hand.e
04:23ddellacosta*hand
04:25hellofunkddellacost let me see if I can pinpoint further
04:28hellofunkddellacosta ah turned out to not be my problem.
04:28ddellacostahellofunk: well then, problem solved. :-)
04:29hellofunkddellacosta: are you able to clear up a simple confusion about line 9 on this: https://www.refheap.com/87993
04:29ddellacostawhat's the confusion?
04:29jeddellacosta: LightTable have inline evaluation triggered by (Ctrl + Enter)... I believe it is connected to a repl somewhere and sends expressions for evaluation and returns the result to the editor
04:29hellofunk"owner" should be referring to the state specified in InitState (and it does) but what then is the owner passed into the function?
04:29hellofunkddellacosta ^
04:30hellofunkddellacosta wouldn't the arg named owner in the function parameter trump everything?
04:30ddellacostaje: it would be worth isolating that code and running it in the browser or in a normal CLJS repl (via austin) to see if it behaves similarly. It could be the case that LightTable is doing something to namespaces under the covers.
04:30ddellacostahellofunk: owner is the argument passed into your component.
04:31ddellacostahellofunk: sorry to be blunt, but what is confusing about that?
04:31ddellacostahellofunk: that is, I'm confused about what you're confused about...haha
04:31hellofunkddellacosta then how would owner in this context point to the state in the "this" ? because the InitState is not in the parent owner, it's in "this" object, yet owner is accessing "this", not the parent passed in
04:32ddellacostahellofunk: because of what Om is doing under the covers. owner is the magical object that manages what is going on with state in your component during the React rendering cycle.
04:32ddellacostahellofunk: ...to grossly generalize
04:33ddellacostahellofunk: this is a case where looking at the Om source code will greatly clear up your confusion about what's going on.
04:33hellofunkso "owner" is referring to the object itself, not the object passed in with the function arg
04:34jeddellacosta: It propably is :) thanks
04:34ddellacostaje: good luck!
04:35ddellacostahellofunk: take a look here: https://github.com/swannodette/om/blob/master/src/om/core.cljs#L604-L607
04:35ddellacostahellofunk: that's at the end of build*
04:36ddellacostahellofunk: it's calling your component (f) with the cursor you pass in (first arg) and owner as "this", within the context of ctor
04:36ddellacostactor by default is built via "pure"
04:37ddellacostahellofunk: pure is created via the pure-methods which are the guts of Om's magic, and which implement the React render cycle for Om: https://github.com/swannodette/om/blob/master/src/om/core.cljs#L204
04:38hellofunkddellacosta ok so owner isn't really representing some outside value getting passed into your function, even though it looks that way from a functional view.
04:38ddellacostahellofunk: no, owner is the component itself
04:39hellofunkddellacosta, ok, that's interesting indeed. it's like a function getting a pointer to itself.
04:40ddellacostahellofunk: well, except it's not--the component function you define is just a function. But the React component (with some wrapper functionality via Om for state operations) is passed to that component function you've defined, basically.
04:41hellofunkddellacosta: ah, so it is a pointer to its represeantion in the React system.
04:41ddellacostahellofunk: so when you consider how the owner knows about stuff you've declared in init-state, keep in mind that the owner has state (in the general sense of the word state) based on the step in the React render cycle that protocol you are defining is called in
04:41ddellacostahellofunk: yeah
04:42ddellacostalook here: https://github.com/swannodette/om/blob/master/src/om/core.cljs#L357
04:42ddellacostahellofunk: and right below it ^
04:42ddellacostahellofunk: where pure is defined, it just points to that Pure. instance which has extra state methods (get-state/set-state/etc.) defined on it
04:43hellofunkddellacosta, ok this helps clear up the, ahem, confusion.
04:43ddellacostahellofunk: great! It is definitely confusing at first.
04:43hellofunkddellacosta i was thinking of it all as clojurescript values getting passed around, though I know there was something more going on behind the scenes, the semantics are not obvious when working at the high level
04:43ddellacostahellofunk: but don't be afraid to dig into the source--it is really the best way to clean up confusion around how it works
04:43ddellacosta*clear up
04:44ddellacostahellofunk: yeah, I mean, build* is doing some sort of magical stuff
04:44ddellacostahellofunk: it's rather clever but a bit unintuitive
04:44ddellacostahellofunk: it allows for a very intuitive way of writing components though, I believe
04:44hellofunkddellacosta yeah to be honest it would take me quite a while to read and understand the source, so much of it uses techniques well beyond my current experience
04:44ddellacostahellofunk: well, one thing at a time. :-)
04:45hellofunkddellacosta appreciate the help, this was bugging me for a while
04:45hellofunkddellacosta i am not the first person to think that owner was the component's parent component
04:45ddellacostahellofunk: sure thing. Regarding difficulty of Om code, I think probably if you have a good handle on Protocols/types, then it becomes far more obvious what David is doing
04:46hellofunkddellacosta the parent-child relationship between components which build other children components makes it easy to incorrectly assume that owner is the component that called build on you
04:47ddellacostahellofunk: yeah, I can understand how one may think that
04:47hellofunka fella earlier in here thought the same
04:48hellofunkanyway, confusion has been dealt a deathly blow
04:48ddellacostahellofunk: excellent!
04:49hellofunkyeah, take that, confusion
04:49Glenjaminowner seems like an odd name then, if i followed that correctly then owner is roughly the react component instance
04:50hellofunkGlenjamin i think i might agree
05:01ddellacostaGlenjamin: I don't pretend to know exactly what dnolen was thinking, but it makes more sense if you think of it as "owner of the React component itself"
05:01ddellacostanot sure what a good name for it would be really
05:43expezAny way to get a :test profile which is used for `lein test`?
06:05ddellacostaexpez: have you tried "lein with-profile test test?"
06:06ddellacostaexpez: that is, assuming you've set up a "test" profile
06:16expezsuppse that would work, and then just make an alias 't' or something
06:16expezthanks
06:26hellofunkddellacosta is on a roll today
06:26hellofunk(inc ddellacosta)
06:26lazybot⇒ 4
06:26ddellacostahellofunk: haha
06:26hellofunk(inc ddellacosta)
06:26lazybot⇒ 5
06:26hellofunk4 just didn't seem high enough
06:26ddellacostawell then. :-)
06:26ddellacostanot sure what that is counting anyways, but hey
06:27hellofunkoh, i can tell you. it is counting the number of times someone types (inc ddellacosta), that's all
06:27ddellacostahellofunk: hahaha, that's an entirely correct and reasonable explanation
06:27hellofunkddellacosta: i thought as much, arrived at it a while back when I too was faced with similar confusion
06:28ddellacosta:-_
06:28ddellacostad'oh
06:28ddellacosta:-)
06:37hellofunkhey while it's not a good idea to update Om's atom outside of an Om component function, I assume it is just fine to read from that atom anywhere?
07:06vijaykiranhellofunk: yeah, reading should be fine
07:06hellofunksweet, yo. thanks.
07:33luxbockis oss.sonatype.org one of the default repositories that Leiningen uses?
07:35luxbockI have a problem where I'm trying to download dependencies for my project on a remote machine (AWS), but all the packages lein hits up from Sonatype are returning 302, which Maven does not know how to handle
07:37luxbockso leiningen thinks that it's getting the dependencies when it's in fact not getting them, and then eventually it fails with java.util.ZipException when it tries to open them
08:47erghis it possible to make an "anaonymous" macro? i just wrote my first (rather trivial) macro, but i only need to locally, in a function. do i have to define it outside t he function with defmacro? what happens when you use defmacro inside a function?
09:01justin_smithergh: tools.macro has a macrolet I think https://github.com/clojure/tools.macro
09:02justin_smithyeah, it looks like macrolet does what you want
09:16smarrHi, I am interested in how Clojure's transactions, agents, locking, core.async, and/or other concurrency libraries are used together. Are there interesting open source libs or applications I could have a look at?
09:16smarr(am really interested in larger projects using such abstraction, not examples or tutorials)
09:16justin_smithwell, directly using locking is extremely rare
09:17justin_smithand refs/transactions are relatively rare
09:22justin_smithone simple example of core.async usage is throttler http://brunov.org/clojure/2014/05/14/throttler/
09:24smarrjustin_smith: thanks, originally I hope LightTable would be written in Clojure, but it seems to be ClojureScript and doesn't use any of the concurrency libraries, wanted to compare a little how large Java applications such as Eclipse and Netbeans compare to similar applications written in languages with more extensive support for concurrency
09:24justin_smithregarding locking, we use immutible data so much in idiomatic clojure that locking is almost never needed - things will never be in invalid read states (the new value is a new binding)
09:25justin_smithsmarr: I don't know if we have anything as desktoppy as netbeans or eclipse
09:26justin_smiththere are some games being developed in clojure that would likely be good examples, I don't know how mature they are though
09:26justin_smith(or the names of the top of my head, sorry)
09:26smarrok, thanks, will try some more google/github queries
09:28teslanickAs a note: concurrency may not be a problem in clojurescript, but asynchrony is. I assume many of LT's internals are asynchronous and single-threaded, given how poorly it behaves when it gets blocked up.
09:32smarrteslanick: if I understand the code correctly, there is some wrapping for webworkers
09:32teslanickI haven't looked, but that wouldn't surprise me.
09:34smarrbut it is all still very rudimentary. netbeans for instance has at least two adhoc 'transactional systems' for various purposes.
09:36teslanickWell, because it's running JS under the hood, transactions are almost never necessary. The only time it is needed is when you're interacting asynchronously with multiple resources.
09:37d0kyhello does anybody know if can be http-kit deployed to tomcat whereas http-kit is ring compatible ?
09:41justin_smithd0ky: http-kit is not a servlet
09:41justin_smithring can generate a servlet compatible war
09:41justin_smithhttp-kit is a self-hosting alternative to that
09:41justin_smithhttp-kit, like tomcat or jetty, is a server
09:42d0kyjustin_smith: and is it good option to deploy app on http-kit ?
09:42justin_smithif you make a war via "lein ring uberwar" that can be run in tomcat or jetty
09:42justin_smithd0ky: http-kit performs much better than tomcat
09:42justin_smithbut does not have the log rotation, multi-app hosting, seamless redeploy, etc. of tomcat
09:43justin_smithbut you can get pretty far if you define a custom service that launches your http-kit uberjar
09:43justin_smithin both cases, you should have nginx (or something similar) in front of your server
09:44d0kyjustin_smith: so it could be deployed as http-kit and in front use nginx ?
09:44justin_smithyeah - well you would make an uberjar with "lein uberjar" and run that with java -jar
09:45d0kyjustin_smith: i heard something about ngnix but i haven't an idea how it works ...
09:45justin_smithd0ky: nginx stands between the outside world and your server
09:45justin_smithit has a number of security features that tomcat and http-kit lack
09:46justin_smithif your site is publicly visible, best practice is to have a well configured nginx server in front of your real server
09:46justin_smithfor performance, you can also add varnish in front of nginx, but that is not a security neccessity, that just helps serve requests faster
09:48d0kyjustin_smith: thanks for all i will look for some papers about ngnix and http-kit how they force them to work together
09:49justin_smithd0ky: the basic idea is that you tell http-kit to run on port 8080 (or whatever other port) and then tell nginx to run on port 80, and forward all requests to 8080
09:49justin_smithand then it blocks certain kinds of malicious or questionable requests, so they never even hit your app
09:50d0kyjustin_smith: woow :) it sounds quite straitforward :)
09:50justin_smithyeah, nginx is pretty easy to set up
09:50justin_smithand also lets you serve multiple clojure apps from one port (ie. /customers and /clients routes can each forward to a different http-kit instance or whatever)
09:51justin_smithbut nginx should be used whether you use tomcat or http-kit or whatever else
09:53d0kyjustin_smith: great because the problem for me with http-kit was ... how to run more than 1 app on one server ? thank you very much for options how to get it works :)
09:53justin_smithnp
09:54justin_smithto be more explicit, you could have http-kit running with one instance on 8080, another on 8081, another on 8082 etc. and have nginx config that forwards the apropriate requests to each of these ports
09:55justin_smithit uses regex to decide which backend serves each request
09:56justin_smith(or at least that's how I have done it - it can also do load balancing and such but with clojure I think it works out better to just have one process with multiple threads anyway)
10:18bacon1989how the heck do I check if a value is contained in a vector?
10:19bacon1989,(contains? ["foo" "bar"] "foo")
10:19clojurebotfalse
10:19teslanick,(.indexOf ["foo" "bar"] "foo")
10:19clojurebot0
10:19teslanickGross. But it works. :c
10:20teslanickYou can also convert to a set.
10:20bacon1989teslanick: that would probably work
10:20teslanick,(contains? (set ["foo" "bar"]) "foo")
10:20clojurebottrue
10:20teslanicker
10:21teslanickYeah, that will work.
10:21Glenjamin,(some #{:a} [:a :b :c])
10:21clojurebot:a
10:21Glenjaminsome is O(n), set contains? is O(1), but you need a set first
10:21Glenjaminif those are concerns
10:22teslanick,(some #{:noexist} [:a :b :c])
10:22clojurebotnil
10:22Glenjamin,(some #{false} [:a :b false]) ; there are still issues :)
10:22clojurebotnil
10:22Glenjamin,(def find (comp first filter))
10:22clojurebot#<CompilerException java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)>
10:23Glenjamin,(def detect (comp first filter))
10:23clojurebot#'sandbox/detect
10:23Glenjamin,(detect #{false} [:a :b false])
10:23clojurebotnil
10:23Glenjaminhrm
10:25cbp,(some #(= false %) [:a :b false)
10:25clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
10:26Dzurkocbp, what is your opinion on the purported newfound homosexuality of Patrick Stewart?
10:36arrdem!votetroll
10:39arrdemBronsa: check out feature/fast-emitter when you get a chance. I'm a little concerned that I broke your representation of a Class's AST, but that was the only really involved part of rewriting TEJVM to use a fipp style list flattening system.
10:39Bronsaarrdem: I saw that, gonna take a better look later
10:40Bronsaarrdem: is there a reason why you replaced the bc wrapping from [..] to (list ..) ?
10:40arrdemBronsa: I didn't. Single instructions are still [], sequences of instructions must be (list ..)
10:41arrdemBronsa: note that this means all instructions don't have to be wrapped, which let me throw out wrapping vectors in a bunch of places
10:42arrdemanyway. I'll be around when you get the chance to look at it. take your time.
10:48Bronsaarrdem: meanwhile, can you rebase to master? I just pushed a fix
10:48arrdemda
10:49arrdemdone
11:23aaronj1335dnolen_ one of our talks at austinjs this month is clojurescript and om! anything in particular we should make sure to cover?
11:25aaronj1335(:instrument, externs, etc)
11:36dnolen_aaronj1335: def externs :) that's the kind of thing that trips everyone up
11:36dnolen_aaronj1335: that's cool that you're covering this at austinjs :)
11:36aaronj1335right on
11:37aaronj1335yea, would have sooner, but we just need to find people with expertise
11:37aaronj1335we'll do a full meetup on it once we find someone willing to do so
11:44daGrevishey! are there any way to do an early return from a function? if yes, is it even okay to do so?
11:47teslanickI don't think so and why do you want to?
11:47dbaschdaGrevis: what are you trying to do?
11:47Willis1(defn func-with-early-return []
11:47Willis1 (if condition "EARLY RETURN MWUAHAHAHA" (do-rest-of-function)))
11:47daGrevisokay, nevermind http://stackoverflow.com/questions/7491360/how-do-you-return-from-a-function-early-in-clojure#7491616
11:52justin_smithdaGrevis: as a special case, there is 'reduced' when you are part of the way through reduce and know the return value already
11:53justin_smith,(reduce (fn [t i] (if (> i 10) (reduced t) (+ t i))) (range)) even works with infinite input
11:53clojurebot55
11:58justin_smith,(last (reductions (fn [t i] (if (> i 10) (reduced t) (+ t i))) (range 23))) for amusement purposes
11:58clojurebot#<Reduced@9aae17: #<Reduced@11b6956: #<Reduced@a0cb37: #<Reduced@7dc4b9: #<Reduced@fe69a1: #<Reduced@c9081c: #<Reduced@3391c0: #<Reduced@1a60283: #<Reduced@1ef1fb8: #<Reduced@ba899: #>>>>>>>>>>
11:58justin_smithif that went deeper, one of those nested reduces would have a 55 in it
11:59justin_smith(that's a distraction though, don't use reduced with reductions, it doesn't work)
12:00justin_smith,@@@@@@@@@@@@(last (reductions (fn [t i] (if (> i 10) (reduced t) (+ t i))) (range 23)))
12:00clojurebot55
12:04arrdemjustin_smith is apparently a 12 star programmer...
12:04justin_smith?
12:04razum2umhi folks. searched through github but havent found any awesome-clojure references. so here it is https://github.com/razum2um/awesome-clojure
12:05razum2umPR welcome!
12:05arrdemjustin_smith: http://c2.com/cgi/wiki?ThreeStarProgrammer
12:06justin_smithhaha
12:06arrdemrazum2um: your clojuredocs link is broken. you also don't have grimoire.
12:06justin_smitharrdem: I have in fact been writing some c code lately (with some levels of pointer indirection), but I think the relationship to this example is pretty tenuous
12:07Willis1tenous but still funny
12:07arrdemjustin_smith: I read @ as * since we don't have "real" pointers
12:07justin_smithit is true, yes
12:07arrdemso maybe it's all in my head
12:07justin_smithno, definitely funny
12:08justin_smiththe "tenuous relationship" is between my C coding activities and this bit of silliness, not between * and @, btw
12:08razum2umarrdem: fixed link. don't understand about grimoire so would you like to do it https://github.com/razum2um/awesome-clojure/edit/master/README.md
12:10Bronsaarrdem: it doesn't look like you actually rebased againsta master to me, e0a00308b7d204ab7d86a3ca795865899efb2dcb is still missing from feature/fast-emitter
12:15myguidingstarhi all, I want to handle on-change event from a input[type=file] in Clojurescript
12:15myguidingstarhow do I loop through (.. evt -target -files) which is a javascript object?
12:16mmitchellAnyone here use clj-logging-config?
12:16myguidingstargiven that in javascript, we can use `for (i, i++ ..) {}`
12:17justin_smith,(first (remove reduced? (iterate deref (last (reductions (fn [t i] (if (> i 10) (reduced t) (+ t i))) (range 200)))))) arrdem: I am now an N* programmer for arbitrary N
12:17clojurebot55
12:18arrdem(doseq [n ∈ ℜ] (swap! justin_smith + n))
12:18justin_smithheh
12:21adelcampois there an existing function that will increment by considering letters? For example “1Z” would increment to “2A” and then “2B”.
12:21justin_smitharrdem: TIL ℜ includes numbers that cannot be defined
12:21TEttinger,(Integer/toString (+ 36 35) 36)
12:21clojurebot"1z"
12:21TEttinger,(Integer/toString (+ 36 36) 36)
12:21clojurebot"20"
12:22arrdemjustin_smith: I mean... you said "arbitrary n" :P
12:22dbascharrdem justin_smith doseq over ℜ woud be a neat trick
12:22justin_smith:)
12:22arrdemdbasch: ikr if only we had an unbounded memory machine to try one on..
12:23justin_smith(for [n (range) d (range 1 n)] (/ n d))
12:23justin_smithor something...
12:23justin_smiththat doesn't get us the irrationals though
12:23TEttingeradelcampo, but I imagine you want it to consider letters as a different type than numbers or something?
12:23dbaschjustin_smith: that would be Q
12:24dbaschfor ℜ you'd need a computer with aleph-1 memory
12:24justin_smithyeah, good luck using any irrationals at all in a turing machine :)
12:24adelcampoTEttinger, yes but your example made me consider not using .getBytes, so thanks!
12:24TEttingeradelcampo, it's definitely possible
12:24TEttingerto do some kind of 1Z-2A thing
12:25TEttingerthe question is what order are numbers and letters in
12:25TEttinger0-9A-Z or A-Z0-9
12:25daGrevisi have a test here http://vpaste.net/xctxS i know what i want from that function, but the problem is that I have no idea how can I express that in functional paradigm. any hints?
12:25dbaschadelcampo: essentially you want a representation of base-26 numbers
12:26adelcampoTEttinger, yeah I just didn’t wan to write something that was already in the language
12:26justin_smithdaGrevis: markov, no?
12:26daGrevisjustin_smith, yes
12:26adelcampodbasch, almost. Numbers should always stay numbers
12:26TEttingerdbasch, and clojure supports radices up to 36
12:27adelcampoand letters always letters
12:27TEttingerah
12:27TEttingerso adelcampo, if I increment Z, what happens?
12:27TEttingerAA?
12:28dbaschadelcampo: so what positions can have numbers?
12:28TEttinger(also, wouldn't AA be 00?)
12:30daGrevishttp://stackoverflow.com/questions/20203883/clojure-simple-markov-data-transform cc justin_smith
12:30justin_smith,(reduce (fn [m [prev next]] (update-in m [prev] (fnil conj []) next)) {} (partition-all 2 1 ["monty" "python" "monty" "hall"])) daGrevis
12:30clojurebot{"hall" [nil], "python" ["monty"], "monty" ["python" "hall"]}
12:30justin_smithoh, similar to what you just found, but that one is better because it does counts (mine would have just made more instances of the same val in the collection)
12:30daGrevisjustin_smith, wow ty
12:31adelcampoAA would increment to 0B. but I’m not sure about a solo Z
12:31justin_smithbut, in my defense, I was just trying to get the literal output you presented (which did not have counts)
12:31dbaschadelcampo: what exactly are you trying to represent?
12:31adelcampoI mean AB
12:32dbaschadelcampo: why do you even need numbers?
12:32justin_smithdaGrevis: also, seeing that the answer is from lgrapenthin reminds me that I should reach out to him again about an old collaboration we had
12:33adelcampogenerating part numbers
12:33daGrevisjustin_smith, http://stackoverflow.com/a/20209575/458610
12:33daGrevisjustin_smith, see 1st solution with merge-with
12:34daGrevisseems to me like an elegant one, no?
12:34justin_smithyes, that is very nice
12:35arrdemdevn: haha yeah if you look at oxcart the pattern is that project.clj has (slurp "VERSION") rather than a version string. I have git hooks that automagically bump the version file rather than rewriting project.clj. the new `lein release` feature may kill this approach however. we'll see.
12:35cbpDoes anything weird happen with timeout core.async channels and clojurescript's :advanced compilation?
12:36cbpthey seem not to wait their timeout amount at all
12:38dbaschadelcampo: do you have a specific part number format that you're trying to follow?
12:43adelcampodbasch, the spec I was given was 3 blocks of 6 digits or characters, incrementing from left to right. characters A-Z and numbers 0-9. digit and character fields never change type. example 001AZ2-BB00ZZ-91EEAA
12:44adelcampocharacters and numbers can be placed in any position by who ever uses this
12:44technomancyarrdem: I believe you owe me a bug report?
12:44technomancyor did you get that sorted out?
12:44arrdemtechnomancy: I haven't looked at that yet.
12:44adelcamporight->left I mean
12:44dbaschadelcampo: what do you mean by "digit and character fields never change type?"
12:45arrdemtechnomancy: also not convinced that I was using `lein release` right either. I'll take a look after lunch.
12:45zanesAnyone know how to pass in a :result-set-fm with yesql?
12:45technomancyarrdem: no rush, just curious =)
12:45adelcampodbasch Z never turns to 0, it goes back to A
12:45adelcampo9 goes back to 0, never turns to A
12:46zanesI am dreading that it may not be possible.
12:46dbaschadelcampo: can you have arbitrary parts that are numbers and others that are letters? otherwise, it doesn't make a lot of sense
12:47dbaschadelcampo: you have a mixed system of base 10 and base 26 for no good reason
12:48adelcampodbasch, yes they’ll choose where the letters go and where the numbers go. any one field can be a number or a letter.
12:49dbaschadelcampo: if it's totally arbitrary, you have to segment your string into base-26 numbers and base-10 numbers
12:49dbaschif you increment a base26 number to the point of overflow, you have to increment the units to the base10 number to the left
12:50dbaschand keep doing that for the entire "number"
12:50dbaschseems unnecessariy complex
12:50zanesDamn. https://github.com/krisajenkins/yesql/issues/10
12:54arrdemBronsa: yeah I didn't do the rebase right. your bugfix breaks a bunch of patches I'll fix it in a minute.
12:54arrdemrebased against my master which wasn't synced to your updated origin/master
12:55Bronsaarrdem: ouch sorry
12:55arrdemBronsa: should only be three impacted patches. should.
12:56adelcampodbasch, thanks I’ll definitely try that
12:58Bronsaarrdem: I still don't understand why you're grouping the bytecode with a list rather than a vector
12:58technomancyoh man
12:58technomancyI didn't realize regexes as fns was on the todo back in the day
12:58technomancyhttp://clojure.org/todo
12:58arrdemtechnomancy: w0000t!
12:59technomancy"support for list-callers" yes please
12:59technomancy"def vars in other ns with explicit qualifier?" huh?
12:59justin_smith"too-large data literals duting compilation"
12:59daGrevisjustin_smith, http://vpaste.net/kuge9 final version
13:00justin_smithinteresting
13:00Bronsatechnomancy: what are list-callers?
13:00daGrevisjustin_smith, i didn't do much but i understood how it works
13:01arrdemBronsa: so the idea is that (list [:pop] (list [:pop] [:pop])) -> (list [:pop] [:pop] [:pop]), right? using lists means that arbitrary sequences of bytecodes satisfy (seq?) and will be mapcat'd by flatten.
13:01daGrevisjustin_smith, it's based on version before that was in that link obviously
13:01technomancyBronsa: slime-who-calls is how I read that
13:01Bronsaah
13:01daGrevisjustin_smith, i'm more interested on how you can think of using those functions in combination that will make such an amazing result. experience?
13:02daGrevisjustin_smith, because for me... first thing i thought of was to create a empty hashmap and iterate over those words
13:03Bronsaarrdem: well, why can't we just make that [[:foo] [[:bar] [:baz]]] -> [[:foo] [:bar] [:baz]] and s/seq/(comp vector? first)/
13:03justin_smithdaGrevis: well, literally speaking, what reduce does with {} as the third arg, is start with an empty hash map and iterate greedily over the last arg
13:03arrdemBronsa: because that doesn't allow us to differentiate between [[:foo] [:bar]] and [[[:foo]] [:bar]]
13:04arrdemBronsa: remember that nested bytecode sequences can occur _anywhere_
13:04justin_smithdaGrevis: reduce is typically my go-to if lazy evaluation doesn't make sense (with a map as result, laziness gains you nothing)
13:04Bronsa arrdem: sorry brb
13:05arrdemBronsa: there are even a couple places where you use a generator that will return a bytecode sequence as the first term in another expression which would without a concat create exactly the above condition.
13:10daGrevishow does clojure programmers feel about nil? is it okay that function returns nil not {} if it usually returns some hashmap with data?
13:10technomancydaGrevis: nil is the worst thing about clojure hands down. however, conflating nil with collections is usually safe.
13:11technomancyreturning nil instead of a scalar value is the worst.
13:11daGrevisbut what will happen when i will want to do coll stuff on nil? will it blend?
13:11teslanickI seem to remember that someone quipped here that nil actually behaves like an infinite tree of nils.
13:11teslanickAnd so can be conflated with collections. ;)
13:11arrdemdaGrevis: nil works fine with collections. (sequables) Nil doesn't work at all with anything else.
13:12technomancydaGrevis: the one thing it'll blow up on is that it's not callable like maps are
13:12daGrevisok then it's fine then
13:12justin_smith,(assoc-in {} [:a :b :c] :d) daGrevis: some functions definitely just take nill and roll woth it
13:12clojurebot{:a {:b {:c :d}}}
13:12technomancybut no one actually puts maps in the call position; everyone puts keywords first
13:12joegalloyeah, that not callable thing is sortof a big deal
13:12technomancybroadly speaking
13:12Glenjaminthey only do that because of the NPE :p
13:12arrdemtechnomancy: only silly people who deserve it :P
13:12joegallounless you're dealing with keyword keyed maps, and always calling via the keyword.
13:12technomancywell.... there's stuff like (map mymap [:x :y :z])
13:13justin_smithI use get explicitly when a map would be in calling side
13:13technomancyactually no, that's better served by juxxt
13:13justin_smithtechnomancy: unless you need the laziness
13:13technomancycurses!
13:14technomancylet's just go with "it's complicated"
13:14daGrevisi guess i'll be fine
13:15Glenjamin(map (partial get mymap) [:x :y :z])
13:17justin_smith(map (fnil mymap {}) [:x :y :z]) ?
13:18justin_smitherr, no
13:18justin_smith(map (or mymap {}) [:x :y :z]) is what I wanted
13:19arrdemBronsa: conflicts resolved & pushed. looks OK to me.
13:31technomancydid the G1 GC get made default in java 7?
13:33Glenjaminnope
13:33Glenjaminwell, not on mine anyway
13:34technomancymust have been 8
13:34timsgHey, tried this question on the emacs channel to no effect, and it’s apropos Clojure, so here goes. I’m implementing a networked Clojure-CLR repl client that I would like to drive from emacs’ inferior-lisp. I want multiline input, so I’m using an EOT character rather than newline to signal form entry, but this does not seem to be the default expected by inferior-lisp. Does anyone have experience with this sort of thing? Question
13:34timsgwithdrawn if it’s too off-topic. Thanks!
13:35technomancytimsg: inferior-lisp is kind of an odd choice for a network client
13:35technomancythat's usually just intended for stdin/stdout interactions
13:36technomancywhy not just port the existing nrepl server to clojure-clr?
13:38timsgtechnomancy: yes, it’s super janky at the moment. Clojure-CLR doesn’t have an nREPL implementation yet, so we’re making do with an extremely simple shell client setup pending a functional nREPL.
13:38technomancyif you use the existing protocol then you don't have to reinvent the wheel for the huge pile of clients that have already been written
13:38technomancyoh, for a stopgap measure; gotcha
13:38technomancywhat's an EOT character?
13:39timsg"\x04"
13:39justin_smithC-d in emacs parlance
13:39technomancyoh, eof?
13:39technomancyI think multiline input is a server-side concern and you should just use newlines like normal.
13:40justin_smithin unicode we have ⌁ or ␄ in modern unicody times
13:41timsgtechnomancy: hm, so would you recommend just sending to the server constantly like a fire hose and then sending a response when it parses as a balanced expression?
13:41justin_smithin redundant cases we also have redundancy
13:42technomancytimsg: that's my understanding of how comint modes typically work
13:43timsgtechnomancy: hm, thanks. I wonder what a simplest way to test for balanced expressions is
13:44timsgI suppose one could use read-string in a try-catch; seems janky tho
13:44technomancytimsg: you can't do it client-side
13:44technomancyread-string in a try/catch is fine
13:45timsgtechnomancy: interesting. Ok I’ll try that, thanks much for the advice!
13:45technomancynp
13:45technomancywhen in doubt, take a look at what reply does
14:16lalilunaHi, what is the best way to find the namespace which provides a function using emacs?
14:20technomancylaliluna: M-.
14:24lalilunaThis only works, if I have required the namespace already.
14:24technomancyyes
14:25lalilunaThis is what I want to find out, what I have to require. ;-)
14:26arrdemthis is not a generally answerable question :P
14:30technomancyyou can use bultitude to find all namespaces and require them, then search with all-ns
14:31amalloytechnomancy: why would you need to use all-ns? once you've required everything, find-doc or apropos or something should find it, i would think
14:31technomancysure, find-doc is one way to use all-ns
14:35technomancyit's a one-liner in any case (for [n (all-ns) [k _] (ns-publics n) :when (= 'reduce k)] n)
14:35technomancy(mapcat ns-publics (all-ns)), ctrl-r
14:38amalloyman, there are some functions in all-ns that are pretty silly
14:38amalloyincluding, amusingly, swank.util/one-of?, which is implemented in exactly the way i told hellofunk and Frozenlo` is a bad way to do it, last night
14:38lalilunaGreat, thanks.
14:39technomancylol swank
14:39amalloyoh my gosh. i wish i had never looked at swank.util
14:40amalloythere's like one function that includes three of my greatest enemies: flatten, eval, and resolve: https://www.refheap.com/4c4327327fae81eb5944ad0e6
14:41amalloy(resolve isn't bad, but it often gets misused)
14:42Glenjaminlooks like a reasonable backport of flatten
14:42Glenjamin$source flatten
14:42lazybotflatten is http://is.gd/JrNQrb
14:43Shayanjmamalloy: what's wrong with flatten?
14:43amalloy~flatten
14:43clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
14:43Shayanjmah I see
14:43laliluna(concat [1 2 3] 1)
14:44Glenjaminbut all the lisp books make you perform operations on a nested list of lists :p
14:44lalilunaSorry, wrong window LOL, missed the REPL
14:44amalloyflatten is kinda like "i have no idea what my data looks like, but i happen have this huge hammer, let's try hitting it"
14:44Frozenlockamalloy: we talked about that yesterday? o_O
14:44FrozenlockI remember 'set' vs 'some'.
14:44amalloywasn't that you, Frozenlock? https://www.refheap.com/727ad34f9db303249e225a67b
14:45FrozenlockNo, unless I spend time here even in my sleep :-p
14:45amalloyFrozenlock: yes, one-of? is solving exactly the problem that led to the set/some question
14:46amalloyand it's doing it by macroexpanding to (or (= x 1) (= x 2) (= x 3) ...), which is a hardcoded version of the some approach
14:49Frozenlockoh right
14:55schmeehello, quick beginner question: what's the best way to replace a subvector in an array with another subvector?
14:57DerGuteMoritzamalloy: some is not short-circuiting like one-of? though, or am I missing something?
14:57tuft_do any of you guys have a favorite talk about using functions over data instead of classes, methods and a proliferation of types?
14:58amalloyFrozenlock: why don't you educate DerGuteMoritz?
14:58DerGuteMoritzyes, please :-)
14:59DerGuteMoritzunless the collection passed to some is lazy, but even then the semantics wouldn't be exactly the same due to chunking, right?
14:59expezI have some tasks that I just spin off into separate threads, these communiate with the rest of the app over a core.async/chan. 1) Is 'future' the best thing to use here? 2) I just had one of these futures silently die, how can I get a stacktrace into the logs?
15:00stuartsierratuft: maybe Stuart Halloway's "Evident Code at Scale"
15:01stuartsierrahttp://www.infoq.com/presentations/Evident-Code-at-Scale
15:24Guest9112I'm trying to help a colleague running windows compile a clojure project. Lein install works but when we try to run maven we get a clj:[0,0] Unsupported character: \com for every file in the package. Has anyone seen this kind of error before?
15:26athinggoingonI'm trying to understand what the following code does
15:26athinggoingon(def world
15:26athinggoingon {:location :a
15:26athinggoingon :nodes {#{:a :b} :y
15:26athinggoingon #{:a :e} :g
15:26athinggoingon #{:b :f} :g
15:26athinggoingon #{:f :e} :g}
15:26athinggoingon :home :f})
15:26athinggoingon
15:26amalloyathinggoingon: please direct large pastes to refheap.com or gist.github.com
15:26arrdemthe paste...
15:31slpsys_ow, my eyes
15:33amalloyanyway, athinggoingon, it seems to be creating a map, where the keys in the :nodes map are sets of keywords
15:33tuftstuartsierra: thanks!
15:34bacon1989question, how could I generate a dictionary from a list where '([key value] [key value])
15:36amalloy&(doc into)
15:36lazybot⇒ "([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
15:36amalloywell, that doesn't answer the question at all. jeez, amalloy, get with the picture
15:37bacon1989I think I could do it with a for loop
15:37amalloy&(into {} '([k v] [x y]))
15:37lazybot⇒ {k v, x y}
15:37bacon1989oh neat
15:37athinggoingonthanks amalloy
15:37athinggoingoni'm new to clojure
15:37amalloybacon1989: remember for is not a loop, but a list comprehension
15:37athinggoingonhow can i create an instance of that map
15:37amalloyit's impossible to use it to build anything but a lazy sequence; you have to use something else (here, into) to do that
15:38technomancy
15:39technomancyaka, "unask the question"
15:39myguidingstarhi all, what's wrong with this om component? https://gist.github.com/myguidingstar/34bad0729c0a9b8f94b1
15:39amalloyathinggoingon: the question doesn't make sense: there's no such thing as "an instance of that map". the map is defined to be stored in the var 'world
15:40myguidingstarthe component didn't re-render after user clicked
15:40myguidingstar(it's written in om-tools syntax)
15:41teslanick:onClick not :on-click
15:41myguidingstarteslanick, it's om-tools syntax
15:42myguidingstarI used js/alert to ensure it got called
15:42teslanickAh.
15:43teslanickYou could figure out what the state is by hooking into IWillUpdate
15:43teslanick(dunno what the om-tools idiom is)
15:43myguidingstarteslanick, FYI https://github.com/Prismatic/om-tools/
15:43teslanickI'm aware of it, I just haven't read the docs
15:43teslanickbut (will-update [_ _ next-state] (prn next-state))
15:44teslanickIf that writes the state, that would ensure that the state is being set correctly.
15:44myguidingstarnice tip, thanks
15:46Fareis there a right way to define data structures with circularities?
15:47AeroNotixFare: never
15:47arrdemAeroNotix: with refs all things are possible
15:47technomancyyou can use laziness to make a list that repeats itself
15:47AeroNotixarrdem: It was kind of a joke
15:47arrdemFare: not using pure immutable datastructures
15:47athinggoingonhere's the code: https://github.com/mfikes/scratch-code/blob/master/vienna.clj
15:47AeroNotix"there's never a right way to define circular data strucrtures."
15:48AeroNotixFare: are you sure you want this?
15:48AeroNotixwhat are you trying to solve?
15:48arrdemAeroNotix: largest prime number
15:48athinggoingonit's supposed to solve the Viennese Maze problem: http://zulko.github.io/blog/2014/04/27/viennese-mazes-what-they-are/
15:48FareAeroNotix, yes.
15:49AeroNotixhmm, I'm not familiar with this and I'm losing interest
15:49AeroNotixGood Luck! :)
15:49FareI was defining this grammar as a data structure, and some circularities show up at the toplevel
15:49Farethanks
15:50FareI'll find a way
15:50AeroNotixI'm sure you will :) refs are a good start
15:50Fareit's just that grammar combinators were working great.
15:51FareI suppose I'll make do with some eta-conversion
15:51Fareη-abstraction FTW
15:52amalloyarrdem: well, not using pure immutable *eager* data structures. haskell manages just fine with stuff like: let a = 1:a in a
15:52myguidingstarteslanick, it turns out that nothing was printed
15:53myguidingstarwhat now?
15:53technomancy,(doc repeat)
15:53clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
15:54technomancysomewhat circular
15:59AeroNotixtechnomancy: I don't think I'd define that as circular
16:00teslanickmyguidingstar: Consider implementing it in raw Om to see if that solves it?
16:00teslanickI've done similar things and not had a problem.
16:04myguidingstarmany thanks, I'm doing it
16:09Glenjamini feel like i've asked this before, but:
16:10Glenjaminis there a collection function which takes a fn and a seq, and returns a seq of the truthy results of f?
16:11Glenjaminor actually, i just want to partition a seq into two seqs with alternate items in each
16:11mi6x3mhey clojure, how would you call a keyword designating a function creating some visual content
16:11mi6x3m:init?
16:11mi6x3m{ :init create-example-window }
16:11Glenjaminso i can probably do that with drop/take + recursion
16:12teslanickGlenjamin: (take-nth 2 coll) (take-nth 2 (drop 1 coll)) ?
16:12Glenjaminyeah, annoying i'm using mori, which doesn't include take-nth
16:13AeroNotixGlenjamin: group-by
16:13AeroNotixor partition-by
16:13Glenjamingroup-by would work, but isn't lazy
16:13Glenjaminand therefore feels less neat :D
16:13AeroNotixmeh
16:13AeroNotixstop fapping
16:14AeroNotixwrite code, make it beautiful, make it fast
16:22mi6x3mnotepad++ syntax file by any chance?
16:43mi6x3mclojure, is it idiomatic for keywords to contain verbs?
16:43mi6x3m:create-content, :extract-src
16:43AeroNotixDunno but it's idiomatic for questions to have more context than that
16:43arrdemnot really... functions should (probably) be your only verbs and keywords are data and thus should (probably) be nouns.
16:44AeroNotixarrdem: keywords are functions
16:44AeroNotixZING
16:44arrdemAeroNotix: no.. they are IFn. that doesn't make them functions. functions are functions. keywords happen to behave the same way in some cases.
16:45myguidingstarteslanick, it turns out that it was because I wrapped my component in a function before sending to om/root
16:45mi6x3marrdem: well how would you name a keyword holding a function to create some demo window
16:45mi6x3m:create-demo create-browser-example
16:45myguidingstarnot om-tools' fault at all
16:45mi6x3mor just :init
16:45AeroNotixarrdem: in which cases do they not?
16:46arrdemAeroNotix: in the case of wanting to do anything besides getting a keyword named value out of an Associative collection :P
16:46AeroNotixarrdem: such as?
16:46arrdemoh add one and one
16:46AeroNotixwat
16:46mi6x3many help on the actual naming issue
16:47AeroNotixmi6x3m: just do it
16:47AeroNotixit's not exactly a really big deal
16:47mi6x3mi wanna stay idiomatic :}
16:47AeroNotixfapiomatic
16:47mi6x3mtrue also
16:48AeroNotixmi6x3m: the other thing is: would you have a datastructure like {:extract-x 10}
16:48AeroNotixand then (:extract-x 10)
16:48AeroNotixand have 10 mean the value called :x?
16:48AeroNotixI don't think so
16:48mi6x3mAeroNotix: no, they are always generate functions
16:48mi6x3mgenerator *
16:48AeroNotixexplain
16:49mi6x3mwell I am modeling a tree which the users actually sees (JTree) and selects example demos with
16:49AeroNotixSo, the name reflects the value
16:49AeroNotixLGTM
16:49AeroNotix:shipit:
16:50mi6x3ma leaf node is { :desc "Description" :create-demo create-simple-window :extract-src ... :avail? true :not-avail-msg "") for example
16:50AeroNotixyeah yeah I get it, LGTM
16:50mi6x3myeah, fine, just double checking, new to all this
16:51arrdemso... why is my :shipit: rendering to a squirrel in a fedora..
16:53arrdemah. GitHub internal thing.
16:59AeroNotixarrdem: :boom::camel::shipit:
16:59arrdemheh
17:03amalloyGlenjamin: (apply map list (partition 2 coll))?
17:04AeroNotixamalloy: with a predicate
17:04amalloyhe said alternate items in each, and take-nth seems to be a solution that was suggested
17:04amalloy&(apply map list (partition 2 '(range 10)))
17:04lazybot⇒ ((range) (10))
17:04amalloy&(apply map list (partition 2 (range 10)))
17:04lazybot⇒ ((0 2 4 6 8) (1 3 5 7 9))
17:04AeroNotixamalloy: uh no
17:05AeroNotixTakes a function and a seq and returns the truthy elements
17:05AeroNotixand later mentioned truthy and falsey thingies
17:05AeroNotixI assume truthy and falsey things, cause they were talking about truthiness before
17:06AeroNotixBut whatever, (<= care 0)
17:11FrozenlockDerGuteMoritz: 'some' will stop at the first result matching the predicate. https://www.refheap.com/88011
17:16Glenjaminthe truthy/falsy question was wanting to use filter to do the odd/even thing
17:17Glenjamineg (->> (map vector coll (range)) (filter (comp odd? last)) (map first))
17:17ybithelp clojure is making me lazy
17:17Glenjaminthe apply map list is neat
17:18ybiti don't want to type commas in other languages
17:19amalloyGlenjamin: well, remember that (apply map list xs) is basically transpose. you're asking for a 2-by-N matrix, and it's easy to get an N-by-2 matrix, so...
17:19Glenjamini managed to sort-of convince work that react+mori is a good idea
17:20Glenjaminso i get to write almost-clojure
17:20amalloyanyway, i'm glad to hear that i correctly understood the predicate thing to be the X part of your XY problem
17:20Glenjaminbut it's annoyingly almost
17:20amalloyer, or the Y? i forget which is which
17:20Glenjaminso in this example, i don't have return-value destructuring
17:21Glenjaminthe JS isn't too terrible in this case at least: m.apply(m.map, m.list, m.partition(2, m.range(10)))
17:27AeroNotixamalloy: just realised that you submitted the problem on 4clojure which has the same answer as the answer you gave Glenjamin
17:27AeroNotixhttp://www.4clojure.com/problem/43
17:27Glenjaminhrm, is apply lazy?
17:28AeroNotixweird memory
17:28AeroNotixGlenjamin: no
17:28amalloyyes
17:28AeroNotixamalloy: yes?
17:28amalloyas lazy as it can be, anyway. try it and see, AeroNotix
17:28AeroNotixlolwat
17:28Glenjamin,(-> (apply map list (partition 2 (range))) first first)
17:28clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
17:28Glenjaminwhoops >>
17:29AeroNotixhmm
17:29Glenjaminso, i can do this - which is lazy:
17:30amalloyGlenjamin: well, yes, transposing a matrix with infinite rows into one with infinite columns isn't going to work. apply in general is lazy, but obviously if you do non-lazy things with it it can't be
17:30Glenjamin,(->> (range 1 10) (map vector (range)) (filter (comp even? last)) (map first))
17:30clojurebot(1 3 5 7)
17:31amalloysee, for example, ##(let [f (fn [& args] (first args))] (apply f (range))
17:31Glenjaminright, i see
17:31amalloy&(let [f (fn [& args] (first args))] (apply f (range)))
17:31lazybot⇒ 0
17:31amalloyGlenjamin: basically when you want to split one seq up into two, you can't have all three of: laziness, immutability, efficiency
17:32amalloyyou can give up laziness with my apply-map-list, or you can give up efficiency by traversing the input list twice, once for each output (which might cause you to hold its head for too long, if you only actually traverse one of the two lists)
17:33amalloyor you can give up immutability by returning two references which mutate each other
17:33AeroNotixamalloy: do people really care about the differences the moment they are writing code?
17:34AeroNotixapply-map-list is the best way to initially write it
17:34amalloyi don't understand that question at all
17:34AeroNotixamalloy: seems like you're advocating premature optimization a little
17:34amalloyseems like i'm answering Glenjamin's question of "why can't i use apply-map-list on an infinite seq"
17:35AeroNotixI didn't see that asked
17:35AeroNotixwhatevs
17:35AeroNotix:)
17:35amalloyi don't understand why you're challenging me so rudely today, AeroNotix
17:35Glenjaminit was implied
17:35AeroNotixamalloy: I don't intend it, honestly
17:35amalloyyou've twice already told me my answers to Glenjamin's questions are wrong-headed, and been wrong both times
17:36AeroNotixindeed
17:36cbp~gentlemen
17:36clojurebotYou can't fight in here. This is the war room.
17:36AeroNotixNothing personal, I'm just parsing things wrong
17:36Glenjamini ask similar questions quite often, amalloy always seems to have the answers
17:36Glenjamin(inc amalloy)
17:36lazybot⇒ 146
17:36AeroNotixI'm not disagreeing
17:36AeroNotixwith that
17:37Glenjaminalso as a bonus i get to name a function (zebra)
17:37amalloyhah. dem stripes
17:37amalloyGlenjamin: the version in useful is called alternates
17:38Glenjamini nearly did that, but then realised zebra was apt
17:38amalloybut what if you want to split it up into ten? i've never seen a zebra with ten colors!
17:38metellusamalloy: fruit stripe gum
17:38Glenjaminoh, i don't parameterise on n
17:38amalloyoh man
17:38amalloyyou're right, metellus
17:39Glenjamini guess zebra is just (partial alternates 2)
17:39amalloyGlenjamin: sure; i was suggesting you could
17:40AeroNotixamalloy: "the version in useful" is useful a library or something?
17:40Glenjaminoo, interesting
17:40amalloy$google flatland useful
17:40lazybot[useful 0.11.2 - Clojars] https://clojars.org/org.flatland/useful/versions/0.11.2
17:40amalloy$google flatland useful github
17:40lazybot[useful 0.11.2 - Clojars] https://clojars.org/org.flatland/useful
17:40AeroNotixwoah wtf, clojars looks way better
17:40amalloyscrew you, google
17:40Glenjaminhttp://flatland.org/useful
17:40amalloyAeroNotix: devn did something to it a week or two ago. big reskinning
17:40AeroNotixcheers for the myriad of links
17:40AeroNotixamalloy: looks a lot better
17:41AeroNotixnow it doesn't look like they asked me to do the css
17:41Glenjamin,(apply map list (partition 2 (range 1 10))) ; <- loses an item
17:41clojurebot((1 3 5 7) (2 4 6 8))
17:41AeroNotixyou can pad
17:41AeroNotixparition
17:41AeroNotixpartition*
17:42Glenjamin,(doc partition)
17:42clojurebot"([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."
17:42metellus,(apply map list (partition-all 2 (range 10)))
17:42clojurebot((0 2 4 6 8) (1 3 5 7 9))
17:42Glenjaminbah, another function not included in mori
17:43amalloyif you pad in partition, you have to use a function smarter than just list, as your mapper
17:43Glenjamin,(apply map list (partition-all 2 (range 1 10)))
17:43clojurebot((1 3 5 7 9))
17:43Glenjaminyeah, i think i'll just iterate twice
17:45amalloy&(apply map (fn [& args] (remove ::fake args)) (partition 2 2 (repeat ::fake) (range 1 10)))
17:45lazybot⇒ ((1 3 5 7 9) (2 4 6 8 :clojure.core/fake))
17:45amalloy&(apply map (fn [& args] (remove #{::fake} args)) (partition 2 2 (repeat ::fake) (range 1 10)))
17:45lazybot⇒ ((1 3 5 7 9) (2 4 6 8))
17:45AeroNotixthis library looks like my utils.clj files :)
17:45AeroNotixnice
17:46amalloy&(apply map (partial apply remove #{::fake}) (partition 2 2 (repeat ::fake) (range 1 10)))
17:46lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long
17:46AeroNotixhaha, rate-limited <3
17:47Glenjaminone too many applies?
17:47AeroNotixsorry, was referring to a function in flatland.useful
17:47Glenjaminoh right, i see
17:47amalloyi don't think so. i don't really understand what's wrong with that version
17:49amalloyAeroNotix: the idea behind useful is to stop copy/pasting the same junk in utils.clj from project to project, and publish your own utils library that you can just depend on
17:49amalloyyou're welcome to use mine instead, of course; i'm just trying to cut down on copy/paste programming
17:49AeroNotixamalloy: yeah, we do that internally here.
17:49AeroNotixBut a community one is obviously way better
17:49Glenjaminthere was a post a while back on the mailing list to the tune of
17:50Glenjamin"don't publish utility belt libs!"
17:50amalloyyeah, that was one of the stuarts, right?
17:50Glenjaminyeah
17:50Glenjaminhe's right, in a sense
17:50amalloysure, i see his point
17:50Glenjaminbut it's because dependencies are broken
17:50Glenjaminin everything
17:50Glenjaminalways
17:50Glenjaminexcept maybe nixOS
17:50stuartsierrathat was probably me
17:51stuartsierraIt's the kind of thing I would say. :)
17:51Glenjaminheh
17:52mimieuxHi guys! what is wrong with: (-> "filename" (io/file) (io/reader) (line-seq) (fn [s] s))
17:52AeroNotixdependencies in jvm shit are of the "almost ok, we can work with them" type, though
17:52AeroNotixmimieux: that (fn [s] s) doesn't do what you think it does
17:52AeroNotixit's a macro that operates on the structure of the code
17:52amalloyAeroNotix: it's only sorta community. i accept pull requests, but only for stuff i'd actually use. if you want something i don't care about, put it in your own utility library
17:52AeroNotixamalloy: gotcha
17:53mimieux:O
17:53Glenjaminmaybe we should have a separate dependency system for util functions
17:53Glenjaminwhere there's a big DB of functions, and some tooling to pull them into your own utils namespace
17:53Glenjaminwith a comment so they can be matched up to the source
17:54amalloyit sounds like the big DB is the internet, and the tooling is copy/paste
17:54AeroNotixstackoverflow driven development
17:55Glenjaminwell yeah, but you could have a little manifest in the file
17:55mimieuxAeroNotix: ((fn [s] s)) thank you!
17:56Glenjamin; (depend [amalloy/useful/alternate 1.0.1])
17:56cbpmimieux: you dont need that fn at all
17:56mimieuxcbp: just for the sake of illustrating my doubt!
17:57amalloy,(identity ((identity identity) identity))
17:57clojurebot#<core$identity clojure.core$identity@16712cc>
17:57Glenjaminand we could make $findfn work on it
17:57AeroNotix,(buffalo (buffalo buffalo))
17:57clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: buffalo in this context, compiling:(NO_SOURCE_PATH:0:0)>
17:57Glenjamin,(alias buffalo identity)
17:57clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: buffalo in this context, compiling:(NO_SOURCE_PATH:0:0)>
17:57Glenjamin,(def buffalo identity)
17:57clojurebot#'sandbox/buffalo
17:58amalloyi think this works better in haskell - id is more fun to type than identity, and you can mix in some operators for fun
17:58AeroNotixwhat was that error in Haskell that blew up the compiler with thousands of calls to id?
17:59amalloyid id (id . id . id . id $ id id id) $ id
17:59AeroNotixoh I think it was when it was trying to determine the type signature of something like that
18:00amalloyyeah, i read about that recently but couldn't figure out how to reproduce it
18:01gratimaxthat isn't a very complicated expression, I think
18:02TEttinger,(def id identity)
18:02clojurebot#'sandbox/id
18:03gfixler,(id identity)
18:03clojurebot#<core$identity clojure.core$identity@16712cc>
18:03gfixler,(identity id)
18:03clojurebot#<core$identity clojure.core$identity@16712cc>
18:03TEttinger,(id id)
18:03clojurebot#<core$identity clojure.core$identity@16712cc>
18:03gfixlerchecks out
18:04stuartsierraI am so tired of this error cropping up everywhere https://github.com/mmcgrana/clj-stacktrace/issues/23
18:05gratimax,(def buffalo identity)
18:05clojurebot#'sandbox/buffalo
18:05gratimax,(def Buffalo identity)
18:05clojurebot#'sandbox/Buffalo
18:06gratimaxwe're ready to begin
18:06mdrogalisWhy's the IRC log not being recorded anymore?
18:06AeroNotixgratimax: now we can play the game
18:06AimHereDuplication of effort. We discovered the NSA were already doing it
18:06AeroNotixAimHere: hard to retrieve logs though
18:06AimHereJust file an FOI request!
18:07amalloylogs.lazybot.org
18:07mdrogalisGot it. Ty.
18:07amalloystuartsierra: i do everything i can to keep clj-stacktrace out of my programs
18:08stuartsierraI wish I could. But tool wants to depend on it, and it keeps sneaking into client projects.
18:08stuartsierra*every tool wants to depend on it
18:09Glenjaminthe solution is to improve stack traces in core, clearly :D
18:09amalloyi'm actually unsure whether you mean that tooling libraries want it, or you're calling everyone who uses clj-stacktrace a tool, but i'm pretty okay with either interpretation
18:09gratimax,(((((Buffalo buffalo) (Buffalo buffalo)) buffalo), buffalo) (Buffalo buffalo))
18:09clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Buffalo in this context, compiling:(NO_SOURCE_PATH:0:0)>
18:11stuartsierra.printStackTrace is perfectly good AND IT NEVER BREAKS
18:12amalloyyessss. the stacktraces from clojure.core are already better than those generated anywhere else, because they work
18:12stuartsierraIf you really want to format it, use (or improve) clojure.stacktrace
18:13amalloychoosing to instead use a stacktrace generator that color-codes, aligns, and demunges them, but 1% of the time completely breaks and you can't find your stacktrace at all? no thanks
18:13stuartsierraamalloy: I couldn't agree more.
18:13stuartsierraNice to know I'm not the only one.
18:13Glenjamini suspect many people haven't hit that 1%
18:14amalloystuartsierra: i know i'm preaching to the choir, just because it's fun to be agreed with
18:14Glenjamini've never had that issue, so would use it assuming all was fine had i not seen this discussion
18:15stuartsierraThe point, which few people seem to get, is that exception handling is an *exceptional* situation. Things are broken. You have to code very defensively, do as little as possible.
18:16zanesOne of my coworkers just asked why let uses a vector for its syntax (let […] …) instead of a map (let {…} …) and I was stumped. Anyone have any idea?
18:16Glenjaminzanes: you can repeat symbols
18:16amalloyspeaking of which, stuartsierra, how goes that (try (f) (catch Exception e (println e))) in core.async? another person was in here earlier this week asking why he doesn't get stacktraces
18:16zanesGlenjamin: Ah, yes! Thanks.
18:16amalloyGlenjamin: perhaps more importantly, maps aren't ordered
18:16stuartsierraamalloy: I keep pushing it with Rich et al.
18:17zanesOoh, that too.
18:17stuartsierraI think I'm getting the beginnings of agreement that the current behavior is less than desirable.
18:18stuartsierraamalloy: http://dev.clojure.org/jira/browse/ASYNC-76 is my ticket, with references to some other variants.
18:19amalloywell, good luck
18:19stuartsierraamalloy: Thanks. You can help (maybe) by voting :)
18:20amalloyyour wish is my command
18:21Glenjaminalmost immediately after naming my zebra function i realised i needed a version with n=3 :(
18:24DerGuteMoritzFrozenlock: yes, it does not traverse the whole collection but unless you pass a lazy-seq, all arguments are evaluated -- and even in the lazy-seq case, more elements than the one it stops at might be evaluated due to the underlying chunking (AFAIK, not sure if that also happens with `next')
18:24DerGuteMoritzs,arguments,elements, I guess
18:29FrozenlockDerGuteMoritz: That's not how I understand 'or'
18:29Frozenlock,(doc or)
18:29clojurebot"([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns a logical true value, or returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expression. (or) returns nil."
18:30amalloyGlenjamin: (def zebra (partial alternates 2)) (def barber-pole (partial alternates 3)) ...
18:31Glenjaminhrm, i never noticed barber pols have a third stripe
18:31Glenjaminalways had it red&white in my head
18:31amalloythen they'd just be candy canes
18:31Glenjaminit's now become everyNth and acts a bit like take-nth
18:32Glenjaminif i had destructuring, i'd stick with the partition
18:36DerGuteMoritzFrozenlock: `or' stops evaluation at the first truthy expression, e.g. (or true (launch-missiles!)) will never launch missiles while (some true? [true (launch-missiles!)]) will launch missiles before even calling `some'
18:38DerGuteMoritzamalloy: can you elaborate why you think one-of? is inferior? AFAICT it's just different
18:39amalloyit's not inferior to using some; they're just both bad
18:40amalloythe discussion from yesterday is at http://logs.lazybot.org/irc.freenode.net/%23clojure/2014-07-08.txt - start at 21:11:12 and go until 21:26:07
18:41amalloyafter that it should be clear why i don't like one-of?
18:41DerGuteMoritzamalloy: ah, I didn't get that nuance earlier :-) *reads log*
18:42Frozenlock,(some true? (repeatedly #(do (println "ping") true)))
18:42clojurebotping\ntrue
18:42FrozenlockDerGuteMoritz: Seems only the first of the lazy-seq is evaluated.
18:44DerGuteMoritzFrozenlock: indeed! perhaps chunking was removed again or something? or only functions that need to consume the whole seq anyway apply it? a mystery!
18:44amalloynot all sequences are chunked
18:44amalloymost aren't, really
18:45amalloybut consider ##(some true? (map #(do (println %) true) [1 2 3 4])), for example
18:45lazybot⇒ 1 2 3 4 true
18:47shanemhansenWhat's the recommended way to preload libraries and functions into a clojure repl.
18:47shanemhansenI'd like to fire a repl up for data analysis and have several simple stats things in my namespace.
18:48arrdemshanemhansen: you can either have a user.clj file with stuff in it, or you can have :injections in your lein profile
18:48DerGuteMoritzright, so I guess I wouldn't rely on lazy-seqs when fine-grained control of realization is necessary
18:48DerGuteMoritzamalloy: thanks!
18:49shanemhansenThanks arrdem
18:49arrdemshanemhansen: yw
18:50DerGuteMoritzOK, I see now that the original discussion was actually about some vs. sets which is of course a different story and I agree that both some and one-of? are not good choices overe sets in that case :-)
18:50DerGuteMoritzok have a good night everyone!
18:52cespareI'm switching from plain jetty to http-kit...maybe a dumb question, but if http-kit is multiplexing multiple requests onto a single thread somehow, does that change/break usage of dynamic vars?
18:53technomancycespare: yeah
18:54cesparehmm, ok. http-kit docs are extremely light on details like that.
18:55cesparedo i also need to worry about blocking the thread? (e.g. making blocking db calls)
19:47myguidingstarhave no idea why cljsbuild yells "No such namespace: markdown.core"
19:48myguidingstarI added markdown-clj to project.clj, restart cljsbuild and saw it being fetched from clojar
19:50brehautmyguidingstar: just to check: are you trying to use a clojure library in clojurescript code?
19:50brehaut(i don know anything about the lib in question)
19:50myguidingstarbrehaut, markdown-clj works with both
19:51myguidingstarother libraries like core.async work as usual
19:51ivanmyguidingstar: unzip -l ~/.m2/repository/markdown-clj/markdown-clj/0.9.45/markdown-clj-0.9.45.jar
19:51ivanthe jar is missing the clojurescript
19:52myguidingstarivan the result show no .cljs file
19:52myguidingstarbut what do you mean "the jar is missing"?
19:53ivanyou might want to file a github issue mentioning that the .jar is broken (missing the .cljs files)
19:54myguidingstaryup, got it
19:57ivanmyguidingstar: if you clone https://github.com/yogthos/markdown-clj and `lein install` it should make a proper .jar; it does here
19:57myguidingstarissue filed. many thanks
20:29bsimaDoes anyone know if there's a way to do a regex match on a seq which is composed of strings and maps? I only want the string content
20:29bsimaSpecific string content, that is, selected by the regex
20:38Jaoodbsima: with logic!
20:38Jaoodbsima: maybe paste an example of the seq?
20:40bsimaThe specific error I'm getting is LazySeq cannot be cast to java.lang.CharSequence
20:40bsima(("\n\t\t\t\t\t\t\t\t\t\t\t\t\t" {:tag :strong, :attrs nil, :content ("AMPAR peptide values in blood of non-athletes and club sport athletes with concussions.")} " Dambinova SA, Shikuev, Weissman JD, Mullins, JD. " {:tag :em, :attrs nil, :content ("Military Medicine.")} " 2013, 178 (3):285-290.\t\t\t\t\t\t\t\t\t\t\t\t")
20:40bsimathere's 189 of those...
20:40hellofunkI am concating two vectors, which creates a lazy seq. Then I am deffing a doall of that lazy sez. When I log the def'd result, it logs as a lazy seq. Shouldn't doall be head-retaining and realize the lazy seq, making it no longer lazy?
20:44mangehellofunk: It doall won't change the type, it will just realise all of the elements. Use (seq (doall ...)) to make it print as a seq.
20:44hellofunkmange: sweet, good tip
20:47mangebsima: Are you trying to regex match over all of the strings in that structure, or only the top-level strings? Do you want to match things only within one string, or is it fine for it to be over the boundary of several strings? Is your data enlive nodes?
20:49bsimaThe data are enlive nodes, a seq of li elements with nested strong and em elements. I want specifically the authors of the studies: Dambinova SA, Shikuev, Weissman JD, Mullins, JD.
20:50bsimaI'm trying to doseq each one into a str and then run re-find on them right now, hopefully it will work
20:51bsimaYeah, it looks like this should work, I just need to work on the regex now
20:51bsima(doseq [seqs (map :content (references))] (pprint (re-find #"(Grindel)" (apply str seqs))))
20:53arkhfor this clojurescript it keeps tripping up on className: (.. js/document (getElementById "logview") className)
20:54arkhhow do I specify that className is a property and not a function?
20:56amalloyarkh: in cljs you use (.foo bar) to call foo as a method, and (.-foo bar) to look it up as a field
20:56amalloythat macroexpands to (. bar -foo), so you should just be able to write (.. whatever (...) -className)
20:56arkhohhh
20:57arkhthat makes sense now; .-className was also throwing an error but that's because I didn't need the '.'
20:57arkhthank you
21:43eraserhdIn the old days, I saw a lot of programs fire up $EDITOR on a template that has Field: Value, and perhaps Field:: multi-line-value, and then parsed it. Like git commit does. Does anyone know if there's some kind of parser for that already?
21:51serjeemis there a shorthand for (apply concat lst)?
21:53bsima@eraserhd does this help? https://github.com/cgrand/parsley
21:53amalloyserjeem: no
21:58arrdembbloom: prototype branch using fipp-like sequence structures rather than macro splicing comes in at least 20s slower than the macro splicing.
22:46rbritoHi. I would like to make a simple program, but it seems like I need mutable state. Can anybody help?
22:47HuinanHi, I'm in a situation where I have to package my clojure project without command line lein. Does anyone know if there is any way to invoke lein tasks within the code (either java code or clojure code)?
22:48rbritoActually, it does not *really* need mutable state, but to be practical, I guess that it does.
22:48rbritoThe problem is the following: given a sequence of integers on stdin, with the sequence terminated by 0, compute the sum of such integers.
22:49rbritoWith an imperative language, I can solve this quite easily, but I don't know how would be the proper way to do that in Clojure.
22:49rbritoOr any functional language, for that matter.
22:49rbritoCan anybody help here?
22:51ttasteriscosounds like homework
22:51bsima(reduce (java.io.BufferedReader. *in*)
22:51systemfaultrbanffy: In functional programming, what you want to do is called a fold (also called reduce)
22:51bsimasomething like that
22:51systemfaultErr, rbrito
22:51rbritoThe problem that I see is that the input sequence can be arbitrarily long and it will potentially exhaust the memory if memory isn't reused.
22:52bsimause doseq
22:52rbritottasterisco: it indeed, is homework. That I will assign to my students.
22:52bsimasee here: http://stackoverflow.com/questions/2034059/how-to-read-lines-from-stdin-in-in-clojure
22:54rbritobsima: thanks. your reduction stuff is a good approximation of what I need, but what if the requirement is changed so that I should stop when, say, the number 42 is entered?
22:55bsimaeh, I'm not sure you can arbitrarily stop doseq…
22:55rbritoNote that I may not be in control of the input... (Think of the input being a pipe).
22:56rbritoUsing scala and mutable state, I was able to create such a program, but I would like to use clojure for this course...
22:57amalloyrbrito: you absolutely don't need any state for that
22:57rbritohttps://github.com/rbrito/macmulti/blob/master/chap01/ex01.scala
22:57amalloy(apply + (for [x (read-numbers-forever) :while (not= 42 x)] x))
22:57amalloywould be one reasonable approach
22:58rbritoamalloy: Ah, my clojure-fu is not up to that list/whatever comprehension. :)
22:58amalloy*shrug* so use take-while
22:58amalloy(apply + (take-while (complement #{42}) (read-numbers-forever)))
22:59rbritoNo, but I would like to use comprehensions if that's the better (read: more memory efficient) computation.
22:59amalloyyou're optimizing about two years too soon
22:59hellofunkamalloy i'm curious, both idioms you just noted are great and equally as succinct. which do you think is the better choice, or is it just taste?
22:59amalloyonce you understand how to write a correct solution to the problem, and you've tried it and discovered it's no good, then you can think about performance
23:00amalloyhellofunk: taste, really. and context: the take-while would fit better into an existing ->> pipeline, but i prefer for in general
23:00rbritoamalloy: well, I actually know about the "premature optimization is the root of all evil". :)
23:01amalloyrbrito: then you should recognize that the optimization question you asked is absurd
23:01rbritoI just want to feed humongous quantities of input to the program and not have it barf on me.
23:01amalloyyou're adding up a list of numbers. on a computer that can download entire video files over the internet in a matter of minutes
23:01amalloyit can handle an awful lot of numbers
23:02rbritoamalloy: one of the things that I have in mind is running all my programs on my armel system with only 128MB before I assign them to my students.
23:02rbritoOoops, this just goes to show that my computer may not be as fast as you think. :)
23:03rbritoJust to give a little bit of my context:
23:03rbritohttps://lists.debian.org/debian-arm/2014/07/msg00033.html
23:05amalloyyou're just completely off on your sense of scale. even if you were keeping all numbers in memory at once (but why would you?), you have more than enough memory to add any quasi-reasonable series of integers
23:06rbritoOK, scratch that. I have one next question: how do I perform dynamic programming with immutable state?
23:07amalloytypically you don't need to. most algorithms that use dynamic programming in a mutable language are better formulated as a pure function windowed over a lazy sequence anyway
23:08amalloyfor example, consider a classic example, computing fib(n) by starting at 0 and building a lookup table
23:08rbritoamalloy: I see. If not all values of the dynamic programming formulation need to be computed.
23:09rbritoOr if they can be discarded after a while.
23:09amalloywell, more importantly, they don't all need to be *saved*
23:09rbritoBut there are some notorious cases where they may need to be kept.
23:09amalloyprobably so
23:10rbritoThe knapsack problem is one of those.
23:11rbritoamalloy: in you snippets, the read-numbers-forever function isn't something that already exists, right?
23:11amalloyright
23:11amalloyif you need to keep a lookup table forever, you can always use it as a loop variable in your loop/recur, or an accumulator in your reduce, or...
23:12rbritoJust tried it on the repl and it complained...
23:13rbritoI am still evaluating if I can give the course in clojure or if I will have to surrender and give it in another language. Of course, I wouldn't be here if I didn't *want* to use clojure, which should say something. :)
23:17hellofunk(set! (eval (give "course in clojure")) true)
23:20rbritohellofunk: yes, more or less like that. :)
23:21rbritoSo, read-numbers-forever can be written something like (repeatadly read)?
23:21rbritorepeatedly
23:24rbritoWell, it worked with that simple implementation. :)
23:24rbritoI now can give my students a new entire class of programs to write. :)
23:24rbritoIt will be possible to avoid scala. :)
23:26rbritoNot that scala is bad, but learning one member of the lisp family will be a nice addition to get out of the mental structure of the programs written like Java (which is all that they know at this point).
23:30rbritoamalloy: doesn't these snippets that you presented me keep the numbers in question in memory?
23:30rbritos/doesn't/don't/
23:31sztamasI love it how you keep be concerned about memory but you don’t even care if what you read in are numbers at all
23:33rbritosztamas: that should give you a hint of my background being non-real-world and only theoretical. :)
23:34sztamaswhat is the course if I may ask?
23:35rbritoThis one will be an introduction to functinonal programming, but I am thinking of giving the equivalent of CS 101 with clojure...
23:35rbritoI am moderately proficient with Python: https://github.com/rbrito
23:36rbritoBut I want to start using functional languages.
23:36rbritoOr using conventional languages in a more functional way.
23:37brehautrbrito: fuctional javascript by fogus is a good introduction to functional programming
23:37rbritoAt least python has higher order functions and comprehensions.
23:37rbritobrehaut: thanks. Javascript is also a good option.
23:37systemfaultTry Haskell if you want to fall into the rabbit hole. :P
23:37gfixlerrbrito: that's my path - Python dev (for games) for years, moving much more into FP now, and bringing that back to my Python work.
23:38brehautrbrito: once you have finished functional js, have a look at joy of clojure 2e
23:38brehaut(also by fogus)
23:38TEttingerclojure's a fun language once you get the hang of it. it did take me a while to "get it," though
23:38brehautFunJS is intended partly as a primer for JoC
23:38brehaut(if i recall things correctly)
23:39rbritosystemfault: I don't think that I'm interested in haskell, but that's my current impression and I may reconsider my position here...
23:39rbritobrehaut: thanks. I think that I will check this out.
23:39rbritoI actually like the little javascript that I know of.
23:40rbritos/know of/know/
23:40brehautrbrito: you dont know enough js then ;)
23:40systemfaultrbrito: With haskell, you’re forced into FP. Unlike most other languages where the escape hatch from FP is too easily accessible.
23:41rbritobrehaut: indeed, my experience is only with C (a little with C++, but nothing substantial) and with Python. (With a moderately successful project in Python on github).
23:41sztamasyou can certainly teach some FP using just python
23:42sztamas+1 for Functinal JavaScript by Fogus BTW, I really enjoyed it
23:43brehautrbrito: if you want an exercise, compare the clojure sequence api to pythons generators and itertools
23:43brehautrbrito: generators are inherently mutable while seqs are not. they otherwise perform similar tasks, but seqs are far more exprsesive
23:44rbritosystemfault: I may be misdjudging haskell here, but the excess of symbols as opposed to the use of words (like in Python) makes me prefer other languages. At least with lisp there's a real break on the syntax. :)
23:44rbritobrehaut: thanks for the recommendation.
23:44brehautrbrito: im a former python programmer too
23:44brehautclojure is a nice next language
23:45brehaut(also F#)
23:45sztamasI’m a python programmer too
23:45ddellacostarbrito: I don't find Haskell too painfully heavy on symbols vs. strings, certainly about the same as Clojure
23:45rbritosztamas: yes, I think that I may fallback to using python, but I don't know if I am allowed to. :( The University has a partnership with oracle... :(
23:46gfixlerrbrito: I had a little revelation today when I found a nice color scheme for Vim - I was writing small functions that were purely functional, and toggling between them and my test file
23:46rbritoddellacosta: I'm not discarding haskell... I would just prefer other things (in my ignorance).
23:46gfixlermy old schemes didn't highlight it, but this one did - my code was all blues and creams, and my tests were all greens and oranges
23:47gfixlerI realized the colors were marking the divide between functional and declarative
23:47ddellacostarbrito: yeah, just saying--give it a chance, I think Haskell uses symbols very judiciously (and the community tends to shy away from syntactic sugar as well, generally)
23:47gfixlerthe functions were all commands and keywords; the tests were all strings and numbers being pushed into them
23:48rbritoI use emacs since 1994, but I don't reject using newer technologies (like an IDE like Eclipse). :)
23:49brehautddellacosta, rbrito: haskell also uses symbols for things that are very abstract and thus hard to name with words. thats not always a negative
23:49rbritoddellacosta: thanks. That's nice to know and to consider. Only one thing that I found error prone was that you apparently can't define variables that start with capital letters.
23:49rbritobrehaut: like >>= ?
23:50brehautrbrito: sure.
23:50rbritoIsn't it "bind" in other languages?
23:50brehauti know it also has a name (bind) but its sometimes useful to get the words out of it
23:50rbritoYou were reading my mind. :)
23:51ddellacostaI think the thing with symbols is that they can be doubly useful when applied judiciously--they can remove boilerplate, and they can provide more immediate visual recognition of what is going on in code
23:52ddellacostaI think Clojure's data structure syntax helps with quickly recognizing what you're working with, for example
23:52ddellacostabut you can go too far: Perl
23:53rbritoBut I am mostly (for some unrational reasons) interested in giving this course in clojure and, perhaps, contrasting with other languages. Here, the suggestions that all you nice people gave about JS, Haskell or even Python (well, this one was already considered by me) were valuable.
23:53rbritoI will check this book on functional programming in JS.
23:54rbritoIt sounds very interesting, given that the students will already, at that point, have some experience with JS (probably more experience than I do).
23:54systemfaultJS (ES5) has some FP stuff.
23:54systemfaultmap/filter/reduce/bind
23:55rbritoddellacosta: being a former Perl programmer that loves Python, I want to avoid symbols as much as I can. ;)
23:56brehautrbrito: dont just haskell by perl's mistakes ;)
23:56brehautsystemfault: a different bind though ;)
23:56sztamasthe FUN JS book uses Underscore
23:56systemfaultbrehaut: Yeah… JS’s bind is like manual currying
23:56brehautsystemfault: also javascript functional stuff is a bit munted (see also: promises)
23:57rbritoI also, for some reason, don't consider parentheses in clojure as "symbols" any more than, perhaps, braces in C.
23:57systemfaultbrehaut: Haha, i love promises though… compared to callbacks.
23:57rbritobrehaut: I promise to look seriously into haskell and I hope to come back to this IRC channel frequently from now on. :)
23:58rbritoA lovely community, BTW.
23:58brehautsystemfault: well yes, its the lesser of two evils ;) but the duck-wrapping :'(