#clojure logs

2012-12-17

00:35metellusum.
01:07seangrovecljs in chrome extensions is really pretty frustrating
01:11seangroveI have to do this for any object that's originated from the content-script: (js->clj (goog.json/parse (goog.json/serialize object-from-content-script)) :keywordize-keys true)
01:15seangroveI don't really understand this: http://dev.clojure.org/jira/browse/CLJS-439
01:16seangroveWhy not use goog.isObject instead of (identical? js/object .)?
02:24amalloyseangrove: tomoj probably knows
02:25seangroveamalloy: Using goog.isObject in that function seems to work fine. I've just copied/pasted it into a helper function I can use instead
02:26amalloyi'm the wrong person to tell
02:26tomojso now try js->clj on some weird stuff
02:26tomojlike a function
02:27tomojor any random object
02:27tomojlike a dom node or something
02:27tomojthat may cause havoc..
02:28seangroveAh, damn
02:28seangroveI suppose I can use it with some modifications for my needs of host<->CS communications though
02:29tomojmaybe just extend IEncodeClojure to your other frame's Object
02:29tomojdunno if you can do that
02:31seangroveYeah, not sure how to do that, or how to get a reference to the other frame's Object
02:37tomojprobably impossible I guess
04:57mindbender1what are some undeniable benefit of typed clojure as against untyped clojure
04:58HolyJakmindbender1: https://github.com/frenchy64/typed-clojure#readme ?
04:58clgvmindbender1: compile time errors when you pass the wrong type to a function, I'd guess
04:58mindbender1to me it looks more like beginner beenfits
04:59mindbender1something to help novice programmers to be more type conscious
04:59clgvmindbender1: if you have your core source completely typed and you change functions signatures that is a really useful tool to find the places where you forgot to change a function invocation
05:00clgvthis is the kind of error which annoyed me a lot during some refactoring
05:00benediktthere is a typed clojure?
05:01HolyJakbenedikt: indeed;  https://github.com/frenchy64/typed-clojure#readme
05:01benediktcool!
05:02mindbender1clgv: I think your case is a really good use case
05:02mindbender1should be mentioned in thagt readme
05:03mindbender1please guys if you have more use case let's share it
05:03clgvmindbender1: I like the idea of external optional typing. I dont know if it is yet so good that you can have the typestuff in completely different files. that would be awesome^^
05:11jballancI'd imagine that, eventually, typed clojure could implement certain optimizations that wouldn't be available to regular clojure
05:12jballancalthough, that's probably all washed out by hotspot
05:12clgvjballanc: typed clojure only checks. you would need additions to clojure's compiler to apply optimizations
05:15jballancright, that's what I mean...once type guarantees are in place, you could (in theory) utilize that information for optimization
06:00mindbender1I thought there was a lein newnew template for lib skeleton
06:00mindbender1lein new lib foo
06:19tgoossensthe dereferencing to get a snapshot is a great idea! But! What in the following case: (def r1 (atom [])) (def r2 (atom [r1]))
06:19tgoossens@r2
06:20tgoossensnot really a stable value as promised
06:21tgoossensthis could be a game board
06:21tgoossenswith players on it
06:21tgoossenshow to cope with this?
06:32clgvtgoossens: you want a consistent snapshot of both r1 and r2?
06:33tgoossensno, i'm just stating that @r2 doesn't really give you a snappshot of whats the situation was back then
06:33tgoossensbecause the nested atom r1 can still change
06:33tgoossensso its a weird situation
06:34tgoossensnot sure what it does when you would go back in history of the persistent data structure
06:34clgvhm what? please make one or two complete setences to describe what you want
06:34edlothioltgoossens: that's (one reason) why nesting atoms is a bad idea
06:34clgvoh they are nested ^^
06:34tgoossens:)
06:35tgoossensnested atoms just break all the goodness that comes with immutability
06:35clgvyeah better do not do that if you need a consistent snapshot
06:36tgoossensi came up with it because i have the situation of
06:36tgoossensa game board, and pieces
06:36clgvyou could have an immutable array with [r1 r2] though
06:36tgoossenshmmm
06:37tgoossensthats not such a stupid idea :p
06:37clgvyou could put the whole thing in a map within an atom: (atom {:board [field1 field2 ...] :pieces [pieces1 piece2 ...]}
06:37tgoossensyes i was just thinking that
06:37tgoossensbut how do i model the following:
06:38clgvif that doesnt work well, you can use refs for all mutable entities and get the consistent snapshot within a transaction
06:38tgoossensanother (concurrent) user of the system wants to track movement of a certain piece over time
06:38tgoossensthe easiest solutions is of couse to nest identities here. but then i'm back at my problem
06:39clgvtgoossens: the pieces have implicit ids within the vector I used in the example above, so (get-in @game [:pieces 1]) works
06:39tgoossenshmmm
06:39tgoossensmmyes
06:41clgvif you need to have change-handlers on every pieces you probably need to use refs instead
06:42tgoossensin my OO project (i'm rethinking it in clojure now)
06:42tgoossensi had a Board class & a Piece class
06:43tgoossensthey were coupled: board.getPieces() , piece.getBoard()
06:43tgoossensmaybe i'm trying too hard to get that functionality as well
06:44mindbender1clojure is about looking at your problems from a different point of view as clgv is stressing
06:45tgoossensi'm trying ;)
06:45clgvjust forget about those classes and use data representations instead
06:46clgvit helps to define the operations you need on that data to decide if it needs any special structure
06:46mindbender1I can't stress enough how Rich Hickey talks hepled
06:46mindbender1helped
06:46tgoossensi've seen a lot of them
06:46mindbender1listen to it over and over and over and over again
06:47tgoossensmaybe next semester, first exams :D
06:49clgvtgoossens: computer science?
06:51tgoossensyes
06:51tgoossensclgv: kuleuven belgium, 3th bachelor Computer Science
06:52clgvso more theoretical computer science now?
06:52andrewmcveigh|wotgoossens: You must be the only other person in Belgium I've heard of using Clojure!
06:52tgoossensWhere are you from then?
06:52tgoossens(in belgium)
06:53andrewmcveigh|woI'm from the UK, but I'm in Brussels.
06:53tgoossensah cool. Well in fact I discovered clojure via another belgium guy
06:54tgoossensi'm still pretty unexperienced, but i got tired of always having to think and work with java/OOP. So i went out on discovery to find something drastically different
06:54tgoossensand ended up with clojure
06:55andrewmcveigh|woYou're from Leuven, or just studying there?
06:57t-goossensI might be the only one at my univ that works with clojure
06:57t-goossensWho knows
06:58andrewmcveigh|woI wouldn't be suprised, I think there were only a couple of people who did anything but java when I was at uni. Few years ago though now.
06:59t-goossensHere almost all courses are java OoP based
07:00andrewmcveigh|woYeah, it's a shame that.
07:00t-goossensNext semester I think im going to read
07:00t-goossensSeven program language s in seven weeks
07:01t-goossensLooks interesting
07:01t-goossensAnd broading
07:02andrewmcveigh|woI just heard about that book the other day. Is it new?
07:02RaynesNot really.
07:03andrewmcveigh|woMaybe someone mentioned it on here...
07:11clgvcan I add an additional "jar" to the classpath leiningen uses for lein repl? just for a one-off test scenario
07:12llasramclgv: You can add the JAR file path to the project :resource-paths
07:25tgoossensandrewmcveigh: enjoy your stay in belgium. I'll be offline for the coming month (exams need a bit more focus ) So cya!
07:25andrewmcveigh|wotgoossens: cheers. Study well!
07:27clgvllasram: ah thx
07:30tomojwhat is the contract of IEditableCollection/ITransientCollection?
08:32TimMcllasram: I finally released lein-otf 2!
08:41clgvTimMc: ah the one with automatically generated main-function?
08:41PudgePacketHey, I'm doing the clojure koans, and I'm upt o recursion. The questions are really weird, do you guys have any pointers ?
08:42PudgePacketWhy would the function is-even? continually decrement ? how does that check if it's even or not at all ?
08:42clgvPudgePacket: if it changes the state of another boolean parameter it can
08:42babilenPudgePacket: You you mind sharing the function (e.g. on http://refheap.com) or give us a link to the particular question? (I, for one, haven't memorised all the koans)
08:43PudgePackethttps://www.refheap.com/paste/7658
08:43clgvPudgePacket: you can decrement and remember whether you decremented an odd or even number in total. if you reach zero you know whether the number was even or odd
08:44babilenclgv: How do you determine if the number of decrement steps (say k) is even or odd?
08:45PudgePacketIs there a function that can be called that will show how many times the function it's in has recursively called itself ?
08:45clgvbabilen: 1. dec -> odd, 2. dec -> even, 3. dec -> odd ...
08:46clgvPudgePacket: do you want a spoiler there?
08:46PudgePacketthen you would have to pass n, and another value to count how many times it has been called
08:46PudgePacketI don't really mind, i understand recursion and i've used it before, it's just this example is really confusing me, it's such a weird way to do it
08:46clgvPudgePacket: hint: is 0 even or odd? and what is n if n-1 is even? what in the case of odd?
08:46clojurebotNo entiendo
08:46babilenclgv: Why do you have to count how often you decrement? You will decrement exactly k times if the number you are testing is k
08:47clgvbabilen: it's not counting just switching the even and odd state
08:48clgvbabilen: I'd check 0th bit if I really needed to implement it ;)
08:48babilenclgv: That would be a sensible way to implement that, but I haven't seen the function PudgePacket is asking about yet and can't say anything about /that/ implementation.
08:48PudgePackethttps://www.refheap.com/paste/7658
08:48babilenclgv: Do /you/ have a link ... ? Ah, thanks PudgePacket :)
08:49clgvbabilien: I gave him a hint. theres nothing more left than the spoiler ^^
08:50babilenclgv: Ah, forget it then. I thought the question was: "Why is is-even? implemented as NEVER-SEEN-THIS which /only/ decrements?" Not: "How could I implement is-even? in a way that decrements/increments a number?"
08:52PudgePacketok I can't figure it out
08:52PudgePacket.........
08:52PudgePacketwithout altering the structure of the function, i don't see how i would implement it
08:53TimMcclgv: It's the thing that makes uberjars non-AOT, yeah.
08:55clgvPudgePacket: spoiler in PM...
09:20AWizzArdI have a sequence s and three functions f1, f2 and f3. I would like to apply the three fns to s and concat their results. Is there a more readable way than (mapcat #(% s) [f1 f2 f3])?
09:21AWizzArd,(mapcat #(% (range 9)) [identity #(partition 2 %) #(partition 3 %)])
09:21clojurebot(0 1 2 3 4 ...)
09:21AWizzArd==> (0 1 2 3 4 5 6 7 8 (0 1) (2 3) (4 5) (6 7) (0 1 2) (3 4 5) (6 7 8))
09:25sgeoUsing juxt maybe?
09:25sgeo,((juxt identity #(partition 2 %) #(partition 3 %)) (range 9))
09:25clojurebot[(0 1 2 3 4 ...) ((0 1) (2 3) (4 5) (6 7)) ((0 1 2) (3 4 5) (6 7 8))]
09:26sgeo,(-> ((juxt identity #(partition 2 %) #(partition 3 %)) (range 9)) (apply concat))
09:26clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$concat>
09:26sgeo,(->> ((juxt identity #(partition 2 %) #(partition 3 %)) (range 9)) (apply concat))
09:26clojurebot(0 1 2 3 4 ...)
09:26sgeoI don't know if that's actually more readable :/
09:35jsabeaudryRecommendations for a notification library from clojurescript?
09:41mthvedtare clojure core protocols standardized? that is, if i write something implementing clojure protocols--a new data structure, for example--is there a guarantee it'll work on clj/cljs/clj-clr/whatever going forward?
09:49clgvAWizzArd: what is not readable with the mapcat approach?
09:52stuartsierramthvedt: no
09:53stuartsierraAt the moment the protocols are different in Clojure/ClojureScript.
09:54mthvedtstuartsierra: thanks
09:55stuartsierraMaybe someday they can be brought into agreement.
09:55mthvedtyes, iirc host independence for the core lib was one of the reasons for protocols
10:13bosiei installed lein-midje via the plugin install mechanism and now i see this in my lein project: "leiningen.midje Problem loading: java.io.FileNotFoundException: Could not locate leiningen/core/eval__init.class or leiningen/core/eval.clj on classpath: (midje.clj:3)"
10:14bosieanyone know why?
10:14duck1123which version of lein are you using?
10:14bosiefresh install
10:14clojurebotI don't understand.
10:14bosielets see
10:14bosieomg
10:15bosieits not 2.0
10:15duck1123that'll do it
10:16AWizzArdsgeo: yes, juxt is a good idea.
10:17bosieguess i have to manually install leiningen
10:17hyPiRionmanually?
10:17hyPiRionAre you running windows or linux?
10:17bosieosx
10:17hyPiRionoh
10:18duck1123the manual process is still pretty automatic
10:18bosiethankfully
10:19bosieand voila
10:19bosielein-midje is installed
10:20bosiethanks duck1123
10:20clgvAWizzArd: but (apply concat ((juxt f1 f2 f3) s)) is even longer ;)
10:21hyPiRion(mapcat #(% s) [f1 f2 f3]) is short and sweet, no?
10:25clgvI'd say so ^^
10:28AWizzArdIt is short, yes. I just have the general concept to map over values. Of course, functions are the values here. But still, juxt is also not a bad candidate, because it directly brings the specific idea/mindset.
10:29AWizzArdTypically in 99% of my map calls the f in #(f …) is fix, while the varying stuff comes then.
10:31AWizzArdjuxt is doing exactly that core task
10:35clgvbut it is not concatenating the results for you
10:37clgv&(apropos "lazy")
10:37lazybot⇒ (lazy-cat lazy-seq *lazybot-dir*)
10:38clgvhumm interesting. repl-y in lein2-prev10 shows something called "lazy-clojuredocs"...
10:52grcMacro question: I'm trying to calculate a value in a macro and use that value in mygenerated code but I'm getting an error "can't use qualified name as a parameter"
10:52grcExample (defmacro foo [a] (let [bar (+ a 2) ] `(fn [bar] (* bar 3)) ) )
10:52gfredericksah ha
10:52gfredericks,`(fn [bar] (* bar 3))
10:52clojurebot(clojure.core/fn [sandbox/bar] (clojure.core/* sandbox/bar 3))
10:53gfredericks,(let [bar (+ 7 2)] `(fn [bar] (* bar 3)))
10:53clojurebot(clojure.core/fn [sandbox/bar] (clojure.core/* sandbox/bar 3))
10:53gfredericks,(let [bar (+ 7 2)] `(fn [~bar] (* ~bar 3)))
10:53clojurebot(clojure.core/fn [9] (clojure.core/* 9 3))
10:53gfredericks^ note this still doesn't make sense since 9 is not a valid function arg-name
10:53gfredericks,(let [bar (+ 7 2)] `(fn [bar#] (* ~bar 3)))
10:53clojurebot(clojure.core/fn [bar__105__auto__] (clojure.core/* 9 3))
10:54gfredericksit's not clear what you're actually trying to do from your example, so either of those tactics could be relevant
10:55clgvgrc: you have to use gensyms for bindings within syntaxquote, e.g. `(fn [bar#] (* bar# 3))
10:56grcgfredericks: I'm generating a function definition where the macro's argument is used (after modification) in the function so your final example looks right. What's the purpose of the trailing #
10:56grcah - gemsyms
10:56clgvgrc: that one would be: (defmacro foo [a] (let [bar (+ a 2) ] `(fn [] (* ~bar 3)) ) )
10:56clgvthe `bar` as fn param is superfluous I guess...
10:57gfredericksthe fact that you had bar as a function argument made it unclear what you were doing, since bar was a number in the context
10:57gfredericksbut debugging backquote is pretty easy since you can play with it outside of a defmacro
10:58grcThanks for that and apologies for the ambiguous nature of the question. Off to play with backquotes and gensyms
11:09clgvdo I need to stop an agent to get it garbage collected? or does not referencing it suffice?
11:11jsabeaudryCan I nest (context in compojure? i.e. (context "/foo" [] (context "/bar" [] foobar-routes))
11:12clgvjsabeaudry: according to the docs yes
11:12weavejesterjsabeaudry: Yep
11:13S11001001clgv: they'll gc, they aren't rooted in any thread
11:16TimMcS11001001: That doesn't make sense to me.
11:16clgvS11001001: good :)
11:17TimMcclgv: Is this some local agent, or what?
11:17S11001001TimMc: threads are rooted, so you have to kill them before they go away
11:17clgvTimMc: yeah. it's going into a closure.
11:18TimMcAh, OK. I'm used to seeing them in vars.
11:29jsabeaudryclgv, weavejester: great, thank you!
11:30clgvTimMc: need them in a closure to coordinate data serialization within a callback
11:33carknow that javafx is provided with the jre, and considering it's not automatically in the classpath : what would be the lein project.clj incantation to make it available to the repl ?
11:36clgvcark: there is probably no way to do that, since you need to know the install directory...
11:36carkbut but but ...
11:37carkin a pdf from oracle :
11:37clgvI'd make my life easy and keep it as dependency^^
11:37carkStarting with JRE 7 Update 6, JavaFX Runtime is part of JRE installation
11:37carkNo separate installation is needed for JavaFX, and there is no need to
11:37carkwrite custom code to detect where JavaFX is installed.
11:38clgvwell then it must be on the classpath, right?
11:38carkit isn't =/
11:38carkhum well
11:38clgvsystem classpath?
11:38carkhow would i check that from the repl ?
11:38clgvdo you have a profiler which lists such environment configurations?
11:39carkerr nope =)
11:39clgvyou could simply try an `import` with a known javafx class
11:39carki tried that
11:39clgvand it did not work?
11:40carknope didn't work, i wouldn't be pestering you about it if it did =)
11:40carkit's a pain to find documentation on the web about all this
11:40carkmuch is about older versions
11:40clgvright. hmm then you have to ask oracle about how the magic of the second sentence you quoted shall work^^
11:40carkhehe i guess you're right =)
11:41carkhow about the part where you said "i'd keep it as a dependency"
11:41clgvis it still available as single artifact via maven?
11:42carkjust add it to the local repository and refer to it as a normal dependency ?
11:42clgvthen use that one as dependency like before jre inclusion^^
11:42clgvhow did you include it until now?
11:42carki never included it, i'm only now investigating it for a new project
11:43carki'd love to have that web view thingie as gui instead of |@#@ swing
12:05clgvcark: depending on how strong you are sold to javafx - vaadin might be an option as well
12:28technomancyhttp://www.bonkersworld.net/object-world/
12:30hyPiRionI suppose "object-oriented" => "java-enterprisey"
12:31gtrakyegge's kingdom of nouns is my fave
12:32eggheadfor want of a horse shoe nail
12:32eggheadgood reference
12:52samrathow would I send a file's contents using the PUT method? here's my current attempt which returns `ClassCastException [trace missing]`: https://www.refheap.com/paste/7668
12:52samratI'm trying to use dropbox's api, btw
12:53TimMcWithout a stack trace, that's pretty hard to debug.
12:53TimMc...but I'd check whether local-path is the value you think it is.
13:06hyPiRionBlech, Travis seems to fail authentication with GitHub
13:08gfredericksdoes != work well with the finite domain code?
13:12gfredericksoh I see there is a !=fd
13:12dnolengfredericks: I commented on your ticket, and yes I would !=fd until the interaction between != and other constraints becomes more well understood.
13:12samratTimMc: it should be something like "~/tmp/foo.bar" right?
13:13gfredericksdnolen: I saw the comment, thanks for the prompt response :) are you actively working on it or is it up for contributions?
13:14dnolengfredericks: it's pretty low in the system - I'm working on it.
13:15gfredericksokay cool
13:16TimMcsamrat: I can only guess wildly.
13:21irctc712stuck in a macro problem
13:22irctc712(defmacro init-db [params] `(doseq [[db-name host db] params] (defdb ~db-name (cfg/build-db-spec ~host ~db))))
13:22irctc712(defmacro init-db [params] `(doseq [[db-name# host# db#] ~params] (defdb db-name# (cfg/build-db-spec host# db#))))
13:22irctc712both don't work
13:23hyPiRionWell, what are the input parameters?
13:23hyPiRionThe last one looks reasonable
13:24hyPiRionThough I'm not sure whether defdb is a macro or not. If it is, then it's attaching a gensym as name.
13:24irctc712yeah defdb is a macro
13:25irctc712the problem of second version is that db-name# should eval to real value, not just db-name#
13:25irctc712no idea how to do that
13:25hyPiRionYeah, here's the issue: ##`(def db-name# :foo)
13:25lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
13:25hyPiRionmeanie, lazybot.
13:25hyPiRion,`(def db-name# :foo)
13:25clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
13:25llasramirctc712: You need to iterate over `params` during macro-expansion
13:26hyPiRionor eval at runtime.
13:26llasramOr KILL BABIES
13:26hyPiRionclojurebot: eval
13:26clojureboteval is evil
13:27irctc712hyPiRion: could you elaborate
13:27ohpauleeztechnomancy: Do you have a document of tips for Code Swarming? PDX is about to do our first one this week.
13:28irctc712is there a solution without using eval
13:29llasramirctc712: Yes. Your macro just needs to iterate over the groups in `params` itself, producing an expansion which contains `defdb` forms for every group
13:29technomancyohpauleez: scripts and technical setup are in https://github.com/nuclearsandwich/swarming but the best general overview might be the clojure/west video here: http://www.infoq.com/presentations/Swarm-Coding
13:30ohpauleeztechnomancy: Thanks!
13:31llasramirctc712: something like (defmacro init-db [params] `(do ~@(for [[db-name host db] params] `(defdb ~db-name (cfg/build-db-spec ~host ~db)))))
13:31technomancyohpauleez: np; hope it goes well
13:31irctc712llasram: thanks, i'll have a try
13:31hyPiRionirctc712: llasram's solution is the "best" one in this case.
13:42jweisswhat's the best way to avoid having to recompile multiple namespaces, when you change a var in one ns, that is referred to in several others? Let's say there are several levels of such references. seems like you would have to make them functions (maybe memoized)?
13:43jweiss(when i say referred to, i mean in a def)
13:43S11001001jweiss: you'd have to make the referring points into functions
13:44jweissS11001001: yeah, i can get away with rebuilding the data each call at runtime but generally that is bad.
13:46llasramjweiss: Anything which actually references the var (normal Clojure function calls included) doesn't need to be re-compiled
13:46jweissllasram: yeah, i mean compile-time values eg, (def x (inc other.ns/y))
13:46jweisswhen i change y, i have to reeval that def
13:48jweissi guess i'd change it to (defn x [] (inc other.ns/y))
13:49duck1123if y is a reference type, you could have a watcher update x when y changes, but that's probably not the best solution
13:52auserhola all
14:03TimMcjweiss: You could build a memoize variant that watches a single atom somewhere. Frob that atom, and all the "memos" are deleted.
14:16dimovcihhello people
14:17dimovcihcan someone plz help me with some code...
14:17TimMcdimovcih: Just go ahead and ask your question; if someone can help they will answer.
14:17dimovcihwhy does (run a) cause the agent to fail with a null pointer error
14:17dimovcihhttps://www.refheap.com/paste/7669
14:20TimMcI have no idea what that code is supposed to be doing...
14:21dimovcihincrease the value held in agent a by 1 each time process is sent
14:21dimovcihthe same principle as the crawler example from Clojure Programming book
14:22TimMcPage?
14:22dimovcih222
14:23gfredericksit looks like it will bounce back and forth at least until the agent is at 10?
14:23borkdudedimovcih I also don't understand the code, but it works in my repl: #<Agent@31eeeaed: 10>
14:23dimovcihgfredericks: yes
14:23dimovcihborkdude: strange...
14:24gfredericksyeah I can't see why it wouldn't work
14:24borkdudedimovcih clojure 1.4.0 here
14:24dimovcihjeezzz... now it works for me too... wtf...
14:25TimMcdimovcih: Did you have old versions of those defns in your REPL, perhaps?
14:25dimovcihTimMC: maybe
14:25TimMcI'm not up to speed on how redefinitions happen, but I'm wondering if process referred to an old version of run.
14:26dimovcihI tested it a couple of times with restarting the repl and got the same error ...
14:26dimovcihwell, good to know it was a repl issue, and not code
14:27dimovcihlol, thanks
14:27TimMcSo frustrating when that happens.
14:39ohpauleez$findfn [[1 2 3][1 2][1]] [1 2 3]
14:39lazybot[clojure.core/first]
14:41gfredericks$findfn [1 2 3] [[1 2 3][1 2][1]]
14:41lazybot[]
14:42gfredericks$findfn [1 2 3] [[1 2 3][1 2][1][]]
14:42lazybot[]
14:42AimHere$findfn [true] [true]
14:42lazybot[clojure.set/union clojure.set/intersection clojure.set/difference clojure.core/list* clojure.core/time clojure.core/dosync clojure.core/distinct clojure.core/lazy-cat clojure.core/sequence clojure.core/rseq clojure.core/vec clojure.core/concat clojure.core/sequ... https://www.refheap.com/paste/7670
14:42gtrakha
14:43gtrak$findfn [0] [1]
14:43lazybot[]
14:43gtrak$findfn [1] [0]
14:43lazybot[]
14:44AimHere$findfn [* [1 2 3 4 5 6]] [720]
14:44lazybot[]
14:44ohpauleezgfredericks: Thanks, that's the I messed up the arg order
14:45ohpauleezI swear I've seen and written a comp to do what I'm looking for, but I can think of it right now
14:45AimHere$findfn [[[1 2 3][1 2][1]] [1 2 3]] [[clojure.core/first]]
14:45carkwhat is this findfn thing ?
14:45lazybot[]
14:45TimMccark: A lazybot plugin. It tests a bunch of fns against your args and output.
14:45ohpauleezit finds functions that give you the result, given some args
14:46AimHereYou feed it arguments and outputs, and it finds the core function that gives the result
14:46carkmhh
14:46ohpauleezyou can also use it locally, though I've never successfully done it
14:46cark$findfn 1 [1 2 3]
14:46carkwhat's the syntax ?
14:46lazybot[]
14:46cark$findfn [1 2 3] 1
14:46AimHere$findfn [5] [0 1 2 3 4]
14:46lazybot[clojure.core/first clojure.core/rand-nth]
14:46AimHereHah, you got lucky there!
14:47lazybot[]
14:47carkhaha
14:47carknice one =)
14:47carkso last argument is the return value
14:47AimHere$findfn [5] (0 1 2 3 4)
14:47lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
14:47AimHere$findfn [5] '(0 1 2 3 4)
14:47lazybot[]
14:48amalloyohpauleez: ##(take-while seq (iterate next [1 2 3]))?
14:48lazybot⇒ ([1 2 3] (2 3) (3))
14:48cark$findfn 5 '(0 1 2 3 4)
14:48lazybot[clojure.core/range]
14:48carkyay
14:48carkthat's almost like a little game
14:48ohpauleezamalloy: That's basically what I have written now
14:48carktest your clojure knowledge !
14:49ohpauleezI felt like I had seen something more succinct before
14:49amalloyi don't think there's a very good way to build it with comp and builtins
14:49AimHereI remember some conj talk or something where the miniKanren guys wrote a program to generate all the scheme programs that evaluated to 6. findfn should go that route!
14:50amalloyif you want heads instead of tails, you can write ##(reductions conj [] [1 2 3])
14:50lazybot⇒ ([] [1] [1 2] [1 2 3])
14:50carkAimHere: exactly what i was pondering
14:50AimHereIf there's no function in core that gives the answer, it should start making them up
14:50carkAimHere: the generated functions were mostly garbage tho =)
14:51cark(defn do-it [] 6) and the like
14:51amalloy&((fn [] ((fn [] ((fn [] 6))))))
14:51lazybot⇒ 6
14:51carkright =)
14:51ohpauleezamalloy: Ahh that totally works in my case
14:51AimHereI don't care. My mind boggles at the idea anyways
14:51ohpauleezthank you
14:52amalloyhah, really? asked the wrong question, then :)
14:52technomancyAimHere: it only works on the toy language they defined, not on actual scheme
14:52ohpauleezI did indeed
14:52carktechnomancy: nothing prevents you from defining a more complete language, maybe a subset of clojure
14:52ohpauleez(I just have to change the sort for something I'm working with)
14:53sgeoApparently there's no such thing as a language good enough that I will stick with it for a year
14:53sgeoAlthough there are some I keep coming back to again and again
14:53carkman i've been sticking to clojure for years now
14:53carksince before 1.0
14:54carkhow long has that been ?
14:54technomancycark: sure; in theory. I suspect it would be incredibly difficult to do it in a way that maintained compatibility with Clojure though.
14:54sgeoI think 1.0 was 2009?
14:54carktechnomancy: if that was easy there would be much more generative programming around
14:54sgeoOr was that when Clojure was first created?
14:55carktechnomancy: the idea is so exciting
14:55dnolencark: technomancy: I think it would be quite challenging - still I think there may be utility in modeling very specific parts of a Clojure / Scheme program w/ their approach.
14:55dnolenchallenging to model an entire language I mean, whether Scheme or Clojure
14:56carkmaybe some hybrid mix of logic and evolutionary programming would help
14:57amalloysgeo: 2009 seems kinda late. i know i picked it up in 2010, and 1.2 was released not long after that
14:58sgeoWikipedia says 2007
14:58sgeoDoesn't say if that's 1.0 or an earlier release
14:58technomancy2009 is correct for 1.0; it was April or so
14:58carkonce 1.0 came out, versions seemed to come faster than i could upgrade my existing projects. So could have been that fast
14:58technomancysame time as the first book
14:59amalloytechnomancy: july 2009 apparently
14:59amalloyhttp://build.clojure.org/releases/org/clojure/clojure/1.0.0/
14:59amalloypresuming that the timestamps weren't later mucked with
15:00technomancywhat the heck; changes.md only covers 1.4?
15:03amalloywho would ever care about any other version, am i right
15:06technomancywell, true of 1.4 specifically
15:10amalloythe git logs for clojure are interesting. apparently rich started work in march 2006, fiddled around a little until october, and then left it alone until june 2007
15:11matthaveneramalloy: hickey was literally laying in a hammock from oct 06 to june 07 ;P
15:11matthavenersort of a software design coma
15:32carkI asked this earlier but want to ask again just in case. javafx is now distributed with the jre. The only trouble is that it is not in the classpath. It is a single jar file jfxrt.jar in the lib directory of the jre. what would be the project.clj incantation to add this classpath to lein in a portable manner ?
15:34technomancycark: "exists somewhere in the JRE directory" and "portable" are mutually exclusive
15:34carkright; but it's included now on linux solaris and windows jre distributions, so there hsould be a way to access it ?
15:35carki managed to add it to my local repo and use it this way, but I don't like this, as my version might not be compatible with future version of the jre
15:36technomancyyou can hack it into :resource-paths, but like I said, you can't do it portably
15:36llasramcark: Is there an official way Oracle expects it to end up on the class path?
15:36carki think they expect you to use netbeans =P
15:36llasramhah
15:37carkmy poor emacs is just not to par ='(
15:40ynnivlazybot handles mail now?
15:41RaynesYeah, it's pretty recently. Only like 2 years.
15:41Raynes;)
15:43ynnivguess I don't get a lot of mail
15:43ynnivis there a clojure validation library that's introspective?
15:44amalloyintrospective sounds more like an implementation concern than a feature
15:45ynnivI have records that will be validated and want to show contextual UI elements for them
15:46duck1123are you doing this client or server side?
15:47ynnivyes
15:48ynnivI've grown a system that validates in clojure, exports descriptions as json, and creates the UI clientside
15:48duck1123I've been going between validateur and clj-schema for validating server side. I'm not sure which I like better
15:52duck1123with either one it should be simple to transform the error report into something you can use client side. I've been using backbone for my client-side models, but haven't hooked in validation yet
15:53devinuswhat's the binary number reader format?
15:54amalloy,101b
15:54clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 101b>
15:54amalloyaw
15:54amalloy,101r2
15:54clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 101r2>
15:54hyPiRion,2r100
15:54clojurebot4
15:54amalloyevidence, i suppose, that knowledge is more efficient than random guessing
15:54llasramI do like that it lets you express numbers in base 7 when relevant
15:55borkdudeis there an example of a small simple imperative language built with clojure?
15:55amalloyit should automatically interpret 755 as octal; i can't think of any other reason to use that number in code
15:55hyPiRionIs there an example of a language built with clojure in the first place?
15:56hyPiRionI've not seen one, but would love to have a look at it.
15:56llasramI guess it depends on what one means by "language"
15:56borkdudellasram a language not represented as clojure sexps
15:56llasramAh
15:57ynnivthat's a different syntax, not a different language
15:57ynnivIIRC clojure doesn't have the extensible reader that common lisp has
15:58hyPiRionyou have reader literals though
15:58borkdudeynniv an example of a small language with a simpe grammar, parsed and interpreted or compiled by clojure
15:58borkdudeynniv imperative
15:59dnolenborkdude: akhudek works on a logic programming language, here's another based on Inform7 targeted at kids http://github.com/maryrosecook/islaclj
15:59ynnivduck1123: I don't want to round trip and report errors, but use the validation schema to display a range for input, like a bounded slider
16:00AimHereYou can fake an inline language with some use of macros
16:00borkdudednolen tnx
16:00duck1123ynniv: Yeah. I don't know anything like that.
16:02dnolenborkdude: I'm sure I've seen some forths and I feel like I heard about a Java compiler.
16:03borkdudednolen a Java compiler in Clojure….? ;)
16:03dnolenborkdude: yes, that using core.logic to do type checking and byte code verification
16:03dnolenuses
16:03hyPiRionheh, sounds like we're talking about unicorns or dinosaurs
16:03hyPiRion"I've sure I've seen some"
16:03callenI was wondering about a potential use-case for core.logic/match (not sure where it would live) and if it would produce pathological behavior or not. Specifically, if one could build up a rules-based / expert system efficiently out of matching rules ala predicate logic and if doing so would be reasonably efficient or not
16:03hyPiRion"I think I heard of"
16:04callenI realize my question is vague, but I can get more specific if anybody gets down to brass-tacks.
16:04dnolenhyPiRion: well I haven't seen it, but I got patches to core.logic, was a student project by one of the Storm devs
16:04callenStorm uses core.logic?
16:04dnolencallen: no
16:04dnolenthe Java compiler project that was a term assignment
16:05callendnolen: do you have any thoughts regarding my expert system question?
16:06dnolencallen: seems in the realm of possibility yes - but I've never looked very closely at expert systems nor how they are put together
16:06callendnolen: the reason I'm envisioning this is that I'm trying to avoid hacking up a custom AI model or abusing a database.
16:06dnolencallen: well you probably end up hacking core.logic - so work will have to be done somewhere ;)
16:06callendnolen: well, just imagine something like a very large collection of "if statements/predicates", and you want to explore that space and get a list of "yeses" efficiently.
16:07callendnolen: taking for granted that some hacking will be necessary, does that sound like an efficient/appropriate use-case?
16:07callendnolen: in particular, something that will help is being able to detect related spaces of predicates so that you can treat it like "20 questions"
16:07dnolencallen: yes I think it would be interesting to use core.match for large decision tree optimization, but we'd probably need to patch core.match for that use case since there are code size limits on the JVM.
16:07callendnolen: where you narrow down the problem/question space as quickly as possible by matching against meta-rules that invalidate as many possibilities at once at a time.
16:08callenthis is simultaneously an interest of mine and a potential "business problem" to be solved at my startup.
16:08callenthe "MVP" version is just if-statements, but I'd rather do it more intelligently if we've proven that it's a useful bit of functionality.
16:09callendnolen: part of the problem is compiling and pre-preparing a tree that can efficiently eliminate as many possibilities at time as possible.
16:09dnolencallen: well that's what core.match does
16:09dnolenwith the specific goal of pattern matching in mind of course.
16:09callendnolen: that sounds like it could work, I'm just wondering how flexible it would be
16:10callenbecause it might mean projecting our data model into a big tuple of pre-prepared predicates. Another issue is that I don't want to match a single case, but rather, get a list of possibilities.
16:10dnolencallen: patterns are not first class - and it generate Clojure code - so the obvious limitations there
16:12callenI get that they're not first-class, I'm just not sure if my modeling of it as, "give everything that's true without testing redundant possibilities" is sensible for core.match. I thought of it as being more comparable to erlang/haskell type pattern matching.
16:13dnolencallen: yes, it's pretty much erlang/haskell style pattern matching.
16:13callenright, which leads to my aforementioned concern that it's a mis-matched use-case.
16:13callenmy impression was that it was designed to narrow down into a single test-case efficiently
16:14callennot explore a multi-faceted search space, avoiding redundant test-cases, efficiently.
16:14dnolencallen: right.
16:14callenlet me propose an alternative, and maybe this will better articulate what I'm thinking of.
16:14dnolencallen: in some distant future, core.logic ideally would have it's own version of the pattern matching optimizations.
16:15callenyou have a user, for which things could be true or not. You have rules you want to match the user against, thereby creating a list of possibilities.
16:15callena hypothetical model is treating the rules as a literal collection of "documents" in an indexed search engine and using a constraint solver of sorts to generate a pre-prepared query to search that space based on the content of the user's data.
16:16callenthen returning all the "matching" documents which happen to be "things that are possibly relevant to this user"
16:16callenalternately, treating each document/rule as a matching rule in a predicate logic/pattern matcher type system.
16:16callenOne is the inversion of the other, hypothetically.
16:17callendnolen: I'm sorry if I'm being opaque or wasting your time. Thanks for your consideration so far.
16:19dnolencallen: sounds like something worth modeling in core.logic - not sure if it can deliver the desired performance you want. though I could imagine some wacky cool solution that perhaps tries to leverage both. sorry I can't be more helpful.
16:19callendnolen: it's quite alright. the reason for the search engine thing is predictable soft real-time performance.
16:21dnolencallen: yeah if something already solves the problem and won't create a mountain of headache - little reason to try to cobble something crazy together from alpha quality open source libs
16:26devinusare regex's compiled during the compile stage or when the program is run?
16:26eggheadruntime i'd imagine
16:26eggheadthough I don't know for sure either way
16:27amalloyread time
16:27TimMcI thought regex literals were interned at compile time, but I couldn't produce any evidence of it.
16:28TimMc&(read-string "#\"[\"")
16:28lazybotjava.util.regex.PatternSyntaxException: Unclosed character class near index 0[^
16:28TimMc^ amalloy is right about it being read time
16:28devinusi wonder why
16:29m0smithhi
16:29eggheaddoes java even support regex at compile time? It doesn't have regex literals
16:29m0smithI have a Lein question
16:30devinusegghead: i know java doesn't, but i wonder if there would be a way to just store the compiled representation in the class file
16:30m0smithwhich is: In Maven I can filter resources so that the contents of the file is changed to include build info like artifactId and the like
16:30m0smithDoes Lein support the same thing/
16:30m0smith?
16:30TimMcIt seems like you ought to be able to write a plugin to do that.
16:31m0smithegghead: no, regexs in Java are simply strings that are compiled
16:32m0smithegghead: the Pattern object can be serialized
16:32devinusm0smith: if it can be serialized you'd imagine it could be compiled at compile-time
16:33m0smithdevinus: I imagine an annotation could be written to do that
16:33amalloythe serialized form of a j.u.regex.Pattern is just a string. it doesn't store any of the interesting stuff
16:34devinusah
16:35amalloy(i recommend having a local copy of the jdk source; it makes answering this sorts of questions so much easier)
16:35devinusErlang's re module returns the compiled regex as a binary, allowing Elixir to embed the compiled regex during compilation
16:40devinusis there anybody doing interesting SOAP work in Clojure?
16:40devinus(well, as interesting as possible given that it's SOAP)
16:41brehautdevinus: no offense, but thats the stupidest thing ive heard in a while
16:41m0smithI was just pondering a JAX-WS client in Clojure
16:41devinusbrehaut: which comment?
16:41brehautdevinus: SOAP in clojure
16:41devinusbrehaut: why's that?
16:41brehautwell because its soap
16:41technomancyor the phrase "interesting SOAP work"
16:41devinusso?
16:42brehautSOAP is the current pinnicle of design by committee meta type systems for RMI
16:42brehautover XML
16:42brehautits the cross product of 4 types of crazy
16:43devinushah
16:43TimMcbrehaut: That's impressive. I though you could only take the cross product of *two* vectors.
16:43m0smithSo how hard would it be to throw a WSDL at clojure?
16:43devinusconsidering i've had to work with SOAP in: PHP, Python, Scala, and most recently Erlang I'm aware of SOAP's crazy
16:43devinusbut the fact is, people still have to work with soap, regardless of what language they're using
16:44devinusso i thought seeing Clojure's answer to it would be interesting
16:44brehautdevinus: i think clojures answer is: cry, and then just use Java.
16:44llasrambrehaut: +1
16:45llasramI've been doing some UPnP stuff helping a friend with a personal project, and just counting on the existing Java libraries to insulate me
16:48devinusamalloy: regarding binary numbers, I swear i just read in JoC that there was a literal binary syntax
16:48brehautdevinus: having implemented one stupid RPC mechanism in clojure, i can understand the motivation. but learn from my fail, and dont take on something as insane as soap
16:48technomancyyou have to draw the line somewhere
16:50gtrak,(Integer/parseInt "0110" 2)
16:50clojurebot6
16:51amalloydevinus: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L64 is all the integer patterns, and there's clearly no binary pattern (aside from the r2 suffix, of course)
16:53eggheadon demand dynamic scoping is really nifty, thanks clojure!
16:55TimMc"clearly", he says, pointing devinus at a big ol' regex
16:57solussdis it possible to type hint using a Protocol name? e.g. (defn blah [^SomeProto obj] (proto-func obj)) ?
16:57TimMcIt also clearly allows 99rf00. :-P
16:58amalloyTimMc: if you're a regex pansy, you can look at https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L362 instead
16:58hyPiRion,99rf00
16:58clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Radix out of range>
16:58hyPiRionfor the masses.
16:58amalloysolussd: that would not be a useful typehint: it cannot improve performance
16:59solussdamalloy: maybe not, but would I get a reflection warning if I passed something else?
16:59amalloyyou don't get that with typehints anyway
16:59amalloy&((fn [^String x] x) 10)
16:59lazybot⇒ 10
17:00amalloytypehints are performance optimizations, not a static type checker
17:00devinusi didn't realize rich was fond of Whitesmiths style indentation
17:02solussdamalloy: yeah, but I thought they helped the compiler avoid reflection
17:02solussderr, runtime
17:02technomancyI always assumed the indentation style used in Clojure's Java implementation was a nameless horror.
17:02technomancykind of disturbing to learn there's a name for it as that implies other people use it
17:02amalloyyes, that is a performance optimization that has no impact on what warnings you get at compile time
17:02callentechnomancy: the horror isn't nameless...Cthulhu ftagn!
17:03dnolensolussd: type hints are only about interop, primitive arrays & unboxed arithmetic. anywhere else they have no effect.
17:03gtraktechnomancy: it's popular for C
17:03amalloydnolen: primitive deftype fields!
17:03devinustechnomancy: lol
17:03dnolenamalloy: oops, right
17:03solussddnolen: any point in type hinting for record types?
17:03callenI'm a fan of this indent style: if (blah) {
17:03dnolensolussd: primitive fields as amalloy pointed out
17:04solussddnolen: how about for functions I write that take a record type?
17:04dnolensolussd: if you want static type checking - help ambrosebs type the rest of clojure.core
17:04amalloysolussd: just for performance of looking up the fields
17:04dnolensolussd: the 4 cases above is it.
17:04solussddnolen: amalloy: thanks
17:05brehautcallen: clojure's java source is the gate and the key, and the guardian of the gate. past, present and future, all are one.
17:05solussddnolen: watched your techmesh core.logic talk thismorning- awesome stuff.
17:05dnolensolussd: thx!
17:06callen(inc brehaut)
17:06lazybot⇒ 8
17:06devinuswhat's a super tight clojure data structure i can use for packed values
17:06dnolensolussd: btw to be clear, type hints on protocols wouldn't make anything go any faster - protocol dispatch if the implementation was inline delivers host dispatch perf on the JVM.
17:06solussdI think I'll use pre-conditions where I feel I need to. I hate static typign. :D
17:06solussdgood to know
17:06hyPiRionHumm
17:06dnolensolussd: I'm still pondering on how we can deliver close to same guarantee on CLJS ...
17:07aperiodicdevinus: primitive byte arrays?
17:07gtrakdevinus: bytebuffer?
17:07devinusbytebuffer looks promising
17:08amalloynaw, solussd, you just hate badly-implemented static typing. static typing in, eg, haskell is pretty nice. choosing between good static typing and dynamic typing is a matter of taste; choosing java's static typing instead is worth hating
17:08callenamalloy: careful what you say re: Haskell and "nice"
17:09callenamalloy: that's only true when you're not using a library that has incredibly invasive monads that you keep having to ditch.
17:09solussdamalloy: you're right- I like haskell static typing- I hate it when static typing feels like it's getting in my way.
17:09callenthis is the same community that looks for excuses to turn every problem into parser combinators.
17:11solussdthe things I most frequently want a statically typed version of are records
17:12gtrakwhy?
17:12clojurebothttp://clojure.org/rationale
17:12duck1123I want static typing whenever I'm looking at docs and all it says is that it takes a function.
17:13brehautduck1123: totally
17:13solussdyeah, that too- or better documentation. :D
17:13technomancyduck1123: so you wish everyone else used it but you didn't have to? =)
17:13brehauttechnomancy: how great would that be :)
17:13technomancylike public transit or being carbon-neutral
17:14gtrakI thought we make the tradeoff that the code is so minimal, reading it is practical
17:14technomancyI would be happy with non-nullable Object
17:14technomancythrilled, in fact
17:14brehautlikewise
17:15technomancy◔ <- a pie chart of how many type errors I make that aren't NPEs
17:15amalloytechnomancy: i would like static typing when writing documentation, so that i *can* say what the dang function takes. it's so wordy to write junk like "returns a function f which takes a collection coll and a function g, and maps g over coll"
17:15technomancyamalloy: meh; "takes a collection coll" is redundant
17:15duck1123I was interested in typed clojure till I saw the video where clojure.set was being typed. That scared me away slightly
17:16brehautduck1123: im still interested, but i dont think i'd use it till it has an inferencer
17:16amalloywhatever, i just made that example up as fast as my fingers could type. the point is that i have written functions where the doc is difficult to write clearly
17:16technomancyamalloy: IME this is most likely to lead to mistakes when a concept has multiple representations in the code and there's no consistency in local names
17:17technomancyfor instance, user-id vs user; is bare "user" a map or was someone lazy?
17:18technomancyduck1123: yeah, without inference I'm certainly not going to take the time to annotate things
17:18eggheadclojure partials with multi arity fns are such a fine magic
17:18gtrakI have an example: "Accepts n-args of thunks that either return an error (value of some sort) or falsy, reduces over them and accumulates any errors. Returns nil if none."
17:19gtrakthe doc is 5 times as long as the function: (->> (map #(%) checks) (filter identity) seq))
17:20devinusyou would think that so would change his username
17:20amalloy"Returns only the truthy results of invoking the supplied thunks", gtrak
17:21llasramdevinus: I know, right? It's been driving me crazy
17:21gtrakamalloy: I suppose that's better :-)
17:21amalloythe implementation is easier too: (seq (keep #(%) checks))
17:21gtrakah, keep, I never use that one, thanks!
17:21amalloyalthough i guess that changes the meaning such that false now counts as an error
17:22hyPiRionyeah
17:22gtrakah, that's probably why I never use keep, I rarely need to differentiate between false and nil
17:22hyPiRion,(keep identity [true false nil :foo])
17:22clojurebot(true false :foo)
17:26devinusis there a function for (keep identity coll) ?
17:27devinus(keepident coll)
17:27hyPiRionA function for removing nils?
17:27hyPiRion(remove nil? coll) is probably more evident
17:27technomancyfunctions that are a trivial partial application of two existing functions generally don't get top-level definitions
17:28devinustechnomancy: probably a good philosophy to have
17:29brehautoh metaWeblog, no. base64 encoded media uploads‽ how is that ever going to be a good idea
17:29S11001001doesn't prevent occasional if-not, though
17:29technomancyS11001001: yeah, IMO that's kind of silly
17:30technomancyif-let is nicer, but only because macros aren't as composable as functions
17:30tgoossensif have a vector [1 2 1] and some collection. i want to sequentially "take&drop the given amount in the vector. Example coll [a b c d] ,vector [1 2 1] it should return [[a] [b c] [d]]
17:30technomancyS11001001: if someone proposed adding if-not today it would get shot down with prejudice before you could blink
17:30tgoossensany ideas?
17:31AimHeretgoossens, I'd knock up something using loop and recur and take
17:31amalloytechnomancy: really?
17:31S11001001tgoossens: you need a reduction
17:31tgoossensi was thinking that as well
17:31tgoossens(recur)
17:31tgoossensi'll go with that for now
17:31S11001001technomancy: I would hope so
17:31gtraka case of 'programmer-convenience thinking' :-)
17:33dnolen\me likes if-not when-not just fine
17:34gtrakI really don't like '(if (seq ..
17:34hyPiRiongtrak: I tend to use (if (empty? .. instead
17:34dnolenalso they leave the door open for some clever optimization by CLJ implementations like CLJS if the host language has effed up notions of truthy falsey like JS
17:35gtrakhyPiRion: yea... seq is supposed to be idiomatic according to the docs
17:35gtrakempty? is more intuitive, but (not (empty? is discouraged
17:35hyPiRionCall me stupid, but I think it reads better
17:35hyPiRionwhy is that?
17:35hyPiRionbetter to use not-empty ?
17:36technomancyyeah, seq is not an english word
17:36gtrak,(doc empty?)
17:36clojurebot"([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"
17:36technomancyeven its clojure definition makes no sense in a conditional
17:37gtrakso now I just call seq on my returns values of things... for the convenience of client ifs... I guess that might be bad.
17:37amalloygtrak: that's not really very nice, because it forces evaluation of a seq that might never get consumed at all, and which might be expensive
17:38gtrakjust the head, I thought
17:38hyPiRion,(take 4 (seq (range)))
17:38clojurebot(0 1 2 3)
17:38technomancygtrak: depends on chunking
17:38gtrakyea, in this use-case, error checks on a web-service input, there will always be a conditional realizing it
17:39gtrakotherwise there's no need to do it in the first place
17:40AimHereIsn't seq bad for testing of empty, since it evals the first element?
17:41gtrakAimHere: there's no other way
17:41gtrakI think this notion of falsity should have matching conditionals though... it's common for me at least
17:41AimHereHmm, (not (empty? [])) also evaluates it, fair enough
17:42gtrakI guess you could implement an 'empty' protocol, or something equivalent
17:43AimHereTrap compiler exceptions and if they're unresolved symbols of the form foo-not, turn them into (not (foo ...))
17:45gtrakhuh, what the heck does #! do?
17:46gtrakah, 'CommentReader'
17:46gtrakthat's new to me
17:46gtrak,#! WTF MATE
17:46amalloygtrak: it's a trick to make shebang work
17:46clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
17:46hyPiRionheh
17:46gtrakah
17:47amalloy#! is strictly identical to ;
17:49matthavenerdoes anyone use shebang? is there a nice workaround to the jvm startup?
17:49hyPiRionI use it for scripts
17:50hyPiRionand for the jvm startup time, there's always Drip
17:51matthavenerwow, drip is awesome, thanks hyPiRion
17:51gtrakfor the clojure startup time, you can lazyload libs by using (require..) and resolve at runtime
17:51TimMcgtrak: And don't forget &| (+ 2 3) |&, of course.
17:51lazybot⇒ 5
17:51gtrakwha?
17:51TimMcYeah man, &|
17:52TimMc(Kidding, it's some random lazybot eval delimiter.)
17:52gtrakhaha
17:53TimMc,'(&|5|&)
17:53clojurebot(&|5|&)
17:53TimMcMmm, it's just like ##
17:54hyPiRion,'( &| 42 |& )
17:54clojurebot(&| 42 |&)
17:54hyPiRionboo
17:54TimMc,'(&|(+ 2 3)|&)
17:54clojurebot(&| (+ 2 3) |&)
17:54lazybot⇒ 5
17:54lazybot⇒ 5
17:55TimMchyPiRion: THe inline eval feature demands parens, or maybe one other leading char.
17:55ynnivhmm, what's wrong with (not (empty? x))
17:55ynnivi usually use (comp not nil?) to filter my collections
17:55hyPiRion&| (+ 1 2) (+ 3 4) ; |&
17:55lazybot⇒ 3
17:56hyPiRion&| (+ 1 2) ##(+ 3 4) ; |&
17:56lazybot⇒ 7
17:56TimMcynniv: Golfers will get annoyed because you could usually just write (seq x).
17:56TimMchyPiRion: It only takes the first form anyhow.
17:56TimMcOh, I see. nvm
17:56hyPiRionUnless you inject some ##'s within there
17:56lazybot⇒ s
17:57brehautTimMc: ive always wonder what running maven backwards would do.
17:57brehautwould it restore sanitiy?
17:57ynnivTimMc: umm, what if I have non-collections in my list?
17:58wingyI have a HTML form that makes a POST go a POST route .. should a POST route redirect to a GET route or is it okay for it to return a HTML response with a body?
17:58ynniv,(filter (comp not nil?) '(a b c nil d))
17:58clojurebot(a b c d)
17:58brehautwingy: if you redirect a post to a get it stops accidental double-submits
17:58ynniv,(filter seq '(a b c nil d))
17:58clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
17:59wingybrehaut: what do you mean?
17:59gtrakynniv: that's a lot like identity
18:00auserhey all
18:00gtrakynniv: err, wait... just use (remove nil? ...)
18:00TimMcwingy: https://en.wikipedia.org/wiki/Post/Redirect/Get
18:00brehautwingy: say your post creates a DB item. (eg, posting a comment on a blog). a double submit will result in the same comment appearing in the DB (and thus on the page) twice. If you just return HTML from the POST route, then double submits are possible, but if you redirect to the GET instead, then the interaction error that causes double submits is avoided
18:00ynnivgtrak: depends on whether falsey means false or no return value
18:00brehaut(inc TimMc)
18:00lazybot⇒ 22
18:01ynnivremove nil? expands into (comp not nil?) anyway. 6 of one?
18:02amalloyTimMc: inline eval demands a collection of any sort
18:02gtrakynniv: I usually go for minimal surface area and maximum display of intent..
18:02gtrak(remove nil? ... ) reads easily
18:02karbakTrying to understand how the following works - (if (#{:a :b :c} foo) (then-clause) (else-clause)) - specifically the syntax around (#{..} foo)
18:03gtrakkarbak: using a set as a function checks for containment
18:03bbloom,(#{:a :b :c} 1)
18:03clojurebotnil
18:03bbloom,(#{:a :b :c} :b)
18:03clojurebot:b
18:03bbloom,(boolean nil)
18:03clojurebotfalse
18:03bbloom,(boolean :b)
18:03clojurebottrue
18:04hyPiRionIf you don't have false or nil in the map, then it's the same as the following
18:04ynnivthats fair, but you don't always get to specify filter vs remove
18:04hyPiRion(if (contains? #{:a :b :c} foo) (then) (else))
18:04wingybrehaut: i c .. so PRG is a good thing
18:04brehautwingy: yes
18:05gtrak,(contains #{nil} nil)
18:05clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: contains in this context, compiling:(NO_SOURCE_PATH:0)>
18:05gtrak,(contains? #{nil} nil)
18:05clojurebottrue
18:05gtrak,(contains? #{} nil)
18:05clojurebotfalse
18:06gtraknil is a silly thing to have in a set
18:06karbakgtrak: thanks, forgot that worked both ways. What kind of object is #{...} - a sequence of some kind?
18:06metellusit's a set
18:06gtrak,(class #{})
18:06clojurebotclojure.lang.PersistentHashSet
18:07ynnivgtrak: why? could be a set of valid inputs
18:07gtrakI'm writing a function that only takes nil or 4... 2 is right out!
18:08ynnivyou laugh...
18:08gtraknah, I'm kidding, it's practical I guess.. but strange if you try to think about it too hard
18:08wingyif i have a ring session and wants to keep it then i shouldn't return a new :session key-value/pair?
18:09ynnivthat's why I never got into haskell
18:09ynnivit always feels like they're thinking too hard
18:09gtrakwingy: the session middleware will do it for you unless you explicitly clear the session with ':session nil'
18:09wingygtrak: great
18:10gtrakI also found myself writing a function to copy a session from a request into a response, in case I want to modify something and I don't want to use the sandbar approach
18:11gtrakbut an empty :session key on a response doesn't alter anything
18:12wingyI get "java.lang.NullPointerException" in Ring response but i can't get what causes it
18:12wingythere is no stack trace as well
18:13gtrakis *e bound?
18:15gtrak,*e
18:15clojurebot#<Unbound Unbound: #'clojure.core/*e>
18:15gtrakhmm, I bet that only works at the repl
18:15gtrak&*e
18:15lazybot⇒ #<Unbound Unbound: #'clojure.core/*e>
18:17wingygtrak: *e was great to get an error message
18:19octagonhi, is there a way to accomplish the same as the javascript "a instanceof B" in clojurescript?
18:19dnolenoctagon: instance?
18:20octagonawesome, thanks dnolen
18:20dnolen(instance? String "foo")
18:20dnolenfor example
18:21octagondnolen: thanks, that looks like what i need. there is nothing in any of the refcards about it, by the way
18:22dnolenoctagon: yeah I'm not in charge of those - might be worth bringing up on the ML or contacting the people that keep them up-to-date
18:23devinusi wonder why apropos returns a list
18:23devinusinstead of a vector
18:24amalloyit surely returns a lazy sequence
18:24bbloom,(class (apropos "do"))
18:24clojurebotclojure.lang.LazySeq
18:25devinusamalloy: ah, curse me getting ahead of myself
18:26devinusi just started the chapter on laziness in JoC
18:26devinusto me it just looked like a list
18:28amalloythat's the idea
18:33wingyi've got a design issue .. so im using datomic where the attributes have a certain data type eg. float, string etc. the form returning the fields (attributes) are all in strings .. so i should convert the form params to appropriate data type manually?
18:34gtrakyes? that should be a function of a serialization/deserialization lib, or you should validate your inputs
18:36gtrakgenerally, you should have the front layer of your app responsible for validating user input, and persistence code should never have to deal with that
18:36wingygtrak: yeah
18:37wingyi wonder how i could know what data type each form field is
18:42gtrakyou mean.. .like a schema?
19:02wingygtrak: lucky me datomic's attributes are just saved as data so i can query them to get what type they are
19:02gtrakah, that's neat
19:04wingyyepp … made my day
19:05samfloreshey, where did seq-utils go?
19:06technomancysamflores: various places; looking for a specific function?
19:07samfloresfind-first
19:07technomancyis that the same as (first (filter ...))?
19:08samfloresyeah, I know. I'm using it. justo wondering if I'm reinventing something that's already implemented :)
19:08samfloress/justo/just/
19:08technomancyfunctions that are a trivial partial application of two existing functions generally don't get top-level definitions
19:08technomancy
19:08samfloresok, then. thanks
19:10technomancys/partial application/composition/
19:10technomancynp
19:10gtrakdidn't you just say that 30 minutes ago?
19:10technomancyyep =)
19:11technomancyIRC is easy when you can just pound M-p
19:11gtrakha
19:11gtrakcareful, you might fail the turing test
19:12callengiven what I've heard about technomancy being tall and having an evil goatee, he'd be the tallest, most evil markov chain that ever was.
19:12AimHereWell that's because Mark V Chaney was a midget
19:13callenAimHere: Shaney
19:13AimHereActually it's Markoff I was thinking of
19:13AimHereMark V Shaney was a bot. Markoff Chaney was the midget
19:14callenAimHere: you don't run into many people that read that series these days.
19:15AimHereYeah, seems to have fallen out of fashion
19:15callenAimHere: I think the general sub-culture died with the 90s
19:15gtrakhm, I'm guessing it's generally a bad idea to capture a handle to a ring request map and send it off to an async thread
19:16callengtrak: nothing is a bad idea as long as you set your expectations very low.
19:16callen"this could explode in my face. Okay then."
19:16gtrakha, it's rare that I worry about a memory leak these days.. but it might bring me to it
19:17gtrakclosures just make it so easy!
19:18samfloresis there a way to define a function in a ns other than the current one?
19:19eggheadwhat are you doing that makes you want to do that samflores
19:19gtraksamflores: yes, you can switch ns mid-stride
19:19technomancyit's possible but not wise
19:19eggheadchanging ns and then deffing something inside a fn, makes my skin crawl!
19:19brehautgtrak: I would be curious what the lifespan of a ring :body is on the request. It may well not live beyond the lifespan of the request / response cycle
19:20brehaut(and may be adapter / server dependant)
19:20gtrakwell, it *shouldn't*, but that means there has to be some indirection in the input/outputstreams, I guess that's what they're for, after all
19:21brehautgtrak: shouldnt might be a flexible notion in context of keepalive
19:21samfloresI'm making a macro (yeah, I know I probably shouldn't) that defines some functions in it's own ns
19:21gtrakit seems like one of those clojure-java value chasms
19:22gtrakwhat's a 'value' in the presence of mutability?
19:22technomancyan integer? =)
19:24hyPiRionuh, that's news to me
19:25hyPiRion,(meta (with-meta '(1 2) {:foo 1}))
19:25clojurebot{:foo 1}
19:26hyPiRion,(meta ^{:foo 1} '(1 2))
19:26clojurebotnil
19:26hyPiRion,(meta ^{:foo 10} (list 1 2))
19:26clojurebotnil
19:28hyPiRionAnyone with experience with metadata
19:28hyPiRionthat could explain the results above for me? I get the (quote (1 2)), but the (list 1 2)?
19:29hyPiRionIn addition, elaborating why quoted lists automatically has {:line lineno} attached would be a great addition.
19:33brehauthyPiRion: i know next to nothing about metadata but reader metadata (such as is attached with ^) is intended for clojure the language, whereas if you want meta data in your program you want with-meta i believe.
19:34brehauthyPiRion: from memory reader metadata is attached to forms that are read, not the functions that are evaluated
19:34brehauthyPiRion: thus ^{:foo 1} (list 1 2 3) is attaching the metadata map to the list '(list 1 2 3) not the list created by evaluating that expression '(1 2 3)
19:35brehauthyPiRion: i suspect that lists that you get back from the reader have metadata annotating textual information because thats useful for error reporting
19:36hyPiRionWell, that's consistent with what I'm seeing here. Thanks
19:36hyPiRion(inc brehaut)
19:36lazybot⇒ 9
19:36hyPiRionI learned something today too.
19:36brehauthyPiRion: it might also be wrong ;)
19:36bosiehttps://gist.github.com/6c7b342124669300d461
19:36brehauthyPiRion: thats based entirely what ive read, not what i know from looking at the implementation or experience
19:37bosiewhy does this result in: Actual: java.lang.IllegalArgumentException: No matching field found: length for class [Ljava.io.File;
19:37ddimadoes anybody have a good source/or collection handy for an explanation or something why TCO is not done? The argument in the doc is that clj uses java calling conventions, which seem to prevent it. Thought I wasnt able to find anything obvious looking thorugh http://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf and some smilar sources.
19:37bosieclearly length is not executed as an instance method, right?
19:37ddimaI guess a thread from the ML could do too ;)
19:37hyPiRion,(. length (into-array [1 2 3]))
19:37clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: length in this context, compiling:(NO_SOURCE_PATH:0)>
19:38brehautddima: its not done for interop reasons.
19:38arohnerddima: the JVM can't tail call across function boundaries, in the general case
19:38arohneror more specifically, can't goto across fn boundaries, because of security restrictions that may be in place
19:38ddimaok, and within functions? (why do we need recur for simple and no co-recursion?)
19:38bosiehyPiRion: i guess i should have an epiphany now but... ;)
19:39hyPiRionbosie: I just wanted to confirm my suspicion
19:39ddimaI mean, I really do not know the jvm too well, what would be a good read and could shed light on how its done and what it can do (and obviously not do)
19:39bosiehyPiRion: hm
19:39arohnerddima: recur asserts that you're in a tail call spot, so it's mostly a safety/asthetic thing
19:39p_lsearch for bytecode reference
19:40brehaut,(source alength)
19:40clojurebotSource not found
19:40ddimap_l: I actually thought that the pdf linked above would be an authoritative source, but there literally not a single mention of calling conventions
19:40brehaut(source alength)
19:40brehautbah
19:41brehautbosie: i think you want alength anyway
19:41ddimaarohner: hm, ok, so it would actually be possible to omit recur within one function. Im just curious and looking to dig deeper because I had a lengthy discussion with a passionate non-clojurist and he really had a problem with recur.
19:41p_lddima: the calling convention of java is very straightforward - put arguments on stack, call, then take return value from stack
19:41bosiehyPiRion: brehaut heh, thats what i am trying
19:41bosienow
19:41bosiealength works
19:41p_lit is, after all, a stack machine
19:41ddimaarohner: his argument was that any good compiler sould detect it (true), and that an explicit recur should not be needed. I only was able to cite interop reasons from memory but couldnt back up with hard jvm facts ;)
19:42brehautddima: its entirely possible to do so. scala does TCO i believe
19:42brehautddima: its an explicit choice to come down on this side of the tradeoff, not due to some compiler implementation deficiency in the clojure community
19:42arohnerddima: yes, it shouldn't be necessary, but I do like the tail-call checking
19:42arohnerit's helped me several times
19:43arohnerI'd like to see an optional (assert-tail-call (foo)) in scheme
19:43arohnerif I ever wrote scheme again, that is
19:43ddimaarohner: personally I dont have a problem with it either, it just was a 'hangup' for the guy, as it seemed as a less 'real tco', since explicit
19:44ddimap_l: thanks for the pointer, thats what i assumed but somehow wasnt able to grasp from the doc.
19:44wingynoob question: how do i for loop a map?
19:44p_lddima: I think the docs for jvm tend to assume that, because "stack machine" is pretty common stuff
19:44brehautwingy: seq on a map results in a seq of pairs (vectors)
19:45brehaut,(map identity {:a 1 :b 2})
19:45clojurebot([:a 1] [:b 2])
19:45wingymy intention is to convert the map to another one .. so maybe i should use a map
19:45gtrakddima: there's work on some macros implementing TCO via CPS transform : https://github.com/cjfrisz/clojure-tco
19:45ddimap_l: hehe, maybe. but assumptions are bad. i mean, they have funny 'complex' opcodes like iconst_5 and iload_2...
19:45brehaut,(for [[k v] {1 2 3 4}] (+ k v))
19:45clojurebot(3 7)
19:45brehautwingy ^
19:45AimHereThere's various ways of doing that sort of thing, wingy
19:45ddimap_l: or maybe im an idiot, who knows.
19:46wingycool
19:46brehautwingy: you might be wanting to (into {} (map … ))
19:46wingyyeah
19:46p_lddima: those are iirc specialized forms for generic iconst and iload instructions that load certain common stuff
19:46brehautwingy: return a vector pair from your map function
19:46hyPiRion,(. (into-array ["foo"]) length)
19:46clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: length for class [Ljava.lang.String;>
19:46hyPiRionhm.
19:46wingyi should know what i wanna get out of it first and then use the correct fn .. since its fp style
19:46ddimap_l: yes, true. still interesting and unusual, at least to me.
19:46p_lddima: so you call them without argument(s)
19:46wingybrehaut: oh yeah i forgot map is only working for arrays right?
19:47brehautwingy: i have no idea what you mean
19:47AimHereMap works on collections
19:47brehautwingy: map works on anything seqable
19:47ddimagtrak: thanks, will take a look at that.
19:47p_lfor example, 0 and 1 are common values in integers (all those compaisons with 0 etc.), so there's special opcode to loading it
19:47AimHeremap works on maps, but it treats a map as a sequence of pair vectors
19:47p_linstead of doing 0 iconst (two codes)
19:48gtrakwingy: you can try reduce-kv as well
19:48ddimap_l: its not that i dont get how that works or why, it still seemed pretty unusual to put that into an own opcode, even for the sake of saving one byte. but thats just my impression.
19:49hyPiRion,(.size (Arrays/asList (into-array [1 2 3])))
19:49clojurebot3
19:49ddimaso thats why i actually thought that a spec as above would explicitly mention that arguments are pushed to stack in order and blabla, because there might be some other funny ways the jvm does it, even if its a stack machine. doesnt prevent funny optimizations ;)
19:49wingyso here is the deal . i need a fn that checks each key/value pair in a map .. the value will be converted depending on what key it is .. so the fn has to take a key/value pair
19:50wingyit seems that the map fn just takes one value from the sequence at a time
19:50wingyand it should return a formatted map structure
19:51AimHere,(let [foo {:a 1 :b 2 :c 3}] (zipmap (keys foo) (map inc (vals foo))))
19:51clojurebot{:b 3, :c 4, :a 2}
19:52AimHere^ that's one suggestion, though I'm faintly worried that keys ... and vals .. might not pull their values out in the same order
19:52gfredericksthey do
19:52gtrak,(reduce-kv (fn [acc k v] (assoc acc k (inc v))) {} {1 2 3 4 5 6 7 8 9 0})
19:52clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: reduce-kv in this context, compiling:(NO_SOURCE_PATH:0)>
19:52gtrak&(reduce-kv (fn [acc k v] (assoc acc k (inc v))) {} {1 2 3 4 5 6 7 8 9 0})
19:52lazybot⇒ {9 1, 7 9, 5 7, 3 5, 1 3}
19:52wingyah you misunderstood .. let me give you an example
19:53bosieanybody can give me pointers as to how i can connect "lein midje" to a nailgun server?
19:53gtrakequivalent to: ##(reduce (fn [acc [k v]] (assoc acc k (inc v))) {} {1 2 3 4 5 6 7 8 9 0})
19:53lazybot⇒ {9 1, 7 9, 5 7, 3 5, 1 3}
19:53gfredericksAimHere: I think that's undocumented though :/
19:53AimHere,(into {} (map #(if (even? %1) (inc %2)) {1 2 2 3 3 4 5 6 7 8})
19:53clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
19:53AimHere,(into {} (map #(if (even? %1) (inc %2)) {1 2 2 3 3 4 5 6 7 8}))
19:53clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval547$fn>
19:53ddimawingy: I think you'd just want something like (map (fn [a b] ...) (seq youdict))
19:53AimHere,(into {} (map #(if (even? (first %)) (inc (second %))) {1 2 2 3 3 4 5 6 7 8}))
19:53clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
19:53AimHereBah
19:54wingyddima: yeah but map takes only one value from the seq
19:54hyPiRion/msg clojurebot guys
19:54ddimawingy: seq will give you a seq of kv 'tuples', which you can use to do your checks
19:54wingyddima: i c
19:54ddima, (map (fn [[a b]] [b a]) (seq kv))
19:54clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: kv in this context, compiling:(NO_SOURCE_PATH:0)>
19:54gtrakddima: you don't need seq... map does the same
19:54ddimaerr, mom
19:54gtrak,(map identity {1 2 3 4 5 6})
19:54clojurebot([1 2] [3 4] [5 6])
19:55hyPiRion,(map class {1 2})
19:55clojurebot(clojure.lang.MapEntry)
19:55hyPiRionet voila.
19:55ddima,(map (fn [[a b]] [b a]) (seq {:a "a" :b "b"}))
19:55clojurebot(["a" :a] ["b" :b])
19:55ddimawingy: should do, right?
19:55hyPiRionbut reduce-kv is potentially faster, so may use that one.
19:55ddimagtrak: oh, really? hm :)
19:55hyPiRionand it's well, as far as I know what you want.
19:56ddimayep. true
19:56ddimanevermind. beers and stuff.
19:56gtrakmore beer! onwards.
19:56mehworkwhy does this give me clojure.set not found: (clojure.set/union #{:foo} #{bar})
19:57gfredericksdid you require clojure.set yet?
19:57mehworkno, the book didn't tell me too ah
19:57AimHereWhich book?
19:57gfredericksburn it!
19:57mehwork"seven languages in seven weeks"
19:57mehworkit's a good book overall
19:57wingyddima: excellent..but how do i convert the sequence with key/value pairs back to a map?
19:57gfrederickswingy: (into {} ...)
19:58wingywiii
19:58wingythx all
19:58AimHeremehwork, shame. I was rather hoping to chastise the author in here, since most of the writers of Clojure-specific books show up in here at some point
19:59gfredericksshame on all of you clojure-specific-book-writers
19:59technomancyin 1.2 you didn't have to require clojure.set
19:59gfrederickstechnomancy: it was used somewhere in core?
19:59technomancygfredericks: not sure if it was that or convenience
20:00mehworkAimHere: well maybe they thought that clojure.set would be auto loaded, as stackoverflow is saying anyway
20:00mehworkit's not for me in the lein repl in ubuntu
20:00ddimawingy: or (apply hash-map [[:key val] [:key val]]) if you feel funny ;)
20:00arohnerright, in 1.3 or so, clojure.set stopped being autoloaded
20:01technomancyall the breaking changes, all the time
20:01gfredericksddima: I'd bet two quarters that doesn't work
20:01gfredericks,(let [val 42] (apply hash-map [[:key val] [:key val]]))
20:01clojurebot{[:key 42] [:key 42]}
20:01ddimadamn, true again
20:01ddimawhy dont i check first
20:01ddimasorry, retreating to the batcave
20:02ddimanesting too deep!
20:03wingyddima: both gave the same value: https://www.refheap.com/paste/7684
20:03wingyi didn't have to use seq
20:03ddimawingy: yes, thats what somebody noted before
20:03wingyweird
20:03ddimaI was wrong, he was right. its not needed.
20:03wingymaybe because of the destructuring clause?
20:04wingyor maybe not
20:04hyPiRionto the source
20:04hyPiRion&(source map)
20:04lazybot⇒ Source not found nil
20:04hyPiRion$source map
20:04lazybotmap is http://is.gd/47nOpc
20:05hyPiRionyeah, it uses seq on its arguments
20:05ddimawingy: i think its more because thats the way maps are seq'ed ;)
20:06mehworkit's kinda weird how def creates a variable
20:06technomancyyou mean a var?
20:07mehworkthere's a diff?
20:07ddimagfredericks: but on a serious note, was into really the only way to build a dict from nested 'tuples'? could have sworn there either was a function or similar. thats why i thought that was an apply thing.
20:07ddimajust curious.
20:07technomancyclojure doesn't have variables
20:07mehworkmaybe you should chastize the author of this book then :>
20:07AimHeremerely 'vars'
20:08gfrederickstechnomancy: what does variable mean such that clojure doesn't have them?
20:08technomancygfredericks: locals that change
20:08gfrederickstechnomancy: okay. clojure doesn't have variables.
20:09AimHeredoesn't that make 'global variables' an oxymoron?
20:09gfredericksddima: I don't know of an easier way. the hash-map function expects pairs of arguments, so you could #(apply hash-map (apply concat [[:foo 3] [:bar "MRHRAH"] [:baz "Lots of money"]]))
20:09technomancyAimHere: depends on the language. usually globals are a completely different mechanism that kind of look like locals if you aren't paying attention.
20:10gfrederickswhile everybody else was busy demonizing global variables clojure kept the globals and just eliminated the locals.
20:10technomancyanyway, a var isn't what most languages call global variables either; it's a storage location
20:10ddimagfredericks: uh, i was pretty close to the real deal, just lacking the concat ;)
20:10ddimaok, then i just dreamed something up i guess.
20:11mehworkso a var is more like an immutable pointer?
20:11gfredericksddima: whoops I forgot to add the extra # so lazybot would eval it
20:11gfredericksmehwork: yes except mutable
20:11technomancymehwork: you can change vars, but unless you're crazy you only do it during development time
20:12mehworkwill it dump core
20:12technomancyno, it'll just make your colleagues hate you
20:12mehworktoo late
20:13gfredericksapparently it is also okay to wrap vars at compile-time.
20:13technomancywell yeah you can push thread-local bindings
20:13gfredericksno I mean alter-var-root
20:14technomancydon't do that
20:14technomancyI mean it's OK for dev tools
20:14brehauttechnomancy means its ok for his code, but not yours.
20:14brehauttalk about your double standards
20:15brehaut:P
20:15technomancybrehaut: I only write dev tools!
20:15technomancyso I'm in the clear =D
20:15brehaut:)
20:15gfrederickshttps://github.com/clojure/core.contracts/blob/master/src/main/clojure/clojure/core/contracts.clj#L65
20:15joevandykis there anything like vcr for clojure? https://www.relishapp.com/vcr/vcr/docs
20:15ddimabtw, has anybody had fun with decompiling clojure just to see what happens?
20:15gfredericksjoevandyk: I started one
20:15gfredericksand so did some other guy.
20:15gfredericksI don't know which one is better.
20:15gfredericksmine is pretty minimal
20:15joevandyki sometimes have to work closely with a lot of 3rd party http services and would like to test against their responses
20:16technomancygfredericks: blurgh
20:16technomancydo not want
20:16gfrederickstechnomancy: vcr or alter-var-root?
20:16technomancygfredericks: this crazy provide function
20:16joevandyktechnomancy: do you guys still have the seattle clojure meetups?
20:16technomancyjoevandyk: yeah totally
20:16technomancyfirst thursday of the month
20:16joevandyki should stop by. getting sick of ruby
20:17gfrederickstechnomancy: I also added a var-reddefer in some code recently for wrapping a function with logging; would you use a defn-macro or something?
20:17wingyhow do i convert a string into a double?
20:17wingy"12.12" -> 12.12
20:17gfredericksDouble/parseDouble
20:17gfredericksor read-string if you want to be sloppy
20:17gfredericksit's shorter!
20:17wingymaybe the former is better for security?
20:17gfredericksyeps
20:17wingyand you cannot execute any code
20:17wingy:)
20:17AimHereThe latter is a proper clojure function
20:17joevandykgfredericks: is your clojure vcd code somewhere?
20:18gfredericks$google fredericksgary vcr-clj
20:18technomancygfredericks: hmmm... that might be permissible because it doesn't change the behaviour
20:18lazybot[fredericksgary/vcr-clj · GitHub] https://github.com/fredericksgary/vcr-clj
20:18gfrederickstechnomancy: yeah I always had the impression that orthogonal concerns _might_ be justifiable
20:18gfredericksnever business stuff
20:18technomancygfredericks: I wonder what tools.trace does
20:18ddimayeah, read string will deceive you horribly in situations with 0 prefixed number etc.pp - great fun ;)
20:19ddima"works till 7, hmmm. close enough!"
20:19joevandykthe thing i have in mind is retrieving tracking numbers against a bunch of different shipping services (dhl, upsmi, ups, sups, fedex, etc) and have a unified api to figure if they have shipped, the best tracking url, etc
20:19technomancygfredericks: in any case I think a blanket "never use alter-var-root" is a good idea because the people who are capable of understanding when it's a good idea are generally confident enough to know when to ignore what they hear on IRC =)
20:19ddimathought, deception is the wrong word. it actually does what its supposed to do.
20:20turbofailis there some way to configure the size of the thread pool used to run futures?
20:20turbofailit seems to be maxing out at 30
20:20gfrederickstechnomancy: never use clojure
20:21technomancygfredericks: brb porting lein to clojurescript
20:21mehworknever use use
20:21brehautnever use :use
20:21brehautuse is sometimes useful
20:21brehaut(at the repl)
20:22gfrederickstechnomancy: I feel like you just defended a big pile of parenting techniques :)
20:23technomancyturbofail: I think there's an open issue for that but no patch yet
20:23CoverSlideok so don't use (ns (:use and don't use (use ok so what do i use?
20:23turbofailah
20:24brehautCoverSlide: (:require ns.foo :refer [baz bop])
20:24CoverSlidehmm
20:24ddimafrighteningly funny channel, actually.
20:25gfredericks(:require [ns.foo :as foo])
20:25mehworklol
20:25brehautgfredericks: that too
20:25gfredericksbrehaut: (:require [jayq.core :as $ :refer [$]])
20:26brehautgfredericks: thats all great except for the use of jquery
20:26gfredericksJayq Weary?
20:27akhudekI expected deftype to support =
20:27gfredericksI think deftype is intentionally pretty bare
20:28technomancyakhudek: deftype supports mutability, and equality can't be meaningfully defined on mutable objects
20:28gfredericksthat's a much gooder explanation
20:28brehautgfredericks: jquery, like all big arse-libraries (xkcd'd for you already), is a giant collection of average implementations of everything
20:28joevandykwhat's the best way of interfacing with postgresql? while using all the nice datatypes, like ranges, intervals, json, etc?
20:29akhudekThat makes sense. Do I need to implement hashcode too? These types are in fact immutable.
20:29technomancyjoevandyk: there's not a great story right now. you have low-level access through clojure.java.jdbc and high-level access with some baked in bad assumptions with korma. pick the lesser of two evils.
20:30seangrovebrehaut: That's a slightly strange stance given the scope of the google closure library
20:30joevandyktechnomancy: bad assumptions?
20:31brehautseangrove: who said i like google closure either :P
20:31seangroveYou did
20:31seangroveAll throughout the internet
20:31brehautseangrove: i never!
20:31brehautlol
20:32seangroveBut, it is pretty closely tied to cljs, for better or worse
20:32seangroveAt least for now, I suppose
20:32brehautindeed
20:32ddimais there a good writeup on 'gc pressure' exercised by clojure though the pretty large number of function objects etc.pp? just curious.
20:32technomancyjoevandyk: it doesn't allow for you to control the scope of your DB connections and IIRC messes up laziness for cursor queries among a few other things I can't remember right now
20:32technomancyI don't use it much, but it comes up every so often in the channel
20:32brehautseangrove: although closure can optimize out the usage of a lot of it if you dont actually use it
20:32brehaut(except where clojurescript.core doe)
20:33brehautseangrove: i don't actually clojurescript at the present time anyhow
20:33seangrovebrehaut: Yeah, but that's really possible with just the compiler
20:33seangroveI could see a future where cljs-in-cljs eventually leads to less of a reliance on the closure library and more on pure cljs libraries
20:34gfredericksas soon as somebody implements format
20:34seangroveCL's format?
20:34gfredericksclojure.core/format
20:34gfredericksor maybe cljs.core/format in this case
20:34seangrovebah, I was excited to see CL's format
20:35seangroveOne of the most baffling and powerful things I've ever used
20:42hyPiRion(require '[clojure.pprint :refer [cl-format]])
20:42hyPiRion,(require '[clojure.pprint :refer [cl-format]])
20:42clojurebotnil
20:42hyPiRion,(cl-format true "~{~A~^, ~}" [1 2 3 4]) ; 'tis powerful
20:42clojurebot1, 2, 3, 4
20:43technomancydoes our version have roman numeral support?
20:43hyPiRion,(cl-format true "~{~R~^, ~}" [1 2 3 400]) ; 'tis powerful
20:43clojurebotone, two, three, four hundred
20:43technomancygeez
20:43hyPiRion,(cl-format true "~{~:R~^, ~}" [1 2 3 400]) ; 'tis powerful
20:43clojurebotfirst, second, third, four hundredth
20:43ddimanice
20:43seangrovehahaha
20:43hyPiRionI think it has everything cl's format has, except function calls.
20:43seangrovetechnomancy: Curious to see the discussion that said it should ship with clojure...?
20:44brehautnext thing you know, well have brainfuck shipping as standard
20:44brehautand someone will have a brainfuck / cl-format polyglot
20:44technomancyseangrove: I think it snuck in as part of pprint
20:44technomancykinda like how clojure.walk snuck in as part of clojure.test
20:44hyPiRiontechnomancy: You forgot the roman numbers.
20:44hyPiRion,(cl-format true "~{~@R~^, ~}" [1 2 3 400]) ; 'tis powerful
20:44clojurebotI, II, III, CD
20:45hyPiRionIn case anyone needs it.
20:45technomancy[17:35] <technomancy> does our version have roman numeral support?
20:45technomancy=){
20:45hyPiRionOh, I read that as written numeral support
20:45hyPiRionsorry
20:46seangroveIterating over vectors, maps, etc. is pretty cool though
20:46technomancyheh; it's cool
20:46gfrederickshyPiRion: man that'd be cool if it could write numerals as well
20:46seangroveI've only used it a handful of times and haven't missed it terribly when in languages that didn't have cl-format, but I do like it overall
20:46cark,(cl-format true "file~p" 1)
20:46clojurebotfile
20:46cark,(cl-format true "file~p" 10)
20:46clojurebotfiles
20:46carkdarn
20:46carkit's all in there
20:47seangrove ,(cl-format true "ox~p" 10)
20:47clojurebotoxs
20:47carkCL's plural thingie isn't that good either =)
20:47seangroveYeah, I ported the rails inflection system to CL as an early project, was fun
20:47brehautplease tell me its not locale aware
20:47carkbrehaut: haha that would be awesome
20:47hyPiRioncark: it's good if you know the plural form
20:48seangroveI posted it to hn and got a good response, and some people asked that I port a perl system over, wonder if I can find it...
20:49seangroveOh, wow, my project was forked and improved on, had no idea
20:50cark,(cl-format true "~{~#[~;~a~;~a and ~a~:;~@{~a~#[~;, and ~:;, ~]~}~]~}" [1 2 3 400])
20:50clojurebot1, 2, 3, and 400
20:50hyPiRion,(cl-format true "~r ox~:*~[en~;~:;en~]" 10)
20:50clojurebotten oxen
20:50hyPiRion,(cl-format true "~r ox~:*~[en~;~:;en~]" 1)
20:50clojurebotone ox
20:50carkhyPiRion: nice one =)
20:51carknow you pass the resource file to your translators =)
20:52seangroveAh, yes, here it is: http://search.cpan.org/~dconway/Lingua-EN-Inflect-1.895/lib/Lingua/EN/Inflect.pm
20:53seangroveI ported rails' inflector as a learner-project, and the top comment included "Damian Conway (Lingua::EN::Inflect's author) also wrote a paper about algorithmic English pluralization that actually takes a linguistic approach to all of this"
20:54seangrove"Oh, I see you have a toy project - have you considered going through all of the academic research and writing a professional-grade system instead?"
20:54carkwe need to bindle that with clojure !
20:54carkbundle*
20:56n_bannnnd one more paper gets added to the list
20:56seangroveReading list, or burn list?
20:56n_bReading
20:57n_bEnglish Lit major, so anything that has CS<->Degree crossover piques my interest
20:57seangroveAh, very cool
20:57seangroveYou could do some good in the world
20:57seangroveThings like Lingua-EN do actually help quite a bit
20:58seangroveEven if a simple table of regexes gets you ~80% of the way there
20:58n_bI started to dissect the Rails inflector once when I had less experience, wouldn't mind giving it another go
20:59seangroveIt's pretty tiny, super easy
20:59n_bWhich leads to all sorts of hilarious outcomes in Rails projects for those unaware of its corner cases
21:00seangroveHere's (I believe) a full recreation in CL: http://trapm.posterous.com/vana-inflector-an-english-inflector-in-common
21:03n_bThat is indeed simpler than I remember
21:03seangroveLooking at it, I don't think it handles camelCase things, which I believe the rails inflector also does
21:03n_bExperience counts for a lot
21:03seangroveSo maybe it's not actually a full port. Owell.
21:05n_band utf-8? Not sure of the status of that in CL
21:06mattmossIf I'm wrapping a (proprietary) java lib with pre-built classes (no src avail), I can't extend-protocol IPersistentMap to it, can I?
21:06mattmossThat is, I know I can't do it directly... since IPersistentMap isn't a protocol. Wondering if there are workarounds...
21:09gfredericksline repple
21:11seangroveheh, what is "The new alternative to `lein repl`"
21:11n_bDoesn't everything hook into lein repl?
21:11seangroveline repple => lein repl
21:11craigbrolime apple
21:12n_bahh
21:13gfrederickshow to install line again
21:13gfredericksshould I use line again too or line again won?
21:14seangrovegfredericks: that's really technomancy's fault for choosing an impossible to spell name
21:14brehautSERD ERPTGERT ERNSTERL LERNERGERN
21:15hyPiRionlien rpel is usually what I manage to type.
21:16seangroveheh, lein repel!
21:16seangroveTo be used when you find foreign jars in your project
21:16n_becho 'alias lr="lein repl"'>>~/.profile
21:16lazybot'alias lr="lein repl"'>>~/.profile
21:16hyPiRionecho $HOME
21:16lazybot$HOME
21:16hyPiRionmeh.
21:16gfredericksecho echo echo
21:16lazybotecho echo
21:16gfredericks,(println "echo echo")
21:16clojurebotecho echo
21:16lazybotecho
21:16hyPiRionyou beat me.
21:17gfredericksclojurebot: echo is foxtrot
21:17clojurebotAck. Ack.
21:36hyPiRion,(println "echo ,(println echo echo)")
21:36clojurebotecho ,(println echo echo)
21:36lazybot,(println echo echo)
21:36clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: echo in this context, compiling:(NO_SOURCE_PATH:0)>
21:36nsxtwhat's the name of the editor that LightTable builds on?
21:36brehautcodemirror
21:36nsxtbrehaut: Thanks!
21:37hyPiRion,(println "echo ,(println \"echo foo\")")
21:37clojurebotecho ,(println "echo foo")
21:37lazybot,(println "echo foo")
21:37clojurebotecho foo
21:37lazybotfoo
21:37hyPiRionwoo, two levels
21:37hyPiRionthe next step is obviously to make an iterating quine out of this.
21:39seangroveUgh, just read through a thread on comp.lang.lisp, incredibly painful to read. So much ego and snark.
21:40gfrederickswait wait
21:40gfredericksyou actually can make a bot trampoline out of that can't you
21:41hyPiRion&((fn [x] (list x (list (quote quote) x))) (quote (fn [x] (list x (list (quote quote) x)))))
21:41lazybot⇒ ((fn [x] (list x (list (quote quote) x))) (quote (fn [x] (list x (list (quote quote) x)))))
21:41hyPiRionsure thing.
21:41hyPiRionJust need a bit of massage
21:41gfrederickswell you need it to alternate forms
21:42hyPiRionyeah
21:42gfrederickswell sorta
21:42gfrederickslazybot won't do any evaling I guess
21:42gfredericksso it's not a twine
22:06hyPiRiongfredericks: Dangit, it's actually working too.
22:22wingyhow can i convert a "123.0" to Long?
22:23wingyLong/parseLong says it's bad input
22:24hyPiRionParse it to a double first, then cast it to a long
22:25hyPiRion,(long (Double/parseDouble "123.0"))
22:25clojurebot123
22:25bbloomhyPiRion: that's probably not a great idea, since long and double don't have the same domain
22:25bbloomwingy: just split at . and parse the first part
22:25bbloomassuming you don't mind truncating instead of rounding
22:25wingybbloom: good idea
22:26brehautbbloom: can you explain 'domain' in that context?
22:26hyPiRiona long can represent something a double cannot, and vice versa.
22:26bbloomdomain, as in function domain, range, co-domain, etc
22:27brehautright
22:30hyPiRion,(let [a [[36 116 105 109 [101 114 32 49 [54 58 48 58 [48 32 44 40 [108 101 116 32 [91 119 104 97 [116 39 115 32 [39 116 104 105 [115 63 32 97 32]]]]]]]]] "] (println (apply str (apply str (map char (flatten (a 0)))) a (a 1))))"]] (println (apply str (apply str (map char (flatten (a 0)))) a (a 1))))
22:30clojurebot$timer 16:0:0 ,(let [what's 'this? a [[36 116 105 109 [101 114 32 49 [54 58 48 58 [48 32 44 40 [108 101 116 32 [91 119 104 97 [116 39 115 32 [39 116 104 105 [115 63 32 97 32]]]]]]]]] "] (println (apply str (apply str (map char (flatten (a 0)))) a (a 1))))"]] (println (apply str (apply str (map char (flatten (a 0)))) a (a 1))))
22:30lazybotTimer added.
22:37erewhonif you're wanting to convert it to a long, why does the input have .0?
22:38amalloyhah, well done hyPiRion. many have tried for the multi-bot quine, and you've finally found a clever hack involving a spot where lazybot doesn't prepend his output
22:38amalloyRaynes: ^
22:41RaynesPretty sure I have a list of people to ignore somewhere that is broken. I'll just have to fix it and add clojurebot.
22:42RaynesThen your evil plans will be foiled once and for all.
22:44RayneshyPiRion: Good work.
22:44RaynesI have a fresh cookie that I'll mail to you promptly, sir.
22:50hyPiRionRaynes: To be fair, if I were evil, I would just do echo instead. $timer removes colons, so I had to use that vector-with-ints hack which isn't needed for echo.
22:51RayneshyPiRion: Echo?
22:51Raynesecho hi
22:51lazybothi
22:51RaynesThat?
22:51clojurebotthat is dumb
22:51RaynesIt is, I agree.
22:51hyPiRionyeah
22:52RaynesWell, if you did that everybody would probably have hated you.
22:52Raynes:p
22:52hyPiRionexactly, heh.
22:52RaynesBut yeah, that's why I had the user blacklist thingy. It used to ignore clojurebot but somewhere along the line I broke it.
22:53hyPiRionhm, better fix it before i make them hold a conversation through timers and Thread/sleeps
22:53gfredericks~botstack
22:53clojurebotPardon?
22:53RayneshyPiRion: Feel powerful, don't you?
22:54RayneshyPiRion: How would you feel if I forced you to talk to gfredericks all day like a broken record?
22:54Raynes:p
22:55hyPiRionRaynes: :(
22:55gfredericks&((apply comp (repeat 10000 identity)) 42)
22:55lazybot⇒ 42
22:55gfredericksI wonder how that computation feels
22:57hyPiRion,(recur)
22:57clojurebotExecution Timed Out
22:57hyPiRionThat is also painful. Poor bots.
23:00gfredericks,(recur 5)
23:00clojurebot#<CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 0 args, got: 1, compiling:(NO_SOURCE_PATH:0)>
23:00hyPiRion,@(promise)
23:01clojurebotExecution Timed Out
23:03ldh\tproject
23:03ldhoops
23:04ldhif i i'm in a repl ("lein repl") and i change a source file, why wouldn't (require … :reload) pick up the change? is there something else i'm missing? i swear this used to work...
23:07brehautldh: it should do
23:08brehautldh: there are some gotchas though, around things like multimethods and anything with defonce semantics
23:08brehaut(not new gotchas however)
23:13ldhbrehaut: i'm tweaking the implementation of a protocol in a defrecord. i do have a couple of instances of defonce data being passed around, maybe that's related. thanks for the tip