#clojure logs

2015-09-07

00:39neoncontrails,(defn dedup [s] (map first (partition-by identity s)))
00:39clojurebot#'sandbox/dedup
00:39neoncontrails,(apply str (dedup "Leeeeeerrroyyy"))
00:39clojurebot"Leroy"
00:40neoncontrails@amalloy: 4Clojure #30 doesn't like the partition-by strategy you taught me yesterday :(
00:40neoncontrailssorry, uh
00:42neoncontrailsamalloy: quick question for you
00:53TEttinger(defn dedup-str [s] (apply str (map second (re-seq #"(.)\1*" s))))
00:53TEttinger,(defn dedup-str [s] (apply str (map second (re-seq #"(.)\1*" s))))
00:53clojurebot#'sandbox/dedup-str
00:53TEttinger,(dedup-str "Leeeeeerrroyyy")
00:53clojurebot"Leroy"
01:01amalloyneoncontrails: ?
01:03neoncontrailsIs there a missing constraint on 4Clojure #30? (see my solution above)
01:05amalloyno
01:06amalloyyou're using defn instead of fn
01:06Rurik_When I do (source def) I get nothing, why is that?
01:06neoncontrailsamalloy: Thanks!
01:07amalloyRurik_: imagine if java had a "source" function. what would you expect to find if you wrote source("while")
01:07Rurik_ah
01:07Rurik_so the def form is implemented in Java?
01:14ska-fanIs there a convention how to put units in symbol names? i.e age-in-seconds maybe age:s?
01:38kavkazska-fan: I don't know the answer to that. Perhaps there is. But perhaps the best thing to do is whatever is most self explanatory
01:38kavkazI don't think you'll be going against some sort of convention / idiom
01:38kavkazbut then again I'm not a Clojure veteran
01:43kavkazbbatsov, who created CIDER, has a pretty handy guide for Clojure style that I just ran into
01:43kavkazhttps://github.com/bbatsov/clojure-style-guide
01:43amalloyska-fan: if you can bear to be a little long-winded, you can encode the units in the value itself, instead of conventionally via the variable name: (def whatever {:unit :seconds :magnitude 5})
03:01felipedvorakGiven the following structure: loop>if>let>if>recur
03:01felipedvorakif the recur argument was defined in let, can the first if see it?
03:08felipedvorakhttp://pastebin.com/GYJ87Q5P
03:08felipedvorakthis is a clojure-bloody-beginner question but clojure beginner isn't active right now, I guess its night where you all live
03:08opqdonutI see your question
03:08opqdonutbut I don't really understand it
03:09opqdonuteverything inside a let sees all bindings made in the let
03:09opqdonutnothing outside the let can see it
03:10felipedvorakso where the "remaining-asym-parts" loses a part?
03:11opqdonutnowhere
03:11ClashTheBunnyHi, I was wondering if I could get some help remembering a project. It was based off of restructuring clojure’s core namespaces, but it was still syntactically the same. Can anybody remind me of it?
03:11opqdonutor more constructively, "remaining-asym-parts" becomes what "remaining" was on the call to recur
03:12felipedvorakopqdonut: so it does see remaining?
03:12felipedvoraksorry, my head is producing smoke right now
03:13felipedvorakI'm almost getting this after 10 hours trying to understand this function (not kidding)
03:13felipedvorakbut this single thing is still escaping me
03:13opqdonutfelipedvorak: loop-recur is just recursion
03:13opqdonutfelipedvorak: you could try writing out the recursive version of this code, without loop-recur, and see if it's simpler
03:16felipedvorakopqdonut: I don't even know what you're talking about hehe where can I understand recursion better?
03:16felipedvorakwould it be to just use "ifs" and anonymous functions to produce the same result?
03:17TEttingerfelipedvorak: I don't know how much you currently know about how recursion works? Also, I can understand some romance languages, but not nearly well enough to be able to read technical portuguese...
03:17opqdonutfelipedvorak: it's the difference between these two versions of factorial:
03:17felipedvorakTEttinger: hehe sorry for the portuguese but it isn't technical, its just me talking with myself trying to make sense of it
03:17TEttingeroh ok :)
03:18felipedvorakI have printed this code and glued it to my bedroom wall
03:18opqdonutfelipedvorak: (defn factorial [param] (loop [acc 1 n param] (if (pos? n) (recur (* acc n) (dec n)))))
03:18opqdonutoops
03:18TEttingerah, this is part of it. you use the same name, final-body-parts , as a local name in the let, and as a name for a loop variable
03:19opqdonutfelipedvorak: (defn factorial [param] (loop [acc 1 n param] (if (pos? n) (recur (* acc n) (dec n)) acc))) -- correct version
03:19TEttingerhm, you know that, nevermind
03:20opqdonutfelipedvorak: (defn factorial-helper [acc n] (if (pos? n) (factorial-helper (* acc n) (dec n)) acc)) (defn factorial [n] (factorial-helper 1 n)) -- recursive version
03:21opqdonutfelipedvorak: anyway, it seems to me if you're struggling with understanding loop-recur, you need to work with simpler code
03:21felipedvorakI just don't get where they connect to each other
03:21felipedvorakI mean, loop is almost a let, but it connects with something that changes it somehow
03:22felipedvorakat least as far as I can understand it hehe
03:22felipedvorakrecur "updates" the value of the new loop with the values it had in the end of the first run
03:22TEttinger,(def asym-hobbit-body-parts [{:name "head" :size 3} {:name "left-eye" :size 1} {:name "left-ear" :size 1} {:name "mouth" :size 1}])
03:22clojurebot#'sandbox/asym-hobbit-body-parts
03:23felipedvorakright?
03:23TEttingerI'll see what I can do...
03:26opqdonutfelipedvorak: if you have a (loop [x ... y ... z ...] ...) and somewhere inside it a (recur a b c), execution "jumps" to the top of the loop and now x has value a, y has value b, etc.
03:26opqdonutfelipedvorak: no other values from the previous iteration of the loop are visible any more
03:27felipedvorakopqdonut: hmmmm, wait, this was a very good explanation, let me look at the code a bit more, I guess its coming hehe
03:28TEttinger,(mapcat (fn [{:keys [name size] :as arg}] (if (re-find #"^left-" name) [{:name (clojure.string/replace name #"left-" "right-") :size size} arg] [arg])) asym-hobbit-body-parts)
03:28clojurebot({:name "head", :size 3} {:name "right-eye", :size 1} {:name "left-eye", :size 1} {:name "right-ear", :size 1} {:name "left-ear", :size 1} ...)
03:29TEttingermy advice is "don't use loop/recur until you are sure you need it"
03:30felipedvorakTEttinger: this is part of braveclojure.com tutorial.. I was getting everything but got seriously stuck by the end of the lesson
03:30TEttingerahhh...
03:31felipedvorakgot it
03:31felipedvorakvoila
03:31TEttingerwoohoo!
03:31felipedvorakjust like this
03:32felipedvorakhauhauh
03:32felipedvorakawesome
03:32TEttinger10 hours in it just clicks, heh
03:33felipedvorakwow
03:33felipedvorak4:33 am here
03:33felipedvorakprobably much more than 10 hours
03:33felipedvorakMy sunday was looking at this function
03:33felipedvorak:)
03:33felipedvorakI'm happy
03:33felipedvorakthanks to both of you
03:36felipedvorakits just like loop is receiving a new set of data from the outside to associate with its bindings :D looks so easy now but damn
03:39ClashTheBunnyDunaj! I found it!
03:41felipedvorakopqdonut: you nailed it with that explanation :) it should be in the documentation hehe
03:42felipedvorakwell, i'll take a shower and dream with symmetrical hobbits
03:42felipedvorakthanks again
03:44opqdonut:)
04:04PupenoWhen making Ruby on Rails applications I generally just throw active_admin into my projects to be able to edit records. My searches for something like this for Clojure turned up nothing (not unexpected). What tools do you use for CRUDing records?
04:06tdammersPupeno: the psql command-line client...
04:07Pupenotdammers: I find it much easier to edit records with an UI and my support person doesn't even know what a command line is.
04:07stainPupeno: just do it in the REPL..?
04:07stainin rails I would use rails console
04:08wasamasa^
04:08stainI wouldn't give a support person full access to the whole of the database
04:08Pupenostain: same thing I mentioned before. I'm not asking for a command line tool. I already have and know those. I'm asking for a UI tool, something at the active admin level or so.
04:09stainbut where is your data now..?
04:09Pupenostain: it's stored in PostgreSQL.
04:09newcljuserHi! I can't figure out why am I getting this dependency error even though I have already imported core.async. http://pastebin.com/C3pwfhmt
04:10wasamasagiven the way web development is done with clojure, I very much doubt there is such a standalone thing
04:10wasamasamaybe it does exist for the more framework-like approaches like luminus
04:10Pupenowasamasa: yeah, I agree.
04:10stainPupeno: any of these? https://wiki.postgresql.org/wiki/Community_Guide_to_PostgreSQL_GUI_Tools
04:10Pupenowasamasa: luminus is not a framework, it's just a template for the usual libraries, compojure and so on.
04:11tdammersPupeno: http://pgadmin.org/ <- this one isn't half bad
04:12Pupenostain: I'm not sure if my support person could use one of those. I do it myself. My problem with Navicat is that it lists all the databases, finding the one you want among the 1000s in Heroku is a pain. I tried PgAdmin for a while, but found it a bit buggy.
04:13PupenoI think I might just throw an empty rails app with active_admin in another server. But if I'm going to do that, I wonder whether there are better tools that would work like that.
04:14wasamasayou could just write your own admin route
04:14newcljuserPlease, can someone help?
04:15newcljuserthis is what my imports look like: http://pastebin.com/mPGu0b3u
04:15newcljuserI am using clojure 1.7
04:15Pupenowasamasa: that is one of the options, and I'm really tempted because it looks line fun, but I already spent way too much time building things to make up for missing stuff in the Clojure world that is already built in RoR; if I keep doing that, my business decision should be to go back to RoR instead of using Clojure.
04:15oddcullynewcljuser: i have my doubts that the version number there does any good
04:16newcljuserWhat should I do?
04:16oddcullynewcljuser: use clojure.core.async :as async :refer [ ... ]
04:17oddcullynewcljuser: and since you have added it here, i just ask: have you added it in your projects deps?
04:19newcljuser@oddcully yes
04:19newcljuserI am using clojure 1.7 though
04:23newcljuseroddcully: now I am getting this java.lang.Character cannot be cast to clojure.lang.Named
04:26roelofhello, what is wrong with this code : http://lpaste.net/140432
04:27lumayou destructure your point as a vector inside a vector
04:28oddcully,(name \a)
04:28clojurebot#error {\n :cause "java.lang.Character cannot be cast to clojure.lang.Named"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Character cannot be cast to clojure.lang.Named"\n :at [clojure.core$name invokeStatic "core.clj" 1527]}]\n :trace\n [[clojure.core$name invokeStatic "core.clj" 1527]\n [clojure.core$name invoke "core.clj" -1]\n [sandbox$eval25 invokeStatic "NO_SOURC...
04:28oddcullynewcljuser: if you relate this error with your code please
04:30roelofluma: oke , back to the drawing board and read manuals how to destruct this properly
04:32oddcullyroelof: && looks out of place
04:32roelofIf I change it to this : http://lpaste.net/140433 i cannot xp
04:33roelofoddcully: what I try to say it that the xp must be between x1 and x2 and yp must be between y1 and y2
04:34oddcullyroelof: in the last one your let []-brackets are off
04:38roelofoddcully: thanks, again back to the manual
04:41roeloffound it. The good answer is this : http://lpaste.net/140434
04:56gargsmsI am authenticating my routes with friend. I used the friend/authenticate wrapper. When I access /login with the correct authentication params, I receive a response from /. But when I try to open the routes wrapped in friend/authenticate without any params, they function just fine.
04:57dstocktongargsms: think you have to wrap the routes in authorize
04:58dstocktonhttps://github.com/cemerick/friend#authorization
05:19gargsmsdstockton, I don't have any roles defined as such. Can I still use authorization?
05:19tdammersq: can I somehow make it such that stack traces include full filenames instead of just the basename?
05:19dstocktongargsms: i don't think so
05:19tdammers"core.clj" isn't exactly helpful usually
05:20dstocktoni don't know honestly, but you can just define one role
05:20dstocktonthat everyone has
05:20gargsmsThe problem is that I am reading my users from a DB and there I haven't defined any roles
05:22dstocktongargsms: you probably have a get-user type function that returns a map
05:22dstocktonjust assoc on a role for everyone
05:22dstocktonafter fetching the rest from the db
05:23gargsmsi will try that now
05:23dstocktonprobably what i'd do, then you can easily replace it with a real role from the db if you wanted them later
05:27amalloytdammers: you can infer the filename from the name of the class in the stacktrace
05:27amalloyit's not ideal i admit, but enough informatio is there
05:27tdammersamalloy: yeah, hmm, figured it out
05:28amalloyeg, the file is core.clj but the exception is being thrown from clojure.core$inc
05:28tdammersthe actual stack trace, the part that I'm interested in, is three screens up
05:28tdammersyeah, got it
05:28tdammersjust got thrown off by this helpfully colored stack trace
05:28tdammerswhich turns out to be the part that I don't need; the interesting part is what gets dumped *before* that
05:29amalloy*shrug* sometimes. i usually find the most interesting part is the top line of the bottom-most exception. but it depends
05:30tdammersit seems that in this case, there is some sort of exception handler hooked into the app that is supposed to produce helpful debugging output in the browser, but that thing itself is throwing
05:32PupenoI’m doing some performance testing of my Clojure app, and it seems the bare minimum will happily eat 350MB of RAM (Jetty with 6 threads, the minimum). As soon as I add Nashorn, it jumps to >512MB. Is this common or am I experience a problem here? Clojure/Java being memory hungry might have an effect on whether I use Heroku or not.
05:36kwladykaPupeno, try load only Nashorn and check how many MB consume
05:38Pupenokwladyka: how would you do that? what would be the goal?
05:39kwladykaPupeno, i don't know. I don't use Nashorn :)
05:40kwladykaBut maybe just Nashorn consume this memory. It sounds like that.
05:40Pupenokwladyka: I don't mean how do I measure memory usage. What I have is coming from New Relic.
05:40Pupenokwladyka: I'm pretty sure it's Nashorn consuming that memory.
05:42kwladykammmm so what is the question?
05:42PupenoI already deployed my app with Nashorn disabled and my testing reported the numbers I already mention. I don't want to re-measure Nashorn, I want to know if this numbers are what to expect.
05:43PupenoIs it common from a bare minimum compojure app to take on 350MB of ram. Is it common for a library or a few libraries to push it beyond 512MB?
05:43kwladykaok, so i don't use Nashorn so i guess i can't tell anything more.
05:43Pupenook.... let's try again.
05:43kwladykaPupeno, 350 MB in REPL or as jar?
05:44Pupenokwladyka: RAM.
05:44PupenoI’m doing some performance testing of my Clojure app, and it seems the bare minimum will happily eat 350MB of RAM (Jetty with 6 threads, the minimum). Is this common or am I experience a problem here? Clojure/Java being memory hungry might have an effect on whether I use Heroku or not.
05:44kwladykaPupeno, yes but are you running your app in REPL or as jar file?
05:44kwladykaREPL consume more and it is slower
05:44Pupenokwladyka: a jar file as far as I know... Heroku runs the uberjar.
05:44kwladykaif you want have real result test it as jar file
05:45PupenoThis is New Relic instrumentation of my app, as real as it gets. And when the app is actually doing something, it goes above 512MB, which I can see in the graphs and in Heroku throwing out-of-memory errors.
05:46kwladykaPupeno, what i can say i have experience only with performance test on my local machine with one algorithm. And what i can say from that:
05:47kwladyka1) i had problem with memory, because of not optimal code. It is hard to do things optimal sometimes.
05:47kwladyka2) i had problem with time execution because of reflections
05:48kwladyka3) and a few more but it is not important in this topic i guess...
05:49kwladykaanyway after only changing the code i changed memory and time extremely, but i don't know what exactly you are doing
05:52kwladykasorry i cant help more
05:52wasamasalet's write webapps in C to conserve RAM
05:58ashwink005does anyone has any info on writing deftests for a mysql db CRUD operations?
06:05Pupenokwladyka: thank you for the comments.
06:05Pupenoashwink005: I use a test database and talk to the real thing. I don't think it worth it to mock it up or anything. Is that what you are asking?
06:06Pupenoashwink005: what I do is put every test inside a transaction so that after the test runs, the data goes back to normal.
06:06Pupenoashwink005: you can look at luminus to achieve that as we implemented it there.
06:16gargsmsI am doing ( ( juxt identity (assoc ? :a "1" ) { :b "2" } )
06:16gargsmsWhat do I replace ? with to make it work?
06:16gargsmsI need { :b "2" :a "1" } at the end
06:24dstockton,(assoc {:a "1"} :b "2")
06:24clojurebot{:a "1", :b "2"}
06:27gargsmsdstockton, I need to pass the result of identity at the place of ?
06:27dstocktoni think you want something like (assoc identity :role ::user)
06:29gargsmsThen I get the error clojure.core$identity cannot be cast to clojure.lang.Associative :(
06:33oddcully,((juxt identity #(assoc % :a "1" )) {:b "2" })
06:33clojurebot[{:b "2"} {:b "2", :a "1"}]
06:40gargsmsoddcully, thanks. what is the # for? I don't have much knowledge of Clojure. :/
06:40dstocktonits a shorthand for an anonymous function, % is the single argument that it accepts
06:41Bronsa#(f %) -> (fn [x] (f x))
06:49gargsmsBronsa, how can two NaN be equal?
06:50gargsms,(= Double/NaN Double/NaN)
06:50clojurebotfalse
06:50gargsmsI remember someone mentioning last day that you know of one hack
06:50gargsmss/hack/trick
06:52Bronsa,(let [[a] [Double/NaN]] (= a a))
06:52clojurebottrue
06:52Bronsaboxed NaNs are equal in java
06:53gargsmsAh.
07:04ashwink005I'm getting a string as k1=v1;k2=v2 etc. How can I convert it to a HashMap?
07:09oddcullyashwink005: split on `;` and then split each item on `=` for the element
07:10ashwink005so split, join, split
07:11oddcullywhat do you want to join?
07:13ashwink005oddcully: I don't think I can split on the resultant vector can I?
07:13ashwink005without iteration
07:16luma,(into {} (map #(clojure.string/split % #"=") (clojure.string/split "k1=v1;k2=v2;k3=v3" #";")))
07:16clojurebot{"k1" "v1", "k2" "v2", "k3" "v3"}
07:18oddcully,(let [s "k1=v1;k2=v2"] (apply hash-map (clojure.string/split s #"[=;]")))
07:18clojurebot{"k1" "v1", "k2" "v2"}
07:19Rurikyou can split on multiple chars in a regex?
07:19opqdonutoddcully's solution is a bit flaky though
07:19oddcullyopqdonut: it's aggressive ;)
07:19opqdonut,(let [s "k1=v1=k2=v2;"] (apply hash-map (clojure.string/split s #"[=;]")))
07:19clojurebot{"k1" "v1", "k2" "v2"}
07:19opqdonutyeah
07:31ashwink005luma: Thanks alot man!
07:31ashwink005worked!!
07:35oddcully,(into {} (map #(clojure.string/split % #"=" 2) (clojure.string/split "k1=v1=k2=v2;k3=v3" #";")))
07:35clojurebot{"k1" "v1=k2=v2", "k3" "v3"}
08:28Olajyd_Hi All :)
08:33Olajyd_Please how can i modify this function (partition-by identity "LeeerrroyyLLy") suche that i have something like [[\L\L\L][\e\e\e][\r\r\r][\o][\y\y\y]]?
08:36ashwink005Olajyd_: you could use java functions to sort it, then create a char array, then selectively create a vector
08:36BronsaOlajyd_: does the order matter?
08:37Olajyd_Bronsa, Nope
08:37Bronsa,(vals (group-by identity "LeeerrroyyLLy"))
08:37clojurebot([\L \L \L] [\e \e \e] [\r \r \r] [\o] [\y \y \y])
08:38lumaalso, if you just want the count of each letter, you can use (frequencies "LeeerrroyyLLy")
08:38Olajyd_Bronsa, merci :)
08:38Olajyd_lluma, really?
08:38Olajyd_luma, really?
08:39luma,(frequencies "LeeerrroyyLLy")
08:39clojurebot{\L 3, \e 3, \r 3, \o 1, \y 3}
08:44Olajyd_Aite thanks
08:47Olajyd_Bronsa, say given (def rows [["coke" "5.6ml"] ["beer" "10.7ml"] ["coke" "500ml"] ["smirnoff" "5.6ml"] ["Red-wine" "33ml"] ["coke" ""] ["beer" “”]]), can I apply the solution you gave based on column 1?
08:47Bronsajust (map first rows)
08:49Olajyd_we’d want to group all rows based on column 1
08:51Olajyd_so we’d have something like [["coke" "5.6ml"] ["coke" "500ml"] ["coke" ""] ["beer" "10.7ml"] ["beer" ""] ["smirnoff" "5.6ml"] ["Red-wine" "33ml”]]
08:51oddcullyuse first instead of identity
08:52Olajyd_Bronsa, ok
08:52Olajyd_Thanks that worked
08:52Olajyd_:)
08:59Olajyd_Bronsa, say we want to remove duplicates based on the value of a given column, i.e given column 2 to have a value of “5.6ml”, after grouping ;)
09:05sobelhow would ["coke" "5.6ml"] be selected over other elements where "coke" is the 1st element?
09:06Hroreksobel, (first ["coke" "5.6ml"])
09:08sobelHrorek: yes, i know how to achieve that result, i was asking Olajyd_ what logic should select that element
09:08Hrorekahh, sorry
09:08sobelnp ):
09:08sobel:)
09:22Olajydsobel, hmm
09:24sobelOlajyd: point being, you don't have duplicate elements of the outer vector
09:24Olajydafter grouping, we’d want to apply a dedups function such that if the second column in the given row is not equal to “5.6ml” we want to remove the row, thus th result will look like: [[“coke" "5.6ml"] ["beer" "10.7ml"] ["beer" ""] ["smirnoff" "5.6ml"] ["Red-wine" "33ml”]]
09:25sobelsounds like a job for filter
09:26sobeli don't know your whole context but it sounds like you need to filter before dedupe
09:28Olajydsobel, can I share the problem on refheap so we can walk through the solution, if its ok by you? You are obviously more experianced ;)
09:29Olajyd*experienced
09:29sobeli won't be here much longer but if you're clear on what your goal is you can get lots of good help here
09:29Olajydaite
09:29OlajydThanks
09:30sobelsure. i'm around frequently but about to have to take off for now
09:30Olajydgreat
09:30Olajydsobel, are you in the US?
09:31sobelyes, CST
09:31sobeli lurk here a lot 5-8am CST
09:32sobeli've gotten lots of small and large help here. it helps to have your questions really clear, but also be prepared to have your questions reformulated by someone who probably already understands what you're doing
09:33ordnungswidrigOlajyd: you might want to do (remove (fn [[f s]] (= s "5.6ml")) mysequence)
09:33ordnungswidrigwhere (fn [[f s]] (= s "5.6ml")) is the same as (fn [row] (= (second row) "5.6ml"))
09:34Olajydok nice, ordnungswidrig :)
09:59trisshey all. anyone like to point out the major differences between codeina and codox?
09:59trisscodeina looks a touch easier to configure?
11:18ceruleancityis there a good way to reduce the depth of nested empty seqs? for example turn (("123")) into ("123")
11:19ceruleancityright now I'm basically using (first (("123"))) because I know the seq I'm dealing with will always be a seq containing one and only seq
11:20expezcursork: flatten
11:20expez,(flatten [[1 2] [3 4]])
11:20clojurebot(1 2 3 4)
11:21expez,(flatten [[1 [2] [3 [4]])
11:21clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
11:21expez,(flatten [[1 [2]] [3 [4]])
11:21clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
11:21expezimpossibru without paredit
11:23ceruleancity@expez mein dude
11:23ceruleancitytyvm
11:24oddcully~flatten
11:24clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
11:43kavkazIf I have an infinite lazy sequence, can I let it go on for a while and then interrupt it and take the element it was currently at?
11:46MasseRkavkaz: I don't think so
11:46MasseRBut you can take the nth element of an infinite sequence if that is what you need
11:49expezkavkaz: the sequence is lazy. If you're not asking it for values it won't produce any. Since it's not doing any work when you're not asking it for values there's also nothing to interrupt.
11:50ClashTheBunnykavkaz, do you want to filter and then take the first value?
11:50ClashTheBunnysomething like:
11:51ClashTheBunny(take 1 (filter #(= 5 %) (range))) will give you the first time that the infinite sequence equals five.
11:52ClashTheBunnyOr do you want a time based selection?
11:52kavkazClashTheBunny: Ah I see.
11:52kavkazClashTheBunny: I would rather have a time based selection yes, something like that
11:53ClashTheBunnySomething like generate permutations for 16ms then render the newest permutation?
11:54ClashTheBunnyI think you want something like https://clojuredocs.org/clojure.core.async/timeout
11:55kavkazClashTheBunny: I will look into that, thank you
11:56ClashTheBunnyThis is on the JVM, right?
11:56roelofhello, I have this project file (http://lpaste.net/140445) but still I see this error message : No :main namespace specified in project.clj.
11:57kavkazBasically I have an infinite lazy prime sequence I implemented. It's very useful when wanting the nth prime, rather than the last prime under n limit. But I wanted to use it in a continuous way, where it just keeps going and going and prints every nth prime or something like that
11:57kavkazClashTheBunny: Yeah this is on the JVM
12:01noncomin clojure i am assembling a list of command line params to be passed to an application that i will run with conch. i have my initial params in a [], then i want to add some other params, depending on conditions
12:01noncomthe problem is that when i conj params, what is returned is a list and it has it's order reversed
12:02noncomafter a few sequential additions, i get a total mess
12:02noncomwhat is the idiomatic way to get around this?
12:02roelofno web developers here ??
12:02noncomi do some little web
12:02noncomwith cljs
12:05roelofnoncom : I do follow the web development with clojure and have some trouble with the first example
12:05roelofhello, I have this project file (http://lpaste.net/140445) but still I see this error message : No :main namespace specified in project.clj.
12:06noncomroelof: you specify a function but you must specify a namespace in which there is a function named "-main", the name is obligatory
12:07noncomit must be of signature (defn -main [& args] ...)
12:07noncomwhere "args" will contain all parameters passed to your app from the command line
12:07noncomas strings
12:07oddcullynoncom: conj onto a vector gives you back a vector
12:07rhg135A static main method
12:08roelofnoncom: this is the function : http://lpaste.net/140446 . I do it like the book says
12:08noncomroelof: nono. you *must* have a funtion named "-main"
12:08noncomroelof: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L177
12:09noncomroelof: not much freedom in this, it's just java
12:09noncomoddcully: how strange. why was i getting lists back then...
12:11rhg135And gen-class
12:11oddcullynoncom: hard to tell without any further information. maybe you are doing at one point something else? map/filter/...
12:11noncomoddcully: maybe.. or maybe i used concat..
12:11noncomrhg135: yes, a gen-class is also important iirc
12:12rhg135Yup
12:14noncomoddcully: this thing is very nasty:
12:14noncom,(conj (concat ["a"] ["b"]) "m")
12:14clojurebot("m" "a" "b")
12:15noncomand i really wish it returned ["a" "b" "m"]... since why would i even wait it to behave the way it does?
12:16rhg135It always returns a seq
12:18noncomrhg135: yeah, but..
12:19kavkaz,(conj (into [] (concat ["a"] ["b"])) "m")
12:19clojurebot["a" "b" "m"]
12:19rhg135It's annoying for sure on vectors, but nice and simple
12:19kavkaznoncom: Would that be feasible for you to do?
12:20oddcully,(conj ["git" "commit"] "-a" "-m" "lerl]")
12:20clojurebot["git" "commit" "-a" "-m" "lerl]"]
12:21rhg135,(let [x [1 2 3] y [4 5 6]] `[~@x ~@y])
12:21clojurebot[1 2 3 4 5 ...]
12:22rhg135Don't do that
12:23rhg135apply conj should work fine
12:25rhg135,(into [1 3 5] [7 9])
12:25clojurebot[1 3 5 7 9]
12:28roelof noncom : thanks
12:35tmtwdhow do we make http requests with om/reagent/cljs?
12:35tmtwdI can't find good resources
12:35ClashTheBunnycljs-ajax?
12:39novak`If I have this kind of expression in Emacs (fo|o1 (foo2 some)) and I want to get (| (fo|o1 (foo2 some))) how to do that? Does it supported by Smartparens or Paredit or something?
13:15noncomkavkaz: rhg135: oddcully: thank you guys!
13:15avallarkhello all :)
13:16noncomavallark: hello!
13:17avallarknoncom: great to get a response. someohow irc is so dead these days.. the only place poeple seem to talk is in #ubuntu and i think i am still banned there :D
13:17noncomi find #clojure, #emacs, #lisp, #lispcafe, #libgdx are pretty alive...
13:17noncom#lispgames also
13:18avallarklispgames? nice.. checking it out
14:44TEttingerso I can report now that an early build from source of OpenJDK 9 does work on Windows, it does start up small Java applications noticeably faster, it does start up maven a hair faster, and it does not appreciably speed up the load times for lein repl (even in an empty folder), because I think the majority of the time is spent loading jars from disk.
14:51justin_smithTEttinger: it would be interesting to see that profiled
14:52TEttingerthe profiler would complain that my disk is too slow
14:55amalloyTEttinger: there is a lot of time spent running the foo.core$__init classes and so on, too
14:55amalloyi'm pretty sure it's not just disk i/o - you can cat an uberjar a lot faster than you can start it up
15:14lodin_Why is (:require [foo :refer :all]) prefered over (:use foo)?
15:15TEttingerI don't think either is preferred over not referring
15:15TEttingerbut for just the two of those, hm, not sure
15:15PupenoWhat do you use to deploy clojure web apps?
15:17Empperiansible
15:18fijgrIn CIDER for Emacs, is it possible to eval every file in src/ and test/? It's pretty annoying to have to open every file in a buffer, and eval them all, to get all the vars I need instantiated
15:18fijgrOr is it possible to eval everything in a ns with only clojure? Then cider doenst need to do it
15:19justin_smithfijgr: this is what require is for
15:19justin_smithit recursively loads an ns and everything it requires
15:19justin_smithtypically a project will have a single ns that is the top of the dep tree, and loading that one will cause all other code to load
15:20fijgrjustin_smith: so if everything is loaded from (or loaded from a child of) my core ns, its top-level forms will be eval-ed?
15:20justin_smithfijgr: right, that is what require is meant to do
15:21fijgrjustin_smith: hmm, I see... I'll have to check that out again. Thank you for your answer :)
15:21justin_smithfijgr: one gotcha is if there is an error during the first load, you need to use the :reload or :reload-all argument to require to force reloading
15:21Empperihttps://www.youtube.com/watch?v=EOjGsdDoicw
15:22fijgrjustin_smith: I see. It was not functioning as you describe it, so maybe I have to do that. Will try. Thank you very much for answering my noob question!
15:35noimAny help will be appreciated: https://gist.github.com/anonymous/041dc81e168f176c7ab1
15:36justin_smithnoim: maps are not ordered
15:37noimhrm any better ideas for a data structure then?
15:37justin_smithnoim: you will need to either manually sort things, or use a sorted-map instead of a map
15:38justin_smithor maybe an ordered map (you can get that from a lib)
15:52TEttingernoim, justin_smith: maps are not sorted but keys and vals both return vecs that have the same order
15:53TEttinger,((juxt keys vals) {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]})
15:53clojurebot[(:a :b :c :d :s) ([34 56 7] [21 87 999] [3] [2 4] [4])]
15:53TEttinger,((juxt keys vals) {:s [34 56 7] :b [21 87 999] :c [3] :d [2 4] :a[4]})
15:53clojurebot[(:s :b :c :d :a) ([34 56 7] [21 87 999] [3] [2 4] [4])]
15:53TEttingerwoah, I'm surprised it's holding up insertion order there
15:54TEttinger,((juxt keys vals) (hash-map :s [34 56 7] :b [21 87 999] :c [3] :d [2 4] :a[4]))
15:54clojurebot[(:s :c :b :d :a) ([34 56 7] [3] [21 87 999] [2 4] [4])]
15:54TEttingerthere we go, it was using an ArrayMap maybe before?
15:56TEttingeralso, noim, your example doesn't make sense in that gist
15:56clojurebotExcuse me?
15:56noimthe intenntion with transform is to setup the rows for an html table
15:57TEttingerok
15:57TEttingerI mean the numbers don't coincide with the ones you gave earlier, and aren't in the same order as supplied in the vectors
15:59noimI failed at copying heres the function call (transform {:a [34 56 7] :b [21 87 999] :c [3] :d [4 5 ] :s [4]})
16:02noimmy function also explodes if I have some thing like this (transform {:a [34 56 7] :b [21 87 999] :c [3] :d [4 5 7] :s [1 3 4]})
16:03noimwrong number of args 3 passed to core/vec
16:04TEttinger&(let [data {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]}] (map (fn [i] (map vector (keys data) (map #(nth % i) (vals data)))) (range)))
16:05TEttingerlazybot ded
16:05TEttinger,(let [data {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]}] (map (fn [i] (map vector (keys data) (map #(nth % i) (vals data)))) (range)))
16:05clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
16:05TEttingerhm
16:05TEttingerah!
16:06TEttinger,(let [data {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]}] (map (fn [i] (map vector (keys data) (filter some? (map #(nth % i nil) (vals data))))) (range)))
16:06clojurebot(([:a 34] [:b 21] [:c 3] [:d 2] [:s 4]) ([:a 56] [:b 87] [:c 4]) ([:a 7] [:b 999]) () () ...)
16:06TEttingerit doesn't have the lone pairs separated
16:06TEttingerand there's worse problems hm
16:08TEttinger,(let [data {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]}] (map (fn [i] (remove #(nil? (second %)) (map vector (keys data) (map #(nth % i nil) (vals data))))) (range)))
16:08clojurebot(([:a 34] [:b 21] [:c 3] [:d 2] [:s 4]) ([:a 56] [:b 87] [:d 4]) ([:a 7] [:b 999]) () () ...)
16:10TEttinger,(let [data {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]}] (take-while seq (map (fn [i] (remove #(nil? (second %)) (map vector (keys data) (map #(nth % i nil) (vals data))))) (range))))
16:10clojurebot(([:a 34] [:b 21] [:c 3] [:d 2] [:s 4]) ([:a 56] [:b 87] [:d 4]) ([:a 7] [:b 999]))
16:10TEttingerthat gets rid of an infinite lazyseq
16:11noimit would be fine if I could get to the next key and extract the first element from each vector val as every n-tupple is a complete row
16:11noimnice
16:12TEttingerif the loners need to be separate, there happens to be a way...
16:15TEttinger,(let [data (map (fn [[k v]] (if (= (count v) 1) [k v] [k (concat [nil] v)])) {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]})] (take-while seq (map (fn [i] (remove #(nil? (second %)) (map vector (keys data) (map #(nth % i nil) (vals data))))) [1 2 3 0])))
16:15clojurebot(([:a 34] [:b 21] [:d 2]) ([:a 56] [:b 87] [:d 4]) ([:a 7] [:b 999]) ([:c 3] [:s 4]))
16:16TEttinger(I'm extremely surprised that worked, I would have thought it would need into {})
16:16TEttingernoim: does that do the trick?
16:17TEttingeryou would need to figure out the maximum count of the vals, which is just...
16:17TEttinger,(let [data {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]})] (apply max (vals data))
16:17clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
16:17TEttinger,(let [data {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]})] (apply max (vals data)))
16:17clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
16:17TEttinger,(let [data {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]}] (apply max (vals data)))
16:17clojurebot#error {\n :cause "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers gt "Numbers.java" 229]}]\n :trace\n [[clojure.lang.Numbers gt "Numbers.java" 229]\n [clojure.lang.Numbers max "Numbers.java" 4027]\n [clojure.core$max invoke...
16:17TEttingersorry
16:18noimno worries
16:18TEttinger,(let [data {:a [34 56 7] :b [21 87 999] :c [3] :d [2 4] :s[4]}] (apply max (map count (vals data))))
16:18clojurebot3
16:18noimin that first let form what does range do
16:19TEttingernoim, are you maybe scrolled up in the chat log?
16:19noimno I just wasnted to know what it did
16:20TEttingeroh ok
16:20TEttinger,(range 4)
16:20clojurebot(0 1 2 3)
16:20TEttinger,(range)
16:20clojurebot(0 1 2 3 4 ...)
16:20TEttingerrange with no args is an infinite lazyseq from 0 onward
16:21TEttingerit needed the (take-while seq .......) because that stops the map once it gets to an empty return sequence
16:21TEttingerthat is, you see ([:a 7] [:b 999]) () () ... in one of the returns without take-while in the code?
16:22TEttingerit would have kept doing () () () () forever without the take-while, but lazybot stops execution after 5 elements in any collection
16:25noimah ok
16:27noimnesting was confusing me
16:30neoncontrailsTEttinger: just curious, how does (range) avoid overflowing once it hits the Java int limit?
16:30neoncontrailsDoes it just convert at that point to bigint?
16:34TEttingerneoncontrails: hopefully it never gets that far
16:34TEttingerthat's the lazy part
16:35neoncontrailsSure, right. But suppose that it does. I believe it still works, right?
16:35neoncontrailsI've used (range) for Project Euler problems and never had trouble.
16:36TEttinger,(nth (range) 36rZZZZZZZZZ)
16:36clojurebot#error {\n :cause "Value out of range for int: 101559956668415"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Value out of range for int: 101559956668415"\n :at [clojure.lang.RT intCast "RT.java" 1198]}]\n :trace\n [[clojure.lang.RT intCast "RT.java" 1198]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compi...
16:36TEttingerthere you go.
16:36TEttinger,(nth (range) 36rZZZZZZ)
16:36clojurebot#error {\n :cause "Value out of range for int: 2176782335"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Value out of range for int: 2176782335"\n :at [clojure.lang.RT intCast "RT.java" 1198]}]\n :trace\n [[clojure.lang.RT intCast "RT.java" 1198]\n [sandbox$eval49 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval49 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "...
16:36neoncontrails!!! I'm glad you clarified this.
16:36TEttingerthat might be nth doing that
16:36TEttingerI think nth can't access more past the 2^31th item
16:37TEttinger,(nth (range) (bit-shift-left 1 31))
16:37clojurebot#error {\n :cause "Value out of range for int: 2147483648"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Value out of range for int: 2147483648"\n :at [clojure.lang.RT intCast "RT.java" 1198]}]\n :trace\n [[clojure.lang.RT intCast "RT.java" 1198]\n [sandbox$eval73 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval73 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "...
16:37TEttinger,(nth (range) (bit-shift-left 1 30))
16:37clojurebotExecution Timed Out
16:37TEttingerand yeah lazyseqs need to calculate every element to do nth
16:38TEttingersince they're very similar to iterators
16:39neoncontrailsThat would make sense
16:40noimthanks again
16:41noogahah
16:42noogaI'm trying to implement efficient immutable graph and it seems that I have no idea how to start
16:45TEttingernooga: have you tried the Purely Functional Data Structures book?
16:45noogaI'd like to (let [g (graph) a (add-node g {:foo :bar}) b (add-node g {:baz :quux})] (add-edge g :label a b)) but since the graph is immutable, add-node and add-edge should return new graph
16:46noogaso this example is stupid
16:46noogaTEttinger: no, I havent
16:46TEttingerhttp://www.cs.cmu.edu/~rwh/theses/okasaki.pdf
16:46noogathx
16:50TEttingerno graphs in it though
16:52noogayup
16:52turbofaileasiest way is probably just a map from node-names to edges
16:53noogayeah but that requires node names from the user
16:53turbofailnot necessarily, you could just have add-node generate names automatically
16:54turbofailobviously you'd still have to thread the graph objects through it, probably using ->
16:55turbofailanyway there's also https://github.com/aysylu/loom to look at
16:59noogahm
17:00noogaturbofail: add-node could generate ids internally but then how can I say connect this to that
17:04noogait (let [g (add-node (graph) :x) x (last-node g) g2 (add-node g :y) y (last-node g)] (add-edge g2 :z x y))
17:04noogait could be*
17:05noogabut this will be catastrophic if I want concurrent writes
17:11Wild_Cat`what's the best practice on functions that take [& args] vs functions that take one seq/vector argument?
17:11Wild_Cat`(as in, when should I use one or the other?)
17:15arryhi! can somebody tell me how to create a new Compojure project? The docs say `lein new compojure-app foo` but it doesn't work, because `lein new` doesn't seem to use the template.
17:15arry(when running `lein help new`, it says Arguments: ([project-name] [project-name project-dir]))
17:19TEttingerarry: hm, I wonder if lein can't connect to clojars on the internet
17:22arryi think i've found the problem: lein version is 1.7.1 (installed via apt-get), while the site says that current version is 2
17:22arryi'm going to reinstall 'properly' and try again
17:26neoncont_I was gonna ask this in #clojure-beginners, but it's looking a little dead there. Maybe #Clojure can help.
17:26neoncont_I just configured figwheel. Trying to write my first webapp. Basic. Just a gui calculator. Figured I should start small.
17:28oddcullyneoncont_: feel free to continue here. but so you know: there is also a #clojurescript channel
17:28neoncont_I have HTML buttons, and my core.cljs file is interfacing with the browser. I can send alerts to the buttons, but I'm not sure how to make them interactive. Can someone hold my hand?
17:29arryyep, the old version was the reason. Now it worked out of the box.
17:29neoncont_oddcully: Oh cool, thanks! Sorry if this is off-topic
17:30ferz_Hello, I am having some issues with running demo Seesaw app. I am getting java.awt.HeadlessException when running lein on Ubuntu. Am I missing something?
17:30oddcullyneoncont_: you mean you are doing alert calls in your onclick of the button?
17:32neoncont_oddcully: heh, so I have figured out how to make the button do something on click. But I'm not sure how to approach the problem of composing a function of three separate button click events. Does that make sense?
17:32oddcullyferz_: is -Djava.awt.headless=true in JAVA_OPTS? or is it the other way around?
17:33neoncont_Or, I should say, at least 3
17:33oddcullyneoncont_: so you want to have some action once three or more buttons are clicked by the useR?
17:34neoncont_oddcully: yeah. I want the app to behave exactly as a calculator behaves.
17:35ferz_oddcully: I did 'echo "$JAVA_OPTS"' and it didn't return anything, not sure how else to check it
17:36oddcullyferz_: are you running your code as root and your x11 is running as a regular user? has the user a DISPLAY var set and can it start x11 apps that show up?
17:36TEttingerferz_: can you check in the package manager if you installed some kind of headless version of openjdk or oracle java?
17:36TEttingerbut oddcully's suggestion is more important to check
17:37justin_smithoddcully: ferz_: you can check the value with ##(System/getProperty "java.awt.headless")
17:37oddcullyyeah could be some "server env" setup for java in ubuntu - i have not used it for so long i don't know where to look
17:38nooganeoncont_: create some state holding your calculation
17:38hlolliignore this message, first time using IRC in 20 years. So this is a test.
17:38justin_smithoddcully: iirc the default ubuntu java is a headless distro
17:38TEttingerhi hlolli.
17:38justin_smithTEttinger: he wanted you to ignore that message, you insensitive clod
17:39hlollinice, well 1999 so almost 17 years. Ok, look forward to read interesting clojure discussion...
17:39nooganeoncont_: it could be a vector in an atom, that could behave as a stack for calculations, number buttons would conj numbers, operation buttons would take the numbers form the stack and conj result
17:40TEttingerhaha
17:41noogahlolli: please tell me that you're running some kind of IRC FS on Plan 9 like it's nineties again?
17:41hlolliNo, I used Mirc on PC in the old days. Looking for a quake scrim. Now Im in emacs... That's old I guess :)
17:42neoncont_nooga: that makes sense. Just to make sure, this doesn't have to be anywhere represented as a DOM element, right? I can just define the vector somewhere in the core.cljs, and use it as a helper function in the code?
17:42noogaahhh mIRC :D
17:43nooganeoncont_: I'd just stick (defonce state (atom [])) in there
17:44nooga(defn input-digit [d] ...) (defn input-operation [op] ...) and then use those two with swap! inside on-click handlers
17:44noogathis should keep things simple
17:44neoncont_defonce gets my vote for funniest, most bizarre-sounding language primitive I've learned yet
17:44neoncont_(inc defonce)
17:45justin_smithneoncont_: it rhymes with beyonce
17:45neoncont_Oh, god. Hahahaha
17:46justin_smithneoncont_: or at least it does if I convince enough people to pronounce it that way :)
17:46noogayeah, wait until you make a typo when writing a controller :F
17:47neoncont_Défoncé is french for being drunk off one's arse, interestingly. Heh
17:47oddcullydefonzie?
17:47justin_smithneoncont_: in all seriousness, the existence of defonce in core shows how important the idea of reloading and redefining things in runtime is in clojure
17:47justin_smithneoncont_: I had no idea
17:48neoncont_hlolli: Hey, welcome! I just saw your facebook post. :)
17:49nooga,(defmacro défoncé [x y] `(defonce ~x ~y))
17:49clojurebot#'sandbox/défoncé
17:49noogahere
17:50justin_smithhaha
17:50lumaso, how does that represent being drunk off your arse?
17:50ferz_running this fixed it forwhatever reason 'sudo apt-get install default-jdk'
17:51justin_smithferz_: yeah, I think you started out with the default jvm, which has no X support, but the default jdk does have X support
17:51ferz_anyway, what does everyone use to write GUI apps in Clojure?
17:51oddcullyferz_: has it actually installed something?
17:51ferz_yeah something was installed
17:51oddcullyferz_: maybe the jre is headless and the jdk changes the env
17:51ferz_50mb of packages
17:51nooga,(defmacro défoncé [x y] `(defonce ~x "burp"))
17:51clojurebot#'sandbox/défoncé
17:51justin_smithferz_: in my opinion using an html renderer and clojurescript, with either reagent or om to manage the dom, is the best option right now
17:51noogabetter
17:52ferz_Yeah I've played with Reagent recently, not much with Om. How about desktop apps?
17:52justin_smithferz_: though seesaw uses a more traditional GUI and is OK too - I just don't think it has the same growth right now
17:53justin_smithferz_: something like atom shell could do interesting things, and for more traditional jvm+X you can use seesaw (it's a swing wrapper)
17:53ferz_It looks like seesaw is dated a bit, their doc references Clojure 1.4, kinda behind
17:53justin_smithit's decent though
17:53justin_smithbut yeah, not as active as the html oriented stuff
17:53ferz_I got my demo app to work so I will be messing with it today
17:53thearthurIt's "mature"
17:54justin_smithpeople also use javaFX - I don't know if any good wrappers are out there? You can do it via regular interop.
17:54ferz_I think interop is pretty good enough, maybe that's why there is not a lot of wrapper or updates for seesaw
17:55ferz_But I am fairly new to Clojure so I can't be the judge
17:55noogaferz_: my Java colleagues wrote this "shell" JavaFX app and we just delivered clj logic
17:55noogaglue was thinner than I'd expect
17:55justin_smithnooga: yeah, glue between java and clojure tends to be pretty thin actually
17:56justin_smithI need a bigger desk.
17:57tcrayford____I need some glue for my desk
17:57tcrayford____(it wobbles)
17:57justin_smithhaha
17:57justin_smithI have some java on my desk, it's delicious
18:03noogaI once read that space probes used to be programmed in lisp and they had REPLs running on the spacecraft during its flight
18:04noogathat makes me want nREPL running inside my apps in production
18:04noogawhich is probably dumbest idea ever
18:04justin_smithnooga: that's pretty easy to do with nrepl
18:04noogaI know :D
18:04noogathat's why it's so tempting
18:04futuroI've been curious about the efforts surrounding auth with nrepl
18:04justin_smithnooga: just be sure to only allow connecting to localhost
18:04noogaI could use ssh tunnels then
18:05justin_smithfuturo: ssh is good enough for host based auth, per-user is another can of worms
18:05justin_smithas it stands, running nrepl means every process on your computer could escalate to your user's privs if it new how to exploit nrepl
18:05futurojustin_smith: yeah, a good first step at least
18:06futurothat's primarily why I'm curious about auth with nrepl
18:06futuroto help avoid exploits utilizing nrepl
18:06justin_smithfuturo: if we ditch windows support it's doable with unix domain sockets
18:06Wild_Cat`(reposting but nobody answered) what's the rule of thumb on functions that take [& args] vs functions that take one seq/vector argument?
18:06justin_smithI don't think there's a portable secure option with the nrepl model
18:07futurojustin_smith: hmmm
18:07futurojustin_smith: has there been any work on securing nrepl on particular platforms?
18:07futurowith middleware, perhaps
18:08justin_smithWild_Cat`: thanks to apply we can easily go from the former to the latter, I guess it depends on whether your functionality treats the args as equivalent items in a series or gives any of them special meaning
18:08Wild_Cat`that's precisely why I'm asking.
18:09Wild_Cat`I mean, given the choice between arbitrary homogeneous arguments, and one argument that's a homogeneous sequence, when do I pick one or the other?
18:09justin_smithfuturo: on unix you could do it with unix domain sockets, but I don't know of anything similar for windows. Maybe TEttinger knows of how to get user permissions for a local socket (or equivalent funcitonality) on Windows?
18:09TEttingernot... really
18:09justin_smithWild_Cat`: I'd go with the latter almost always (but there are plenty of functions, like str that go the other way in core)
18:10TEttingermy method of security is mostly "don't do online banking"
18:10justin_smithWild_Cat`: interesting question, I wonder if there are good arguments about when you would chose either one
18:11noogaWild_Cat`: I'd go for the latter if you return another sequence or you expect long sequences, the former if you make scalar value from the arg sequence
18:44Wild_Cat`nooga: makes sense. Thank you!
20:02neoncontrailsIs there an equivalent way of writing this code without Sablono? https://github.com/bhauman/lein-figwheel/wiki/Quick-Start
20:03justin_smithneoncontrails: well, you could use reagent, or om, or punch the dom in the face directly with your bare fists
20:03justin_smitheach of these will look different
20:04neoncontrailsHeh. I'd like to understand cljs basics first before I commit to a framework. Is that reasonable
20:05justin_smithusing some version of react is much simpler than manual dom transformations
20:05justin_smithreagent, om, sablono are all react frontends
20:05mungojellycan anyone link me to a short program in clojure that makes a pretty picture?
20:05neoncontrailsNot for ideological purity reasons, just because I find this code very mysterious for something so basic and simple
20:06justin_smithneoncontrails: the alternatives are not less mysterious
20:06justin_smiththe DOM is weird
20:06neoncontrailsGood to know.
20:07justin_smithmungojelly: I saw this guy talk recently about his project - it uses clojure to generate images, and then it mutates the code based on feedback on twitter https://github.com/rogerallen/tweegeemee
20:07neoncontrailsI never did figure out how to implement that atomic swap nooga recommended earlier. Probably because I don't know the context in which my code is executing
20:08justin_smithmungojelly: that project uses Clisk, so you might just want to skip straight to Clisk and generate images that way https://github.com/mikera/clisk
20:09justin_smithmungojelly: here's the account for the twitter bot for tweegeemee that tweets the images it makes https://twitter.com/tweegeemee
20:09justin_smithmungojelly: each image links to source code that made it
20:09mungojellyjustin_smith: wow that looks awesome thanks, evolving processes is just what i'm working on :)
20:09justin_smithawesome
20:11mungojellyalso though does clojure have anything truly simple for beginners, you know like racket does, something where just a few words makes pictures appear?
20:11justin_smithmungojelly: that should be possible with clisk which I linked above
20:12justin_smithmungojelly: looks simple enough from here https://github.com/mikera/clisk#example-code-and-resulting-image
20:14mungojellyyay yeah that looks good! i've been mystified in the larger picture how there's so little given to real beginners, it seems so easy to throw people a bone and make something you can just play with.
20:15justin_smithmungojelly: there is also quil which is a wrapper for processing, oriented to beginners
20:15mungojellyis leinining.. leiningin.. leiningen, is this the package manager y'all use lately, i should learn that?
20:15justin_smithbut fair warning, to an experienced clojure user some things about quil are just - a bit off
20:15nooganeoncontrails: I know the initial cljs ordeal can be mysterious and unclear
20:16noogabut really you just need to chill out, it's still the browser that's running your stuff, you don't need to know every bit of the stack you're running on
20:16justin_smithmungojelly: yes, it's how almost all of us manage dependencies - it's not quite a "package manager" in the traditional sense because there is no global install, just a local cache of available packages, and each run will decide which of those packages to make available to a program
20:16justin_smithso it's more selective, kind of like the nix package manager where you have full freedom of multiple package versions, which one version per program
20:17justin_smith*with
20:17noogabasically cljs functions are just JS functions in the end, runtime handles atoms and other async primitives so you don't have to worry
20:17mungojellyoh cool yeah nix is a distro right, i've been thinking of trying that out yeah, sounds good, makes sense
20:17justin_smithmungojelly: well, there is a nix distro and a nix package manager
20:17noogareagent is just layer on top of react, which AFAIK decides what to do with DOM inside requestAnimFrame
20:18justin_smithmungojelly: but the real point was that unlike eg. gem or apt where you pick a version to install globally, you get to pick which versions of which lib you want on a per-run basis (and leiningen is built to manage that)
20:19nooganeoncontrails: try to write an inc/dec counter
20:19mungojellyok yeah that's good, everything should work that way, we have enough disk space now, gotta keep up
20:19justin_smith:)
20:19noogawith two buttons
20:20justin_smithmungojelly: yeah, it simplifies things to have that kind of fine-grained per run control when needed (but it also does automatic recursive dep management and resolution, as you'd expect from a smart dep manager)
20:24neoncontrailsnooga: did that already. And I get that it works, sure. I just don't see any reason why I shouldn't be able to now replace those calls to inc/dec with a cc like ((fn [val] (conj register val)), for instance
20:26ferz_I gotta ask this... Do I have to learn Emacs? I can't touchtype so should I bother with Emacs at all? I use Cursive at the moment. I haven't developed anything bing Clojure yet, am I better off with Emacs as an "investement" if I learn it?
20:27justin_smithferz_: I don't think you are missing out using cursive instead of emacs
20:27noogaferz_: I sterted using emacs with clojure and wouldn't come back but that's subjective imo
20:27justin_smithferz_: emacs is what I use, and I love it, but for clojure development specifically cursive is probably better
20:28nooganeoncontrails: I'm not sure if I follow you, maybe you have a gist I can look at?
20:28justin_smithin terms of quality of feature integration and ease of use
20:28neoncontrailssure, let me rewind it to a previous state
20:28mungojellyferz_: the fact that some people know a lot about emacs doesn't mean you need to know everything about emacs to use it, i'm by no means an expert in emacs but i certainly don't regret trying it out and learning some things-- it's free
20:29noogaand remember to get SYMBOLICS sticker for your keyboard...
20:30ferz_yeah thats what I am thinking. It seems like people are proficient in either vim or emacs can utilize it and it's nice to have editor that I can run from terminal. Maybe I should look into it.
20:30ferz_touchtyping probably helps too?
20:30justin_smithyeah, I took the time to learn ed, vi, vim, and emacs, currently use emacs with evil mode (which emulates vim)
20:31rhg135It helps for a lot of things
20:31mungojellyferz_: i use and recommend the dvorak keyboard, if you don't touchtype yet all the more reason not to learn wrong ;)
20:31noogarebinding caps lock to ctrl helps
20:31justin_smithtwo great ways to learn touch typing while also ruining your life is to get into the game nethack or start playing muds. They are both addictive so you will get very good at typing fast.
20:31ferz_I've seen dvorak keyboards and it feels compelling, I just might do that
20:32justin_smithand also probably lose your job, and all your relationships, and flunk out of school if applicable, etc.
20:32ferz_oh then I am perfect for this game
20:32ferz_I am already ahead...
20:32justin_smithheh
20:32noogaI was always afraid of non qwerty keyboards because they look like the best way to ruin your muscle memory
20:33noogaand make you unable to use any other machine besides your own
20:34ferz_how many of you code Clojure for a living?
20:34justin_smithferz_: I've been a full time clojure dev for about 4 years now
20:34ferz_justin_smith: woah, nice
20:35justin_smithferz_: I actually learned clojure because a job expected it (though I already did scheme / ocaml / common lisp for hobby projects)
20:35ferz_justin_smith: do you work in a clojure shop or it's one of the many languages you use?
20:35ferz_I see
20:36noogadoes running a startup powered by clojure count?
20:36justin_smithferz_: funny thing, both of the long term jobs were ruby shops that started migrating to clojure for web dev for performance / stability reasons
20:36justin_smithwith part of performance being how many servers you need to keep running (eg. a cost thing)
20:36ferz_nooga: actually yeah, big brownie points for a clojure startup, how is that working out? I want to see more clojure shops but alas it's rare
20:37ferz_you think clojure will get more popular with start ups like ruby/rails?
20:38noogaferz_: you're not the first person that tells me that :) It's my second company, we have an awesome team which comes from various backgrounds but we all like smart things so we got interested in clj, then started doing some side projects and then wrote our core stuff in clj
20:39noogareplacing node.js pieces one by one
20:39justin_smithferz_: well, it has the bonus of facilitating more stable large scale design, and utilizing resources more effectively. But it has the disadvantage of not providing as many cookie cutter solutions to common tasks, and being a little harder for inexperienced devs to jump into sometimes (if even just because they are not used to so many parens)
20:39ferz_nooga: that's awesome, I hope it's working out for ya'll, I like clojure and I hope it gets more mainstream as a viable solution.
20:40noogait's fun and we're learning a lot with every iteration
20:41noogabut we had mocroservices from the start so the transition wasn't very painful
20:41noogamicroservices*
20:41noogaand some things even got smaller by factor of 10 code wise
20:42justin_smithgluten free macrobioticservices*
20:44justin_smithsorry, kidding
20:44noogaferz_: from my experience, RoR shops have their methods polished and their CTOs aren't very keen to dump that for another tech
20:45noogaand they're still making good money
20:45ferz_I think my city has 1 Ruby shop and it's pretty new, some of their coders been playing with Elixir but thats about it.
20:45ferz_Local clojure meetup has like 5 people...
20:46ferz_and it's the 7th largest city in the US, lol
20:46noogahere we have a ruby shop that became international and huuge
20:47noogabut it's like a factory, they train students and write CRUDs
20:47ferz_thoughtbot? or something lol
20:47noogaI happen to know the CTO, he doesn't even like adapting new gems
20:48noogaJS community is pretty strong
20:48ferz_can't blame them, rails is solid
20:48noogabut I think there are only two clojure using companies in the town
20:48justin_smithnooga: aren't deps a huge source of instability in ruby land? that seems sensible from what I have heard
20:48ferz_I started to "get" ruby a bit more after clojure
20:48noogaone of which is mine, and there's this software house
20:49mungojellyi'm bikeyboardal, i only have to use qwerty occasionally to keep my qwertyism ok
20:49noogajustin_smith: it's a nightmare
20:50noogaIIRC ruby was excruciatingly slow
20:51noogai used to like it but then it got sour after some time
20:51ferz_ruby is alright, still fun, but lisp blew my mind
20:52noogal
20:52noogalambda enlightment hehe
20:53ferz_to me it was like, why haven't I encountered this before, it makes so much sense..
20:53neoncontrailsnooga: tried to modify this to insert a decrement side-by-side with increment, but my attempts at that just overwrote the previously created dom object. Oops
20:53neoncontrailshttp://pastebin.com/1K6cFNw8
20:53neoncontrailsthis is basically just the "getting started with figwheel" tutorial at https://github.com/bhauman/lein-figwheel/wiki/Quick-Start
20:56nooga[:a {:href "#" :onClick #(swap! data update-in [:likes] dec)} "Dec it"] ?
20:57noogatried that?
20:59neoncontrailsYeah I just figured it out. I didn't realize you could nest two elements inside the same div
21:00rhg135HTML, it's fun to learn
21:00nooganeoncontrails:
21:00noogahttp://pastebin.com/TtgfwTvN
21:01neoncontrailsI'm familiar enough with HTML, but clojurescript that outputs *to* HTML is brand new to me
21:02noogaI'd guess that sablono is all about expressing html (DOM) as a data structure
21:03neoncontrailsIt does look that way, doesn't it
21:05nooganow try to bind text input to some bit of state, make some buttons that append digits to this string
21:07nooga#(swap! data update-in [:display] str digit)
21:08noogaadd another field for current operation
21:08noogaetc
21:10neoncontrails"str digit" that's interesting, I'll try that
21:12neoncontrailsnooga: gotta go, but that actually solves a problem I was having trying to encapsulate the value.
21:12neoncontrailsThanks!
21:12neoncontrails(inc nooga)
21:12neoncontrails,(range 4)
21:12clojurebot(0 1 2 3)
21:13neoncontrails,(inc nooga)
21:13clojurebot#error {\n :cause "Unable to resolve symbol: nooga in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: nooga in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: nooga in this...
21:13neoncontrailsd'oh. I tried!
21:22elvis4526Hey, is there a way to display variables when debugging with CIDER in the repl ?
21:30mungojellyA+ to "lein repl" for telling me right off what to say to quit :o)
21:39rhg135^D is nice
21:43mungojellyrhg135: ^D is what i would have tried, but it's nicer not to have to know things, i like for anyone else to be able to follow me. :/ speaking of, clisk doesn't have any cartoons or anything in it does it?
21:44rhg135Ah right screencasts exist
21:44mungojellyi want cartoons and toys and pretty things pls
21:48rhg135This seems out of context
21:48mungojellyyou'd think writing games would entail writing little toy pieces people could play with but no, mostly big god objects :(
21:49kavkazelvis4526: http://endlessparentheses.com/cider-debug-a-visual-interactive-debugger-for-clojure.html
21:57kavkazelvis4526: It's pretty cool actually
22:13rhg135mungojelly: sad, ain't it
22:14mungojellyrhg135: i'm poking around the games i can find in clojure and tehy're all a flat list of functions like create-player-body-thingy :(
22:16mungojellyi'd just like some sort of play space, like you know morphic in squeak? or just things that know how to draw themselves in their bounding boxes so you can zoom around their world and ask the appropriate ones to draw themselves to you. any basic context to play with things.
22:17dnolenmungojelly: I'm not aware of anything that general in Clojure
22:17TEttingermungojelly: have you seen play-clj ?
22:17mungojellyTEttinger: i haven't, i'm new, i'll look now :)
22:17TEttingeror brute for an ECS, there's at least three entity-component systems for clojure
22:18TEttingerhttps://github.com/muhuk/clecs https://github.com/markmandel/brute
22:18TEttingerand the resatori one doesn't have the blog working
22:18TEttingerhttp://web.archive.org/web/20150204201847/http://resatori.com/clojure-entity-component-system
22:19TEttingerplay-clj has something called nightmod that is meant for beginners to clojure
22:19TEttingerhttps://sekao.net/nightmod/
22:22mungojellyok yay that does look fun, thanks, i'm sure this will be enough to teach me, i just don't know why nowhere has anything really more basic and torn apart, where you can play by making really simple things
22:22mungojellyit seems like we're so abstracted that we literally cannot remember what normal simplicity even looks like, it becomes unimaginable
22:23TEttingergames are not something friendly to simplicity
22:23mungojellybut there's no reason we can't have a fun little world where the fun characters in the world are made with a few lines of code and you can try changing "green" to "blue"
22:24TEttingeryou have the innate mutability of graphics. you have some rather intense performance needs for all but the simplest games. you, in particular, have a unique problem of visual behavior being especially inextricable from what should be pure logic (re: animations)
22:25TEttingerthe one thing that seems like it could be an escape rope from that is functional reactive programming, but there haven't been any successful commercial games to use it IIRC
22:25mungojellyin general in the lisp world there's this statement in the abstract "we can make really simple DSLs" but then what's actually done is an integrated process of making and then applying a DSL, which involves simplicity but is itself complicated, as opposed to ever actually providing anyone ELSE any simple DSLs
22:26TEttingerclojure doesn't really emphasize DSLs as much as sensible APIs for regular code
22:26TEttingernot having reader macros means you can't make clojure look like something else very easily, and the consensus is that it's not a great idea usually anyway
22:27mungojellywell that's superficial, i mean you can create a set of primitives related to a problem, you can create a vocabulary for a situation
22:28mungojellythe only problem is that it gets as "simple" as "simple" a wrapper around a C graphics library but never as "simple" as actual ordinary every day red blue apple sunshine happy sad SIMPLE simple
22:28mungojellyracket goes a little way towards meeting reality and normal people, if somewhat condescendingly, you can say to it (jack-o-lantern 100) and that makes a little picture of a jack o'lantern
22:29mungojellyand squeak tried to go a little further, but also it's built all out of mutable objects so it predictably inevitably falls all over itself in the process, sigh
22:29TEttinger...yeah, because we live in the real world and everything has to go down to OpenGL eventually. unless you want software rendering, which... believe me, I have written a lot of software rendered code, it is extremely hard to make it fast
22:31TEttingerit's unfortunate that currently the big C OpenGL API and wrappers around it are the only choices, but Vulkan is on the horizon and would enable quite a lot of fun stuff
22:31mungojellyof course i want a wrapper around opengl, and then i want another wrapper around that that makes it really actually easy within some basic assumptions, and then i want a wrapper around THAT that makes it easy to make cartoons, and then i want a wrapper around that that makes particular fun cartoons i get to play with
22:31TEttingerthat sounds closer to play-clj with each sentence :)
22:32TEttingerplay-clj is a wrapper around libgdx, which wraps lwjgl on desktop and different stuff on android and iOS, and each of those wraps something OpenGL or OpenGL ES like.
22:32jeayeIt takes hundreds of lines of code to get a modern GL context setup enough to render a triangle, typically. Going higher level is a good idea, if you can spare the performance.
22:33TEttingerplay-clj is about as far as you can get from writing OpenGL gets in clojure-land
22:33jeayeFor cartoons, you almost certainly can.
22:34TEttingerwhen I say play-clj wraps libgdx, I mean the API is extremely clojure-like and not at all java-like. and libgdx adds a ton of java-level abstractions to the C-level OpenGL API.
22:34TEttingerseako did a good job there :)
22:34TEttingerbut I think that's an away nick
22:40seakoTEttinger: what did I do?
22:41TEttingerheh, sorry thought you were sekao
22:41mungojellyi do understand what y'all mean by play-clj being a soft gentle wrapper, i do, i'm with you, because i know what's under it, but also if you'd please try to imagine being a normal human being-- the least abstract thing in this toolkit seems to be a polygon
22:41TEttingerah. yeah play-clj is much better at handling sprites
22:41TEttingerwhich I mean, most games are going to want graphics
22:48dnolenmungojelly: that's a very narrow definition of "normal" human being. Clojure programmers are also "normal" human beings. But I'll go out on a limb and say they are as a population generally less interested in system features with significant pedagogical benefits because they are building systems where the tradeoff assessment doesn't tip that way.
22:49dnolenmungojelly: the only person I know doing serious work in this area is Robert Krahn, somewhat unsurprising since he works with Dan Ingalls. http://cloxp.github.io/cloxp-intro.html, he's been working on a Clojure version of Dan's Lively Kernel.
22:49mungojellydnolen: it seems to me that generally the "tradeoff assessment" people are making is they should make everything fairly obscure and difficult to use to guarantee themselves power over it, but um that's fucked up!?
22:50dnolenmungojelly: that's just a lot of rhetoric, sorry not interested
22:52mungojellymaking something so other people than yourself can use it isn't really so much paedogogy as just not pulling the ladder up after yourself. i don't really want a simple interface that's for me to learn a little before graduating to a complex one, i just want simple interfaces, forever.
22:59rhg135~simple
22:59clojurebotCool story bro.