#clojure logs

2015-01-30

01:59irctcHello everyone
01:59rhg135Hi
02:00irctcI'm having an issue with destructuring
02:01irctcI defn a function with parameter-vector : [[firstPerson secondPerson] peopleVec]
02:01irctcwhen I try to pass in the peopleVec vector - REPL tells that I've passed too few parameters?
02:01amalloyyour function takes two arguments
02:02amalloythe second is called peopleVec, and the second is destructured as [firstPerson secondPerson]
02:02amalloyer, the first is destructured
02:02irctcI understood that [firstPerson secondPerson] will be bound to the contents of peopleVec
02:03irctctherefore [firstPerson secondPerson] does not count as a parameter?
02:04rhg135:as
02:07ianhedoesit,(defn foo [[fp sp] pv] (prn fp sp pv))
02:07clojurebot#'sandbox/foo
02:07ianhedoesit,(foo [:first :second] :person)
02:07clojurebot:first :second :person\n
02:08amalloyshredder supply OP
02:09amalloyoops, wrong wnidow
02:09ianhedoesit,(defn bar [[fp sp :as pv]] (prn fp sp pv))
02:09clojurebot#'sandbox/bar
02:09ianhedoesit,(bar [:first :second])
02:09clojurebot:first :second [:first :second]\n
02:09amalloythe dangers of connecting to twitch chat via irc i guess
02:09ianhedoesitirctc: does the above help?
02:10irctcianhedoesit: :as binds the entire passed-in vector
02:11ianhedoesityes, in the case of `bar`, `pv` is the name bound to `[fp sp]` (I think I said that correctly)
02:11irctcwhat I was hoping is selective binding like all the examples provide using let eg. (let [x y] [1 2])
02:13irctccorrection: (let [[x y] [1 2]])
02:14irctcin my case I made the [1 2] vector a parameter of a function - I guess this not be the way function parameters work
02:15ianhedoesitI'm not smart enough to see the obvious is there is something obvious I'm missing, so mabe a more specific example would help?
02:15amalloyirctc: so, here is the thing. things in clojure which could be names can instead be destructured
02:15amalloythe first half of a let-binding can be a name, so you can destructure it
02:16amalloyeach argument to a function could be a name, so you can destructure it
02:16amalloyif you destructure a thing, you don't *also* name it
02:18irctcthx amalloy - let me process this for a moment(eg. work through an example)
02:27irctcgot: (defn destruct-this-3 [[fp sp]] (println fp sp)) - my problem was to equate "let" and "defn" destructuring
02:28irctcIn the case of a defn the second vector in let eg. [[x y] [1 2]] -- is implicit in the parameter one passes-in
02:29irctcamalloy: your statement make perfect sense now - many thanks
02:29hellofunkamalloy: you say "if you destructure a thing, you don't *also* name it" but what about :as ?
02:33amalloythat's a way to destructure it though
02:33amalloyit's the way of destructuring which says, give this thing a name
02:34hellofunki see, i follow, i understan' my G, i feel you!
02:56irctcanyone else using "pidgin" as irc client? what settings are you using, please?- trying to connect to bear.freenode.net is timing out for me
02:58ianhedoesitirctc: is there any reason you need to connect to bear.freenode.net? irc.freenode.net is a load balancer and any channel on the freenode network will work when connecting to any specific server, I believe.
02:58irctcianhedoesit: only reason is that I couldn't find #clojure
02:59irctcwill try again...
02:59ianhedoesitbut you're on #clojure!
02:59seancorfieldI only connect to irc.freenode.net and I'm here :)
02:59irctcianhedoesit: through the web interface
03:00ianhedoesitah, I see that now. may I ask why you wanted bear.freenode.net specifically?
03:00irctcin the web interface it shows me connected to that server
03:01ianhedoesitah
03:02ianhedoesitI can't possibly imagine how this could change anything, but try chat.freenode.net maybe?
03:03Kirianhedoesit: I'm in thanks - it did not show in the list - I had to connect manually
03:04ianhedoesitI haven't used Pidgin in years, but I think I know what you mean. it lists a number of networks like EFNet and whatnot but no freenode or something?
03:06Kirnot quite: once connect to irc.freenote.net one get pull a list of all available rooms - searching for clojure in this list did not find this room
03:06Kircorrection:..one can*
03:07Kirianhedoesit: thanks all the same :)
03:07ianhedoesitoh, okay. well I don't know what I did but I'm glad you're not using an awful web interface anymore.
03:07ianhedoesitstill, you could do better than pidgin.
03:07ianhedoesit:)
03:08KirI'm open to suggestion?
03:09ianhedoesitKir: *nix or Windows?
03:10KirI use both
03:10Kircurrently on windows
03:12ianhedoesitit seems like a lot of people are rather fond of Hexchat, especially those who use both Windows and some flavor of Linux since it's cross-platform
03:12fairuz I use pidgin both in windows and linux
03:12fairuzquite happy with it
03:12ianhedoesitit's also open source, which is nice.
03:13ianhedoesitKir: listen to fairuz if you wish! I cannot speak for the usability of Pidgin today - like I said it's been years since I've used it.
03:14ianhedoesitif you want to make your friends think you're a hacker, use irssi like me! people will think you know far more than you actually do!
03:14fairuz:)
03:14fairuzagree ^
03:15rhg135Telnet ftw
03:15Kirlol
03:16daniel__ianhedoesit: i use irssi tooo
03:17daniel__and i3 window manager
03:17ianhedoesit"what are you doing?" "I am establishing an ssh connection to my vps in SF with an attached tmux session to talk to some chans on irc about clj"
03:17ianhedoesit"so you're hacking?"
03:17fairuz"of course"
03:17ianhedoesitdaniel__: I have no wm. I'm so hip and retro.
03:19daniel__ianhedoesit: i boot straight into emacs
03:19ianhedoesitlol
03:19rhg135I flashed it to my bios
03:25Kirianhedoesit: hexchat is looking like it will replace pidgin - only think I'm missing is the ability to stop logging when users login/logoff?
03:25Kirthing*
03:28ianhedoesitKir: in irssi I just /ignore #clojure: JOINS PARTS QUITS MODES TOPICS
03:28ianhedoesitwell, /ignore #clojure JOINS PARTS QUITS MODES TOPICS
03:28ianhedoesitwithout the :
03:28ianhedoesitbut that might not work in hexchat, I don't know
03:28KirOh, pardon, didn't notice your not using it
03:28rhg135Right click the channel in the menu
03:29Kiryou're*
03:30ianhedoesitKir: http://wiki.xkcd.com/irc/Hide_join_part_messages#HexChat
03:31Kirthx ianhedoesit
03:32ianhedoesit:)
03:36daniel__i do /ignore ianhedoesit
03:48ianhedoesitdaniel__ no
03:48ianhedoesitwhy me
03:48daniel__just kidding ianhedoesit :)
03:49ianhedoesithow can I know you're actually replying to me if you ignored me!
03:51daniel__ianhedoesit: yes, i hacked irssi to reply on my behalf
03:51daniel__to trick you
03:52ianhedoesityou did say you boot straight into emacs, so I'm inclined to believe you.
03:53daniel__you're talking to ELIZA
03:55ianhedoesitI feel much more at home knowing that.
04:16sm0kehello i want to ^:replace a bool property in lein. but meta cant be applied to bools i think
04:16sm0ke,^:replace true
04:16clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Metadata can only be applied to IMetas>
04:16ianhedoesit,^:replace [true]
04:16clojurebot[true]
04:17sm0keianhedoesit: what about false?
04:17ianhedoesitsm0ke: I was just dealing with that for something. it's not a very elegant solution since you need to mess with how you deal with it, but until someone gives a better answer that seems okay?
04:18ianhedoesitsm0ke: what do you mean? the point is that all the containers can have metadata (I think?)
04:18sm0keianhedoesit: no, its just not about having metadata somehow
04:18ianhedoesitso just wrapping anything in a vector or list or whatever will allow it to have metadata
04:19ianhedoesitI must be misunderstanding what you're asking
04:19sm0keianhedoesit: the problem is ^:replace false is like saying ovrrite this property value with a false
04:19sm0keso i can just say ^:replace [false] because ##(true? [false])
04:19lazybot⇒ false
04:20sm0kelol what
04:20sm0ke,(doc true?)
04:20clojurebot"([x]); Returns true if x is the value true, false otherwise."
04:20ianhedoesitsm0ke: any vector is truthy
04:20ianhedoesitonly nil and false are falsy
04:20ianhedoesit,(true? 0)
04:20clojurebotfalse
04:20ianhedoesitoh
04:20ianhedoesitand 0
04:20sm0keah
04:20sm0keianhedoesit: yes exactly my point
04:20ianhedoesit,(true? [])
04:20clojurebotfalse
04:20ianhedoesitoh
04:20ianhedoesitwow
04:20ianhedoesitI was wrong
04:20sm0keianhedoesit: no it just checks for `true` literally
04:20ianhedoesitoh
04:20sm0kenot logically
04:21ianhedoesit:D
04:21ianhedoesitwell I don't know much of anything about nothing so I'm just gonna be quiet about what you're doing so as to not make things worse.
04:21sm0ke,(when [false] "This cant be true!")
04:21clojurebot"This cant be true!"
04:22sm0keits always nice to get another set of eyes though
04:22ianhedoesitRaynes: I'm making something similar to tentacles but for something other than the GitHub API - I've been using some of tentacles.core as a learning tool for a great way of doing api calls and I hope you don't mind me using a couple functions as starting points. obviously not just copying it, but I've been learning a lot from your api-call and related functions and can't imagine any better sort of structure for something like that.
04:22TEttinger,(when 0 "this can't be true!")
04:22clojurebot"this can't be true!"
04:22ianhedoesitTEttinger: this is the place where I think I was right (only false and nil are falsy)
04:23TEttingeryes
04:23ianhedoesit,(if [] true false)
04:23clojurebottrue
04:24sm0kethis is very basic there must be some trick for this
04:24sm0kemany lein properties are boolean
04:24sm0keand they heavily use metadata too
04:25ianhedoesitsm0ke: because I don't fully understand but I want to, what exactly are you talking about? I don't have a very good understanding of how lein works.
04:27sm0keianhedoesit: you can have lein profiles with confilicting data e.g. profile1 says :aot true while profile2 says :aot false, now i want to give one profile precendence for replacing the others
04:28sm0keso if you are doing lein with-profile +pf1,+pf2 what would :aot be?
04:29ianhedoesitI have no idea. I didn't know you could target multiple profiles at the same time like that. I've only done like `lein with-profile test`
04:31ianhedoesitis the project.clj file read just like any other clojure file? as in can you have arbitrary evaluations in the file? or is there a bit of magic done by lein?
04:32sm0kei dont know internals of lein, but i guess it would be a `read-string`, defproject is a macro afterwall
04:32sm0keits a regular clojure file
04:33ianhedoesithm, right.
04:33sm0keyou can actually put (println "hello") before (defproject..) and it would be printed for every lein task
04:33sm0keyou do pretty fancy things with it
04:33sm0keyou can*
04:34sm0keits kind of awesome to have a programmable build file :D
04:35ianhedoesithave you tried boot?
04:36sm0keno, i am kind of very amazed with lein itself
04:37sm0keits too overwhelming for me
04:37ianhedoesitI haven't tried Boot, and I'm obviously a novice lein user, but the people who say anything about boot tend to make it seem magical.
04:38sm0kemagic is good but stability and features are biggest factors imo
04:38sm0kei will read the rationale behind boot some day though
04:40naconAnyone having experience with clojure.java.jdbc and postgres' new json/jsonb types? Especially the writing/reading in combination with clojure.data.json. It seems I have to create a PGobject myself and set the type and value..
04:40ianhedoesitI was trying to think of a word better than magical. I wasn't trying to say it did a bunch of non-obvious magic or anything - from my understanding it's the opposite, which I enjoy.
04:44mavbozonacon: have you tried https://github.com/remodoy/clj-postgresql ? it seems like they have automatic json conversion
04:45naconmavbozo: no I'm using the clojure.java.jdbc api right now -- but might give this a try, thanks!
04:54slipsetI'm just starting out with https://github.com/krisajenkins/yesql
04:54slipsetso you can write the sql queries as select foo from bar where qux = :qix
04:55slipsetbut when calling the query, I haven't found a way to pass the params to the query in a named fashion.
04:55slipseteg, I'd like to do (query-quxes db {:qix "lols"})
04:55slipsetis that possible?
04:56slipsetfor this example it's not so important, but when having multiple params, I'd rather not remember their order.
04:57slipsethttps://github.com/krisajenkins/yesql/issues/8
04:57ianhedoesitslipset: what do you mean remember there order?
04:58slipsetwell, if I have a query like "select * from foo where bar = :bar and qix = :qix"
04:58slipsetI need to pass the arguments in order when I issue the query
04:59slipset(foos-and-bars db "value for bar" "value for qix")
05:01ianhedoesitslipset: it looks like that's been fixed since September, though?
05:01ianhedoesithttps://github.com/krisajenkins/yesql/releases/tag/v0.5.0-beta1
05:01slipsetYeps, but not in the non-beta version I guess which is 0.4.0
05:02ianhedoesitI was confused because I've used yesql for a couple things and I pass around maps just fine.
05:02ianhedoesitI'm using 0.5.0-rc1
05:02slipsetbut yes, I'll just upgrade to 0.5.0-rc1 and check it out
05:02ianhedoesitthere's also rc2 as of a week ago, I didn't realize.
05:06slipsetianhedoesit: it worked, thanks!
05:06ianhedoesitslipset: yup, no problem.
05:06slipsetianhedoesit: so if I have a query "select foo from bar" and issue it using yesql, I'll receive something like this:
05:07slipset[{:foo "value1"} {:foo "value2"}]
05:08ianhedoesitI believe so, yes.
05:09ianhedoesitI mean I don't know if it's a vector or what container it is, but that shouldn't really matter.
05:09slipset(inc ianhedoesit)
05:09lazybot⇒ 1
05:10ianhedoesitbut for example, (first (query/select-all)) => {:id 1 :foo "bar"}
05:11ianhedoesitthat is a working test.
05:11slipsetthanks
05:11ianhedoesitalso, hey thanks! :) my first inc, whatever that means.
05:12slipsetI have no idea, I just see that people get inc'ed whenever they seem to deserve it :)
05:12slipset(karma ianhedoesit)
05:13slipsethttps://github.com/Raynes/lazybot/wiki/Commands
05:13slipsetlazybot doesn't seem to respond well to karma queries
05:16ianhedoesityeah, I was just looking at the source.
05:21skratl0x1Cis it possible to model an undirected immutable graph, without duplicating the data? ie. without having each vertex in the structure more than once?
05:24clgvskratl0x1C: depends what you do not want to replicate. you can identify the vertex via an integer id and then use either an adjacency matrix or an edge list to represent existing edges
05:24clgvskratl0x1C: then you'd keep the data separate so that you can look up the data via the id
05:25skratl0x1Cclgv: aha, so I should give them IDs and store the adjacency data separate from the vertex/edge data?
05:26ianhedoesit(identity slipset)
05:26lazybotslipset has karma 0.
05:26ianhedoesit(identity ianhedoesit)
05:26lazybotianhedoesit has karma 1.
05:26slipset:)
05:26slipsetwas just RTFS'ing myself :)
05:27ianhedoesit(inc slipset)
05:27lazybot⇒ 1
05:27slipset:)
05:27ianhedoesitfor reading source!
05:27slipseteverybody lies, except the source
05:28slipsetgiven, of course, that the source is not self-modifying
05:28clgvskratl0x1C: yes, that's the common way in most graph algorithms
05:29ianhedoesitI'm curious as to why the README points to the wiki on the flatland fork when that one isn't being updated or mirroring Raynes' repository
05:29sm0keclgv: hello, :classifiers may be of interest to you
05:30slipsetianhedoesit: at least now the documentation is more correct
05:30slipsethttps://github.com/Raynes/lazybot/wiki/Commands
05:30clgvsm0ke: what?
05:31sm0keclgv: about the test thing which i was asking yesterday
05:31ianhedoesitslipset: neat! :)
05:31sm0kei though it might be of interest
05:31clgvsm0ke: ah ok
05:32sm0keclgv: you can have a :classifiers {:tests {:source ^:replace []}}
05:32sm0kein lein and it will install the test sources with `tests` classifier in maven
05:32sm0ke:D win win!
05:32sm0keits pretty cryptic there are no docs for it
05:33hyPiRionsm0ke: oh dang, really? We should fix that
05:33sm0kei am thinking of sending a pr to lein for this
05:33sm0kehyPiRion: i have a issue for it
05:33sm0kehttps://github.com/technomancy/leiningen/issues/1589
05:33hyPiRionoh
05:33sm0kewill send a PR, you can also do :classifiers {:foo :foo}
05:34sm0keand it will pick up the :foo profile
05:34slipsethyPiRion: http://2015.flatmap.no/
05:34sm0keits pretty neat hugo duncan guy committed this
05:34slipset;)
05:34hyPiRionsm0ke: I'd totally send out stickers for that PR
05:34sm0ke:D i want i want
05:35ianhedoesithyPiRion: you have stickers?
05:35sm0kehyPiRion: you will send me a sticker for a doc pr ?
05:35sm0kewow let me add that right now
05:35hyPiRionianhedoesit: yeah
05:35ianhedoesit:O
05:36ianhedoesitI've never had more incentive to learn a tool and contribute to it than right now.
05:36hyPiRionsm0ke: of course, any accepted PR gives you rights to a sticker
05:37sm0kenice
05:37hyPiRionianhedoesit: haha, we should probably emphasize it a bit more
05:37hyPiRionfor some reason many people still doesn't know about the stickers
05:38ianhedoesitI do remember seeing it when I first read the leiningen page I think. to be fair, it is the very last sentence on the page apart from the footer.
05:39Glenjaminhrm, damn - i could have sworn i had a leiningen commit
05:39hyPiRionslipset: I want to wait a tiny bit before submitting, as I believe I have a new persistent data structure brewing. (But I need to prove some property first)
05:40hyPiRionI think that might be interesting to speak about, along with the pvec.
05:41ianhedoesithttps://twitter.com/technomancy/status/21632759649
05:42ianhedoesit"10 months old and 41 contributors"
05:44tomjackpvec?
05:44hyPiRiontomjack: persistent vector
05:44hyPiRionIt's so long to write
05:45tomjackah
05:45ianhedoesithypirion.com/musings/understanding-persistent-vector-pt-1
05:45ianhedoesithyPiRion: that?
05:45hyPiRionianhedoesit: yup
06:16hellofunkanyone in here got an emacs erc setup that only shows direct mentions in the mode line, and not all other channel activity? i've been trying to figure this out for days. #emacs guys haven't had much to offer
06:19dysfun_emacs fanboy as i am, i use irssi
06:51luxbock,(let [[:a :b & :rest] [1 2 3 4]] [a b rest])
06:51clojurebot[1 2 (3 4)]
06:52luxbocko_O
06:52luxbockis there a use case for this?
06:54Glenjaminwell, that's odd
06:55Bronsait works as an accident since 1.6
06:59luxbockBronsa: do you know why the (keyword? b) clause is needed in the 1.6+ clojure.core/destructuring?
06:59luxbockI'm working on something destructuring related and was puzzled by it when reading the source
07:00Bronsa,(let [{:keys [::foo]} {::foo 1}] foo)
07:00clojurebot1
07:00Bronsaluxbock: ^ to allow support for destructuring namespaced keywords
07:00luxbockoh
07:01luxbock(inc Bronsa)
07:01lazybot⇒ 89
07:02hellofunk(set! Bronsa (* Bronsa Bronsa))
07:08RoccoDHi, is this also the channel to ask about clojurescript ?
07:10hipsterslapfightRoccoD: #clojurescript
07:10RoccoDoeps. sorry, thanks
07:16kitalliswhat would be the easiest way to search within a list of vectors like (["a" "val"] ["b" "val"]) for the value of a specific key like "b"?
07:17Bronsa,((into {} '(["a" "val"] ["b" "val"])) "b")
07:17clojurebot"val"
07:19hyPiRion,(first (for [[k v] '(["a" "val"] ["b" "val"]) :where (= k "b")] v))
07:19clojurebot#<CompilerException java.lang.IllegalArgumentException: Invalid 'for' keyword :where, compiling:(NO_SOURCE_FILE:0:0)>
07:19Bronsas/where/when
07:19hyPiRionyesh
07:19kitalliscool
07:19hyPiRionI do that mistake all the time :(
07:20expezdoes `lein capsule` work or is it extremely alpha?
08:27justin_smithexpez: funny, it looks like new code got pushed to that repo about 30 minutes after you asked that. Not that this is an answer to your question :)
08:27expezjustin_smith: yeah I submitted a minor bugfix
08:27justin_smithahh, OK
08:28expezjustin_smith: I'm trying to get it to package it refactor-nrepl so we don't pollute the user's classpath with tooling related dependencies.
08:28expezI think the generated capsule is OK now, but it fails to register the middleware
08:37justin_smithinteresting
08:42jlamainif i have a defrecord "rec" and I do an assoc on it (assoc rec :x 0) i get a new record. But if i have records containing records, if i change the inner record, does the outer record change ? or does it contain the old value ? I have a bit of a hard time coming from a c++/javascript background ;-)
08:43justin_smithjlamain: records do not change
08:43justin_smithjlamain: assoc creates a new record
08:44justin_smithjlamain: so to update a record inside a record, you are creating new versions of both
08:44justin_smithjlamain: update-in makes this easy
08:44justin_smith,(update-in {:a {:b 1}} [:a :b] inc)
08:44clojurebot{:a {:b 2}}
08:44justin_smithjlamain: note how really we only updated the inner hash-map
08:45justin_smithjlamain: but technically two new hash-maps were created
08:46justin_smithand yes, the original {:a {:b 1}}, if we still had it around, is unmodified (in this case it was garbage collected because we have no pointer to it)
08:46jlamainthanks justin. But now the question. If i have a record implementing a protocol. A function in this protocol needs to add something to the record. Can the function add something to "this" ? if so how is this working for the upper records. if not, what is the clojure way to do suys things?
08:47justin_smithjlamain: the protocol method would be able to return a modified version of "this", it is up to the caller to use it or not, the original is unmodified
08:48justin_smithjlamain: the behavior of records is identical to the behavior of hash-maps in most ways, including this one
08:49justin_smithjlamain: in fact, I would use update-in in order to update the record via its protocol method, if the record were inside another one
08:52jlamainjustin_smith: thx. Then i'm completely out of ideas how to complete implementing somethink like a UI dsl like in my gist: https://gist.github.com/jlamain/478c6978816b71257930. basically I have functions creating records. (layer, rectangle). But if some aotm changes i need to update some internal fields in a record. This means i should update all higher records also ? Please do not laugh too hard about my first clojure(script)
08:53justin_smithjlamain: the key is that anything modified needs to be passed into the modifying function, and also returned from it
08:54justin_smithif you need to do a series of updates, you likely will end up doing a chain of update-in operations, inside a swap! call if it must be an atom
08:54Glenjamini quite like using (->) for DLS
08:54GlenjaminDSLs even
08:54justin_smithGlenjamin: yes, -> / ->> are definitely called for when doing multiple updates within one nested data structure
08:56justin_smithjlamain: you could simplify the code to render-translated as follows: new-translate (-> translate (update-in [:x] + x) (update-in [:y] + y))
08:57justin_smiththat chains both the updates into one logical operation, without needing to bind the individual new values
08:57SagiCZjlamain: do you really need that protocol? maybe you could just use hash-maps?
08:57justin_smithjlamain: also, do blocks are not needed in let bodies
08:59perplexawhat would i do if i have [1 2 3 4 0 5 6] and want [1 2 3 4 5 6]? ie. drop the 5th item from the vector
08:59octatoneHello
08:59octatoneI am a clojure noob, is there an easy way to log to repo from Midgje auto test in my tests?
08:59SagiCZperplexa: you could join two subvectors.. but no there is no core function that does that
08:59justin_smithperplexa: create a new vector, if you need to do this alot, don't use a vector, dropping from the middle is not efficient
08:59octatone^repl
09:00perplexanah, i'm just doing this to modify values for the tests ;x
09:00perplexai reuse intermediate results
09:00perplexabut i need to drop a row
09:00octatonemidje seems to just pr-str
09:00jackhilljustin_smith: what would you use if you needed to do it a lot?
09:01Glenjamina hash-map
09:01justin_smithjackhill: finger-tree
09:01octatoneseems to just eat it
09:01jlamainSagiCZ: you mean operating over hash maps using functions ? No records anymore ?
09:01justin_smithjackhill: or rrb
09:01hyPiRionjackhill: RRB-tree. core.rrb-vector. But it sort of depends on how large they are
09:01hyPiRionfor less than 1000 elts it's probably not worth the effort.
09:01SagiCZjlamain: yeah.. but maybe this is easier.. in similar code of mine i used regular hash-maps with :type keyword and multimethods that dispatch on the :type.. very powerful and easy to extend
09:01jlamainjustin_smith: thanks for the improvements
09:02jackhilljustin_smith, hyPiRion: awesome, thanks. I was just curious what was out there
09:02justin_smithjlamain: records and hash-maps are behaviorally identical, except with records you have optimized default field lookup, and the possibility of protocols instead of functions (also potentially an optimization)
09:05octatoneI just want to log to repl from midje autotest ... is this possible? It seems that pr-str is just eaten
09:05justin_smithoctatone: what do you think pr-str does?
09:05octatoneprints ?
09:05justin_smithno, it creates the string that would be printed if you had printed
09:06justin_smithyou just want println
09:06justin_smith,(pr-str :a)
09:06clojurebot":a"
09:06justin_smith,(do (pr-str :a) nil)
09:06clojurebotnil
09:06justin_smithno printing
09:06hyPiRion,(prn pr)
09:06clojurebot#<core$pr clojure.core$pr@38950703>\n
09:06hyPiRionyayy
09:06octatonethanks
09:07jlamainoke. thx. i'll try to do with multimethod than. But i'm still confused about the propagation of updated records/hashmaps to upper values. So the multimethod returns a new hashmap when updated and the the upper hashmap does an assoc. hmm. Quite hard embedded engineer normally doing c/c++/javascript ;-) haha
09:09justin_smithjlamain: but the update/assoc can be a single operation thanks to update-in - the thing to remember is that you can't update something if you don't return it to your caller
09:10justin_smithjlamain: and what eventually becomes clear is that this restriction elimanates many points of failure - you know that any part of your code without mutation can only update what it returns
09:14perplexajustin_smith: using (vec (map #(vec (concat (subvec % 0 7) (subvec % 8 11))) aqft/expected-views)) but it is very ugly ;D
09:14perplexait gets rid of the 8th item, tho. so it's ok ;p
09:15justin_smith(vec (map ...)) is (mapv ...)
09:15perplexaoh right :) thanks!
09:16hyPiRionalso, do #(into (subvec % 0 7) (subvec % 8 11)) instead
09:16hyPiRionmore efficient
09:16justin_smith(inc hyPiRion)
09:16lazybot⇒ 61
09:18jlamainjustin_smith: so if i do a (update-in map [:l1 :l2 :l3 :l4 :x] 500) everything is updated updated "four levels" deep.
09:18justin_smithwell 500 isn't a valid arg to update-in, and that's 5 levels :)
09:18justin_smithupdate-in needs an updating function, maybe that should be assoc-in if you want to set the thing to 500
09:19justin_smithbut yes, that's the general concept
09:20jlamainok. thanks!
09:20perplexahyPiRion: oh!
09:28jlamainjustin_smith: I'm now googling and see http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples/Advanced_Data_Structures. If i have a deep tree of maps and one of the deeper subtrees is a complex ui component it might not be handy to every time give the full "path" to the assoc-in/update-in functions. Is it possible to give the "component" a shortcut to its own part of the tree ? How ? Is that were zippers are for, s
09:28jlamainits zipper and say "update yourself!" ?
09:37justin_smithjlamain: the answer may be related to the answer to the quesiton "why do you have a deep tree?" - if each subtree is self contained, perhaps it should have its own implementation of update, such that it updates each of its own contents, recursively
09:37justin_smithjlamain: in which case you would call some update function on the top item (passing parameters) and it passes the parameters to an update call to each of its branches, etc.
09:38justin_smithI've never actually found zippers especially useful
09:40jlamainoke. thanks. Indeed thats also a simple/good solution
09:43zactshi #clojure
09:49justin_smithcode that uses zippers reads like konami cheat codes
09:51Glenjaminthe xml-zip stuff seems to work pretty well, but i've never traversed up the tree with it
09:52justin_smithGlenjamin: (-> (xml-zip form) zip/up zip/down zip/up zip/down zip/left zip/right zip/left zip/right :a :b :start)
09:52justin_smithsorry
09:53chouserI still like it with data.zip
09:53justin_smithmaybe I need to give them a second chance
09:54hyPiRionYou usually make general functions on top of zippers. Like recursion schemes
09:57hyPiRionIt's possible to use them yourself too, but I've felt it's only "viable" after a bit practise.
09:59hellofunkzacts: that SICM book is what exactly, a clever analysis of basic physics?
10:03SagiCZwould you consider Clojure a good scripting language? like perl or python?
10:04justin_smithSagiCZ: there's a few limitations - the lack of access to the PID of a child process, the relatively long startup time
10:04justin_smithSagiCZ: though I think cljs/node would address both of those
10:04SagiCZi see
10:06chouser(def pid (Long/parseLong (str (Files/readSymbolicLink (to-path "/proc/self"))))) ;; probably only Linux
10:06stuartsierraMost "scripting" languages are implemented in C, putting them closer to POSIX-style system calls that are important for scripting.
10:06justin_smithchouser: I mean the PID of a child process
10:06justin_smithchouser: which amazingly, is not provided by Process
10:07chouserjustin_smith: *sigh* That JVM. *smh*
10:08chousereven clojurescript is a bit clumsy for scripting type tasks though because of JVM-based compilation.
10:08justin_smithSagiCZ: also, pixie is very similar to clojure in a lot of great ways, and has decent scripting support I think (or at least has that as a goal)
10:08justin_smithchouser: I had imagined using the compiled output for scripting
10:09SagiCZjustin_smith: who makes pixie?
10:10justin_smithSagiCZ: it's a collaboration, but tbaldridge is the biggest contributor
10:10SagiCZjustin_smith: oh. nevermind then
10:10justin_smithSagiCZ: ?
10:10justin_smith$last tbaldridge
10:10lazybotCouldn't find that user.
10:11tbaldridgelol, I'm here
10:11justin_smithhaha
10:11tbaldridgeregardless of what lazybot thinks
10:11SagiCZheh
10:11justin_smithI hope that isn't something I broke in the lazybot codebase...
10:11justin_smith$last tbaldridge
10:11lazybotCouldn't find that user.
10:11justin_smithso weird...
10:11hyPiRion$last justin_smith
10:11lazybotjustin_smith last listened to: Jean-Baptiste Lully - Ouverture [LULLY: Ballet Music for the Sun King]
10:12justin_smithhaha
10:12justin_smithof course
10:12SagiCZwait what
10:12justin_smith$seen tbaldridge
10:12lazybottbaldridge was last seen talking on #clojure 1 minute and 1 second ago.
10:12hyPiRionlast.fm
10:12SagiCZoh there we go
10:12justin_smithI was using the wrong command, my bad
10:13justin_smithSagiCZ: anyway, pixie has better access to the kind of stuff you would want for scripting, I think
10:13SagiCZi see.. well i might as well learn perl since i know nothing about pixie
10:13justin_smithSagiCZ: like I said, pixie is very similar to clojure
10:13justin_smithintentionally so
10:14tbaldridgesomeone should package up node/cljs somehow so that it's easy to compile scripts from lein
10:14justin_smithtbaldridge: agreed
10:14hyPiRionThat plugin must surely be called inlein
10:14Glenjaminas in "script.cljs" -> lein compile script.cljs -> ./script
10:14zactshellofunk: it's a book on classical mechanics
10:15justin_smithGlenjamin: exactly, that would be great
10:15Glenjaminshould be pretty doable
10:15hellofunkzacts: right, meaning, basic physics?
10:15zactshellofunk: http://en.wikipedia.org/wiki/Classical_mechanics
10:15Glenjaminthey're quite chunky though, a small app like that will be 80k of JS
10:15Glenjaminthere's no nice way to share libs or a runtime between compiled cljs afaik
10:16zactsadvanced newtonian physics
10:16hellofunkzacts: i know what mechanics is, but i'm wondering if that book has much incommon with SICP or if it's just cashing in on the name
10:16zactsyes it has *much* in common with SICP
10:16zactsit uses scheme to teach classical mechanics
10:16justin_smithhellofunk: I think that it is just using the house naming style for the curriculum
10:16SagiCZhellofunk: what is SICP? i see that thrown areound here a lot
10:16zactsthen the math notation afterwards
10:16hellofunkSagiCZ: Sussman's ouvre
10:17zactsso you get an intuitive sense of how classical mechanics work
10:17justin_smithSagiCZ: SICP is a free online book, with accompanying free online lecture videos, that introduce programming via scheme
10:17justin_smithSagiCZ: very good course
10:17zactsI have yet to read SICM, and much of SICP
10:17SagiCZthis? http://mitpress.mit.edu/sicp/
10:17zactsyes SagiCZ
10:17justin_smithSagiCZ: yeah - it was my CS 101 and served me very well
10:17zactsI'm wondering if Sussman and Aebelson are planning to update SICP to a 3rd edition, I don't know though
10:18SagiCZi see.. thanks
10:18zactsjustin_smith: MIT or Berkeley?
10:18justin_smithSagiCZ: see also these lectures by the author https://www.youtube.com/playlist?list=PLB63C06FAF154F047
10:18justin_smithzacts: MIT
10:18zactsah nice
10:18justin_smithzacts: that youtube link is video of the MIT lectures
10:18zactsyes
10:18Glenjaminhow about "lein backer script.cljs"
10:18zactsI've watched some of those
10:18jackhillzacts: MIT changed the CS curriculum, so probably not.
10:18zactsjackhill: well it's nice that justin_smith studied SICP when they used that
10:19justin_smithjackhill: much the worse for all of us, that
10:19justin_smithzacts: well, I did it on my own - it's been a free book for a long time now
10:19zactsoh I see
10:19jackhillThere is also How To Design Programs which takes a different tact for how a first CS course should be structured (and uses racket)
10:19zactsI couldn't personally get into HTDP
10:19justin_smithI meant "101" in the general sense, I just read it and did the exercises independently
10:19zactsI much prefer the tone of SICP for my taste
10:20zactsalthough, to be fair I couldn't get myself to get past the first couple of ch's of HTDP
10:20zactsperhaps it gets better
10:20jackhillzacts: Different things work for different people. Maybe SICPs better for you.
10:21zactsah yeah
10:21jackhillI've spend more time with SICP than HTDP, but I appreciate that the HTDP people have articulated why they wrote the book the way they did.
10:21jackhillIf nothing else, it help me think of how best to explain things to others.
10:22jackhill(their critique of SICP is Structure and Interpretation of Computer Science Curricula)
10:23jackhillAnyways, I came here to get a critique of some of my early days in clojure code:
10:24jackhillI've written a function, http://paste.ubuntu.com/9957756/ , that returns a sequence of ratios. Is there a "better" (more clear/less repetitive/more efficient) way I could have done it?
10:27justin_smithjackhill: you could easily make that function lazy if you used lazy-seq in the tail call
10:27justin_smiths/tail-call/self-call
10:28justin_smithjackhill: added benefit of lazyness would be not blowing up the stack with large sequences
10:29jackhilljustin_smith: where would I insert lazy-seq?
10:29justin_smithjackhill: one moment, I'll paste my version
10:30hyPiRion,(let [nums [1 2 3]] (map (fn [[f s]] (/ s f)) (partition 2 1 nums)))
10:30clojurebot(2 3/2)
10:31hyPiRionKnowing that you can make pairs with (partition 2 1 ...) is really useful
10:31jackhillhyPiRion: thanks!
10:31justin_smithjackhill: https://www.refheap.com/96695
10:32justin_smith(inc hyPiRion)
10:32lazybot⇒ 62
10:32justin_smithonce again, his version is better
10:33hyPiRionjackhill: also take a look at justin_smith's one. It's good to know how the base mechanics of laziness works (where to put lazy-seq etc)
10:33jackhilljustin_smith, hyPiRion: thanks. I just have to read them a couple time to make sure I understand
10:34justin_smithjackhill: I may have obfuscated my point by doing some DRY / extending the destructuring a bit
10:34hyPiRionjackhill: I can refactor my version to this (->> nums (partition 2 1) (map (fn [[f s]] (/ s f))))
10:35jackhilljustin_smith: perhaps. Although I suspected I wanted to use a let, so that's great. I also hadn't seen the multi-level destructuring before, so that great too
10:35chouserjustin_smith: I think that's less lazy than it could be. Is that intentional?
10:35chouseror perhaps just not important.
10:35justin_smithchouser: not intentional, I'd be glad for a tip to make it lazier
10:36chouserfor maximum laziness, you generally want the lazy-seq form as close to the outside as possible. Alas this often means you don't destructure in the fn args.
10:36hyPiRionjackhill: (partition 2 1 [1 2 3 4]) => ((1 2) (2 3) (3 4)), and (fn [[f s]] (/ s f)) is just a fancy way to say "take a seq of two elements, and return the second divided by the first"
10:37justin_smith(fn [[f s]] (/ s f)) can also be "cleverly" expressed as (comp (partial apply /) reverse)
10:37jackhillhyPiRion: ah, and both partition an map return lazy-seq's?
10:37justin_smith(for two element list input)
10:38chouserAs you've got it, calling empty? on remains means that remains will be forced immediately on calling rolling-ratio, which I think means it will immediately force 3 steps when called.
10:38chouserIf you put lazy-seq just inside the defn, you can reduce that to 0.
10:38justin_smithchouser: oh, wow, yeah - the deep digging kills the laziness of course
10:38hyPiRionjackhill: yes
10:39chouserjustin_smith: you got it.
10:39hyPiRionjackhill: most functions that work on seqs are lazy (map, filter, take, drop, etc)
10:40hyPiRionSo it's very common to just use them than to use lazy-seq yourself, as you can often compose those into the desired output
10:40hyPiRionto make the desired output, rather
10:41jackhillIndeed. And map alrady knows to stop at the end, so I don't need to explicitly check for it.
10:42hyPiRionyup
10:43jackhillYay, thanks everyone this really helped.
10:43justin_smithchouser: jackhill: my version more lazy https://www.refheap.com/96696
10:45justin_smithI just edited to add a version with a let binding, but I am not sure that is any better in this case
10:46justin_smith(if only we had a when-let that tested/required multiple bindings in core)
10:59chouserjustin_smith: looks good to me
11:00justin_smithso now I've identified two corners of clojure I could brush up on today, laziness and zippers
11:09raggeI'm contemplating trying to implement something that would allow you to use maven packages JARs with nix. Does anyone know if something like this has been done/tried?
11:09raggeIdeally, I'd like to express JAR deps using nix, and stick JAR + all deps into nix store
11:10justin_smithragge: what would this do that current usage of maven dependencies / uberjar would not?
11:12raggejustin_smith: short answer is that I'd like something that plays well with nix ecosystem
11:13raggeallowing things like nix-copy-closure
11:14justin_smithragge: typically my clojure deploys consist of creating an uberjar and a shell script that runs it, and putting those two files on a server
11:14TimMcSame here.
11:14justin_smithragge: I like the modularity of nix, but when a deploy has so few pieces, I don't really see what is being gained I guess
11:15raggejustin_smith: mine too, but there's alot of stuff that's not captured by that
11:15justin_smithragge: OK
11:15justin_smithragge: what about using nix to abstract the rest of the stuff, and using the maven stuff as usual? I don't see what's gained by wrapping up the maven part too
11:15raggelike which JVM, which native deps
11:16justin_smithragge: ahh, native deps are another story
11:17justin_smithragge: but still, I feel like wrapping the maven dependency management in nix feels like a pointless layering. my approach would be to wrap everything maven doesn't do well / can't do with the nix abstractions, and then instead of abstracting over maven, just generate the uberjar and treat that as a single atomic artifact
11:18raggejustin_smith: this is really just an exercise for me to try something a bit different
11:18raggeidea is to not really use maven or leiningen, or create uberjar
11:18raggejust express jar dependencies
11:19TimMcYou're gonna have to reinvent a lot of stuff.
11:19raggemake nix download them, and provide them as needed for compilation/runtime
11:19raggethen use plain old java -jar clojure.jar:... clojure.main
11:19raggeor clojure.compile
11:19raggeTimMc: thats possible
11:20raggeand even likely
11:20TimMcHow will you set the JVM args necessary for the app?
11:20TimMcfor example heap size, system properties...
11:20justin_smithif you're exercising, as long as you're having fun I guess. But it will be a lot of work for little pragmatic end.
11:20raggewould be part of your package
11:20raggewhat you execute is up to you
11:20raggenix can help provide dependencies
11:21raggeconstruct classpath with appropriate JARs (and native deps) stuff from nix store
11:21TimMcI see, the command would have to be provided elsewhere, possibly from a shell script anyhow.
12:12gfredericksanybody did done made a library for deffing things with HOFs?
12:13gfredericksdefpartial, defcomp, at least
12:13gfredericksnot sure if anything else would fit in that group
12:14chouserdefmap, defreduce?
12:14gfredericksthe point would be to have better reloadability (by using vars) and better arglist metadata (by stealing it from the original)
12:14justin_smithdefdef
12:15justin_smith(higher order macro for creating def-like forms)
12:15gfredericksI feel like I threatened to make a def-oriented library at one point I can't remember what happened
12:15tcrayford____gfredericks: free name "defning"
12:15justin_smithat least we would never need defdefdef
12:15gfrederickstcrayford____: that was suggested for another library already :P
12:16tcrayford____dammette
12:16chouserjustin_smith: probably not, but I could find a use for defdefmacrodef
12:16justin_smithhaha
12:16gfredericksone name I would consider is defdefdefdefdefdefdef
12:16tcrayford____gfredericks: "defntlynot"
12:17hiredmanstick a random f in there
12:17hiredmandefdefdeffdefdefdefdef
12:17gfrederickshiredman: I'm not opposed to this
12:17justin_smithdefdefdefdefdefdefdefdef-mushroom-mushroom
12:18chouser,((get get get get) (get get get) ('get get) 'get)
12:18clojurebotget
12:18chouserwho did I steal that joke from?
12:18stuartsierradeffr, rhymes with zephyr
12:19justin_smithchouser: (get get get get) was my "discovery" I think, but I like that variation
12:19tbaldridgeobligatory Monty Python vid: https://www.youtube.com/watch?v=anwy2MPT5RE
12:20chouserjustin_smith: thought it might have been you. It's a wonderful theme, full of potential variations.
12:20justin_smithsemantic saturation for fun and profit
12:22gfredericks,(defn get-it [] (repeatedly (inc (rand-int 4)) #(case (rand-int 5) (0 1) 'get (2 3) ''get 4 (get-it))))
12:22clojurebot#'sandbox/get-it
12:22gfredericks,(get-it)
12:22clojurebot((quote get) (quote get) (get get) (get (quote get)))
12:23gfredericks,((quote get) (quote get) (get get) (get (quote get)))
12:23clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/get>
12:23gfredericks:/ I guess it's not likely to evaluate
12:24chouser,(map map (meta meta))
12:24clojurebot()
12:24justin_smithnice
12:24tcrayford____(:or :or :or)
12:24tcrayford____,(:or :or :or)
12:24clojurebot:or
12:25justin_smithsomeone is totally new to clojure and wondering what the fuck they just got into
12:25justin_smith(also all of this is totally hilarious)
12:26TimMcoh, if we're doing this...
12:26TimMc,((((comp comp) (comp comp)) ((comp comp) (comp comp))))
12:26clojurebot#<core$identity clojure.core$identity@320baa47>
12:27chousernice!
12:27justin_smithNICE
12:28nic77<justin_smith> someone is totally new to clojure and wondering what the fuck they just got into
12:28nic77yes thats me
12:29nic77yall set me back 10 years just now
12:29justin_smithnic77: we don't do this in real code, I hope you realize :)
12:30justin_smithnic77: though there may be some benefit to realizing why these silly things work
12:30justin_smitheven if you would never do them on purpose
12:32TimMc,(eval (nth (iterate #(list % %) comp) 5))
12:32clojurebot#<ExceptionInInitializerError java.lang.ExceptionInInitializerError>
12:32TimMc?
12:33justin_smithTimMc: weird, that works locally
12:33justin_smith&(eval (nth (iterate #(list % %) comp) 5))
12:33lazybotjava.lang.SecurityException: You tripped the alarm! eval is bad!
12:33justin_smithmaybe the eval is the issue? does clojurebot usually allow it?
12:34TimMc,(eval 5)
12:34clojurebot5
12:34TimMc*shrug*
12:34TimMc,(eval (nth (iterate #(list % %) comp) 5))
12:34clojurebot#<ExceptionInInitializerError java.lang.ExceptionInInitializerError>
12:38TimMcWe should be able to do eval in lazybot, right? As long as we can resolve vars.
12:38justin_smithTimMc: I think it is an arbitrary sandboxing constraint, I don't know what the reasoning was.
12:39TimMcChallenge: Build a fn that allows you to do this: &(let [ev (fn ...)] (ev (list + 2 3))) ;; 5
12:39TimMcand have it fit in an IRC message, obviously.
12:39TimMc... = 5 is cheating
12:39TimMcor [] 5 in this case
12:41justin_smith&(let [ev (fn [f & args] (apply f args))] (ev (list + 2 3)))
12:41lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
12:41justin_smithhrmph
12:41justin_smithoh, duh
12:41justin_smith&(let [ev (fn [& [f & args]] (apply f args))] (ev (list + 2 3)))
12:41lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
12:41justin_smithOK, back to my own repl, sorry
12:42Bronsajustin_smith: remove the &
12:42justin_smith(let [ev (fn [[f & args]] (apply f args))] (ev (list + 2 3)))
12:42justin_smith&(let [ev (fn [[f & args]] (apply f args))] (ev (list + 2 3)))
12:42lazybot⇒ 5
13:00justin_smithTimMc: '(+ 2 3) would have made me use resolve
13:01TimMc&(letfn [(ev [s] (if (list? s) (apply (first s) (map ev (rest s))) s))] (ev (list + (list * 2 3) 5)))
13:01lazybot⇒ 11
13:01TimMcrecursive!
13:02justin_smithI think that's really close to one of the 4clojure problems actually
13:05mearnshthis one? https://www.4clojure.com/problem/121
13:05mearnsh4clojure forbids resolve though
13:05justin_smithyeah, that's the one I was thinking of
13:06benmossdoes anyone have any advice for how to serialize a byte buffer/byte array in order to write decoding tests against it?
13:06benmossi’m up against the limits of my knowledge here
13:07justin_smithbenmoss: I use base64 to turn it into a string that I put as a literal or into a resource file, then bas64decode to turn it into a byte array again for testing
13:07TimMcYou could turn it into a seq of bytes or maybe produce a base64 string.
13:07justin_smithhttps://github.com/clojure/data.codec data.codec does base64
13:07TimMcSeq of bytes is dumb but easy (unless you'll be interacting with resource files.)
13:07TimMcThen it's just dumb.
13:08justin_smithyeah, for a smaller one at least seq of bytes would be fine too
13:08TimMcOh, I guess with a seq of bytes you have to deal with the fact that they're signed... :-(
13:09justin_smithTimMc: well, it's a transperent thing when you go both ways with it
13:09justin_smithit's not like the double conversion would lose anything
13:09benmosshmm how do you turn it into a seq of bytes? i assume we are talking about a byte array here
13:10justin_smith,(seq (byte-array (map byte [1 2 3 4]))
13:10clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
13:10justin_smithoops
13:10justin_smith,(seq (byte-array (map byte [1 2 3 4])))
13:10benmossgroovy
13:10clojurebot(1 2 3 4)
13:10Bronsajustin_smith: is the map byte really necessary?
13:11justin_smithor to construct a vector literal (into [] (.getBytes "hello"))
13:11benmossthat is perfect for my needs
13:11justin_smithBronsa: I recall byte-array complaining
13:11justin_smith,(byte-array [1 2 3 4])
13:11clojurebot#<byte[] [B@385fbfa0>
13:11justin_smithBronsa: I was wrong
13:11justin_smith,(into [] (.getBytes "hello"))
13:11clojurebot[104 101 108 108 111]
13:15justin_smithmaybe I was thinking of something like (into-array Byte [1 2 3])
13:15Bronsa,(into-array Byte [1 2 3])
13:15clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: array element type mismatch>
13:15Bronsauh
13:15Bronsa,(into-array Byte/TYPE [1 2 3])
13:15clojurebot#<byte[] [B@4cef0f23>
13:16Bronsacool
13:16justin_smiththat's where (map byte ...) is needed, but now I struggle to recall why I would make an array of Byte instead of Byte/TYPE
13:16stuartsierra,(byte-array [1 2 3])
13:16clojurebot#<byte[] [B@1eb9de7e>
13:17Bronsastuartsierra: yeah we were just wondering when (map byte [1 2 3]) is necessary and when [1 2 3] is ok
13:22stuartsierraah
13:22stuartsierrabyte coercions are odd. Just the other day I had to write (.byteValue (Long. 0xFF))
13:24hiredman(doc unchecked-byte)
13:24clojurebot"([x]); Coerce to byte. Subject to rounding or truncation."
13:24justin_smithcool
13:24justin_smith,(unchecked-byte 1000)
13:24clojurebot-24
13:47Bronsajustin_smith: who needs unchecked-byte when you can do ##(first (byte-array [1000]))
13:47lazybot⇒ -24
13:47TimMcThis seems sensible.
13:48justin_smithTimMc: after all, it is 24 short of a value that should map to 0
14:07gfredericksthinking of adding a test.chuck namespace for making assertions about generators & their distribution
14:07gfredericksand am trying to name the namespace
14:11hiredmantest.check.gauss
14:11gfredericksit would be structured a lot like such-that
14:11gfredericksyou give it a predicate and it checks that the generator generates something satisfying the predicate before too long
14:12gfredericksprobably by increasing the size the same way such-that does
14:16{blake}Is it true that I need a Clojure library (like "classpath") in order to figure out what the classpath is? (I would've thought it was a built-in.)
14:17hiredmanthe classpath is a static thing handed to the jvm at start up, why would you need to know what it is?
14:17{blake}hiredman: I'm trying to use yesql, which requires the sql to be put on the classpath.
14:18hiredman{blake}: at run time the classpath is whatever you tell the jvm, at dev time it is the same, but generally people let lein manage launching jvms at dev time, and lein has a classpath command which prints out the classpath it is using
14:19gfredericks{blake}: the /resources directory is the normal place to put non-code on the classpath
14:19hiredman{blake}: but generally you would put things like the files yesql uses in a directory called resources/
14:20{blake}hiredman, gfredericks: Thanks. Does it search subdirs?
14:20justin_smith{blake}: provide a path that is relative to that directory
14:20{blake}I guess not.
14:20justin_smithie resources/sql/my-query.sql
14:21justin_smiththen ask for "sql/my-query.sql"
14:21{blake}Oh, right. Duh. That's what I started with but off the root.
14:21{blake}Points party!
14:21{blake}(inc hiredman)
14:21lazybot⇒ 69
14:21{blake}(inc gfredericks)
14:21lazybot⇒ 114
14:21{blake}(inc justin_smith)
14:21lazybot⇒ 178
14:27benmosshmm, anyone familiar with ztellman’s byte-streams/manifold?
14:28benmossi am trying to emulate the incoming tcp stream from aleph for a test, but can’t wrap my head around how to do it
14:29benmossi have the byte array i was talking about earlier, but not sure how to turn it into a stream of bytes consumable by gloss
14:29benmossstuck in ztellman hell
14:40tcrayford____benmoss: well, I tooted it at ztellman. Iirc he's on freenode, maybe you could just private message him on here?
14:41benmosshah i just saw that
14:41tcrayford____(I use other parts of the ztellman kingdom, but not manifold or gloss or manifold)
14:41ztellmanbenmoss: hey, sorry for the troubles
14:41ztellmanif you just use decode-stream on the aleph gives you, it should work
14:42benmossno no its just my relative newbishness
14:42ztellmanon the stream aleph gives you*
14:42benmossyeah that works fine, i’m trying to diagnose a problem in my codec and thus trying to recreate the TCP stream in a test
14:42ztellmanthen you can just create a sequence of bytes, or a byte array, or whatever
14:42ztellmanand (->source bytes)
14:43benmossyeah, i have that much, i get “cannot convert byte[] to source”
14:43cemerickstuartsierra: you want (unchecked-byte 0xff)
14:44ztellmanbenmoss it has to be a sequence
14:44cemerickmeh, should've kept reading the scrollback :-P
14:44ztellman(->source [bytes])
14:44ztellmanif it's just a byte-array
14:44ztellmanI've got to run, unfortunately
14:44ztellmansend me an email if you keep having trouble
14:44benmossno worries, thanks though
14:45benmossyour libs are a joy to work with as soon as i can wrap my head around them :)
14:45ztellmanas a rule of thumb: you can convert streamy and sequencey things to Manifold streams, so you'll need to coerce it at least that ar
14:45ztellmanfar*
14:45ztellmanyou can also just call gloss.io/decode on the byte-array
14:45ztellmanas an alternative
14:45ztellmananyway, best of luck
14:52stuartsierracemerick: ah, thanks
14:54cemerickstuartsierra: sure; ironically, working with bytes in javascript is actually more pleasant than on the JVM because of the signededness
14:59sdegutisWhat majestic technique would you use to return all the non-alphanumeric characters in a string (duplicates found in the string are allowed but not required in the result)?
15:01amalloy(.replaceAll s "[a-zA-z0-9]" "")
15:02amalloyor use clojure.string/replace, whatever suits your fancy
15:04edw,(inc 41)
15:04clojurebot42
15:04benmoss,(re-seq #”\W” “foo@bar.com”)
15:04clojurebot#<ArrayIndexOutOfBoundsException java.lang.ArrayIndexOutOfBoundsException: 8221>
15:05sdegutisamalloy: thanks
15:05amalloybenmoss: close, except that removes _ as well
15:05sdegutis,(re-seq #"\W" "foo@bar.com")
15:05clojurebot("@" ".")
15:05sdegutisexcellent thanks benmoss
15:05benmossah, don’t listen to me :)
15:05sdegutiswhy?
15:05clojurebotwhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
15:05sdegutisit was a legitimate solution benmoss
15:05edwAlso, benmoss, you has some weird cury quotes in there.
15:05sdegutis,(.replaceAll "foo@bar.com" "[a-zA-z0-9]" "")
15:05clojurebot"@."
15:05amalloy,(re-seq #"\W" "foo_bar.com")
15:05clojurebot(".")
15:05benmossyeah not sure where that crap is coming from
15:06sdegutisoh
15:06llasram,(into #{} (remove #(or (Character/isAlphabetic (int %)) (Character/isDigit %))) "What's this `*` doing in my code?")
15:06clojurebot#{\space \` \' \* \?}
15:08sdegutisWhat's a consummate way of removing all duplicate characters from a string?
15:08TimMcbenmoss: oh ess ex
15:08llasram,(Character/getNumericValue \Ⅼ)
15:08clojurebot50
15:08benmossTimMC: yep just figured out how to disable that :)
15:08TimMcllasram: ooooh
15:09llasram,(Character/getNumericValue \L)
15:09clojurebot21
15:09TimMc,(.getPort (java.net.URL. "http://www.example.com:Ⅼ/&quot;)) ;; just checking
15:09clojurebot#<MalformedURLException java.net.MalformedURLException: denied>
15:10TimMc,(.getPort (java.net.URL. "http://www.example.com:८५/&quot;)) ;; for comparison
15:10clojurebot#<MalformedURLException java.net.MalformedURLException: denied>
15:10hellofunksdegutis: duplicates in succession, or duplicates anywhere?
15:10TimMcuh
15:10TimMc&(.getPort (java.net.URL. "http://www.example.com:८५/&quot;))
15:10lazybot⇒ 85
15:10amalloynice
15:11sdegutishellofunk: anywhere
15:11TimMc&(.getPort (java.net.URL. "http://www.example.com:Ⅼ/&quot;))
15:11lazybotjava.lang.NumberFormatException: For input string: "Ⅼ"
15:12hellofunksdegutis: probably many ways but you could just reduce over the string and add each char to a set which automatically removes duplicates, check for set inclusion in your reduce fn.
15:12sdegutishellofunk: nice
15:12llasram,(into #{} "um, like this?")
15:12hellofunksdegutis: i'm sure there are other oways
15:12sdegutisoh wait
15:12sdegutisthis
15:12clojurebot#{\space \e \h \i \k ...}
15:12sdegutis,(= (set "foo") #{\f \o})
15:12clojurebottrue
15:13sdegutisduh lol
15:13llasramhaha
15:13llasramEven better
15:13sdegutisthanks everyoen for your help
15:13sdegutis,#{#{\@ \% \- \.} #{\@ \.} #{\@ \% \.} #{\@ \- \.}}
15:13clojurebot#{#{\@ \.} #{\@ \% \.} #{\@ \% \- \.} #{\@ \- \.}}
15:27gfredericksjust made an alternative to test.check's prop/for-all that handles the bindings differently: https://github.com/gfredericks/test.chuck#properties
15:28tomjacklooks like it exposes the generator monad?
15:29tomjackbrilliant
15:29tomjackI wrote something like that which didn't handle :let and :when. thank you!!!
15:29gfredericksbasically; it's based on another macro that does that as a generator rather than a property
15:29slipsetBurrito!
15:29gfrederickstomjack: see this for the generator variant: https://github.com/gfredericks/test.chuck#for
15:30gfrederickstomjack: it also has :parallel for doing gen/tuple
15:30tomjackpretty awkward to deal with generators which take generated values as parameters without something like that, I think
15:30gfredericksyeah I've used it pretty heavily
15:36tomjackI've wondered if maybe the generator monad should be made a bit more like core.logic's monad?
15:36tomjacke.g. (gen/sample (gen/bind gen/nat #(gen/such-that even? (gen/return %))))
15:36tomjackshould that fail..?
15:37gfredericksI don't think so...does it?
15:37gfredericksor wait
15:37gfredericksis this a such-that thing?
15:37gfredericksgotcha
15:37tomjackyeah, isn't that how your :when works?
15:37tomjackbasically I want fair conjunction I think
15:38gfredericksyeah, if you went out of your way to write it that way
15:38gfredericksI've pondered an extra feature that would let you group things for applying the :when more selectively
15:39gfredericksI haven't actually needed different :when granularity very much
15:39tomjackI was trying stuff like "generate an active domain, then bind and generate some stuff from the domain such that certain conditions hold"
15:40tomjackbut if the conditions can't be satisfied for any active domain, it breaks
15:40tomjackI mean, if for some active domain, the conditions can't be satisfied at all
15:40gfredericksright
15:40gfredericksso the question is if you can recognize those kind of domains
15:40gfredericksand filter early with that
15:40gfredericksif not, then yeah you need different granularity
15:41gfredericksI was thinking the syntax could be (for [:group [domain gen-domain, stuff (gen-stuff domain)] :when (...)] ...)
15:41gfredericksbut couldn't decide what the keyword should be called. :group? something else?
15:42gfredericksthere might have been some trickier aspect that I can't even remember at the moment
15:42hellofunkanyone know where the term "list comprehension" came from? it seems like an odd term. is it from lisp heritage?
15:43tomjackI think it's from http://en.wikipedia.org/wiki/Axiom_schema_of_specification
15:43hiredmanhttp://en.wikipedia.org/wiki/Set-builder_notation
15:43amalloyhttp://en.wikipedia.org/wiki/List_comprehension#History
15:43justin_smithhttp://en.wikipedia.org/wiki/List_comprehension#History
15:43justin_smithhaha
15:43hellofunkholy wow
15:43hellofunkyou guys are on top of it!
15:43amalloyso uh, tldr the internet is not a hard place to find things
15:43hellofunksigh.
15:44gfredericks:group seems like a decent name now that I think about it
15:45tomjackthat means (for-all [[domain stuff] (for-all [domain gen-domain, stuff (gen-stuff domain)] [domain stuff]) :when (...)] ...) ?
15:46gfrederickss/for-all/for/ but yeah
15:51mspohey can someone show me how to configure connection pooling with mysql on org.clojure/java.jdbc?
15:52justin_smiththe mysql part isn't relevant btw - it's the same for any jdbc driver - one minute, there's a good example out there I can dig up
15:53justin_smithmspo: https://github.com/niwibe/clojure.jdbc-c3p0 this lib makes it very easy
15:54justin_smithmspo: this shows how to do it via interop http://clojure-doc.org/articles/ecosystem/java_jdbc/connection_pooling.html which is not super hard either
15:57mspothanks
15:58hellofunkanyone used Julia?
16:01cddrI want to process a map recursively, collecting the values into a flattened sequence after running each one through a fn. Is that something I could/should use clojure.walk/walk for?
16:02amalloyprobably not. just mapcat+recursion
16:08justin_smithtree-seq could be an option if you filtered out the leaves ##(remove coll? (tree-seq coll? seq {:a 0 :b [1 2 3 [4 5 [6]]]}))
16:08lazybot⇒ (:b 1 2 3 4 5 6 :a 0)
16:08zactsis there a way I can reload a core.clj within a lein repl, without actually killing and restarting the repl?
16:08amalloyjustin_smith: that's just flatten
16:08amalloyzacts: (require 'my.ns :reload)
16:08justin_smithamalloy: nope ##(flatten {:a 0 :b [1 2 3 [4 5 [6]]]})
16:08lazybot⇒ ()
16:09justin_smithmaybe flatten + seq?
16:09amalloyjustin_smith: yes, yes, a slightly improved version of flatten in that you use coll? instead of sequential?
16:10mgaarezacts: also can look at clojure.tools.namespace for the Big Guns (reloads all namespaces that have changed and their dependencies in the right order)
16:13zactsoh thanks!
16:13justin_smithamalloy: now I must take a hard look in the mirror and accept the fact that I have written a slightly improved version of flatten
16:13noonianzacts: also (require 'my.ns :reload-all) if code changed in a file required by my.ns
16:13amalloyjustin_smith: or just break the mirror. some things are worse than seven years' bad luck
16:13justin_smithhaha
16:15zactsoh is it a single quote?
16:15zactsnot 'my.ns', but 'my.ns ?
16:15zactsI'm getting an error
16:16amalloyzacts: 'foo' is pretty much always wrong in clojure
16:16noonianyes, the single quote in clojure is used to suppress evaluation, and is syntactic sugar for (quote my.ns). You don't need it if you are doing this from inside the ns form
16:17hellofunkwhat's an approach to a functional lens in clojure? how would one do that?
16:17noonian,foo
16:17clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:17noonian,'foo
16:17clojurebotfoo
16:18amalloyhellofunk: for simple lenses, update-in and get-in basically handle it all; for complex lenses nobody really bothers
16:18BobSchackhellofunk: Here's an article about strongly typed lenses http://blog.podsnap.com/tinhole.html
16:18hellofunkamalloy: cool i follow you
16:21{blake}Is there a string formatting utility such that "The :speed :color :animal jumps!" would come out as "The quick brown fox jumps!" when passed a map of {:speed "quick" :color "brown" :animal "fox"}?
16:21hellofunkamalloy: http://stackoverflow.com/a/21293171/3758484
16:22stuartsierra{blake}: yes, string-interpolation in core.incubator
16:23{blake}stuartsierra: Thank you!
16:23{blake}(inc stuartsierra)
16:23lazybot⇒ 18
16:23hellofunkamalloy: most interesting quote: "Importantly that means that we can be sure when we have a true lens that datatype descent cannot fail—that kind of guarantee is impossible to make in Clojure."
16:25amalloyso you've been reading about haskell like you planned, hellofunk?
16:25hellofunkamalloy: i have. but mostly going above languages in general to read more about functional theory
17:28{blake},(let [f0 "C:\\long\\fn.ext" f1 (apply str (take (.lastIndexOf f0 ".") f0))] (apply str (drop (inc (.lastIndexOf f1 "\\")) f1)))
17:28clojurebot"fn"
17:28{blake}Seems cumbersome.
17:30Mr0rris0what is it
17:31{blake}Strips a (Windows-style) path of all but the filename.
17:32{blake}You start with a string, which gets turned into an array as you use take, which you turn into a string again, and then turn back into an array with drop, then turn back into a string.
17:39TMA,(defn foobar [f0] (let [f1 (apply str (take (.lastIndexOf f0 ".") f0))] (apply str (drop (inc (.lastIndexOf f1 "\\")) f1))))
17:39clojurebot#'sandbox/foobar
17:39TMA,(foobar "c:\\long.ext\\extensionlessfilename")
17:39clojurebot"long"
17:40TMA,(foobar "c:\\long\\extensionlessfilename")
17:40clojurebot""
17:40chouser,(let [f0 "C:\\long\\fn.ext"] (second (re-find #"([^\\]*)\.[^.]*$" f0)))
17:40clojurebot"fn"
17:41amalloy{blake}: why are you doing this with strnigs at all?
17:41chouser,(let [f0 "C:\\long\\noext"] (second (re-find #"([^\\]*)\.[^.]*$" f0)))
17:41clojurebotnil
17:41{blake}I think I have a line (lein?) on what might be causing my Compojure access errors: When I run "lein new compojure app" and then "lein ring server" on the result in a HEADLESS enviornment, I get an X11 error...like it's trying to open a display.
17:41{blake}amalloy: 'cause that's what comes to me? A filename string?
17:41amalloymake a java.io.File, ask it for the filename-part
17:41kodumuloLooking for a streaming http client library. I'm looking at a chunked request. I tried http-kit and clj-http and they both seem to block rather than returning some sort of stream
17:42kodumulochunked response*
17:42dakronekodumulo: clj-http will return a stream if you use {:as :stream} with it, then you can read as you need
17:42amalloy,(.getName (java.io.File. "/foo/bar/baz.txt"))
17:42clojurebot"baz.txt"
17:42kodumulodakrone: (def foo (client/get "http://localhost:9090&quot; {:as :stream})) is blocking my repl
17:43amalloywill do the same thing on windows, for windows-style paths
17:43{blake},(.getName (java.io.File "C:\whatever\what\os.txt"))
17:43clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported escape character: \w>
17:43chouser,(.getName (java.io.File. "c:\\foo\\bar\\baz.txt"))
17:43clojurebot"c:\\foo\\bar\\baz.txt"
17:43{blake}amalloy: If I'm running on Linux and getting a Windows path?
17:43{blake}amalloy: (I mean, I didn't think of it. But wondering it hat would cause trouble.)
17:43{blake}er, if that
17:44amalloywell it won't do anything very useful then
17:44kodumulodakrone: might be the servers fault though, thanks
17:44{blake}amalloy: Because it's assuming the path is going to be native?
17:45amalloyyeah more or less
17:45{blake}(And why wouldn't it. I only have to do this because, apparently, IE gives the whole path where other browsers just give the filename.)
17:45{blake}So, yeah, last segment between \ and . (Extensions required.)
17:46kodumuloAh its working now
17:59{blake}So, why would a brand new compojure app generate this? "No X11 DISPLAY variable was set, but this program performed an operation which requires it".
18:00hiredmanyou are loading some java library that is trying to do gui stuff
18:00amalloybecause lein ring server attempts to open a browser window and navigate to your server, for some misguided reason
18:00Mr0rris0is that just another name for clojure?
18:00hiredmanlein ring has some really terribel stuff :/
18:01{blake}amalloy: Oh, sure. It does that locally, but it can't do that on my remote headless server.
18:01amalloymhm
18:01{blake}Dammit, I thought I was on to something.
18:01amalloyonto something?
18:01{blake}Yeah, because I get access errors when I run locally.
18:01hiredmandon't use lein ring to run your app
18:02{blake}hiredman: Locally? Why not?
18:02hiredmanwhen doing dev, sure
18:02{blake}And it's not my app, per se, it's any Compojure app.
18:02hiredmanI mean, it is kind of terrible still
18:02hiredmanit adds all kinds of middleware and behaviour that will trip you up when it is different without it
18:02{blake}hiredman: Using Wildfly in production.
18:03hiredmanok, no worries then
18:03{blake}Well, different worries, anyway.
18:03hiredmanwell, it is almost certainly lein ring trying and failing to open a browser
18:04hiredmanso just do lein ring server-headless or whatever it is and you'll be fine
18:04{blake}hiredman: Yeah, and that might be why I get local errors, too. For some reason, lein does not have permission to do that all of a sudden.
18:04hiredmanbut in theory, it could be some other random code loading java.awt or something
18:05{blake}Bingo!!
18:05hiredmanwhich, well, I think incanter might do that
18:05TEttingeryeah
18:05{blake}Well, that's a relief.
18:05hiredman(for the graphing stuff)
18:05{blake}I was getting it with a compojure starting template.
18:05{blake}So it's just a weird Windows thing. I no longer care. =P
18:05hiredmanthere is a command line option you can pass to java to use the headless version of the gui toolkit too
18:06hiredmanI forget what it is
18:06amalloyit varies by OS i think, hiredman
18:06amalloyoh or i think i'm thinking of something else
18:06hiredmanhttp://stackoverflow.com/questions/2552371/setting-java-awt-headless-true-programmatically
18:08{blake}Good to know.
18:51justin_smith{blake}: yeah, compojure uses awt to use the desktop stuff to make the browser open a page on startup
18:52justin_smith{blake}: oh, and I see someone already said that
18:56LewixIn terms of trend Go is pulverizing clojure
18:56Mr0rris0ya?
18:56Lewixyup
18:56Mr0rris0whats go
18:57Lewixmore people use it , and it's growing faster
18:57LewixMr0rris0: the new google language
18:57Mr0rris0oh
18:57Mr0rris0im just starting to learn something, anything really
18:57tbaldridgewell shoot, I guess I'll just stop programming clojure then...gotta go with the trends
18:58LewixMr0rris0: are you new to the world of programming
18:58Mr0rris0yes
18:58Lewixtbaldridge: yea do that
18:58hellofunkwise man once said somewhere that a language's popularity can be approximated by its number of starts on github. in which case Go is about tied with Julia, which I'd never heard of before this evening, both of which are significantly more starred than clojure
18:58hellofunk*stars
18:58Mr0rris0im trying to understand what these vecters are about with the graph theory, not sure why though
18:59Lewixhellofunk: i wonder what attracks people to Go as opposed to clojure and vice versa
18:59justin_smithLewix: the languages have very little in common
18:59metellusI'm not sure it's fair to assume that all languages will have github representation proportional to popularity
18:59tbaldridgeLewix: could be nothing more than PR. Google is a tad bigger than Rich's team
18:59LewixMr0rris0: graph theory? why did you choose clojure to start with in the world of programming
19:00hellofunkLewix: a significant part of Go was simply added to Clojure as a single library, so that breaks down the power of the languages pretty clearly
19:00tbaldridgesame with Rust, the language isn't even finished, but Mozilla keeps hyping it so much it's gaining traction
19:00Mr0rris0its just something a guy un here mentioned having to do with a game
19:00Lewixhellofunk: well , do you know go at all?
19:01hellofunkLewix: never used it, just going off others' remarks and articles
19:01amalloyblack plays first, you want to surround territory and capture stones
19:01LewixI stumbled across a few block of people moving from clojure to goland
19:01Mr0rris0well i was looking for places like this one and found it
19:01justin_smith(inc amalloy)
19:01lazybot⇒ 219
19:01tbaldridgeI've played around with it a bit, it's cool and all, but not even close to the reach that a JVM based language gets.
19:01Mr0rris0clojure was just a chat when i looked at the more than 15,000 freenode channels
19:01Mr0rris0its alphabetical so thats prett much why
19:01Lewixaha
19:01Mr0rris0:D
19:01Lewixnice
19:02Mr0rris0yup
19:02amalloywe'd get more uptake if rich had had the foresight to name this language Aardvark
19:02Mr0rris0there was a room and it was named something closer to A than Z
19:02Mr0rris0yup
19:02hellofunkam i imagining it or is there a proliferation of new programming langauges these last few years, coming into the scene at a faster clip than previous decades
19:02Mr0rris0Aardvark++
19:03tbaldridgeforget it, I'm going to program in APL
19:03Mr0rris0probably not imagining it
19:03LewixI think it's all about easy and simple
19:03LewixGolang is both
19:04Mr0rris0if it works it works
19:04Lewixclojure might be simple but it's not easy
19:04Mr0rris0that may be an asset in the long run
19:04tbaldridgeI'd debate the whole "go is simple" thing. It has mutability through the entire thing
19:04tbaldridgeOOP languages are not simple, let alone those that embrace CSP
19:04Lewix tbaldridgei won't listen if you never played with go
19:05justin_smithLewix: few of my criteria that led to choosing Clojure apply to golang. It isn't a lisp, it isn't designed to make functional programming easy to do, it doesn't support programming against interfaces. The only things it has going for it is not being heavily OO and having a smart setup for concurrency, as far as I am concerned.
19:06Lewixand for people who don't like java like me it takes a lot to convince us to learn clojure - so far so good , i enjoy it
19:06Mr0rris0if its easy everyone does it depends on what side of the racket your on as to that being good or bad
19:06Lewixjustin_smith: what do you mean by programming against interfaces?
19:07hellofunkjustin_smith: just started watching this. first big point he makes is about how important interfaces are in Go: https://www.youtube.com/watch?v=ytEkHepK08c#t=73 though i'll have more idea what he's talking about in a few minutes
19:07justin_smithLewix: code where concrete types rarely matter, and instead you can code in terms of an interface any type could implement.
19:07justin_smithhellofunk: interesting, I could be wrong on that point then
19:07{blake}Lewix: If you don't like Java, there's always ClojureScript and ClojureCLR.
19:08Lewixjustin_smith: yes you're wrong about that
19:09Lewix{blake}: well I'm currently learning clojure, and I like it with the very basics stuff I learned so far - it's just at some point when ill be more fluent im pretty certain ill encouter java code while debugging
19:09hellofunkLewix: {blake}: i don't think liking/knowing or not-liking/not-knowing Java has much relevance to whether one should/could use/love/learn Clojure. I've never used Java in my life and continue to avoid it despite working in Clojure all day
19:10Lewixhellofunk: I think it depends on the type of work you do
19:10justin_smithLewix: java code never shows up in debugging. Java stacktraces sure, but not java code.
19:10{blake}Lewix: I've encountered Java code but never while debugging. Just put up a big project using POI.
19:10{blake}Which was awesome, because I got to leverage Java without having to use it.
19:10Lewixhey guys im not arguing against clojure
19:10justin_smithLewix: but the code and documentation is good enough in quality generally that you don't need to read java to fix your bug, unless you were writing java.
19:10{blake}hellofunk: I agree. I leveraged it. Was happy to have it.
19:10Lewixjust saying try Go you'll also love it
19:11{blake}Lewix: Oh, I didn't think you were. A lot of newcomers seem to have that reservation, vis a vis Java, is all. And it's only as relevant as you want it to be.
19:12LewixBlake1: most libraries use java , the whole point of being on the jvm is to take advantage of it
19:12{blake}Just saying: I had a major win here by implementing an Excel/Java thing without having to use either Excel or Java.
19:12amalloywell if i use clojure i might encounter java code, but if i use go i will definitely encounter go code
19:12Lewixif you're the kind of programmer that tweek libraries, doesn't it make sense you'd encouter java
19:13{blake}Lewix: Sure. But it's not necessary. The other big project I manage goes nowhere near Java.
19:13{blake}amalloy: BaZING!
19:13LewixI didn't say it was. I said in my use case it matters
19:13Lewixso I had to suck it up
19:14hellofunkman this Go syntax is looking a lot like C. i think lisp has really spoiled me.
19:14Lewixamalloy: are you a go dude
19:14dnolenLewix: people here are familiar with Go especially its concurrency model and we love that part, but given its unquestionably weak support for functional programming I don't think you're going to find many converts in #clojure
19:14Lewixhellofunk: it sure does
19:14Lewixaha
19:15Lewixdnolen: well if you're closed minded that is
19:15hellofunklol
19:15clojurebotGabh mo leithscéal?
19:15{blake}But will Go be as successful as Dart?
19:15Lewixdnolen: i came across great blog post about people who are very active with clojure who love go and vice versa
19:15hellofunkif dnolen is close minded then i'm an elephant taking a massive shit on the moon
19:15{blake}lol
19:16LewixI don't understand how people can argue or pretend to when they never used what they're aguing against
19:16LewixI fail to understand that
19:16justin_smithLewix: there are thousands of languages I could go learn. I'm here because I use Clojure.
19:16Lewixexactly
19:16hellofunkLewix: Go's async abilities are very well understood in the clojure community because of core.async, so it's not total ignorance
19:17dnolenLewix: I've used Go, just never in anger, and I tried it enough to respect it but have zero desire to use it in anger
19:17hiredmanI started writing a lisp to go transpiler, and wrote a minikanren port to go, I hated it
19:17Lewixhellofunk: well it doesn't represent the whole language, so criticizing or assuming you won't like it because you're a "functional guy" is closed minded IMO
19:17hellofunkLewix: i never said anything like that
19:18Lewixhiredman: I see. your opinion count then =)
19:18Lewixhiredman: at least you know both
19:18justin_smithLewix: I've done imperitive code, rejecting it again isn't close minded.
19:19Lewixjustin_smith: it is, the fact that people don't wanna try functional programming is because they think about lips and close their mind to other options such as scala or #f, or clojure
19:19hiredmanI started the lisp transpiler precisely because I was interested in go's concurrency, but the runtime was/isn't dynamic enough
19:20hellofunkLewix: i will say this, i've rarely encountered someone anywhere who has used a lisp for a long time who didn't want to stick with it after seeing how it works, because other languages just don't quite feel the same to a lisper
19:20hiredmanI did the minikanren port, because part of the justification for the lisp to go compiler was "oh, maybe I can make this lisp stuff more available to go", but then I thought "I could just do it in go" so I did
19:20hiredmanthe datastructure related work for minikanren was really painful
19:20imancwhy would someone define a function like this? (defn foo [& [a b c]]... )
19:20hiredmanI imeplemented a redblack tree for a persistent map
19:21justin_smithimanc: if they don't actually care about the argument count
19:21justin_smithimanc: and will just fill in unsupplied args with nils
19:21hiredmango is not a great language for custom data structures
19:21hiredman(fighting or ignoring the type system)
19:23imancjustin_smith: so presumably a, b, c will be assigned the first 3 params, anything else will get discarded?
19:23Lewixhiredman: I see. I give myself a few weeks with clojure - I was attracted to it mainly because of machine learning
19:23hiredmanhave fun, it is a blast
19:23Lewixhiredman: go lack the ecosystem / the libraries etc
19:24Lewixthanks
19:24noonianI don't agree with the premise that functional programming with immutable values and imperative programming with mutation is merely a matter of taste. I believe there are real technical advantages to avoiding mutation.
19:24noonianimanc: yep, exactly
19:25{blake}Lewix: What's kind of cool about Clojure is that people will wrap up other language libraries and make them better.
19:26{blake}(Or at least arguably so.)
19:26Lewix{blake}: really? good to know
19:26imancso why not just do (defn foo [a b c & _] .... )
19:26Lewix{blake}: it reminds me of ruby
19:26{blake}Lewix: Yeah. So you may find, if you dig around in libraries, you're more inclined to stay out of the host environment.
19:26justin_smithimanc: that would not accept (foo a)
19:26justin_smithimanc: the other def will
19:27noonianimanc: the original one allows you to call it like (foo a) without throwing an exception as long as the body can deal with nil arguments gracefully
19:27justin_smithimanc: in fact, it would even work as (foo)
19:27imancahhh.. .awesome!
19:28{blake}Lewix: I came from Ruby (i.e., that was the language I was using professionally) and while Ruby was easier to get started in, Clojure has been easier to get to the details of.
19:28Lewix{blake}: im gonna use it then if i like it convince my team to use it for our next service
19:28{blake}Lewix: Go for it. It's worth it just for the discipline and the mindset.
19:28Lewix{blake}: i'll have to fight someone else who's learning go (and people in the office who like go including me)
19:29Lewix{blake}: oh great - i also started with ruby, and use it mostly
19:29{blake}I think I listed a dozen languages yesterday I'd programmed in, and I liked most of them. It's okay to like multiple things. Just ask yourself: What choice makes you a better programmer?
19:29Lewixruby gets messy
19:29Lewix^^
19:30Lewix(rails)
19:30Lewixok guys enough talking clojure time
19:30Lewixthanks for the useless chitchat
19:30Lewixalways good for relaxing :)
19:31{blake}Lewix: Good luck.
19:32kir"Clojure Is the New C" - interesting take on why Clojure
19:37justin_smithkir: link?
19:38hellofunkkir: i wonder if that article suggests that like C, Clojure is a good tool to build other tools (i.e. languages) with
19:39amalloyjustin_smith: it looked to me like another talk by bob martin based on wholly unsubstantiated claims
19:43hiredmanamalloy: no different then many other claims made every day about programming here and elsewhere
19:43hiredmanthan
19:43hiredmanthen?
19:43justin_smiththan is the comparitive
19:43hiredmanbut new c seems really weird
19:44amalloyhiredman: i dunno about "no different than". bob reaches for some grander claims than most
19:44justin_smithoh that one
19:44justin_smithhaha
19:44hiredmanI do want a c to jvm compiler
19:44amalloyanyone remember "the last programming language"?
19:44hiredmanvaguely
19:45amalloyin which he claims that clojure is so perfect it could realistically be the last programming language anyone ever invents
19:45amalloyor uh something like that. it's been a while since i listened to it
19:45hiredmanwell, I mean, that is pretty spot on, no?
19:45hiredman:P
19:46hellofunkamalloy: someone needs to show him the Sussman lecture about how all programming langauges we have are already obsolete
19:47noonianI find him fun to listen to even if I don't always agree with him
19:52{blake}The last programming language was COBOL.
19:53{blake}So easy, even your secretary could write programs.
19:53justin_smiths/secretary/boss
19:54justin_smitha big motivation was the theory that management would actually be able to read the code
19:54hellofunki still remember my elementary school librarian telling me about her Cobol work history
19:55{blake}My dad told me one of his clients gleefully told him how COBOL would make his services unnecessary.
20:15hellofunkwhat would it entail to lauch a local web server like normal from the REPL and have other computers in the same home/office network have access to what it serves
20:15justin_smithhellofunk: give them a URL with your port number in it, and be sure your firewall settings leave that port open
20:16justin_smithhellofunk: we would do that a lot at the web shop I used to work at
20:16justin_smithhellofunk: also, with linux and OSX at least, the machine will set it up so other people can navigate to http://your-host-name.local
20:16justin_smithfor whatever the name of your machine is
20:16hellofunkyou make it sound pretty simple
20:17justin_smithit is!
20:17hellofunkcool
20:17justin_smithIDK about windows though
20:17justin_smithI think windows makes these things harder
20:17hellofunkon OSX i wouldn't think the default is to just let any other machine access what you serve, is it?
20:17justin_smithbut linux / osx, very simple
20:17amalloyhellofunk: just depends what interface you bind your server to
20:18amalloyif you bind to localhost, then no; a public ip, then yes
20:18justin_smithhellofunk: on the contrary, if you don't make some effort to run a network service local only, other machines on your local network can access it
20:18hellofunkinteresting.
20:18justin_smiththough yeah, for example nrepl binds to localhost, for good reason
20:22kirjustin_smith : pardon the late reply(phone) : the link : http://www.infoq.com/presentations/clojure-c
20:23justin_smithkir: yeah, found it in the meantime, thanks
20:26kirmy take: clojure is more complex then C/Go(feature wise - has much wider abstraction); much of what exists in Clojure can be and inevitabily will be duplicated in those langauges(as can be said for assembler vs C)
20:28kir... clojure provides feature and implements them in a highly consistant and integrated manner - far better then those languages could; accept the initial conceptual learning curve, become a better programmer, use Clojure
20:29kirfeatures*
20:30AeroNotixwhat's that library for converting between naming styles?
20:30AeroNotixlike fooBar -> foo-bar
20:30justin_smithAeroNotix: camel-snake-kebab
20:30AeroNotixjustin_smith: thanks!
20:30justin_smithor was it camelSnake_ke-bab
20:30justin_smithsomething like that :)
20:31AeroNotix:)
20:32zactskir: key point asm > clojure :-D
20:32zacts(joking)
20:34kirzacts
20:34kirasm?
20:34justin_smithI think we should bring back the old rule about Haskell, but for evangelism in general
20:34justin_smithkir: assembler macros for generating machine code
20:35zactssorry kir I misread your post, I was trying to make a joke off of it
20:35tomjackwonder why they didn't use Guava
20:35zactsIt was to say that I thought the post was putting down clojure
20:35zactsso I said, oh well that proves asm > clojure as a joke
20:35kirzacts: k
20:35zactsbut I had the post all wrong anyway
20:36kirzacts : yep :)
20:41kirWanted to add before I go: I'm comming from C++ and recently Go - learning Clojure makes me a more concise and more thoughtfull programmer in those languages; for what it's worth.
20:43zactsindeed
21:14dnolenmethinks needs Figwheel https://www.dropbox.com/s/0o6pa3jdsueeovc/react-native-editing.mp4?dl=0
21:19tomjackhuh. I don't think the idea of writing native apps in cljs had occurred to me
21:20tomjackI thought apple required using objc?
21:23dnolentomjack: not since iOS 7, official JavaScriptCore bridge
21:23dnolenalso React Native works for Android
21:23dnolen(though that work is still underway)
21:23tcrayford____dnolen: isn't official jscore *really* slow?
21:24tcrayford____(iirc there's still no JIT in the javascriptcore that you can use inside apps)
21:27dnolentcrayford____: not true anymore as far as I know
21:28dnolentcrayford____: and the JSC fast interpreter was never slow, but anyways JIT is on now from what I've heard
21:28dnolentcrayford____: FB Groups app is already React Native only
21:28tcrayford____damn
21:29tcrayford____(to be fair, last time I used JSC was in 2011)
21:29cflemingdnolen: Unfortunately seems to be confirmed that there's no JIT for standalone JSC - not an issue for 99% of apps though.
21:29dnolentcrayford____: it's a come a very, very, very long way in 4 years
21:29dnolentcrayford____: on many benchmarks for ClojureScript it is on par or besting V8
21:30cflemingdnolen: i.e. FB groups is obviously responsive and does no heavy lifting
21:30tcrayford____dnolen: yea, damn
21:31tcrayford____dnolen: it's used by safari right? guess that's all the impetus they need to sink a tonne of money into it
21:31dnolencfleming: ah K good to now, still I suspect for many applications modern JSC perf even non-JITed is great
21:31dnolentcrayford____: yeah JSC is the Safari / Mobile Safari engine, they've got some serious compiler heads on it now
21:32cflemingdnolen: yeah, no doubt. WKWebView does JIT on iOS 8, it seems: https://twitter.com/awfulben/status/561015998610821120
21:35dnolentcrayford____: https://www.webkit.org/blog/3362/introducing-the-webkit-ftl-jit/
21:36dnolenand SpiderMonkey is finally catching up too now that they have Generational GC
21:36tcrayford____dnolen: dope, thanks!
21:36cflemingdnolen tcrayford____ : I love that article, one of the most interesting things I've read in ages
21:36cflemingdnolen: on-stack replacement in JS engines is amazing.
21:37tcrayford____cfleming / dnolen like 3 (?) years ago I took several months off and studied the luajit source code intensively. Compiler optimization is such a fun topic
21:39cflemingtcrayford____: Nice, LuaJIT is an amazing piece of work.
21:40tcrayford____yeah, it's super intense. It's also amazingly readable (or was back then) - the whole thing is like 40k lines of C + 8k lines of assembly
21:47LewixI find it quite difficult to get going with clojure - what materials did you use to learn it
21:48LewixI tried a couple of different books but none of them hold my attention long enough
21:49justin_smithLewix: have you tried 4clojure or the clojure koans at all?
21:49Lewixi dont think so
22:09n0n3suchsometimes the best way to learn a language is to pick a project and dig in
22:09n0n3suchworked for me with scala
22:09n0n3suchready to try clojure now
22:28danlentzmonotonic timestamps
22:28danlentzhttps://gist.github.com/danlentz/301a0f056ffd9c6605a9
22:39gfredericksdanlentz: swap!+constantly = reset!
22:39danlentzyup. doh
22:39danlentzgfredericks: thanks
22:41gfredericksdanlentz: this smells racy
22:44TimMcgfredericks: That's the best way to suss out race conditions. Just run it a few times. :-)
22:45justin_smithgive it a head start
22:45danlentzyes, that is what has been working for me :)
22:45gfredericksyep looks like collisions
22:46gfredericksany kind of "deref the atom, the swap based on what you see" is racy
22:47justin_smithdanlentz: either put both stamps-this-tick and last-time inside a single map in an atom, or make them refs and use a transaction
22:47danlentzyeah
22:48sdegutisCan you do monads in Clojure?
22:48gfredericksand if you use a single atom you have to do the logic inside the swap function
22:48gfrederickssdegutis: it's less rewarding
22:48sdegutisgfredericks: why?
22:48justin_smithsdegutis: yes, but it performs poorly and it usually isn't especially useful
22:48gfredericksa) no type checker to fit the pieces together for you
22:48gfredericksb) the pertinent 0-arg functions don't work
22:48gfredericksI forget what they're called
22:49sdegutiscurry?
22:49sdegutisbind or something?
22:49gfredericksmzero and something else
22:49p_lI'd add reason 0 = You're trying to escape time-travel hell in your code
22:49sdegutisjustin_smith: why wouldn't it be useful?
22:49sdegutisTo be fair, I don't understand why monads are useful even in Haskell.
22:50gfrederickssdegutis: I think clojure's for syntax is a decent approach for lots of monadic things
22:50p_lsdegutis: because they simplify what was previously a rather convoluted mess
22:50gfredericksthere's just not a once-for-all impl of all the monad infrastructure like in haskell
22:50p_lbut generally, monads are much less useful if you don't have heavy slant on purity that Haskell has
22:50sdegutisp_l: oh
22:51p_lsdegutis: Monads in Haskell started out from a certain Glasgow extension for doing IO ;)
22:51sdegutisneat
22:51p_lwhich replaced declaring main to be a function that consumes future and spits past, or something like that
22:51p_l(actually it might have been the other way around)
22:52sdegutisweird
22:52sdegutisBut that's basically what monads seem like to me.
22:52p_lsdegutis: generally, Monads in Haskell are kinda a way to make impure seem pure
22:53gfredericksit's nice to have that stuff tracked in the type system though; e.g. the java type system has no idea where your side effects are
22:53justin_smithp_l: I'm pretty sure consumes past and returns future
22:53justin_smithyeah, and clojure monads aren't as useful because they can't segregate side effects really
22:53p_ljustin_smith: I recall it was a bit non-intuitive
22:54gfredericksbut this kind of syntax ends up being plenty useful even though it smells like monads: https://github.com/gfredericks/test.chuck#for
22:55gfredericksyou could make a similar thing for Maybe
22:55p_lanyway, pseudo-monads were a patch on ills of Haskell (Most of Haskell monads are not, actually, monads)
23:26tomjackdoesn't :let implement return?
23:26tomjackand :when is mzero
23:27tomjackbut only usable in 'for-notation', hmm
23:29tomjackwell
23:29tomjackonly need them otherwise if you want to write something monad-polymorphic
23:30tomjackwhich I guess could be quite useful..
23:37Mr0rris0i found an old book on basic
23:37Mr0rris0is that of any use?
23:38Mr0rris0was in the loft in my barn
23:38Mr0rris0it looks pretty old, its just a student handbook thing for learning basic
23:41Mr0rris0whats that long number mean (possibilities) (~possibili@2601:9:280:b6b:5126:6189:b7b2:4
23:41justin_smithlooks like a truncated ipv6 address
23:42justin_smiththere should be 3 more hex digits at least
23:42Mr0rris0lol no clue what that means
23:42justin_smithMr0rris0: domain names map to ip addresses
23:42Mr0rris0ya
23:42justin_smithipv6 uses a different format from ipv4
23:43Mr0rris0truncated?
23:43justin_smithtruncated means the end is cut off
23:43Mr0rris0oh
23:44justin_smith~foo@address is shortand for the user foo's home directory when you log into that address
23:44clojurebotRoger.
23:44Mr0rris0foo?
23:44justin_smith~forget foo@address
23:44clojurebotTitim gan éirí ort.
23:44clojurebotfoo is learn foo
23:44Mr0rris0whats foo
23:44Mr0rris0lol
23:45justin_smithfoo is the standard metasyntactic variable
23:45justin_smithin your example it was possibili
23:45Mr0rris0that bit before the @ sign?
23:45justin_smithso I was saying for any given name n ~n@address means the home directory of n when you log into address
23:46justin_smithyeah
23:48Mr0rris0i watched a little bit of that Go video
23:48Mr0rris0that one guy promoting Go alot earlier linked a youtube vid
23:49Mr0rris0i only got to see the first bit of it but it looked cool
23:49Mr0rris0i know so little but it seemed a little like the IRC
23:49Mr0rris0just in how it looked
23:49rhg135it's all nice until you call foreign-libs
23:49Mr0rris0how to work it ive got no clue but i managed to get little scripts going to run my game from irc
23:50Mr0rris0whats foreign-libs
23:50Mr0rris0whats it for
23:50rhg135erm, i meant any code you didn't write
23:50dmitrig01hey all! core.typed question. I’m using clojure.tools.logging, and when I do (log/error …), which is a macro that expands into a bunch of calls to other tools.logging functions… I’m fine providing them type annotations, but a bunch of them are methods on a protocol, and I don’t know how to annotate that
23:51rhg135mutability + code out of your control is a pain
23:51Mr0rris0like cutting stuff out and putting other things in?
23:51Mr0rris0whats mutability, i see that word alot
23:51rhg135things that can change basically
23:52Mr0rris0right i saw how it was hard to customize or edit things that had been done already
23:52Mr0rris0the stuff that is already in irc looks different than things people make for it
23:52rhg135it gets hard once you can call code and be unsure if you're data hasn't been changed
23:53Mr0rris0hmm
23:53Mr0rris0whats call code
23:53Mr0rris0remember all the shit and not need copy paste?
23:54justin_smithor more generally, to get a big picture view of what the invarients of a given piece of code might be. When things are immutable you know exactly where things propage (arguments and return values)
23:54justin_smithMr0rris0: when you use a function that you already defined, that's calling the function
23:54rhg135yes as justin_smith says flow becomes explicit
23:54justin_smiths/propage/propagate
23:55Mr0rris0this is aggrigatin
23:55Mr0rris0:P
23:56Mr0rris0i need a new dictionary
23:56Mr0rris0or just use the old one
23:56Mr0rris0:D lol
23:56Mr0rris0uncommon words to me
23:56Mr0rris0seems theres a few in everything i read about this stuff
23:59Mr0rris0its bugging me all of the things i dont know
23:59Mr0rris0lol but im happy about it, dunno why