#clojure logs

2014-12-24

00:27crispinhey, I want to use an externs in cljs
00:27crispinthat is, NOT bring in the js code to the closure compiler
00:27crispinI've made my extern js file
00:27crispinIve put it in :externs
00:28crispin(as per instructions)
00:28crispinbut compiling keeps giving me WARNING: No such namespace: PIXI at line 1 src/cljs/cljs_jam/gfx.cljs
00:28crispinWARNING: Required namespace not provided for PIXI
00:28crispinSEVERE: /home/crispin/dev/clojure/cljs-jam/resources/public/cljs_jam/gfx.js:4: ERROR - required "PIXI" namespace never provided
00:28crispingoog.require('PIXI');
00:28crispinit shouldnt be goog.require()ing it
00:29crispinits an external!
00:29crispinoh wait!
00:29crispindo I need to :use instead of :require it in ns?
00:31crispinnope that didn't work
00:32crispinhow do I reference external javascript?
00:32crispinI followed the docs. Doesn't work
00:35crispinok got it working
00:35crispinhad cljsbuild auto
00:35crispinchanged my project.clj file
00:35crispinneed to ctrl-c and restart the auto build. It doesnt pickup project.clj changes
00:36crispinno wait. thats still trying to google closure compile it
00:36crispin(I added :foreign-libs)
00:37crispinhttp://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html
00:37crispinhow do I reference external javascript?"
00:37crispin"Referencing a library outside your compilation"
00:37crispindoesnt work
00:37crispinkeeps wanting to goog.require() my extern library
00:41crispinmaybe theres a problem with my externs... let me try modifying it a bit
00:41crispinit is one gripe I have with leiningen
00:41crispinsilences so many errors
00:41crispinbad path in there somewhere.... crickets
00:44crispinFUUUUU
00:44crispinso frustrating
00:47crispineg. put a completely bogus path into externs. no error at all
00:47crispinjust silence
00:49andyfYou can try filing an issue for Leiningen: https://github.com/technomancy/leiningen/issues
00:50crispinok I think I got it. Errors in the externs
00:51crispinbut yes. will check for a ticket. Because if the path doesn't exist, you get no error
00:51crispinI had a typo in the path
00:51crispinnow I get: ERROR: JSC_PARSE_ERROR. Parse error. '}' expected at /home/crispin/dev/clojure/cljs-jam/src/js/pixi/externs2.js line 651 : 0
00:51crispinif the path doesn't exist
00:52crispinjust fails bizarly. Will check the leiningen issues and raise one if theres not one already
00:54crispinok fixed all that. still doesnt work :P
00:54crispinwill keep digging
00:58maxpnhow to split sequence by chuncks?
00:58maxpn[1 2 3 4 5 6] -> [1 2] [3 4] [5 6] ...
00:59maxpnchuncks of n-elements each
00:59luxbock,(doc partition)
00:59clojurebot"([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."
00:59maxpnthank you
01:00luxbockthere's also partition-by which is handy at times
03:04Rayneshttps://github.com/scopely/sqlquest/issues/16#issuecomment-68034697 I love my coworkers.
03:04RaynesTeasing me about my Clojureness on a Coffeescript project that I wrote :P
03:27andyfYou should respond and tell him its a Python triple-quoted string thing.
03:28lxsameerhey guys, I really confused in a two way situation between clojure and scala, What is the most important advantages of clojure over scala ?
03:29sg2002lxsameer: Clojure is a lisp.
03:31lxsameersg2002: ok and how is that an advantage my friend ?
03:33sg2002lxsameer: The answer to that would be a long one. Just gonna say that there are people who believe that lisp style languages are better and if you're one of them, that's an advantage of clojure over scala.
03:34sg2002lxsameer: Another specific clojure advantage is it's concurrency model. But again you have to understand it before you know whether you need it.
04:38ddellacostaIs there an equivalent to Haskell's flip function in Clojure?
04:40hellofunkddellacosta: interesting we discussed that yesterday, flip exists in a common library for clojure, can't remember which one now
04:40hellofunkthough it's trivial to write it yourself
04:40ddellacostahellofunk: thanks, yeah, just would be handy if it was already part of core, but ah well
04:40hellofunknot in core
04:42hellofunkddellacosta: it is in flatland/useful according to my chat logs
04:42ddellacostahellofunk: cool, thanks
04:42ddellacostaprobably not worth using the lib just for that now, but good to know
04:44hellofunki'll have to take a look at the library to see what else might be "useful", no pun intended
04:50hellofunkddellacosta: i'm curious why flip comes up often, why is it important to rearrange arg order so often?
04:51SagiCZ1what about if you want to use threading, and one of 10 functions has a different arg order than the others?
04:51ddellacostahellofunk: I'm still learning Haskell so I can't tell you in general, although pair tuples are a more common type that you run into in Haskell, so that may have something to do with it
04:51ddellacostahellofunk: the reason I wanted to use it just now was to flip a sort, basically
04:52ddellacostaand yeah, in Clojure at least, SagiCZ1's example seems pertinent
04:53SagiCZ1i wonder what as-> does.. didnt understand it
04:53SagiCZ1(doc as->)
04:53clojurebot"([expr name & forms]); Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form."
04:54SagiCZ1seems like it is for when you have functions with different args order and you want to still use threading
04:55hellofunkSagiCZ1: ddellacosta: ah i get it. i rarely use the thread macro so maybe haven't run into that need. i'm still old school leaning on comp and partial a lot
04:55SagiCZ1i guess its just a matter of preference..
04:55ddellacostahellofunk: I used to use the threading macro a lot more, and use it less now, as I find (ironically) readability can suffer using it sometimes
04:56ddellacostaand if I've got a huge stack of functions then probably I'm doing something wrong
04:56SagiCZ1i am a beginner so this may be something i am heading towards in the future
04:57hellofunkSagiCZ1: i should sit down and memorize the core api some time. little nuggets like this as-> keep popping up and i wish they where in my regular vocab
04:58hellofunkfor Om, i wish I'd adopted doto a long time ago, would have cleaned up a number of things for me.
04:59SagiCZ1i learn it similar to a human language vocabulary.. if i run into a need of some function many times over and over i remember it.. otherwise its not worth my time
04:59ddellacostaI've been using Clojure for years now and I still come upon functions I was barely aware of, or new idioms
05:00ddellacostaalso there are some functions I finally have "gotten the hang of" and know when to use
05:00ddellacostaI couldn't for the life of me figure out why to use juxt for a long time, for example
05:00ddellacostastill don't think it's that useful actually, haha
05:00ddellacostabut figured out some uses
05:01hellofunkddellacosta: someone showed a good example of juxt the other day: using it to pull out isolated values from a map, based on just a selection of its keys.
05:02ddellacostahellofunk: yeah, that's what I was thinking of actually...and that's all I've ever been able to do with it!
05:02ddellacostamaybe I'm not imaginative enough
05:03ddellacostaalso starting to learn Haskell lately, there are a few functions I wish were named differently
05:03hellofunk,((juxt :a :b) {:a 1 :b 2 :c 3 :d 4})
05:03clojurebot[1 2]
05:03hellofunkin this case i think of it as "just" the keys i want
05:03ddellacostacomp seems so unwieldy now, love the simple .
05:03ddellacostayeah, that is handy, definitely
05:03ddellacostaand that + map can be really useful
05:04hellofunkyou are saying you do or do not like using comp now?
05:04ddellacosta&(map (juxt :a :b) [{:a "a" :b "b"}{:a "a1" :b "b1}])
05:04lazybotjava.lang.RuntimeException: EOF while reading string
05:04ddellacostad'oh
05:04ddellacosta&(map (juxt :a :b) [{:a "a" :b "b"}{:a "a1" :b "b1"}])
05:04lazybot⇒ (["a" "b"] ["a1" "b1"])
05:04hellofunkddellacosta: almost like an sql query in that case
05:04ddellacostahellofunk: I'm saying I might use comp more if the syntax was simpler, since it's super powerful
05:04ddellacostayeah, never thought of it that way
05:05hellofunkddellacosta: i think i will steal that idiom you just shared when i get back results from postgres!
05:05ddellacostaha, yeah, although to be honest I find it of limited utility
05:06ddellacostabut would be interested in hearing how other people have managed to use juxt
05:06hellofunkit comes up a lot when reading others solutions to the 4clojure problems. lots of ingenuity to be learned from that site.
05:06SagiCZ1~juxt
05:06clojurebotjuxt is pretty metal
05:06ddellacostagood point, I need to revisit that site
05:08hellofunkddellacosta: perhaps better for the cljs room but have you done much drag and drop operations in Om? i'm tackling the sortable example today to really grasp it
05:08ddellacostahellofunk: I have done a drag and drop implementation in Om, as a matter of fact
05:08ddellacostait was a pain in the ass, but mostly because drag and drop freaking sucks
05:08hellofunkddellacosta: did you model it on the Om example for sortable?
05:09ddellacostaer, I don't think so
05:09ddellacostasorry. :-(
05:09hellofunkddellacosta: then you must really know JS because it seems to involve a lot of stuff i'd never know without following that example closely
05:10ddellacostaI mean, I got to know the drag and drop API pretty well because of it
05:10ddellacostabut it is really just frustrating to work with, and there are a lot of browser quirks
05:10hellofunkusing googe closure utilities?
05:10ddellacostaI did not use Google Closure, no, that may be one way around the challenges
05:10ddellacostabut our front-end is too specific to use whatever Google offers in that domain
05:11ddellacostaand in general I find trying to integrate google closure widgets into Om is a major PITA
05:11hellofunkddellacosta: ok. dnolen's uses closure for a few things in the example
05:11ddellacostait could work, I honestly don't know
05:11ddellacostawe just have a very specific set of needs
05:12ddellacostaand certainly there is a lot of utility in the Google Closure library, I think some parts of it are very robust
05:12ddellacostaI don't love the interface in general, it's super Java-y
05:12ddellacostabut it handles a lot of browser quirks well
05:12hellofunkddellacosta: its the event handling and stuff that the Om example uses
05:13ddellacostahellofunk: oh, yeah, he falls back on that a lot, which makes sense because otherwise you have to import Dommy or something
05:13ddellacostahellofunk: certainly the event handling lib in Google Closure is lightweight enough
05:13ddellacostahellofunk: I was more talking about the UI widgets
05:13ddellacostaGoogle Closure's lib is huge
05:15ddellacostahellofunk: re: drag and drop, I don't feel like the situation has changed much since this was written: http://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html
05:15hellofunkddellacosta: he does stuff like this: (doto js/window (events/listen EventType.MOUSEUP mouse-up) (events/listen EventType.MOUSEMOVE mouse-move))
05:15ddellacosta(well, it's improved a bit, I used it at least)
05:15ddellacostayeah
05:15ddellacostathat's simple enough, and not much different from how it would look in Dommy
05:16hellofunki've been tasked with a big drag and drop interface and we use Om so i hope it goes well
05:16ddellacostahellofunk: Om is the easy part. Be careful about checking what parts of the api all the browsers support
05:17hellofunkddellacosta: well fortunately we don't support all browsers :)\
05:17ddellacostahellofunk: that is the part that sucks and will make you miserable
05:17ddellacostahellofunk: good for you, you're lucky. :-)
05:18hellofunkfor now, we will be expanding it in the future. hopefully by then we have a real browser expert to take over stuff
05:40cfleminghellofunk: My argument wasn't so much that we shouldn't be using text, which I think is actually a pretty good serialisation mechanism, but that tools should understand what that text means
05:41cfleminghellofunk: I'd love to provide a formatting "view" on code, it's something I always wanted in Java, where different formatting styles are much more different than in Clojure
05:42hellofunkcfleming: yeah i paraphrased you confusingly perhaps. i think it was about the writing of text and focusing each minutiae like indents, line breaks, parens, etc that gets in the way of "the zone" of expressing ideas
05:42cfleminghellofunk: Yeah, I'm definitely a fan of removing all that.
05:43hellofunkcfleming: i don't want to have to focus both on my code as well as its display formatting simultaneosly; yet the display formatting affects the ease of writing the code, so it's an annoying feedback loop
05:43cfleminghellofunk: I'm actually planning to record where the user has made changes, and automatically reformat the current top level form after a second's inactivity.
05:43cfleminghellofunk: So you
05:43cflemingOoops
05:44cfleminghellofunk: So you'll modify the code, stop to think for a moment, and it'll format what you've done so far.
05:44cfleminghellofunk: Doing that just for the top-level form should make it interactive-level fast
05:44hellofunkcfleming: that would work, as you type new nested forms, it reformats parent forms to "make room" for them on the screen without line wrapping
05:45hellofunkand by "reformat" i usually just mean where the line breaks are inserted, since they affects the overall indentiation of deep nested forms
05:46cfleminghellofunk: Yeah - that's a little tricky, automatically breaking lines is quite controversial and requires some knowledge of the forms themselves
05:47cfleminghellofunk: I'm experimenting with that right now.
05:47SagiCZ1can really imagine how would that work
05:48SagiCZ1whats hard about manually inserting line breaks when you write code?
05:48hellofunkcfleming: here is an example: https://www.refheap.com/95377 note how the final arg2 has vastly different indentation despite that both versions here are correct
05:49cflemingSagiCZ1: Generally, that different people like to do it in different ways, and doing it interactively often requires the full context which you may not have.
05:49mi6x3mhellofunk: i prefer the second :)
05:49cflemingSagiCZ1: e.g. a simple example is that I often have (if condition (then-form) (else-form)) on the same line if it's short
05:49SagiCZ1i insert them where it makes code more readible.. no strict rules
05:49SagiCZ1yeah
05:50hellofunkSagiCZ1: because when you are writing a fn, you don't necessarily know in advance when line wrapping will occur, which is ugly and throws off the readability of the code. having to stop and go back to format your code just so you can continue to work with something readable is a stumbling block in the workflow
05:50cflemingSagiCZ1: Exactly, but that's a very difficult heuristic to apply automatically
05:50SagiCZ1but you do want to try to implement that heuristic, is that what you are talking about here?
05:51cflemingSagiCZ1: I'd love to, but the problem is automatic formatting is infuriating if it doesn't work well.
05:51hellofunkto me the issue is not complicated. just add line breaks to parent forms after the fn name when line wrapping occurs.
05:51SagiCZ1cfleming: that would be my fear exactly
05:51mi6x3mI had the idea of writing an automatic formatter for the clojure style guide using fipp
05:52mi6x3mmainly test-driven
05:52hellofunkmi6x3m: i only like the second when i have to use it to avoid line wrapping. generally i prefer the first but when working with Om which has #js literals and other things, the code can get quite long and then starts wrapping a lot
05:53cfleminghellofunk: That can be mitigated by allowing functions to indent two spaces, which was one of the focuses of the recent discussions around formatting Clojure code
05:54hellofunkcfleming: i don't follow... allow a fn to indent? what does that mean?
05:54cflemingIf you haven't read it, Steve Yegge's post on implementing an IntelliJ style mode for JS is a really great read: http://steve-yegge.blogspot.co.nz/2008/03/js2-mode-new-javascript-mode-for-emacs.html
05:54cflemingIn particular how difficult indentation is.
05:55cfleminghellofunk: Bozhidar feels very strongly that only macros should have body-like indentation of two spaces.
05:55cfleminghellofunk: So functions can only line up in your two styles there.
05:56cfleminghellofunk: Om in particular has a lot of forms that are actually functions but which benefit from macro-style indentation, which is why Cursive allows that.
05:57hellofunkhm i must admit i'm still confused what you mean by macro indents vs fn indents. i've never noticed the differences.
05:57cflemingSee https://github.com/cursiveclojure/cursive/issues/536
05:58cflemingSee the difference?
05:58hellofunkcfleming: i see. i never noticed that macros do it differently. probably because i don't use too many macros. but you are right that Om would really benefit from this
05:59hellofunkcfleming: in fact I became passionate about this "problem" only when I started using Om, but then realized that it applied in general.
05:59cfleminghellofunk: There are lots of other examples too. In general I'm not a fan of the one-space indent (the second example in your refheap).
06:00hellofunkcfleming: that issues link refers to a "reformat" feature in Cursive, is that right? kinda like a "beautify" ?
06:01cfleminghellofunk: Yeah. Currently it doesn't actually break lines, it adjusts the indent and also aligns some things automatically, like map values and (soon) let bindings and the like.
06:01hellofunkcfleming: that issue was closed on gh, what was the outcome? is it just for Om fns or in general you can set in Cursive your preferred indent style for any fn?
06:02cfleminghellofunk: It's actually capable of breaking lines now too, if only I can get the heuristics right. I'm working on that for EDN first since that's easier - I'll then pretty print REPL results and so on.
06:02cfleminghellofunk: It's also used for the diff view for test results, but that's a hack right now and doesn't use the proper formatting engine.
06:02cfleminghellofunk: It's general, you can set it for any fn.
06:05hellofunkwell it's just one more reason i need to devote some time to giving Cursive a solid look.
06:05cflemingLet me know what you think if you do, for sure - I'm always interested in feedback, good and bad
06:05SagiCZ1hellofunk: definitely worth it, i cant imagine coding without it, its super intuitive and just works like a charm
06:06hellofunkthe irony is that after using emacs for 1 year I'm finally starting to really really get into it. but there are some things for cljs that emacs will never do right until someone write a good syntax parser in the spirit of what Cursive/IntelliJ does
06:06cflemingIt'll be interesting to see how dnolen's new compiler functionality for cljs.test will help cljs tooling in Emacs
06:08hellofunkone thing i liked right away -- the simple things -- when i looked at cursive once was the little vertical line that helps you see where things are lined up. of course, this could also be done in emacs
06:09SagiCZ1i think thats an intellij feature though
06:09hellofunkSagiCZ1: regardless, it's sweet
06:09cflemingYeah, I got that one for free. It is nice, though.
06:09SagiCZ1thats another advantage of cursive though.. that it has a solid and stable intellij to run on
06:10SagiCZ1if it was an eclipse plugin, i would have rather learned emacs :P
06:10hellofunkcfleming: and you demoed some things where actual code lines would change and get rewritten automatically, and while cool, i can see a meta form of this where users can add their own little coding tools to do this for various circumstanced.
06:11cfleminghellofunk: The refactoring stuff, you mean? Yeah, that's easy to do really nicely - it took a while to get the infrastructure in place, but I can add new things pretty quickly now.
06:11hellofunki mean once you have a great tool like cursive that understands the lanuage syntax, there is a whole new level of tooling that can come from that, the demos just scratch the surface.
06:12cfleminghellofunk: Yeah, absolutely, I'm really just at the point now where I'm starting to add functionality based on the infrastructure, which has taken a year or so to get to where it is now.
06:13hellofunkcfleming: i can completely see how some day it could be possible that the code you physically type and code that ends up on the screen are quite different, making it possible to get ideas across almost in shorthand. like improvising music. that would be the ultimate realization of what lisp has to offer, i think.
06:13SagiCZ1you gotta be lazier than i am if you came up with such ideas
06:13SagiCZ1:D
06:15hellofunkwell just imagine the power of an interactive programming environment like any good lisp but without the tedious layer of lots of typing in the middle. our ideas are always bigger than the process of typing little keys. FP feels a lot like a gesture-driven or musical process to me, less like a textual one
06:19cflemingYeah, there's lots of potential. In particular I do think some of this kind of functionality can let you sketch out code and then have it be filled in/organised for you.
06:20cflemingI'm also toying with the idea of being able to capture a REPL session and automatically turn it into unit tests.
06:20cflemingOr at least semi-automatically.
06:20cflemingRight, bedtime for me
06:20hellofunkoh exactly. i really think that text editing is going to be a smaller part of the future of coding in general.
06:20cflemingHappy Christmas, everyone, if you're in a Christmassy sort of place.
06:20hellofunkmerry xmas!
06:24tomjack'(def symbol ^holy-crap! doc-string? init?)
06:26SagiCZ1merry christmas to you all guys
06:27SagiCZ1is it the 23 or 24 in the us?
06:27hellofunkSagiCZ1: it is the 24th now everywhere in the world
06:27SagiCZ1cool.. i never know whether to add or substract to my timezone :-/
06:41SagiCZ1how would you pick random n elements from a collection?
06:42SagiCZ1,(take 5 (shuffle (range 10)))
06:42clojurebot(7 2 5 3 4)
06:42SagiCZ1it would be cool if shuffle was lazy
06:43Bronsahow would it work
06:43Bronsa?
06:44SagiCZ1it would return a random element, and remove it from the collection
06:44delexiis there a function/idiom in clojure acting like flip in haskell? As a concrete example: I want to pass the arguments to mod in the reverse ordering. I want to use (mod num div) as (mode div num).
06:44BronsaSagiCZ1: but get a random n element in a coll, you have to resolve that collection until the nth element
06:45SagiCZ1Bronsa: i see
06:45BronsaSagiCZ1: and how can you even know how big the collection is without realizing it?
06:45SagiCZ1count on vector is O(1) though?
06:45Bronsavectors are not lazy
06:45SagiCZ1of course
06:45SagiCZ1sorry i am stupid in the mornings.. thanks
06:46BronsaSagiCZ1: i mean, there can be lazy + O(1) count colls, e.g. range in cljs
06:47BronsaSagiCZ1: but still, there's really no good way to have a shuffle a lazy collection without realizing it
06:48BronsaSagiCZ1: I suppose shuffle *could* produce a lazily shuffled coll, but the issue of having to realize the coll still remains.
06:48SagiCZ1so it wouldnt save any time on (take n (shuffle coll))
06:49tomjackif the lazy seq is very big, you can do better, I think. not lazier, but more forgetful.
06:50BronsaSagiCZ1: it would save time if n was sufficiently small, realizing coll was sufficiently fast and shuffling the whole coll took a long time
06:50BronsaSagiCZ1: wich I think is an unrealistic scenario
06:51ctfordI've found something strange while working in a directory with an accented character - using clojure.java.io, (-> "file.txt" io/resource io/reader) fails, due to URL encoding of the path.
06:52ctfordDoes anyone know if there's a way to handle this correctly, or is it just a limitation in the Java libraries?
06:54BronsaSagiCZ1: thinking about it it might make sense in the case of, (take small-number (lazy-shuffle (vec (range BIG_NUMBER))))
06:56ctfordPerhaps using getResourceAsStream() would avoid the problem? I believe it would still be compatible with io/reader.
07:00SagiCZ1,(into {} (map #(vector %1 :x) (range 5)))
07:00clojurebot{0 :x, 1 :x, 2 :x, 3 :x, 4 :x}
07:00SagiCZ1any way to make this look better?
07:01mi6x3mSagiCZ1: define "better"
07:01SagiCZ1shorter
07:02ctford,(zipmap (range 5) (repeat :x))
07:02clojurebot{4 :x, 3 :x, 2 :x, 1 :x, 0 :x}
07:02SagiCZ1ctford: pretty cool, thanks
07:03ctfordSagiCZ1: no problem.
07:30ctfordWould there be an interest in an io/stream-resource to match io/resource? It would return an InputStream, and thus avoid URL-encoding issues.
07:36OscarZ-if i have some client side app that interacts with Clojure server.. i'd like to do some server side validation on the data sent by client.. what do you guys recommend for that sort of task ?
07:36OscarZ-i guess usually the JSON is converted to clojure maps
07:37ctfordOscarZ-: What kind of validation? If it's simply checking that the input is of the right format, Prismatic Schema is very handy.
07:37ctfordHowever, it's designed to either succeed or fail - it won't give you errors back as data that you can format for clients.
07:38OscarZ-im thinking stuff like making sure there are no extra fields, the fields that are there are in specified format.. ints, strings, maybe i could use some regexp patterns too
07:38OscarZ-yeah, i'd like some kind of feedback too
07:40OscarZ-hmm.. ive been thinking of some simple exercise project for learning Clojure.. maybe i could try to do that myself
07:44OscarZ-i also ran into EDN data format.. but i guess its not for this sort of thing
07:53OscarZ-if i have a map, and the map can have other maps inside it (and recursively they might have more maps inside them) .. whats the best way to transform all those nested maps with some function ?
08:04AimHereOscarZ-, you looked into zippers?
08:05FrozenlockOscarZ-: zippers, walk, even 'for' might be good enough.
08:05OscarZ-nope.. ill check them out :)
08:08OscarZ-"Editing trees in Clojure with clojure.zip" sounds just like the thing im looking for :)
08:10OscarZ-this is probably something i should be able to program myself
08:12OscarZ-but with Clojure, as its so data- oriented, if i have some problem with data transformations that sounds "primitive enough", i usually find out its already there :)
08:14OscarZ-hmm.. zippers seem a bit complex.. maybe they are too flexible for my thing..
08:19OscarZ-ill try to formulate what i want: given a map, i want everything else but maps to be "copied" as they are.. for maps i'd like to run a some "check" function, if check=true, then the map transformed by some function of my own, if check=false, then it is copied as it is and not recursed
08:20OscarZ-is this a case for zippers?
08:22AimHereYou might get away with some recursive function using something like recurse-kv
08:22AimHerereduce-kv rather
08:28hellofunkOscarZ-: that kind of validation seems rather simple to send from a browser to a server and then back. unless it depends on data that is on the server, why not just validate client side? and if you cljs client side, this is pretty straightforward
08:35OscarZ-AimHere, does that do only one level though ?
08:37OscarZ-hellofunk, id like a function "layer" in my server side code that if it passes the validation, it is safe to pass it down to save it to database etc..
08:39OscarZ-hellofunk, i suppose i could do more heavy validation on client side that would provide feedback, but i certainly need some validation on server too for security reasons... and as they are surely overlapping concerns, i wouldnt want to do it twice if possible
08:41OscarZ-CLJS on client side and Clojure on server it sounds like a library is needed :)
08:43hellofunkOscarZ-: well, there are many libraries out there for interop between cljs and clojure. but in your case if the nature of the validation requires information the browser does not have, then of course you'd do that on the server.
08:45OscarZ-hellofunk, yeah true, i didnt even think about that.. i could need that too, eg. check if the username exists and that sort of thing
08:47OscarZ-i guess the way i would like forms on a web page to work needs to have some server side validation too
08:47AimHereOscarZ-, it does, but you can put it in a recursive function; there's also 'walk'
08:47OscarZ-for example when you type in a username, we need to check if it already exists
08:48OscarZ-and i need to do that per input field, its not enough to first do client side validation and if it passes, then do server side
08:49uris77that sounds like database validation
08:49OscarZ-AimHere, ok.. i didnt understand it from the docs
09:03kldo you guys throw exceptions, or use another approach for exceptional situations that is referentially transparent?
09:05ddellacostakl: you might want to take a look at dire, if you haven't: https://github.com/MichaelDrogalis/dire
09:06ddellacostanot exactly referentially transparent, but maybe as close as you're going to get with Java in the mix
09:07hellofunkOscarZ-: are you sending down your info to the server for validation via a socket or ajax?
09:07OscarZ-hellofunk, ajax
09:07hellofunkOscarZ-: are you doing it only on form submit, or constantly monitoring their changes as they type?
09:08hellofunkor perhaps doing it in an onBluer
09:08hellofunk*onBlur
09:08OscarZ-onBlur, i'd like instant feedback as they move out of some input field
09:09hellofunki've been working client side with sockets from a vendor and must admit they are quite nice over ajax. i hope to study the mechanics of getting it all going serverside too, but i think i'd need to switch to http-kit
09:10hellofunkby which i mean, nicer than ajax (preferred over ajax)
09:23klddellacosta: I'm surprised that the maybe/try monads like Scala/Haskell aren't used
09:26klThrowing exceptions is *very* referentially untransparent - not very functional at all
09:26tcrayford____kl / ddellacosta : I use that style in my app's API: http://yellerapp.com/posts/2014-06-27-api-error-handling.html
09:28tcrayford____roll a thing on top of ->> and -> that shortcircuits when an error type is returned from one of the functions
09:30kltcrayford____: I'll have to revisit this when I've got a better understanding of clojure. I've just started
09:31tcrayford____yeah. It's just a reimplementation of the `either` monad :)
09:31klOh. That sounds like what I'd hope for
09:31tcrayford____but it's not widely used
09:32tcrayford____(I mean, the code in there isn't in a library or anything, so it's not too surprising other folk don't)
09:33klI find it a little disappointing that side-effects are common for functions in a language that's meant to be a functional language
09:34tcrayford____you mean like, clojure.core has a load of side effecting functions in it?
09:34Bronsakl clojure doesn't enforce purity. But the core language has very few side-effecting functions
09:34kltcrayford____: I mean exceptional cases in functions we use/make seem to be handled by exceptions, which are side-effects
09:36tcrayford____are they? they're just control flow things as far as I can tell
09:44kltcrayford____: I don't know whether that's the common clojure line of thought: but I think all Scala/Haskell etc. devs would disagree with that
09:45tcrayford____kl: that's coming from a dude who's done ~10k+ lines of production haskell over the past 5 years
09:45tcrayford____;)
09:50kltcrayford____: strange. I suppose they are different to "non-local side effects". I'll have to meditate on this one
09:51tcrayford____you can sorta imagine it if you wrapped the entire program with an Either monad, it'd come out just like exceptions
10:41jonathanjhow do things like :dev :prod :test keys get set when using lein?
10:42jonathanjcan i find out whether my application is running in dev, prod or test myself?
10:42dnolen_jonathanj: you can w/ environ https://github.com/weavejester/environ
10:44jonathanjdnolen_: well what i'm trying to do is not repeat myself when using joplin: i have to specify the database connection string in the :joplin key (in project.clj) and then in my db-spec that i use in various places in my code; i can't see any clear way to avoid repeating the URL
10:48dnolen_jonathanj: sounds solvable w/ environ, a while ago I played around with Stuart Sierra's component model + environ - seemed promising
10:48jonathanjdnolen_: hrm, i'm not sure how i would solve it with environ
10:49dnolen_jonathanj: have you never done this before w/ Django or Rails, etc?
10:49jonathanjdnolen_: or more specifically, i'm not sure how i call an environ function from projuct.clj
10:49dnolen_jonathanj: seems the same to me.
10:49dnolen_jonathanj: it's not an eviron function, you have dev, staging, prod profiles in project.clj and you can read these via envrion in your program
10:50jonathanji thought environ only read values from the :env key in your project.clj
10:50dnolen_jonathanj: each profile can have it's on :env key
10:51dnolen_s/on/own
10:52dnolen_jonathanj: ah but you're probably saying :joplin is not this flexible
10:52jonathanjokay, so if i specify the database-uri to :joplin {:databases {:blah {... :uri URI_GOES_HERE}}}, i have no idea how to avoid repeating that
10:52jonathanjbut i guess if i put the env and joplin defs next to one another in each profile then it's probably okay
10:53jonathanjdnolen_: i'm not really sure how joplin could be made better, in this regard
10:53jonathanjdnolen_: sure you could add an external config file but then you kind of still have this problem, maybe it's marginally better
10:53jonathanj(i mean, i would contribute to making joplin better if i knew how)
11:02trisshey all...
11:03trisswhat's this operator all about #'
11:03Bronsatriss: clojure doesn't really have operators, that's a reader macro
11:03agarmanit is the same as (var ...)
11:04Bronsatriss: that reader macro expands to (var ..) e.g. #'+ == (var clojure.core/+)
11:04Bronsa,#'+
11:04clojurebot#'clojure.core/+
11:04Bronsa,'#'+
11:04clojurebot(var +)
11:04Bronsa,(var +)
11:04clojurebot#'clojure.core/+
11:04trissnow I'm wondering what var does.... of to the docs i go
11:04trisscheers chaps!
11:06Bronsa,(doc var)
11:06clojurebotI don't understand.
11:06Bronsa:<
11:06Bronsa$doc var
11:06Bronsa&doc var
11:06lazybotjava.lang.RuntimeException: Can't take value of a macro: #'sandbox11388/doc
11:06Bronsabah
11:06hellofunkBronsa: lol i was going to do the same thing
11:06Bronsa&(doc var)
11:06lazybot⇒ "Special: var; The symbol must resolve to a var, and the Var object\nitself (not its value) is returned. The reader macro #'x expands to (var x)."
11:06Bronsathere we go
11:07hellofunktriss: if you understand what a var actually is, and its difference from what its contents *do*, then you'll understand what (var..) does.. i hope
11:07Bronsatriss: if you don't know what a Var is, http://clojure.org/vars
11:09hellofunkin the practical world, calling var explicitly (including using the reader macro) is often used in environments where you don't want to recompile the caller to get the callees newly compiled changes.. i.e., in Ring handlers for web servers
11:10hellofunkyou can usually use the var of a fn in place of the fn itself, since the var will lookup and point to the fn when the var is invoked.
11:10Bronsa(inc hellofunk)
11:10lazybot⇒ 1
11:10hellofunk$(#'+ 5 6)
11:10hellofunk&(#'+ 5 6)
11:10lazybot⇒ 11
11:10mbacwhat's the minimal translation of this clisp code? (defun foo (n) (lambda (i) (incf n i)))
11:10hellofunkworks just like +
11:11mbacis it (defn foo [n] (let [n (atom n)] (fn [i] (swap! n (partial + i)))))
11:12Bronsambac: clojure strongly discourages mutable state, we don't have an equivalent for incf
11:12mgaarewhat does incf do?
11:12Bronsaor for setf, that is
11:12Bronsamgaare: it's +=
11:12mgaareah
11:13hellofunkmbac: that would depend on whether you want the atom closed over or recreated every time you call the function
11:13Bronsambac: the clj code you pasted is not equivalent to the CL one
11:14hellofunkmbac: your clj translation really doesn't need atom at all i think
11:15hellofunkmbac: and actually your passed in arg of n is ignored when you rebind it via let
11:16mbachellofunk, the atom n shadows the original n, which is the intent
11:17hellofunkmbac: i'm sorry i misread the atom form
11:18mbacfor context, this little toy come sfrom the appendix in http://www.paulgraham.com/icad.html
11:21hellofunkmbac: the problem is that in your code, there is a separation from the original n, which remains unchanged, and the n created by foo, which is closed over as a new atom. your original n will not change as you call this function, which i think is the intent of the CL snippet you pasted
11:22hellofunkin clojure, you would just make n an atom from the start if you need it to be stateful
11:23mbacwhat problem in my code are you referring to specifically?
11:23mbacmy only complaint is the clisp version is way more succinct :)
11:23hellofunkmbac: i assume you are trying to mutate the original n via the final lambda created
11:24hellofunkmbac: i disagree. if you make n an atom from the start, the clojure version is just as succinct. your code is adding new features by creating a new stateful n detached from the original n.
11:24mbacis the clisp version mutating the original n being passed in?
11:24hellofunkmbac: i assume that is the case, it is not?
11:24mbacbeats me, i don't write clisp :)
11:25hellofunkin CL data is not immutable by default, which was my biggest gripe with that language because some fns mutate the arg and others do not, and it wasn't always clear which they were
11:27jonathanjwhat should my main function look like for a ring app?
11:27jonathanj`lein ring server` doesn't run the main function (afaict) but `lein ring uberjar` complains i have no main function
11:29hellofunkmbac: yes looks like it does mutate, so the translation to clojure is to just make n an atom if that's what you really want: http://dantorop.info/project/emacs-animation/lisp9.html
11:32mbaccool
11:36hellofunkmbac: there are a number of sites and blog posts from several people about converting Paul Graham's work to Clojure. worth checking out since it's not just syntactic transformation but often conceptual improvements as well since there are big philosophical differences between the languages
11:37mfikesdistinct claims to be lazy, but embedded inside of it is an eager optimization, causing this to hang: (take 10 (distinct (concat [1 2 3] (repeat 4)))) Wondering what it means to claim laziness...
11:39jonathanjaccording to http://yogthos.net/posts/2013-01-11-One-Ring-to-rule-them-all.html `lein ring uberjar` should generate a main for me?
11:39hellofunkmfikes: nice example, but think about how, how could distinct be lazy on an infinite sequence?
11:40hellofunkthe docs say it is lazy, but i don't see how that is possible
11:40mfikeshellofunk: I'm wondering if the recur inside if it is necessary
11:41hellofunkmfikes: if you take 1, 2, 3, 4 it works. the problem is it keeps looking and looking and looking once it cannot find a 5th distinct item you have requested. so i see now how it is lazy, though it is easy to get an infinite loop with it, even with take
11:44mfikeshellofunk: Right... I see what you are saying. It will hang looking trying to realize the next novel element no matter what solution you employ
11:46dnolen_,(type (distinct '(1 1 2 2 3 3 4 4)))
11:46clojurebotclojure.lang.LazySeq
11:47dnolen_mfikes: just because it's lazy doesn't it mean it won't hang
11:47mfikeshellofunk: Makes me ponder the true meaning of lazy: It doesn't seem to guarantee that take will complete. But, arguably, it is living up to its definition of deferring work until it needs to be done.
11:47dnolen_(filter true? (repeat false))
11:47mfikesdnolen_: Cool. I learned something new. :)
11:47dnolen_call first on that will hang, distinct is not different in this case
12:06hellofunkdnolen_: great example. learned something on that one.
12:18cbryanwhat would be the idiomatic way to write the equivalent to this java code? http://hastebin.com/omahoyamus.avrasm I think I did the loop nicely, but I'm not sure how to efficiently and readably do the conditions. http://hastebin.com/tadaxehube.coffee
12:37hellofunkcbryan: isn't "for" quite a lot of fun?
12:49cbryanhellofunk: indeed, i only recently learned about :when and :let :D
12:50cbryani just cant get the conditionals to be pretty
13:05hellofunkcbryan: i think there is a syntax error in there, where's the final ] ?
13:44daniel_what are some techniques for making a library configurable? i want to be able to require it and then define certain constants which it relies on
13:44justin_smith$mail cbryan (= x 0) should usually be (zero? x)
13:44lazybotMessage saved.
13:50bbloomcbryan: `for produces a sequence, but it looks like you're trying to return a scalar value
13:50bbloomso the vertexOffset parameter is really like state, so you may want to consider using reduce
13:50bbloom(reduce (fn [vertex-offset i] ...) 0 (for ....))
13:50bbloomcbryan: for that first "..." try cond
14:04aaelonyin emacs markdown-mode, I get nice element items by starting the line with a dash "-" in an unordered list. Hitting return then takes me to the next line with correct indentation for the next element of the list in my markdown. When I parse the markdown with clj-markdown however, items where I did that don't render the quite right, and I need to replace all the tabs with spaces manually. They don't appear to be actual tabs though, as (cloju
14:04aaelonyre.string/replace s #"\t" " ") doesn't remove them. What's the best way to find out what they are and replace them appropriately?
14:10andyfaaelony: To find out what they are, debug prints can be very informative
14:11andyfperhaps after breaking up into lines, if you aren't doing that already.
14:11wjlroewith core.logic.pldb, when facts have been defined, how do you do disequality with those facts? If (db-rel grouped x y) - how do I unify 2 values that aren't in that relationship?
14:11aaelonyandf: indeed, but for whitespace?
14:11andyf,(map int " abc")
14:11clojurebot(32 32 97 98 99)
14:12aaelonyandyf: thanks, I'll try that.
14:16aaelonyandyf: thanks for that, I feel stupid as it was simply 4 space characters...
14:18andyfno worries. Forgive yourself :-)
14:20aaelony;)
14:56lxsameerhey guys, 1) can create a binary executable using clojure ( java independent ) ?
14:57justin_smithlxsameer: clojure needs a target platform to run (jvm, or clr, or javascript)
14:57lxsameerjustin_smith: so answer is no. fair enough
14:57justin_smithit doesn't need java though (jdk) just the vm
14:58lxsameerjustin_smith: jre only, am I right ?
14:58justin_smithright, that's what I meant
14:58lxsameer2) Can i use java lib directly in clojure ?
14:58borkdudehmm, #<CompilerException java.lang.RuntimeException: No such var: clojure.core.cache/through, compiling:(clojure/core/memoize.clj:52:3)> what?
14:59justin_smithlxsameer: yes, all of the jvm is available from clojure
14:59justin_smithie. ##(java.util.Date.)
14:59lazybot⇒ #inst "2014-12-24T19:56:09.925-00:00"
14:59lxsameerjustin_smith: do I have to write a wrapper or something
14:59justin_smithlxsameer: though some things are easier than others (you need ie. gen-class and static compilation to do all the features of concrete inheratence)
15:00justin_smithlxsameer: no - what I did above directly instanciated a Date object
15:00justin_smithno wrappers
15:00justin_smith*instantiated
15:00lxsameerjustin_smith: cool
15:00justin_smithclojure compiles to jvm bytecode, and directly does anything you can do on the jvm (though some things are easier than others)
15:01lxsameer3) can I use OOP along side with functional programming in clojure ?
15:01borkdudeI get this exception when adding com.cemerick/friend "0.2.1" to my project, weird?
15:01borkdudelxsameer sure https://pbs.twimg.com/media/B3QEKjUIUAEPYtk.jpg:large
15:02lxsameerborkdude: I meant the actual code, not the principles
15:02borkdudelxsameer you mean interop? not sure what you mean
15:03borkdudelxsameer you don't want to write java classes in clojure, but you can use them
15:03justin_smithlxsameer: yeah, you can do OOP with classes / methods etc. But clojure doesn't really encourage concrete inheritence, or make it easy. Which is a good thing imho.
15:03justin_smithborkdude: defrecord, fn, defprotocol... these things all generate classes
15:04borkdudejustin_smith fn also generates a class, that is not important
15:04lxsameerjustin_smith: borkdude , I know that it's not a good idea, but can I define a class in clojure ?
15:04justin_smithyes
15:04lxsameergood
15:04justin_smithwith deftype, or gen-class, or defrecord
15:04justin_smithand defprotocol for interfaces
15:05justin_smithalso, there are reify and proxy for instantiating / extending a java class or interface with an anonymous singleton class instance
15:06justin_smithas can be needed sometimes to interoperate with things written in java
15:06lxsameer4) what about using codes which is written in other JVM base langs like JRuby or scala, can I use them clojure
15:07justin_smithyes, they all generate classes with methods, and you can instantiate their classes and invoke their methods via clojure without any wrappers needed
15:07lxsameerjustin_smith: niceeee
15:07justin_smiththough in some cases a very small "shim" java class, in regular java, can make things easier
15:09justin_smithI think the right approach with clojure, as borkdude was hinting also I think, is to stick to immutable collections (hash-maps, vectors, lists, sets) and writing pure functions that use those
15:09lxsameerjustin_smith: can I use Akka framework of scala in clojure for example ?
15:09justin_smithand then do only as much OO as you need to interact with the features you need from other things on the jvm
15:09borkdudelxsameer you probably want to use core.async before looking at Akka from clojure
15:09justin_smithlxsameer: yeah, there are even some helpers to make that simpler
15:10lxsameerborkdude: yeah you right, but I'm looking for some answers in all these stupid questions :P
15:10lxsameerjustin_smith: awesome
15:10justin_smithlxsameer: yeah, in general for anything with message passing / async / threads / state coordination, the normal clojure way will likely be a lot better than bindings to another lang's lib
15:10lxsameerborkdude: justin_smith I'm trying to choose between clojure and scala and I messed up :[
15:11justin_smithcool, then you can definitely interact with akka :)
15:11lxsameerjustin_smith: thanks man, you really helped me a lot
15:11justin_smithand eventually, you may agree with us about Clojure's superiority and migrate to pure clojure for the async stuff
15:11justin_smith;)
15:11borkdudelxsameer I wouldn't worry much about "can I do this feature from my favorite language in clojure", because clojure has indeed it's own way and many things are much simpler than the tangible mess most OO languages are ;P
15:12justin_smithborkdude: but he isn't asking about the feature, he is asking about extending code he already has
15:12justin_smithwhich is totally valid imho
15:12borkdudejustin_smith I missed that part then I think.
15:12lxsameerborkdude: thanks man
15:13lxsameerI have a huge rails application right now which is run on Torquebox
15:13borkdudecan someone help me with this exception? #<CompilerException java.lang.RuntimeException: No such var: clojure.core.cache/through, compiling:(clojure/core/memoize.clj:52:3)>
15:13borkdudeI got it after adding friend to my project
15:13borkdudecemerick maybe?
15:13lxsameerI wanted to re implement several parts of it in an JVM base lang
15:13justin_smithborkdude: I remember issues regarding lein and core.cache... wish I remembered the details
15:13borkdudelxsameer I'm using JRuby now since 4 weeks and coming from clojure I want to go back iasao ;)
15:14borkdudelxsameer *asap
15:15lxsameerborkdude: cool
15:15justin_smithlxsameer: my intro to clojure was being hired to work on a ruby web platform replacement (modified rails like thing) with a clojure system (for sanity and performance reasons)
15:15borkdudelxsameer although JRuby isn't that bad compared to Java EE :P
15:15lxsameerborkdude: but I really like Ruby and ROR
15:15cemerickborkdude: probably related to https://github.com/cemerick/friend/issues/116
15:16lxsameerjustin_smith: really ?
15:16borkdudemy experience with (J)Ruby is that you get lots of things for free, but that it's hard to track down when something goes wrong and too much magic is happening to my taste
15:16justin_smithlxsameer: clojure is really great for things like a web backend where you have very long program running times, and can use as much ram as you need within system limits and just need fast throughput and dynamism
15:16borkdudeJRuby + RoR I mean
15:16justin_smithlxsameer: yup. Caribou project.
15:17lxsameerjustin_smith: awesome , but How is clojure in matter of resource usage ?
15:17lxsameerborkdude: I hope you find it more interesting in the future
15:17ro_stit uses them all. but it uses them wisely. :-)
15:17justin_smithborkdude: "too much magic is happening" could be both ruby's best motto, and it's worst slur :)
15:18justin_smithlxsameer: the baseline is pretty high - but it can keep going for months or years without blowing up (unlike some platforms I can name)
15:18borkdudelxsameer I'm sure only a month experience is not a position to give a fair judgement and I do like a lot of stuff of it
15:18justin_smithlxsameer: a big part of this is you get the entire clojure compiler, for free, whether you want it or not, as part of your deployed runtime.
15:18lxsameerjustin_smith: can you name those , For my information :P
15:18borkdudeit seems that I won't be using friend then for a simple login
15:19justin_smithlxsameer: ruby, node, php - good luck getting month long uptimes in one process under any load with any of those
15:19justin_smithborkdude: I wish I understood friend.
15:19borkdudejustin_smith what are you using for authentication?
15:19lxsameerjustin_smith: interesting
15:20lxsameerjustin_smith: borkdude thanks guys, you helped me a lot
15:20justin_smithborkdude: username + bcrypt hash of password stored in the db, authorized token in session in a server-side in-mem cookie
15:21borkdudelxsameer sure thing, welcome to clojure, there is (almost) no way back ;)
15:21justin_smithborkdude: plus a very simple middleware that sends you to the login for protected routes (and login checks pw to hashed pw, etc.)
15:21borkdudejustin_smith do you have some sample code?
15:21lxsameerborkdude: :))
15:21lxsameerborkdude: thansk buddy
15:21justin_smithborkdude: let me check
15:22borkdudejustin_smith I think I'll go for lib-noir's session thing
15:22borkdudejustin_smith unless you offer me something better :)
15:23justin_smithhttps://github.com/caribou/caribou-admin/blob/master/src/caribou/admin/controllers/settings/account.clj#L35 borkdude admittedly not pretty, but here is how we do it in the caribou admin
15:24justin_smithcome to think of it though, the logic is kind of scattered in different parts of the code (which is one thing friend and lib-noir improve)
15:25justin_smithbut it's only a few things - retrieving and comparing a hash, routing based on whether the user is authorized
15:25tuckerhello
15:26tuckerHow does (def head-fibo (lay-cat [0N 1N] (map + head-fibo (rest head-fibo))) work
15:26tuckerbecause it seems to make a recursive call to head-fibo, yet this function isn't set up to take any arguments
15:54justin_smithtucker: def does not create a function, it creates a var. It isn't calling itself, it is including itself in the calculation used to create itself
15:54justin_smithit's a clever trick, but not neccissarily good style
15:54justin_smith,(def head-fibo (lay-cat [0N 1N] (map + head-fibo (rest head-fibo)))
15:54clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:55justin_smith,(def head-fibo (lay-cat [0N 1N] (map + head-fibo (rest head-fibo))))
15:55clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: lay-cat in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:55justin_smith,(def head-fibo (lazy-cat [0N 1N] (map + head-fibo (rest head-fibo))))
15:55clojurebot#'sandbox/head-fibo
15:55justin_smith,head-fibo
15:55clojurebot(0N 1N 1N 2N 3N ...)
15:56justin_smithit relies on the fact that vars are created before they have values assigned (so that they can refer to themselves in the code that constitutes them)
15:56tuckerso (def head-fibo (lay-cat [0N 1N] (map + head-fibo (rest head-fibo)))
15:56justin_smithit's not lay-cat, it's lazy-cat
15:57tuckerjustin_smith: so
15:57tuckerjustin_smith: we bind head-fibo to what's inside the parenthesis right?
15:57justin_smithwe bind it to the result of calling lazy-cat with those args
15:58justin_smithso really there are two "tricks" here - the fact that it can refer to itself in its definition, and the fact that lazy-cat only creates elements of the result sequence as you use them
16:00justin_smith,(let [fib-subseq [0 1 1 2 3 5]] (map + fib-subseq (rest fig-subseq)))
16:00clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: fig-subseq in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:00justin_smith,(let [fib-subseq [0 1 1 2 3 5]] (map + fib-subseq (rest fib-subseq)))
16:00clojurebot(1 2 3 5 8)
16:00justin_smithmaybe seeing that helps a little?
16:01justin_smith,(let [fib-subseq [0 1 1 2 3 5]] (map vector fib-subseq (rest fib-subseq))) ; showing pairs of args this time
16:01clojurebot([0 1] [1 1] [1 2] [2 3] [3 5])
16:01tuckerjustin_smith: hmm bare with me. In the REPL, I cannot simply do (+ [0 1] [3 4]), but I can do (map + [0 1] [3 4])
16:01tuckerwhy?
16:01clojurebothttp://clojure.org/rationale
16:02justin_smithtucker: see what hapens when I map vector in that last call
16:02justin_smith,(map vector [:a :b :c] [:x :y :z])
16:02clojurebot([:a :x] [:b :y] [:c :z])
16:02tuckersurely (+ [0 1] [3 4]) must be valid for it then to apply map ?
16:02justin_smithno
16:02justin_smith[0 1] is not a number
16:03tucker,(+ [0 1] [3 4])
16:03justin_smithnotice that I map vector - then I get a lazy seq of vectors
16:03clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>
16:03justin_smithif I map + instead of vector, I get each sum instead of each pair
16:03tuckerhow do you know it's a lazy seq here?
16:03justin_smith,(type (map + [1 2 3] [4 5 6]))
16:03clojurebotclojure.lang.LazySeq
16:04justin_smithmap always returns a lazy-seq
16:09tuckerjustin_smith: I get (let [fib-subseq [0 1 1 2 3 5]] (map vector fib-subseq (rest fib-subseq)))
16:09tuckerjustin_smith: but (def head-fibo (lazy-cat [0N 1N] (map + head-fibo (rest head-fibo)))) still eludes me
16:10justin_smith,(let [items '[a b c]] (map list items (rest items))) ; does this help?
16:10clojurebot((a b) (b c))
16:10justin_smithhmm, more items would likely help there
16:11justin_smith,(let [items '[a b c d e f g h]] (map list items (rest items))) ; does this help?
16:11clojurebot((a b) (b c) (c d) (d e) (e f) ...)
16:11tuckeryeah, I see
16:11justin_smithsee how (map f x (rest x)) operates on each consecutive pair? and isn't that kind of how fib is defined normally?
16:14tuckerjustin_smith: I get it. Awesome. And this is bad for recursion as the head-fibo will hold the entire collection? That is, it will always store every element calculated ?
16:15justin_smithyeah, like any infinite lazy-seq defined at the top level, the only way to clear the heap used by the collection is to destructively redefine it
16:15justin_smithunless it was closed over - then it isn't freed until those closed-over contexts are freed...
16:17justin_smithif instead you defined a generator function, then you could use it inside a let block and if you are careful about scope leakage the clojure compiler and the jvm gc can make sure it is freed when needed
16:18justin_smithcome to think of it, that's using a function as an "anti-closure" - storing the method of production instead of the result of production
16:42tuckerjustin_smith: Thanks alot. In regards to your closure comment, you said normally the closure pattern stores result of production. Can you expand on this (I use closures all the time in my work, but I wasn't sure what you're getting it)?
16:43justin_smithit's a pattern more common to common lisp / scheme (let [x (make-x)] (defn foo [y] (g x y)))
16:43justin_smithso it's storing x as part of the function closure
16:44justin_smithas opposed to (defn fibs [] (lazy-cat ...)) which would ensure you recreate the lazy-seq on each invocation rather than storing it for later
16:45tuckerI think I see what you're getting at. g is just some kind of operator, right?
16:47hellofunk(inc justin_smith)
16:47lazybot⇒ 162
16:47justin_smithtucker: yeah, some function or another, not really important there what it is
16:49hellofunkjustin_smith: i remain a fan of the idiom (let [x (make-x)] (defn foo [y] (g x y)))
16:50justin_smithhellofunk: we even have partial to make it more succinct (def foo (partial g (make-x)))
16:50hellofunknifty
16:50justin_smithhellofunk: but in an environment of pervasive immutability, locally hidden state is often worse than global state would be
16:51hellofunknice point.
17:05munderwoHi all. Has anybody had to interop with promises is javascript from clojurescript? Any pointers on how to handle it?
17:09hellofunkmunderwo: fyi there is also #clojurescript though you might get some pointers here too.
17:10munderwooh, yeah. I always forget to ask there… I’ll cross-ask (?) there and see if anybody has had any luck
17:12dnolen_munderwo: interop'ing with promises is just basic JS interop, also pretty straightforward to bridge promises to core.async channels if you need to
17:13munderwoahh ok. I think im still trying to get my head around how they actually work. that and I think Im using a hand rolled version of promises. I gather than the .then function gets called automatically once the promise is realised?
17:31dnolen_munderwo: yes same as JS
17:46makkhello
17:47makkIs there a clojure function similar to map that doesn't collect results? I want to apply a function on elements in a vector without really collection any results (i.e. maybe just return nil)
17:48SagiCZ1doseq
17:48SagiCZ1or, if you want map syntax.. you can (doall (map ..))
17:49SagiCZ1,(doseq [e (range 2)] (println e))
17:49clojurebot0\n1\n
17:49SagiCZ1and it does return nil btw
17:50tomjackif you want to return nil, dorun instead of doall
17:50SagiCZ1yeah sorry.. dorun
17:50makkthank you, I'll check out dorun and doseq
17:51SagiCZ1dorun is to force evaluation of lazyseq.. its useful in general.. doseq is exactly for calling a function on each element of collection to produce sife-effects
17:57thhellerclojure 1.7 has (run! some-fn coll) if you are playing with the alpha ;)
18:00SagiCZ1thheller: what does that do
18:00thhellercall (some-fn item) for each item in coll, return nil
18:01SagiCZ1is that not doseq?
18:01thhellerhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L7298-L7303
18:01thhellerwell (doseq [item coll] (some-fn item)) is a bit longer ;)
18:02SagiCZ1and whats up with the exclamation mark.. seems like they are getting too generous with them
18:02thhellerslight difference that it uses reduce internally
18:03thhellerwell its to force side effects, so run! is good
18:03SagiCZ1why doseq doesnt have an exclamation mark then?
18:04thhellerstarts with do? don't care honestly ...
19:43justin_smiththheller: at one point we talked about adding don't blocks to the useless lib
19:43justin_smithlike do, except it doesn't
19:44justin_smith(defmacro don't [& _] '(do nil))
20:07rpaulo_heh
22:25gfredericks,#"(?<=xx*)" ;; okay fine
22:25clojurebot#<SecurityException java.lang.SecurityException: denied>
22:25gfredericks&#"(?<=xx*)" ;; okay fine
22:25lazybotjava.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index 6
22:25rksm_
22:25rksm_[Wed Dec 24 2014]
22:25rksm_*** Topic for #clojure: Clojure, the language http://clojure.org | Currently
22:25rksm_ at 1.6.0; top analysts expect this to be followed by newer versions with
22:25rksm_ still higher numbers:
22:25rksm_ https://github.com/clojure/clojure/blob/master/changes.md | discussion:
22:25gfredericks&#"(?<=x*)" ;; wat
22:25lazybot⇒ #"(?<=x*)"
22:25rksm_ http://groups.google.com/group/clojure [18:16]
22:25rksm_*** #clojure: topic set by
22:25rksm_ technomancy!~user@ec2-54-244-178-65.us-west-2.compute.amazonaws.com,
22:25rksm_ 2014-03-26 09:33:15
22:25rksm_*** Users on #clojure: rksm_ sgregory dalzony looper wiggen ztellman n0n3such
22:25rksm_ brucehauman apah fivebats yeahnoob ChiralSym cydork m_3 farhaven ka2u pdk
22:25rksm_ robustus swgillespie jimduey jumblerg kristof andres-v jasonjckn Jabberz
22:25rksm_ namra mumrah hbccbh conan telex andyf astrofog mrcheeks` rksm Kohelet
22:25rksm_ seangrove h_ Rhainur1 jareddba rcarey4 TEttinger w4ffles__ MadFunk aka
22:25rksm_ meandi jlf dc_ munderwo moisesv_ havenwood ajhager sak supersym lyddonb
22:26rksm_ dsantiago nuwanda dopamean_ OlegYch6 wildnux
22:26rksm_*** Users on #clojure: keen__________12 sova gws tucker Atlanis lordB8r
22:26rksm_ craigglennie daniel_ drbobbeaty prc danielglauser adamhill_ olivierrr
22:26rksm_ mikem mbac klyed2 ticking meoblast001 adamhill newportd carc presto
22:26rksm_ charliekilo dnolen_ oscar_toro ivan\ mnemnion Frozenlock fsvehla triss
22:26rksm_ vendethiel dakrone robink elarson_ Jellydog nw Intensity rkneufeld_ pfeyz
22:26rksm_ mtd_ jconnolly OscarZ- nicferrier sw1nn Javran mrBliss psy_ frkout mee
22:26rksm_ malyn dabradley kanobe_ lnostdal razum2um1 gigetoo tobik
22:26rksm_*** Users on #clojure: jweiss sarlalian audaxion mysamdog insamniac srcerer
22:26rksm_ mlb- jakecraige wtflem_ DomKM herme5 abhirc skrblr rplaca jlewis jlewis_
22:26rksm_ paulweb515 zerokarmaleft wolfes hodlr kephale necronian AimHere Ragnor
22:26rksm_ ordnungswidrig Excureo cascada-io daemian _5kg superjudge_ jmccune
22:26rksm_ TEttinger2 ibdknox lifenoodles_ rs0 willgorman teejar_ heurist clojurebot
22:26rksm_ crazysim Natch rlb TDJACR Raynos ZucchiniZe Xorlev ConstantineXVI Xe Cr8
22:26rksm_ Klumben Alina-malina arekinath xpika luxbock uber
22:26rksm_*** Users on #clojure: SegFaultAX PeregrinePDX samflores r4vi boyscared matt_c
22:26rksm_ cherwin cYmen_ rtl turbofail hooptw sobel ska-fan ieure neena ryanf
22:26rksm_ perplexa kylo eevar FMJaggy abh jcsims magopian twem2 jfojtl vmesons
22:26rksm_ spwhitt rowth Kneiva juhani hipsterslapfigh- onthesta1rs oyvinrob
22:26rksm_ jackjames scopedTV scttnlsn the-kenny noidi_ gideonite devn Pistahh Kruppe
22:27rksm_ msassak greenyouse amontalenti edw spjt _trev TristamWrk icedp Trieste
22:27rksm_ jave ngk Lugoues jetlag lvh Adeon tuft godd2 ktsuji
22:27rksm_*** Users on #clojure: luigy stderr wang saurik glitch100 tbaldridge someone
22:27rksm_ Mongey Luyt_ broquaint jlpeters d4gg4d jlouis boodle amoe AeroNotix
22:27rksm_ sbauer322 cfleming akhudek Rapp 7YUAAPOC8 s_e Orva Shayanjm codelahoma jwm
22:27rksm_ [blake| dogonthehorizon jeremyheiler rufoa mattrepl moquist verma LBRapid
22:27rksm_ jswanson lfranchi mekaj spectre256 maxmartin jinks_ gko kiwitobes tomjack
22:27rksm_ wirrbel ered auganov thecontrarian42 Sorella eristic [Neurotic]
22:27rksm_ greghendershott nmashton si14 whodidthis raywillig
22:27rksm_*** Users on #clojure: ipolyzos bjeanes NhanH gluegadget ambrosebs rigalo_
22:27rksm_ fuziontech____ Robdor nseger_ mccraig metadaddy andreypopp__ lijnen_
22:27rksm_ dzimm_ jonathanj jayne_ reiddraper kzar mcav elsen_ thheller sohum
22:27rksm_ sea-gull- arkh divyanshu bodie_ sordina3 soncodi rfv joshhead ThePhoeron
22:27rksm_ jcrossley3-away StianE rpaulo ChongLi nickenchuggets relgar Tuna-Fish
22:27rksm_ pawnda dysfun clauswitt joshbamboo2 Christmasiumn alandipert arohner
22:27rksm_ Glenjamin saltsa Duke- pppppaul engblom npr owengalenjones
22:27rksm_*** Users on #clojure: troydm codeburg ahihi chriswk_____ pgmcgee
22:27rksm_ gratimax|away opqdonut nullptr H4ns ggreer sneeu brixen ivan`
22:27rksm_ StevePotayTeo chridal itruslove joshskidmore grauwulf pjstadig hakvroot
22:27rksm_ LukeWinikates___ jez0990 tcrayford____ fmu yazirian guilleiguaran jdaggett
22:27swgillespieok
22:28rksm_ yogthos|away ucb__ brianwong anildigital hiredman cdombroski banjiewen
22:28rksm_ josephwi_ mjz Mendor|scr joegallo shoky morganastra luisalima maxigas
22:28troydmwtf
22:28rksm_ borkdude justinmcp_ tikotus neektza justin_smith haroldwu fikusz
22:28rksm_*** Users on #clojure: yason awkorama alxlit Sgeo libertas jerseykx
22:28sovalol
22:28rksm_ bencryption igorw matthoffman babilen kryft rovar_ yunfan povilas nikola
22:28rksm_ jgmize `brian lhdc_ lobotomy torgeir waf rweir amalloy_ oskarth grandy_
22:28rksm_ larme demolithion cosmicexplorer profil tomku kristian_ Guest50300 supki
22:28rksm_ jabbslad seubert cursork numberten shem machty jodaro hash averell jlyndon
22:28rksm_ karls zph dkua khmer madscientist` aksatac zanes troezen Empperi majoh
22:28rksm_ dominiclobue zonpantli algernon pyrtsa orkaa
22:28rksm_*** Users on #clojure: edoloughlin ninjudd janne byaruhaf l1x avdi nexysno
22:28rksm_ Raynes Revenrof Guest83413 jamiei ffwacom 32NAARMUJ okic jmolet cantsin
22:28rksm_ ekroon marce808 micrypt hguux_ aperiodic zpconn__________ wink l3dx
22:28rksm_ mariorz augustl donmullen littleli magnars tbatchelli___ korpse
22:28rksm_ bbyler_tho_ nathan7 arrdem schwap_ terom_ jimt_ TMA kreg_ qz anekos
22:28sovahey does anybody have a tedious listing of all the users on this channel handy?
22:28rksm_ varioust addisonj ggherdov tcrawley-away gignosko pickledonion__ mrb_bk
22:28rksm_ michaniskin andy_c_ andrewstewart bcarrell sundbp chenglou zrl
22:28rksm_*** Users on #clojure: rhg135 rjknight__ tomobrien katratxo hugod mynomoto
22:28rksm_ martinklepsch sross07 canassa akkad owenb____ TrafficMan_ SHODAN fvt tpope
22:28rksm_ fryguy wunki honkfestival octane--_ ianhedoesit Shambles_1 ctrlrsf
22:28swgillespiesova: oh boy, we're in luck!
22:29rksm_ noncom|3 apetresc matt_d thearthur erdic peted misv Deraen jml cmiles74
22:29rksm_ Mandus Jaood j0ni snzmn philandstuff zoldar anon-6857 mearnsh ipostelnik
22:29rksm_ jefelante _ato kerneis_ lpvb axylos bool_ HeXFuRy timvisher llasram
22:29rksm_ dyreshark David iamdustan mgaare sethalves whee
22:29godd2sova what order did you want them in?
22:29rksm_*** Users on #clojure: filabrazilska metellus merlinsbrain bobpoekert
22:29rksm_ bsansouci awwaiid cyraxjoe hipsterslapfight tazjin newgnus log0ymxm spicyj
22:29rksm_ danneu myguidingstar rlr leathekd Adr1 Licenser pcn emacsnw lokydor
22:29rksm_ jgdavey lotia enn danlarkin JSON_voorhees tomhs yacin maio DerGuteMoritz
22:29olivierrrhuh?
22:29rksm_ Chousuke certainty mrLite lazybot sfa laurio manytrees jeregrine
22:29Raynesrksm_: I will murder you and your family.
22:29rksm_ jakebasile_ howard sivoais alexbaranosky groot_ kmicu lancepantz ozzloy
22:29rksm_ amano-- matthavener TimMc beppu machuga rasmusto ikitommi
22:29rksm_*** Users on #clojure: mikko raek shwouchk kungi slpsys_ yumike bobwilliams
22:29sovagodd2: loosely sorted is fine
22:29rksm_ l_ch_nm_y_r @ChanServ Meeh septomin Nahra m1dnight_ taij33n tac-tics
22:29rksm_ nmontecc klobucar______ beawesomeinstead leifw gf3 gregburd_ l2x dj_ryan
22:29rksm_ dselph_____ seabre leptonix squeedee MerryL235 zeapo gazarsgo n1ftyn8
22:29rksm_ jzelinskie pmbauer_ danlucraft nwjsmith bruceadams Scorchin hyPiRion
22:29rksm_ kikkerbrood ToxicFrog dean someplace raoul ddima ikitommi_ segmond
22:29rksm_ dottedmag georgej162__ locks tephra FliPPeh kraft Morgawr
22:29rksm_*** Users on #clojure: alloyed coffeejunk halorgium wormphle1m mrowe_away
22:29rksm_ peeja kral zymurgy Tristam lpaste wjlroe suvash_away JStoker nathanic
22:30rksm_ deadghost octe knyppeldynan danlentz eagleflo mdeboard kandinski
22:30rksm_ brainproxy TheMoonMaster saiam gfredericks expez cmbntr hfaafb silven
22:30rksm_ Viesti ucb harrigan thomas Floyd_ Blkt _jimrthy f3ew scgilardi adammh
22:30rksm_ Riviera_ ephemeron marienz julienXX arianvp_ brackets p_l rippy obobobo
22:30yunfanrksm_: what's up? are you detecting zombie?
22:30rksm_ Foxboron chouser_log tmarble stain zakwilson AWizzArd
22:30rksm_*** Users on #clojure: yocapybara joelkuiper sorenmacbeth ontoillogical acagle
22:30olivierrrban?
22:30rksm_ puyo grim_radical kitallis cross rotty_ pepijndevos splunk_ kenrestivo
22:30Shambles_1rksm_: Guessing you're using a out-of-date EMACS IRC client. Might want to get that looked at.
22:30rksm_ tomaw honza swen ivan
22:30rksm_
22:30RaynesSo here's the deal folks.
22:30RaynesThere are no moderators around.
22:30n1ftyn8Yikes
22:30RaynesYou can /ignore this fella if it continues.
22:30swgillespielooks like he's done
22:30sovaThe calm before the storm
22:30godd2anarchy!!!
22:30olivierrr#freenode can help.
22:31Shambles_It's a old EMACS client bug.
22:31swgillespieShambles_: that's a hell of a bug
22:31olivierrrhahah.
22:31Shambles_swgillespie: Still happens every few weeks years later on the #emacs channel.
22:32swgillespielol
22:33yogthosjonathanj: if you're using lein-ring then you don't need to have a main
22:34yogthosjonathanj: in your project.clj there should be a :ring key that points to the handler
22:36ztellmanwhat's going on
22:45sovaztellman: listening to the doors and learning some clojure
22:46gfredericksztellman: ###"(?<=x*)"
22:46gfredericksI mean
22:46gfredericks,#"(?<=x*)"
22:46clojurebot#"(?<=x*)"
22:46gfredericks,#"(?<=x**)"
22:46clojurebot#<NoClassDefFoundError java.lang.NoClassDefFoundError: Could not initialize class java.util.regex.PatternSyntaxException>
22:46gfredericksoh constantinople
22:46gfredericks&#"(?<=x**)"
22:46lazybotjava.util.regex.PatternSyntaxException: Dangling meta character '*' near index 6
22:47gfredericks&#"(?<=xx*)"
22:47lazybotjava.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index 6
22:47gfredericksthis is a terrible demonstration
22:47gfredericksbut that is what is going on with me
22:51sovagfredericks: you fight the good fight
22:54gfredericksgoing to give up for the night the good give up for the night
22:56adamwarlockif i do (go (>! some-chan (blocking-call)) will it park the thread or block it?
23:05ddellacostaadamwarlock: I was curious as well, and I think this stackoverflow answer gives a good response which answers your question: http://stackoverflow.com/a/21467918
23:05ddellacosta" The magic non-blocking nature of go-blocks comes from "parking," which is a special sort of pseudo-blocking that core.async's state machine uses — but since your database calls genuinely block instead of putting the state machine into a parked state, you'd just be blocking some thread from the core.async thread pool."
23:21kenrestivoit'd sure be nice if there were shifts such that there were ops around 24/7
23:21kenrestivoconcurrent with that... if there were more ops
23:21kenrestivomany hands make light work. it is the way of open source.
23:23adamwarlockoh, so as long blocking-call blocks so will the thread