#clojure logs

2015-03-18

01:45SeyleriusWorking through Project Euler problems, and I'm trying to cap fibonacci values at a specified max. What am I doing wrong here? It's whining about not knowing how to create an ISeq from a long. http://sprunge.us/fBCK
01:47nuwanda__Seylerius: you can't (cons long long) doesn't work
01:47nuwanda__,(cons 1 2)
01:47clojurebot#error{:cause "Don't know how to create ISeq from: java.lang.Long", :via [{:type java.lang.IllegalArgumentException, :message "Don't know how to create ISeq from: java.lang.Long", :at [clojure.lang.RT seqFrom "RT.java" 506]}], :trace [[clojure.lang.RT seqFrom "RT.java" 506] [clojure.lang.RT seq "RT.java" 487] [clojure.lang.RT cons "RT.java" 620] [clojure.core$cons__4053 invoke "core.clj" 29] [sand...
01:48SeyleriusAh.
01:55TEttinger,(def fibs (map second (iterate (fn [[a b]] [b (+ a b)]) [0 1])) )
01:55clojurebot#'sandbox/fibs
01:55TEttinger,(take 5 (drop 5 fibs))
01:55clojurebot(8 13 21 34 55)
01:56TEttinger,(take 5 fibs)
01:56clojurebot(1 1 2 3 5)
01:57koddssonIs there a function in clojure that will return a function with the original functions argument list reversed?
02:03koddssonie. (= ((reverse-args (/)) (/ 1 2)) 2)
02:05amalloykoddsson: note that you don't mean (/), but just /
02:05amalloyi faguely suspect that you're a haskeller who thinks (/) is an operator section, but it's not
02:05amalloy*vaguely
02:06koddssonYeah no I just made a mistake
02:06koddssonhave never done any haskell ;)
02:06amalloykoddsson: there's nothing built in, but of course you can write it easily
02:06amalloy(defn flip [f] (fn [& args] (apply f (reverse args))))
02:08koddssonSweet
02:08koddssonThanks amalloy
02:09koddssonWould this be something I'd use when I want to switch the arguments for a `/` in a `->>` chain or is there a better way?
02:09koddsson(Hope I'm making myself understandable ;)
02:18amalloykoddsson: no, probably not. it's kinda unusual to have a ->> chain where you want something to go in at the front; usually it's better to have a -> chain, possibly with a -> inside it
02:19amalloyeg, instead of (->> x (map whatever) ((flip blah) y)), you cna write (-> x (->> (map whatever)) (blah y))
02:19koddssonAh ok
02:19koddssonI'll try something like that
02:19koddssonThanks for the help amalloy
02:41bcmbefore i write my own... there must be a map-keys function that will work with a deep map
02:41bcmbefore i write my own... there must be a map-vals* function that will work with a deep map
02:42bcmso that (f {:a "a" {:b "b"}} str/capitalize) ;=> {:a "A" {:b "B"}}
02:42bcmis there a good place to look for stuff like that?
02:43Kneivabcm: walk perhaps?
02:43bcmI found one in here: https://github.com/jaycfields/jry
02:43bcmI suppose I'll use it.
02:43bcm(update-vals {:b {:c :d :e :f} :h {:c :d :e :f}} dissoc :c) => {:b {:e :f} :h {:e :f}}
02:44justin_smith(clojure.walk/postwalk (fn [x] (if (string? x) (.toUppercase x) x)) {:a "A" {:b "B"}})
02:44justin_smith,(clojure.walk/postwalk (fn [x] (if (string? x) (.toUppercase x) x)) {:a "A" {:b "B"}})
02:44clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
02:44justin_smithergh
02:44justin_smith,(clojure.walk/postwalk (fn [x] (if (string? x) (.toUppercase x) x)) {:a "A" :bs {:b "B"}})
02:44clojurebot#error{:cause "clojure.walk", :via [{:type java.lang.ClassNotFoundException, :message "clojure.walk", :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}], :trace [[java.net.URLClassLoader$1 run "URLClassLoader.java" 366] [java.net.URLClassLoader$1 run "URLClassLoader.java" 355] [java.security.AccessController doPrivileged "AccessController.java" -2] [java.net.URLClassLoader findClass "...
02:45justin_smith,(require 'clojure.walk)
02:45clojurebotnil
02:45justin_smith,(clojure.walk/postwalk (fn [x] (if (string? x) (.toUppercase x) x)) {:a "A" :bs {:b "B"}})
02:45clojurebot#error{:cause "No matching field found: toUppercase for class java.lang.String", :via [{:type java.lang.IllegalArgumentException, :message "No matching field found: toUppercase for class java.lang.String", :at [clojure.lang.Reflector getInstanceField "Reflector.java" 271]}], :trace [[clojure.lang.Reflector getInstanceField "Reflector.java" 271] [clojure.lang.Reflector invokeNoArgInstanceMember "Re...
02:45Empperilol, .toUpperCase :)
02:45bcmperhaps... walk it is
02:45justin_smith,(clojure.walk/postwalk (fn [x] (if (string? x) (.toUpperCase x) x)) {:a "A" :bs {:b "B"}})
02:45clojurebot{:a "A", :bs {:b "B"}}
02:45justin_smithFINALLY
02:45Kneivayay \o/
02:45bcmthanks justin_smith
02:45Empperialthough your input data already has uppercase characters lol
02:45justin_smith,(clojure.walk/postwalk (fn [x] (if (string? x) (.toUpperCase x) x)) {:a "a" :bs {:b "bellow"}})
02:46clojurebot{:a "A", :bs {:b "BELLOW"}}
02:46Empperiwell now they are lowercase :)
02:46Empperiwell done!
02:46justin_smithEmpperi: it's St. Patric's day in the US, and I just got back from a show :)
02:46bcmgoing to lift your code via erc
02:46Empperihehe
02:46bcmwelcome back justin_smith
02:46EmpperiI'm at work just starting my working day
02:46bcmthats 2x you've helped me.
02:46TEttinger(inc justin_smith)
02:46lazybot⇒ 214
02:46justin_smithbcm: np, glad I could be of assistence
02:46bcmit's 5:46pm here Empperi
02:47justin_smithjust about 0:00 here
02:47bcmjustin_smith: are you a prof?
02:48justin_smithbcm: heh, no
02:48bcmMath software sounds extremely fun
02:49bcmmaxima-lly fun ._.;
02:49justin_smithhaha
02:50bcmalright back to work, I'm lifting a competitor's FAQs page. is that sketchy? we're going to re-write it a bit
02:51justin_smithso I saw this guy tonight, the first time we really hung out was the first time he ever tried acid, and while I was tripping I decided it would be fun to make him try to use vi
02:51justin_smith(he had never seen such a thing)
02:51bcmwhat the fuck hahahaha
02:51Empperilol? acid tripping vi first time usage
02:51justin_smithI was like "write some poetry"
02:51Empperithis is starting to sound epic
02:51SeyleriusWhat does cond do if there are two conditions in a row?
02:51justin_smithSeylerius: what makes something a condition?
02:52EmpperiSeylerius: cond is like if - else if - else if - else -structure
02:52bcmSeylerius: cond takes implicit pairs of condition -> action
02:52justin_smithSeylerius: as far as cond is concerned, conditions are alternating forms
02:52SeyleriusOh, now I get it.
02:52justin_smith,(cond nil (= 1 2) 1 (even? 0))
02:52clojurebottrue
02:52justin_smithaha
02:53SeyleriusI don't mind cribbing from another source, but I don't let myself submit it until I grok it.
02:53SeyleriusI do have rules, y'know?
02:53bcmcool, thanks Seylerius
02:53SeyleriusThank y'all.
02:54justin_smithSeylerius: clojure is really great for having so many pure functions - you can usually figure out what things do by trying subforms in the repl
02:54SeyleriusTrue dat.
02:54justin_smith(impure functions of course make this harder)
02:54TEttingerI'm doing some crazy polyglot stuff today. I spent about 6 hours writing reversible atomic updates to all state in a game, in C#, then fell asleep, and since then have written a clojure glPolygonStipple pattern generator and a C skeleton for someone trying to execute a function on timesteps when a timer gets to certain values
02:54bcmI listened to a podcast about a guy who's hobby is to change mis-used uses of 'comprised of' on wikipedia. he's changed 45k of them, and there are < 100 left. every sunday night he goes in and fixes all 100.
02:56TEttingerbcm, that's uh... quixotic
02:56justin_smithhaha
02:56bcmyeah, he said lots of people called his hobby a flat out waste of time
02:56bcmbut then he had a good point -> hobbies are usually a waste of time
02:57bcmlike watching sports or something
02:58bcmsounds productive TEttinger
02:59bcmjustin_smith: how did your first-time vi buddy fare with the poetry?
03:00justin_smithhe found the experience hilarious
03:00justin_smithI should ask him how much he remembers of that
03:03bcmis there a way for lein to add a dependancy to the repl while its running
03:04TEttingerkinda, you can use (what is it again? aether or pomegranate)
03:04justin_smithbcm: lein cant't, but you can
03:04bcmsay its [cheshire "5.4.0"]
03:04bcmwhere can i learn more?
03:04justin_smithI find pallet/alembic nice because it can load project.clj and use lein syntax
03:05TEttinger$google pallet/alembic
03:05lazybot[pallet/alembic · GitHub] https://github.com/pallet/alembic
03:05justin_smithbcm: add pallet/alembic to your ~/.lein/profiles.clj :user dependencies
03:05bcmsuhh-weet.
03:05TEttingeroooh that is nice
03:05justin_smith(require '[alembic.still :as still]) (still/distill '[cheshire "5.4.0"])
03:05TEttinger(inc alembic)
03:05lazybot⇒ 2
03:05justin_smiththat's literall all you need once alembic is loaded
03:06bcm:D!
03:06justin_smithor you can edit your project.clj then run (alembic/load-project)
03:06bcmIve been a clojure dev for over a year!!
03:07justin_smithload-project can be run multiple times - it won't get a different version of a dep, or unload deps, but will find and load new ones
03:07TEttingercongrats bcm!
03:08bcmThanks TEttinger.. but i meant it the way of: 'how have i never heard of this!!'
03:09TEttingerI hadn't either, but I'm not a full-time clojure guy
03:10justin_smithTEttinger: bcm: I try to bring it up whenever it is relevant here
03:10justin_smith(this channel is how I heard of it)
03:11TEttingerone of my projects has been fun lately, it has involved a C library that I hacked to output JSON files instead of images, then writing a C# library to load the JSON, then a Java lib to load the JSON, then changing a copy of the C lib to output Lua source, then a small Lua lib to load that Lua...
03:11TEttingerit's involved more IDEs than normal...
03:13bcmnow it totally works :D
03:13bcmTEttinger: not just emacs?
03:14bcmI guess Java -x-> emacs
03:15TEttingerand C# =/= emaca
03:17bcmfeeling lucky i dont have to leave home
03:44nicola_hello, how is everyone doing today?
03:46justin_smithnicola_: almost sobered up enough to go to bed
03:46nicola_hahaha where are you from?
03:46justin_smithwest coast US
03:47nicola_ah, whats the time there?
03:47justin_smith~00:48
03:47clojurebotCool story bro.
03:47nicola_lol good luck!
03:49nicola_its only 09:48 here
03:51bcmhi nicola_. 6:50 now
03:51bcmpm :)
03:52nicola_and where is that?
03:58nicola_so, are you guys working on anything interesting?
04:00daniel`nicola_: you must be in eastern europe
04:02nicola_im in south africa
04:02nicola_Cape Town :)
04:06daniel`ah :)
04:06nicola_daniel`: where you from?
04:07daniel`uk but i live in romania
04:07nicola_ah cool
04:07nicola_how long you been programming?
04:07daniel`as a job, about 4 years
04:08nicola_nice, where you working?
04:08daniel`as a hobby for longer
04:08nicola_ive only been at it about a year
04:09daniel`at a small online advertising startup, i don't use clojure in my job unfortunately
04:09daniel`mostly python
04:10nicola_ah well its hard to find a job as a clojure programmer
04:10daniel`im trying to bring some clojurescript to the frontend
04:10daniel`its harder, probably not that hard if its the most important thing for you
04:11nicola_people tend to be a bit afraid of functional languages
04:12daniel`its probably harder to hire, but you probably attract better people on average
04:13nicola_thats true. Well im not super familiar with industry standards, im still in uni
04:14daniel`good to see that clojure is gaining interest in cape town, i was there with work a little over a year ago
04:15nicola_yeah, weve got a small community going here
04:15nicola_its pretty cool
04:15dysfuni think ptaoussanis is from cape town as well. i use several of his modules
04:16nicola_i actually dont know
04:16nicola_would be cool if he is
04:17dysfunah no, i think it's Jo'burg, but it cuts off
04:17dysfunbut he's currently in thailand anyway
04:17nicola_ah i see
04:18nicola_well i have to go. :)
04:18daniel`cya
04:27SeyleriusWhat's the appropriate way to iterate down a seq, then stop and return a value when a function returns true?
04:29TEttingerprobably reduce and reduced with the value
04:30TEttinger,(let [coll [nil false 0 "" :hooray]] (reduce #(when (= %2 :hooray) (reduced %2)) [] coll))
04:30clojurebot:hooray
04:31TEttinger,(let [coll [nil false 0 ""]] (reduce #(when (= %2 :hooray) (reduced %2)) [] coll)) ; if it doesn't have it
04:31clojurebotnil
04:31TEttinger,(let [coll [nil false 0 ""]] (reduce #(when (= %2 :hooray) (reduced %2)) nil coll)) ; slight fix
04:31clojurebotnil
04:35borkdudein liberator, when I want only the content-type text/html for a put! request, but image/jpeg or image/png for get requests, what is the best way to accomplish this?
04:35ordnungswidrigborkdude: as the response content-type?
04:35borkdudeI had a nasty problem with IE9 having its in its accept header image/jpeg as the first thing
04:35borkdudeordnungswidrig yes
04:36borkdudeI'm posting to an iframe using iframeio
04:36borkdudebut in IE9 I got a popup because it returned the response as image/jpeg
04:37ordnungswidrigborkdude: you can use a fn for :available-media-types and depending on value in (get-in ctx [:request :request-method]) return different lists
04:37borkdudeah, thanks you!
04:38borkdudeordnungswidrig I didn't realize it could also be a function, but I read it now in the docs :)
04:38ordnungswidrigborkdude: liberator.util/by-method is a helper which dispatches on the request-method, e.g. :available-media-types (by-method :get ["image/jpeg" "image/png"] :put ["text/html"])
04:38ordnungswidrigborkdude: not tested, though
04:39borkdudek
05:03daniel`if a third party library uses extend-type, how can i also have the type extended the same in my code?
05:04daniel`rather than reimplement the protocol
05:14bcmis there a place where one can watch livestreams of programming?
05:25ordnungswidrigbcm: that sounds like a very nice idea. maybe even with live question to the programmer?
05:27bcmit'd be nice. I'd like to watch
05:28bcmI did some fun stuff this afternoon that i think maybe someone somewhere would like to watch
05:29bcmI like watching SC2 because the players are so skilled. I'm not that skilled but i'd sure like to watch someone who is extremely skilled at e.g. emacs do their thing
05:29bcmeven though questions would probably knock them off their train of thought
05:29wagjobcm: there's http://www.twitch.tv/directory/game/Game%20Development
05:29wagjobcm: aaand http://coderstv.com/
05:30bcmI've seen the twitch streams, I'll have to checkout coderstv
05:30Empperioh god, I'm just about to go insane
05:31Empperilein deploy, how hard it can be?
05:31Empperipretty darn hard it seems
05:34daniel`if a 3rd party lib uses extend-type to implement a protocol, can i use that same implementation in my code rather than reimplement it?
05:35bcmwhat's the O runtime of this function?
05:35bcm
05:35bcm(def a (atom 0))
05:35bcm(dotimes n (swap! a #(+)))
05:36bcmnooo :(
05:36bcmcorrected: (dotimes n (swap! a #(+ 1 %)))
05:41bcm,(def a (atom 0))
05:41clojurebot#'sandbox/a
05:46zotdumb question: is there a way to conditionally define a macro/function, ie (defmacro update …), but only for clojure <1.7?
05:48daniel`,(clojure-version)
05:48clojurebot"1.7.0-master-SNAPSHOT"
05:49ro_st1zot: here prismatic/plumbing only defines `update` if cljs doesn't already define it
05:49ro_st1https://github.com/Prismatic/plumbing/blob/ea5bfe00ac4eed1174cc2865ef640b8fb759b4b7/src/plumbing/core.cljx#L41-L50
05:50zotro_st1: perfect, that's exactly what i want to do atm :) thanks!
07:38clgvclojure.tools.logging question: I want to log a stacktrace and then exit the program. currently using (binding [log/*force* :direct] (log/errorf ...) (System/exit 1)) does not result in a log entry. Is there some method to flush the logger before calling System/exit?
07:47eglibcm: there is http://www.zombieclj.no/ which is highly entertaining
07:47agarmanclgv: why not use log/fatal ?
07:47eglithey speak norwegian but you can sort of follow along looking at the source code
07:48clgvagarman: huh? a change of loglevel for the message should have which effect?
07:51hyPiRionegli: Do you think there is demand enough for subtitles?
08:24m1dnight_Guys, for an irc bot I have a thread that runs an infinite loop to read from a socket
08:24m1dnight_what is a better abstraction to use than a Thread?
08:24m1dnight_(for easy abort etc)
08:36pandeiroanyone know of any gotchas using ring-mock's request w/ wrap-edn-params? when i request over http, the edn params are parsed and end up in :params; when i send the mock request to the app handler (with edn-params), params don't get parsed at all
08:44pandeiroanswering myself - :content-type "application/edn" needs to be assoc'd on to the mock request directly (i was doing it @ :headers {"Content-Type" "application/edn"})
08:44eglihyPiRion: I don't think there is enough demand for subtitles.
08:44eglibut I don't they are really needed. All they do is write code and comment it. As the code is all written in English it's really easy to follow along
08:45hyPiRionegli: ah, alright
08:47zotanybody have cljx 0.6 working nicely w/ cider/repl? the readme says that it should "just work", but afaict, 2.5.1 prevents it: https://github.com/lynaghk/cljx/issues/66
08:52slipsetm1dnight_: a go-loop?
08:52slipsetwith a kill-channel and alts?
08:53zot(fwiw, it does work w/ 2.5.0 — wanted to see if there was a usable manual sol'n w/ 2.5.1)
08:54m1dnight_slipset: valid point, the example shows that it might be what I need
08:54m1dnight_docs are a little scarse though
08:54m1dnight_oh nvm, i should read docs for go
08:54m1dnight_thanks slipset
08:54m1dnight_(inc slipset)
08:54lazybot⇒ 3
08:54slipset:)
09:24nicferrierI am having some trouble understanding how to use repeatedly.
09:25nicferrierif I do (repeatedly my-function-that-does-something) do I have to doall that to get it to actually do it?
09:25nicferrierI was hoping to use it instead of a while loop to loop forever.
09:25dm3nicferrier: then doall should work
09:25dm3but I'd choose while for clarity in this case
09:27dm3does anyone know how the clojure mailing list is administered? wrote a post couple hours ago which still didn't appear
09:28gfredericksnicferrier: I also agree that while is best, but it's worth pointing out that doall would be a memory leak when used like this, so dorun is better
09:28nicferriergfredericks: nice.
09:28nicferrierI might actually put it in a core.async loop
09:30clgvnicferrier: please don't use `repeatedly` like that
09:30nicferrierare you going to arrest me?
09:31clgvnicferrier: no, just sending my mobster buddies to your house ;) :D
09:31nicferrierhilarious.
09:34patrkrishi folks. if I change the implementation of a protocol method implemented on a record, do I have to restart the running REPL for it to come into effect? shouldn't it be enough to eval the defrecord form?
09:35nicferrierclgv: it's not a good approach, at least for me. why don't you explain what you think the problem is?
09:35patrkris(I've implemented the protocol directly in defprotocol)
09:36clgvpatrkris: no you will end up with a new class of the defrecord which is not compatible with the existing instances of the previous class
09:36patrkrisclgv: ah... any way to work around that? will it help to use extend-protocol/extend-type?
09:37clgvpatrkris: yeah, those are supposed to work
09:37patrkrisclgv: great, I'll try that. thanks.
09:37clgvpatrkris: all the other methods except the inline implementation within the defrecord
09:38clgvnicferrier: using some collection construction function to do side effects is a significant semantic clash
09:38patrkrisclgv: do people generally prefer implementing protocols that way?
09:39clgvpatrkris: that probably depends. afaik the inline implementation is more efficient since the usual lookup mechanism for java classes is used instead of the custom clojure protocol lookup
09:39patrkrisclgv: thought so. thanks again
09:39clgvpatrkris: but this only matters in a small number of scenarios
09:41patrkrisclgv: it's the same situation with deftype then?
09:41clgvpatrkris: yes
09:42clgvpatrkris: defrecord is implemented on top of deftype
09:42nicferrierclgv: you may want to downvote this and explain - http://stackoverflow.com/a/17531455/130125
09:43nicferrierthe reason I used repeatedly was that I could take just a few of it and see that it does it repeatedly.... or I could do all of it.
09:43nicferrierso the loop contents doesn't change. just some construct outside of it
09:43nicferrierif you use a while you have to have an extra condition which you then have to alter.
09:44clgvnicferrier: well, if you are actually interested in the results of invidividual runs that's fine. but your description read differently
09:44Glenjamin(doc repeatedly)
09:44clojurebot"([f] [n f]); Takes a function of no args, presumably with side effects, and returns an infinite (or length n if supplied) lazy sequence of calls to it"
09:44Glenjamin^ side effects implied
09:45schmirpatrkris, clgv: I can change the implementation of methods at runtime without problems
09:45nicferrierclgv: I'm not interested in anything but the side effect of the repeated function.
09:46clgvschmir: the problem of patrkris is that he used inline implementation and had to reevaluate the defrecords and hence define a new class by doing that
09:46clgvnicferrier: then it is not really appropriate.
09:46schmirand he expects the old instances to use the new methods?
09:46clgvnicferrier: consider it a hack for that use case
09:46clgvschmir: that's how I understood it
09:47patrkrisclgv: understood correctly
09:47schmirok. sorry for the noise
09:47nicferrierclgv: ok. I just don't really get it. I'll probably do it differently anyway with a loop recur... but I don't see what's wrong with repeatedly. it even notes it's "for" side effects.
09:48clgvschmir, patrkris: from a pure clojure perspective you could think that classes were just modified, but that is not the case
09:48clgvnicferrier: why construct a sequence when you do not need one.
09:48clgv+?
09:49TEttingeryeah, a typical use for me of repeatedly is ##(repeatedly 20 #(inc (rand-int 20)))
09:49lazybot⇒ (20 20 15 9 2 18 20 6 18 17 6 4 5 6 18 8 8 9 16 12)
09:49TEttingerwow, lucky night
09:49TEttingertriple crit
09:49nicferrierclgv: it's a good point.
09:50nicferrierclgv: but one throws it away... and there are advantages as I noted. but ok. if that's your objection I do now at least understand it. :-)
10:36gonk---hey, all. im trying to get a good idea in my mind of when to use atoms instead of agents and vice versa. ive looked around a bit, but could not find any examples that clearly state "i used x here because y would have z implications." can anyone shed some light?
10:37gonk---for example, agents happen in another thread by default compared to atoms. what difference would there be from something like (future (change-atom my-atom))
10:41chousergonk---: there are a bunch of differences that may or may not be relevant in any given use case
10:42timvisherdoes anyone know if `cider-nrepl` used as a plugin should decorate `lein ring server-headless` when it has `{:nrepl {:start? true}}` set?
10:44chouserfor example, in (future (swap! my-changer myatom)), my-changer may be run multiple times, whereas in (send my-changer my-atom), it will be run exactly once.
10:44timvisherit looks like it should based on https://github.com/weavejester/lein-ring/blob/master/src/leiningen/ring/server.clj#L46-L48
10:44chousergonk---: This would matter for example if my-changer had side-effects.
10:45timvisherunless there's some load order issue
10:46gonk---chouser: aha! OK, that's a great example that solves a problem I was having yesterday using atoms then.
10:46clgvgonk---: http://clojure-doc.org/articles/language/concurrency_and_parallelism.html
10:48maio/truncate-buffer
10:49gonk---clgv: ive looked that over, but never realized that agents will occur exactly once, whereas atoms may retry.
10:50timvisherlooks like it works with `lein repl :headless` though
10:51chousergonk---: Another difference is integration with STM. If you call send from inside a dosync, it will be held until the dosync transaction commits, and then will send exactly once. If you call swap! from inside a dosync, the atom will be mutated each time the transaction retries (hence the ! vs no-!)
10:52clgvgonk---: oh you are right. they dont convey the basics of agents well
10:52chousergonk---: If you're interested in advice on when to use or not use various Clojure features, and why, there's a book I could recommend. ;-)
10:53gonk---chouser: haha, i thought your name looked familiar!
10:53clgvgonk---: the O'Reilly book does a better job, if you happen to have that one lying around
10:55clgvthat other book is a good read as well ;)
10:55gonk---clgv: i see most people call JoC a more advanced book, so im not sure if I'm ready, haha.
10:56gonk---clgv: ok. perhaps its time to move off of the online snippets i pick up and move to something more 'established'
10:56clgvgonk---: yeah it probably helps to read "Programming Clojure" (2nd edition) or "Clojure Programming" first
10:58gonk---clgv: i know they both probably do roughly the same job, and i also know they both score the same under the all-important 'has a bird on the cover' metric, but are there any points that put one over the other?
10:58clgvgonk---: writing style, I think
10:58timvisherah. looks like it was a versioning issue. i was on lein-ring 0.8.7
10:59clgvchoose the one whose writing appeals more to you
11:01gonk---clgv: ok. im not sure how much experience you have with them, but i prefer 'good examples' and 'not dry' to most other metrics, so would you say one is better than the other in those regards?
11:02gonk---clgv: by the way, thanks for your patience. :)
11:07clgvgonk---: I'd say "Clojure Programming" has a more narrative style while the other has a more technical style. Both have plenty of examples
11:10clgvgonk---: I think both have sample chapters you can read
11:13gonk---clgv: ok. already checking out some samples. thanks.
11:17irctcsay something
11:19gonk---anything
11:22clgv,(println "something")
11:22clojurebotsomething\n
12:08justin_smith,'somethingcompletelydifferent
12:08clojurebotsomethingcompletelydifferent
12:46clgv,(print "/me greets justin_smith")
12:46clojurebot/me greets justin_smith
12:46LunarLandingworth a shot
12:49ordnungswidrigclgv: /me is implemented as a different IRC command, IMHO
12:50justin_smithyeah anything starting with / is a special command interpreted by your client, not the irc server
12:50clgvdamn ;)
12:50justin_smithI forget which client, but ages ago I used one with vi like bindings, that even used : instead of /
12:51justin_smithmaybe it was an option in tirc?
13:09mistaBIZso with a dirct connection to a running lein repl i have WAARNING: CIDER requires nREPL 0.2.7 to work properly
13:12timvisherare ring auto-reload and nrepl known not to play well together?
13:13timvisheri'm seeing a very strange issue where if i have them both set up and i'm doing live dev, eventually tests make there way into the execution path
13:14justin_smithmistaBIZ: what version of cider, and what version of cider-nrepl, are you using?
13:17anewhat's the idiomatic way to test for "not {}"? (not (empty? m)) ?
13:17justin_smithane: seq
13:17justin_smith,(doc empty?)
13:17clojurebot"([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"
13:17eli-sehi
13:18aneoh. sweet.
13:18justin_smithane: if you want it to be a condition and also the binding (eg. if-let) than (not-empty m) is good
13:18justin_smith,(if-let [m (not-empty {:a 0})] (:a m))
13:18clojurebot0
13:19justin_smith,(if-let [m (not-empty {})] (:a m :default))
13:19clojurebotnil
13:19anejust for a unit test
13:20ane(is (seq m)) worked great
13:22justin_smithheh
13:46dogonthehorizonGreetings all! I'd like to write a macro that takes a name and a set of fields (with types) and outputs Java source implementing a simple Builder Pattern for me. I'm aware of tools like ANTLR for outputing Java source but it seems rather complex for what I'm after. Am I needlessly complicating things or is therer something simpler that I can do in Clojure?
13:47amalloydogonthehorizon: you don't need a macro to output java source code. it should be (mostly, anyway) functions
13:49dogonthehorizonamalloy: Interesting, are you suggesting something like gen-class? I've experimented with gen-class and defrecord but unfortunately I lose type information when I attempt to use these classes from Java...
13:50amalloyhuh? no, you're just trying to output strings, right? that's what java source code is
13:51amalloyi mean personally i have to say there's probably a better way than outputting java source code, but if that's what you want to do all you need is a function that produces a string
13:53dogonthehorizonHa! My bad; that makes sense. What better way would you suggest, then? I have a working implementation right now that uses gen-class but the lack of type information (e.g. List instead of List<Foo>) makes the Java code rather unwieldy
13:53dogonthehorizonLots of type casting, etc.
13:54justin_smithdogonthehorizon: wait, what's the relationship between gen-class and java source?
13:55dogonthehorizonjustin_smith: I'm attempting to create Java friendly APIs for a small library I've written
13:55amalloydogonthehorizon: when i am trying to produce code that is to be consumed by java programmers, i usually write an interface in java, an implementation of that interface in clojure, and some stub java code that loads the clojure implementation
13:55justin_smithahh, and javac can't help you with the generics since it came from clojure
13:56amalloyi would counsel strongly against generating java code if your goal is just to provide a java-friendly API
13:56justin_smith(inc amalloy)
13:56lazybot⇒ 237
13:56justin_smithyeah, that's the sane way
13:56justin_smithwrite the interface in java, implement in clojure, have the java programmers code to the interface
13:56dogonthehorizonamalloy: Similar to how clojure.core does this with IPersistentVector vs PersistentVector?
13:57amalloysee, for example, https://github.com/amalloy/thrift-gen, which is a library implemented in clojure, with a few dozen lines of java wrapped around it so that it's easier for java users
13:57amalloydogonthehorizon: no, those are java classes with java interfaces and implementations in java
13:57amalloyyou don't want to do that
13:57amalloyoh
13:57amalloyyes, do that. i misread
13:58amalloyi, in fact, wrote a little tiny builder for the java side of that library
13:58amalloyit's tedious, but it's not long, and it's way easier than generating source code
14:00dogonthehorizonamalloy: thrift-gen is exactly the example I was looking for :) Thank you and justin_smith as well for steering me in the right direction!
14:00amalloyactually i guess i didn't use any interfaces for this one. interesting
14:13McCoyPauleyhello
14:13Balveda<Balveda> How could I access the data in a cljson decoded object? I get this in result: #js {:serverUsed 127.0.0.1:27017, :ok 1, :n 0}
14:13Balveda<Balveda> But I can't seem to be able to touch it through vec, map, list, etc
14:16Balveda(aget map "ok") did it
14:21justin_smith(inc Balveda)
14:21lazybot⇒ 2
14:21justin_smithfor sharing the answer
14:22Balvedathanks
14:24BalvedaReminds me of that age old situation
14:25Balvedadecade old forum threads, asking for an answer, the last message is just a "fixed!" or "sent by pm" and the thread is closed
14:40benjyz1hi. I'm looking for some point for running a clojure-ring webapp in production
14:40benjyz1*pointers
14:48justin_smithbenjyz1: do you plan on using a container?
14:49benjyz1no. one machine with not much load for the time being
14:49justin_smithif not, you can use aleph or http-kit and just make a runnable uberjar
14:49benjyz1I'm currently just using ring
14:49justin_smithwell, whether you use a container and how many machines you use are orthogonal
14:49benjyz1thx. why not just Jetty?
14:49justin_smithbenjyz1: ring is an adaptor over various web servers, I assume you are using the embedded jetty adaptor?
14:50benjyz1exaclty, yes
14:50benjyz1I want to keep it simple. I need to add an SSL cert
14:50benjyz1but don't want to get into NGINX right now
14:51justin_smithbenjyz1: I'd use an nginx reverse proxy, most of the java http servers are not really hardened
14:51benjyz1just the most simple setup and go from there. I'm wondering about securities aspects
14:51benjyz1I see. Jetty is not?
14:51justin_smithsecurity wise the simplest thing is nginx
14:51justin_smithnot the way nginx is, no
14:52benjyz1I see. wondering for what kind of attacks..
14:54amalloyi think benjyz1 is getting the wrong idea: justin_smith isn't saying to not use the embedded jetty adapter
14:55benjyz1I guess if fewer people use something, it's less well tested
14:55amalloyie, you run the ring-jetty-adapter inside your clojure app, but he's suggesting you don't use the jetty *container*
14:55amalloyi'd echo the suggestion to use nginx for your ssl proxy, though. it's well-tested and easy to set up
14:56benjyz1sounds good. I'll rethink my choice there. thanks
14:56benjyz1any idea whom could I contact for detailed knowledge about ring in production?
14:57benjyz1I'm wondering whether bigger shops are using it. it's not always obvious
14:57amalloybenjyz1: more or less everyone who uses clojure webservers uses ring
14:58benjyz1ok, cool. I saw for example prismatic posted a lot of info about what they are doing
15:01justin_smithbenjyz1: nginx has options like not responding to server scans (requests meant to hit multiple hosts, fishing for results while finding an open exploit), limiting obscure request methods, block referral spam, block hotlinking, etc.
15:01iulhysuigharwdid usa covertly supply isis with weapons like they did with al-qaeda to justify creating wars?
15:01iulhysuigharwdid usa excute the creative mess in the middle east like they said they will, does the creative mess include explosions with uncertain responsibles to create wars?
15:01iulhysuigharwplz, send my qs to help limiting usa&israel aggression against others.
15:01iulhysuigharw.
15:01iulhysuigharwdid usa covertly supply isis with weapons like they did with al-qaeda to justify creating wars?
15:01iulhysuigharwdid usa excute the creative mess in the middle east like they said they will, does the creative mess include explosion with uncertain responsibles to create wars?
15:01iulhysuigharwplz, send my qs to help limiting usa&israel aggression against others.
15:01iulhysuigharw.did usa covertly supply isis with weapons like they did with al-qaeda to justify creating wars?
15:01iulhysuigharwdid usa excute the creative mess in the middle east like they said they will, does the creative mess include explosion with uncertain responsibles to create wars?
15:01iulhysuigharwplz, send my qs to help limiting usa&israel aggression against others.
15:01iulhysuigharw.
15:01iulhysuigharwdid usa covertly supply isis with weapons like they did with al-qaeda to justify creating wars?
15:01iulhysuigharwdid usa excute the creative mess in the middle east like they said they will, does the creative mess include explosion with uncertain responsibles to create wars?
15:01iulhysuigharwplz, send my qs to help limiting usa&israel aggression against others.
15:03ibashwut
15:03benjyz1just_smith: you mentioned alpeph. I've come across it and it looks interesting.
15:03benjyz1that's more alpha though?
15:03benjyz1no pun indented
15:03justin_smithit's a good server
15:05benjyz1cool. I'm using buddy for crypto. it's a new library
15:05dopamean_is there a term for a function that does completely different things based on the type of the argument?
15:06amalloyconfusing
15:06benjyz1you might be looking for http://clojure.org/multimethods
15:07dopamean_amalloy: very
15:07dopamean_this is a question from someone else. i immediately thought of multimethods but he said that there was a more general term for it
15:07amalloyhe means polymorphic
15:08AimHereMultimethods doesn't just dispatch on type, it dispatches on damn near anything you want
15:08dopamean_i tried that as well. he said thats not it
15:08dopamean_said it was a weird sounding word and thats why he cant remember it. oh well
15:08dopamean_apparently jquery's jQuery() function is an example of it
15:19justin_smithdopamean_: parametric polymorphism?
15:20dopamean_so i guess i asked the question incorrectly. its not the type that determines the behaviour of the function but the actual value of the argument
15:21dopamean_so in the case of jquery it could be a selector or it could be html
15:25amalloydopamean_: a functino which returns a different thing based on the value of its argument is just called a function
15:29justin_smith(inc functino)
15:29lazybot⇒ 1
15:29justin_smithI do that all the time, hah
15:31amalloyjustin_smith: i transpose letters a lot more than i used to. not sure if it's the keyboard, or if my fingers are getting old
15:32justin_smithit's probably contagion from my own terrible typing skills
15:34benjyz1thanks justin_smith & amalloy for your input
15:35amalloymaybe i should learn to use C-t. at some point i rebound that to transpose-sexp, because i knew that i'd never remember to use it for single character accidents vs just deleting and retyping
15:36nullptramalloy: global abbrevs fix most of these automatically for me... (e.g. "teh" -> "the")
15:36anti-freezeHey everyone. So I'm trying to test my compojure app, and I can't seem to get around the CSRF token when making mock requests, causing any post request to return a 403. Any ideas?
15:37kungianti-freeze: Yes wait a second :-)
15:37justin_smithanti-freeze: seems like the two clear options are including the token properly, or turning off the anti-forgery middleware in the test
15:38justin_smithanti-freeze: for example, for many endpoint tests, it should suffice to call the unwrapped endpoint directly, unless the functionality you are testing somehow relies on middleware
15:38anti-freezejustin_smith: I was considering either setting up a test env with test middleware disabling the anti-forgery middleware, or sending the token in the post data. I don't know how to do either however
15:38justin_smithanti-freeze: you don't need a test env, you don't even need the ring server to be running to test an endpoint
15:38kungianti-freeze: I include (csrf-util/anti-forgery-field) in every test
15:38justin_smithgive the endpoint the request map, test the output map
15:39justin_smithno need for the server to be running
15:39anti-freezejustin_smith: So I don't use mock/request?
15:39justin_smithanti-freeze: I never use mock/request
15:39kungijustin_smith: really? never? I think it's quite handy.
15:39anti-freezejustin_smith: If I wanted to send the token with mock/request, how would I do that?
15:40justin_smithkungi: a request is just a map
15:40justin_smithI don't need mocking for that
15:40justin_smithanti-freeze: I have no idea, I never use it
15:40kungijustin_smith: I am aware of that. but mock/request makes map creation a bit nicer
15:41amalloy(inc justin_smith)
15:41lazybot⇒ 215
15:41anti-freezekungi: So, if i was to do something like: (mock/request :post "/login" {:email "a@a.com" :pass "pass"}) where would I include the CSRF?
15:42kungianti-freeze: in the params map
15:42kungianti-freeze: have a look into ring.util.anti-forgery
15:42anti-freezekungi: just a plain {... (csrf-util/anti-forgery-field) ?
15:43kungianti-freeze: no.
15:43kungianti-freeze: the name of the parameter is __anti-forgery-token
15:43anti-freezekungi: No utility functions for that to make it a little nicer?
15:44kungiso it's like {:email ... :pass ... :__anti-forgery-token ring.middleware.anti-forgery/*anti-forgery-token*}
15:45kungianti-freeze: Not in this case. But why not write your own utility function.
15:45anti-freezekungi: That's what I was planning to do.
15:46anti-freezekungi: I still get 403's
15:47kungianti-freeze: is the code online somewhere?
15:48anti-freezekungi: https://ideone.com/31xqsK
15:51kungianti-freeze: I think I know why this does not work. The middleware expects the token either in a header called x-csrf-token or in a form paremeter called __anti-forgery-token
15:52kungianti-freeze: you can use ring.mock.request/header to set it.
15:53anti-freezekungi: Ah, alright. I'll give it a go. Should I leave the __anti-forgery-token in the request map?
15:53kungianti-freeze: no you won't need it there
15:53anti-freezekungi: Alright, thanks a bunch. I'll give it a go and report back
16:00justin_smithkungi: anti-freeze: to be more explicit about my not using mock-request, I will spit the pprinted request I want to test to a file, remove irrelevant data, and then use that as my test data (either inserting it as a literal in the test file, or loading it as a resource .edn file)
17:25raspasovhi all, any recommendations for a Clojure or Java library for running shell commands on remote machines?
17:30justin_smithraspasov: I wouldn't use a library for that, I would use clojure.java.shell/sh - (shell/sh "ssh" "-i" "my.pem" "user@host" "-c" "command to run")
17:31raspasovjustin_smith: nice, thanks! I'll check that out
17:31amalloyjustin_smith: minus the -c
17:31raspasovI'm looking for the simplest possible thing :)
17:31justin_smithamalloy: ahh, I got the args wrong, OK
17:32justin_smithraspasov: anyway, I would definitely use a pem file, because that avoids checking remote credentials into your codebase
17:32raspasovjustin_smith: yea, definitely, makes sense
17:35Lewixanyone used robovm before?
17:35amalloy~anyone
17:35clojurebotanyone is anybody
17:35amalloyi hate this feature
17:36Lewixamalloy: feature?
17:37amalloythe feature where clojurebot remembers that anyone is anybody and can't be friggin untaught it, so you can't get at the actually-useful factoid also stored under anyone
17:41justin_smith~anybody
17:41clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
18:02dan_bI know all the arguments that thinking hard about the code is a more effective debugging technique than an interactive debugger
18:03dan_bbut I still somwtimes wish I could just stirck a breakpoint in a ring hander and find out what all the values in the request map actually are
18:04justin_smithdan_b: here's a favorite trick of mine: (defonce debug (atom [])) then inside some choice bit of code (swap! debug conj m)
18:05justin_smithuseful variations include addint timestamps, or keyed values with a hashmap instead of a vector
18:05justin_smith*adding
18:05justin_smithdan_b: also, cursive probably has the best debugging integration right now
18:05{blake}dan_b: You mean in the macro? Because, yeah, as justin_smith sez, you can debug in Cursive.
18:05dan_byeah, maybe at some opoint I should look at Things That Are Not Emacs
18:06justin_smithdan_b: hell, even SLIME/Swank had better debug support than cider does
18:06dnolendan_b: you can do this so easily in Cursive, it's worth having on your machine even if all you use it for is debugging IMO
18:07dan_bI remember slime from CL days. I may even still be listed as a contributor
18:09dan_briddn.core=> (slurp (BytesInputStream. (.getBytes "hello") 5))
18:09dan_b"hello"
18:09dan_bhmm, that wasn't what I expected to happen
18:09justin_smithdan_b: what did you expect that to do?
18:10dan_bI expected it to be a byte array
18:10amalloyjustin_smith: what's better about slime's debugger than cider's?
18:10amalloydan_b: slurp is for strings
18:10justin_smithamalloy: at least there's debug-repl - or is there something like that for cider now?
18:10amalloyis there something like that for swank? i don't know about it
18:11dan_byep, you're right, it does say "returns a string"
18:11dan_bI won't probe too hard into what character set/encoding it uses when given a byte strwam then
18:15justin_smith,(slurp (.getBytes "hello☃") :encoding "US-ASCII")
18:15clojurebot"hello���"
18:15justin_smith,(slurp (.getBytes "hello☃") :encoding "UTF-8")
18:15clojurebot"hello☃"
18:15justin_smithdan_b: ^
18:15justin_smithUTF-8 is the default, but you can specify any encoding the jvm understands
18:15justin_smithdan_b: http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html
18:16dan_boh, thx
18:16dan_bwasn't expectig you to do the work for me ;-)
18:17justin_smithfor values of "work" that include "remembering some trivia I learned a while back"
18:28tolstoyIs add-watch run in the same "transaction" as the actual update of the value of (say) an atom?
18:30tolstoySeems like from the code (clojure.lang.Atom and clojure.lang.ARef) that the atom is not "swapped" until all watches are complete.
18:31tolstoyBut there seems to be a delay between when a value is written to a file and when I can read it back out.
18:31AeroNotixtolstoy: show example code.
18:31tolstoyhttps://gist.github.com/zentrope/512edc035b894f56878e
18:32amalloytolstoy: no, atoms are not transactional
18:32tolstoyI'm not sure if the (occassional) problem is in the way I'm testing it, or the concept itself.
18:33AeroNotix...why do you need a file-backed atom?
18:33amalloyi haven't looked at the internals of watchers on atoms, but the only way i can imagine it working is: swap starts, stop completes, atom has new value, watchers are called with old and new value
18:34tolstoyAeroNotix: We have a need for some concurrent access to text files.
18:35AeroNotixmutex
18:35tolstoyamalloy: swap calls compareAndSet which, if it succeeds, calls the watchers.
18:35amalloytolstoy: right
18:36tolstoyAeroNotix: There are lots of ways to solve the problem. I'm curious if this is one of them.
18:36amalloyi think that's the scenario i described
18:36tolstoyYeah.
18:37AeroNotixthe simplest thing that works and fills your requirements is a mutax
18:37AeroNotixmutex
18:41tolstoyMaybe my test is bad.
18:43tolstoyIf I delay checking the content of the file for 1 sec, it has the value I expect.
18:43tolstoyOops. Nope.
18:43tolstoyOkay, experiment failed.
18:43tolstoyEr, hypothesis.
18:44amalloytolstoy: the most obvious problem to me is that a second swap! can run successfully while the watchers for an earlier swap! are still running
18:45amalloyso you can have two watchers running concurrently, with different old/new values
18:51tolstoyYeah, that makes sense.
19:12justin_smithamalloy: looks like the swap! doesn't finalize until the watch returns https://www.refheap.com/98599
19:13justin_smithor at least, it acts like it doesn't return until the watch does
19:13amalloyjustin_smith: i don't understand what that's demonstrating. you know that watchers are run on the same thread that's doing the swapping?
19:14justin_smithamalloy: added futures just now if you reload
19:14justin_smithhttps://www.refheap.com/98599
19:16amalloyjustin_smith: your scheduler is too precise
19:16amalloytry (Thread/sleep (+ 500 (rand-int 500)))
19:16justin_smithOK
19:16amalloyto see the uncoordination in action
19:17justin_smithamalloy: you're right, paste updated
19:17justin_smith(inc amalloy)
19:17lazybot⇒ 238
19:17amalloyi know, i tried it already just in case
19:17justin_smithwell we both knew, now everybody can know :)
19:18amalloyindeed
19:22justin_smithamalloy: on the other hand, an agent would block on the validator, right?
19:22amalloyprobably. i don't understand validators as well as watchers
19:24justin_smithanswered my own question and updated https://www.refheap.com/98599 - yeah the watcher stays in sync with an agent
19:24justin_smithoh, I meant watcher not validator
19:24justin_smithsorry
19:29tolstoyHm.
19:29justin_smithupdated the paste again, trying a validator this time https://www.refheap.com/98599
19:30justin_smithso many retries, but it stays serialized with a validator instead of a watch
19:31LewixHow come clojure hasn't been bought by a large corporation yet
19:31justin_smithtolstoy: anyway, if you intend to serialize access to the file, an agent is a better pick than an atom
19:31justin_smithLewix: is it for sale?
19:35tolstoyjustin_smith: Using the validator, rather than the watch on the agent?
19:35justin_smithtolstoy: it will work with a watch or a validator on the agent - agents don't optimistically execute or retry the way atoms do
19:35tolstoyjustin_smith: I was also thinking of just implementing clojure.lang.IAtom. ;)
19:36tolstoyAh.
19:36justin_smithif all you need is guaranteed exclusive access, agents make that straightforward enough I'd think - the operation won't go through until previous dispatched ops are done
19:37justin_smithbut the send / send-off still returns immediately on the caller's end though
19:37amalloyjustin_smith: honestly if you are just using an agent as a convenient thing to lock/sync on, it's just a mediocre reimplementation of a mutex
19:37tolstoyI'm mainly after being able to use swap! and reset!. But can back it with an agent, sure.
19:38justin_smithtolstoy: send-off does what swap! does, without the retrying stuff
19:38justin_smithamalloy: except it doesn't block callers
19:38amalloyif there's some stored state, and you want the asynchronicity (asynchrony?), agents are good
20:55celwellHi, I'm using a library that I pulling in with lein in my project.clj, but I need to make a small change to one of the functions in one of the clj files in that lib. What's the best way to override that function? Or do I need download the whole library and keep my own modified copy?
20:56tcrayford____celwell: recommended would be to fork and reupload it to clojars under your own group
20:56tcrayford____or send a PR if it's a generally useful change
20:57tcrayford____if you really wanna create a nasty mess by changing one of the functions, look at clojure.core/alter-var-root
20:57justin_smithcelwell: would a wrapper or utility function suffice, or does the change really need to be internal to that lib?
20:58celwelljustin_smith: then I think I would have to import a bunch of java files that are already in that library
20:58justin_smithcelwell: import is just a syntactic convenience
20:59tcrayford____doesn't sound too hard ;)
21:00celwellif i'm using a clj lib that is importing java files (like aws sdk) does that mean I can access/import those same files anywhere in teh project?
21:00tcrayford____yep
21:00justin_smithcelwell: as long as your deps ensure that they are on the classpath, yes
21:00celwellah, i just rewrite a simialr function then
21:00amalloycelwell: but note that nobody's actually importing java files, or accessing java files. it's java *classes* that are being used at runtime
21:01justin_smithyeah, better to rule out the easiest/simplest thing first :)
21:01amalloythe .java files were compiled long ago into .class files
21:15aytchwould anyone mind helping me solve this? I'm trying to work through 4clojure.com, and I feel like the test spec is failing.
21:15aytch(= __ conj '(2 3 4) 1)
21:16justin_smithaytch: OK, what did you try?
21:16amalloyaytch: as the owner of 4clojure.com i have to say you didn't actually copy the test spec correctly into this chat room
21:16aytchif I run (conj '(2 3 4) 1), I get back (1 2 3 4) - as I expect
21:16aytchoh, hi amalloy! you are correct - I was typing it.
21:16aytch(= __ (conj '(2 3 4) 1))
21:17justin_smithOK, so what did you suppy as an answer?
21:17aytchthank you for the awesome site. It's gotten me very interested in learning Clojure.
21:17aytch(1 2 3 4)
21:17aytch1 2 3 4
21:17aytch[1 2 3 4]
21:18amalloyaytch: you tried each of those, or you tried one answer which was all three of them?
21:18justin_smiththe first one is an error, the second one is calling = with 5 args, and the third one would work
21:18bchamCan someone help me with Carmine? I'm getting totally fucked here and I just can't figure out why. I'm using docker and I'm linking my redis container to my main app container.
21:18bchamI can ping the redis server no problem
21:18bchambut carmine can't connect to it
21:18TEttinger(= [(*)(+ (*)(*))(+ (*)(*)(*))(+ (*)(*)(*)(*))] (conj '(2 3 4) 1))
21:18bchameven though the host is available within the docker container.
21:18TEttinger,(= [(*)(+ (*)(*))(+ (*)(*)(*))(+ (*)(*)(*)(*))] (conj '(2 3 4) 1))
21:18clojurebottrue
21:19amalloyTEttinger: that's not helpful
21:19justin_smithTEttinger: correct, and not at all helpful
21:19TEttingerI know
21:19justin_smithlol
21:19aytchamalloy: I've tried all of them
21:19amalloyaytch: like justin_smith said, the last one would work
21:19amalloytry it again
21:19TEttinger,(= [1 2 3 4] (conj '(2 3 4) 1))
21:19clojurebottrue
21:19aytchoh......I see now.
21:19aytch[1 2 3 4], by itself, solves both.
21:19TEttinger,(= '(1 2 3 4) (conj '(2 3 4) 1))
21:19clojurebottrue
21:20aytchI thought it was two separate tests
21:20justin_smith,(= 1 2 3 4 [1 2 3 4])
21:20clojurebotfalse
21:20aytchso I've always had two lines
21:20TEttingerif you try to use (1 2 3 4) without the ' , it will try to call 1 as a function
21:20justin_smithaytch: yeah, that would mess it up
21:21amalloyi guess conj is the first problem with multiple test cases, isn't it
21:21aytchI believe so.
21:21amalloymaybe i'll add an explanation to that problem, like we did to the math one where people kept "filling in the blank" by restating the whole test case instead of just supplying a value for __
21:21justin_smithyeah, I think that is a good idea
21:22aytcheven just something like "one answer must pass both tests"
21:22aytchthank you, kind folk!
21:22amalloyaytch: http://www.4clojure.com/problem/5
21:23justin_smithnice
21:23aytchHooray! Also: that was quick!
21:23amalloyaytch: it's nice that we have live-editing of the problem statements built in; it's one of the few things i don't have to restart the server to do
21:26aytchI'm a little confused by this, still: https://clojuredocs.org/clojure.core/conj
21:26aytch(conj [1 2 3] 4)
21:26TEttingerconj acts differently for lists and vectors
21:26aytchis a vector, which returns [1 2 3 4]
21:27TEttinger,(conj [1 2 3] 4)
21:27clojurebot[1 2 3 4]
21:27justin_smithand differently still on sets :)
21:27TEttinger,(conj '(1 2 3) 4)
21:27clojurebot(4 1 2 3)
21:27justin_smith,(conj #{1 2 3} 4)
21:27clojurebot#{1 4 3 2}
21:27aytchyeah, but the question shows a list, and the answer is a vector
21:27TEttinger(but sets aren't ordered so don't worry)
21:27justin_smith,(conj {:a 1 :b 2} [:c 3])
21:27clojurebot{:a 1, :b 2, :c 3}
21:27TEttingeraytch, yeah, sequences are checked for equality by their elements
21:27justin_smithaytch: oh, that's another thing, clojure does structural equality for some types
21:27TEttingernot the actual type of the sequence
21:30aytchOkay. I'm still confused, but I shall soldier forward and work out these mysteries in time.
21:31justin_smithaytch: structural equality just means that lists and vectors are equal if they have the same elements in the same order, even though the type is different
21:31justin_smiththey generate different structures when you use conj, but are considered equal
21:31aytchahhh, okay! That's an interesting thing to know.
21:43justin_smithamalloy: you may be able to give a good answer to this SO question http://stackoverflow.com/questions/29131907/why-is-a-read-as-a-list-while-a-b-isnt
21:45amalloyi mean, i know the technical answer to that question, but i think a better answer is like, "don't care about this; use seq? in place of list?"
21:46justin_smith"list? is stupid and useless, use seq?"
21:46justin_smith(dec list?)
21:46lazybot⇒ -1
21:47amalloyi would upvote that answer
21:49Guthur`i would downvote list? because it's semantics are confusing
22:11justin_smithamalloy: well, I took my stab at it, but I feel like more info about the "why" he asked, or at least a good justification for not answering that part, would be nice.
22:12amalloyjustin_smith: i think an important example you're missing is ##(class (seq [1])), to remind people that the explicitly named types aren't the only kinds of seqs you'll find
22:12lazybot⇒ clojure.lang.PersistentVector$ChunkedSeq
22:13justin_smithoh, good call! thanks
23:54devn,(range 0 10 9/4)
23:54clojurebot(0 9/4 9/2 27/4 9N)
23:54devn,(map long (range 0 10 9/4))
23:54clojurebot(0 2 4 6 9)
23:55justin_smith,(range 0.0 (/ 1.0 0.0) Math/PI)
23:55clojurebot(0.0 3.141592653589793 6.283185307179586 9.42477796076938 12.566370614359172 ...)
23:56devn,(map long (range 0.0 10.0 9/4))
23:56clojurebot(0 2 4 6 9)
23:56devnjustin_smith: ah yeah, i think that's what i was trying to remember
23:56justin_smithwhich?
23:56devnerr wait
23:56devnno, there's a bug im trying to remember
23:56justin_smithwhat kind?
23:58devn,(partition-all 9/4 (range 10))
23:58clojurebot((0 1 2) (3 4 5) (6 7 8) (9))
23:58devn,(partition-all (long 9/4) (range 10))
23:58clojurebot((0 1) (2 3) (4 5) (6 7) (8 9))
23:59devnjustin_smith: there it is ^
23:59devnif there isn't a patch for it, there will be