#clojure log - Jul 08 2015

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:27 kschrader: ttt_fff: https://github.com/omcljs/om/blob/master/src/om/next.cljs

0:27 :)

6:04 loke: Is there a library that helps parsing/generating CL-compatible sexps from Clojure? My server-side is written in CL, and the client is written in Clojurescript. I'd like to be able to simply output my CL sexps straight to the client instead of having o go via JSON, which isn't native to either platform.

6:11 r4vi: maybe there is a CL library to parse EDN?

6:12 loke: r4vi: That would be good too, but I haven't found one.

6:13 r4vi: I just feel that I jump through one too many hoops when using JSON to interchange data between CL and cljs

6:13 It irks my sense of perfection :-)

6:14 r4vi: yeah I can understand why it'd be annoying

6:15 loke: I've considered limiting myself to a compatible subset of sexps that work in both, but it's quite limiting. I can basically only use plain lists, integers and keywords (the last one if I mess with the readtable case on the CL side betcause of casing issues)

6:17 Clojure doesn't support read-time eval, does it?

6:18 expez: loke: it does

6:19 ,(read-string "#= (+ 1 1)")

6:19 clojurebot: #error {\n :cause "EvalReader not allowed when *read-eval* is false."\n :via\n [{:type java.lang.RuntimeException\n :message "EvalReader not allowed when *read-eval* is false."\n :at [clojure.lang.Util runtimeException "Util.java" 221]}]\n :trace\n [[clojure.lang.Util runtimeException "Util.java" 221]\n [clojure.lang.LispReader$EvalReader invoke "LispReader.java" 1100]\n [clojure.lang.LispRe...

6:19 loke: Ah nice

6:21 Frozenlock: loke: time to write transit for CL? :-p

6:21 loke: Frozenlock: what is transit?

6:21 Frozenlock: https://github.com/cognitect/transit-clj

6:22 loke: Oooh

6:22 Frozenlock: You should read the rationale if it's your first contact.

6:23 loke: I am. I like it already

6:23 Frozenlock: There's a transit implementation for many languages already https://github.com/cognitect

6:23 loke: The limitations of JSON has bugged me for so long that I'm already (after just 30 seconds of browsing the summary) liking it

6:24 Looks easy enough. I'll write a parser for this in CL

6:24 If I read this correctly, it supports circular data structures and shared references?

6:25 Frozenlock: I don't know... I naively use it just to send my EDN everywhere :-p

6:28 loke: OK, I'll consider building cl-transit-format.

6:29 hyPiRion: loke: Clojure itself doesn't really support circular data structures (only through mutable data structures on the underlying platform), so I'd be surprised if that was the case.

6:30 Disclaimer: I've not used transit, so I might be wrong.

6:30 loke: hyPiRion: well, it seems to be able to encode references to other elements.

6:31 Oh well, I don't need that stuff anyway :-) At least I found a new toy

7:55 kwladyka: how to do test with not thrown?

7:56 (is (not (thrown? Exception (board-validation 10 10)))) <- something like that, but it doesn't work

7:56 (is (board-validation 10 10)) <- and i can't do thing like that because function return nil

7:57 eventually i can check if it is nil, but it is not exactly what i want to test, test should say not exception thrown

7:58 snowell: Wrap it in a try, then (catch (fail "thrown"))?

7:58 kwladyka: snowell, is it only one solution? nothing more beauty? :)

7:58 snowell: Haha that's my quick and dirty "get it to work" solution :)

7:59 kwladyka: i have to write hight quality code for recruitment challenge

8:02 snowell, but i am afraid this solution is the only one

8:07 snowell: kwladyka: You could also macroexpand is, negate it, and create your own is-not macro

8:07 noidi: I don't see why you should check for _not_ throwing an exception

8:08 it's implicitly tested by your tests that check the return value

8:08 snowell: ^ Also a fine point

8:08 kwladyka: noidi, because i am testing exceptions for some functions, and i want some parameter to pass without exception

8:09 noidi, but testing return value it is not really what i want to test, i want test exception

8:09 what if retrun value will change? It will affect test

8:10 noidi: yes, it will affect the test that would have checked the return value anyway

8:10 if you have a function which does not return a sensible return value, but instew

8:10 but instead just throws or does not throw an exception

8:11 you can rewrite it to return a boolean value for whether the input was valid or not

8:13 kwladyka: i am creating board for chess and function can get only positive integer

8:13 there is no real use of this, it is just theoretical problem to solve

8:14 so i choose exception in situation when inputs are not logic

8:17 as i know it is in conception of Exceptions

8:19 J_Arcane: Is there a core function for producing a function that spits out a static value? Something like identity but for closures?

8:20 I wound up just using (fn [_] true) in a few places today, and it seemed like this might be a thing there was already something for.

8:23 snowell: J_Arcane: http://clojuredocs.org/clojure.core/constantly

8:23 J_Arcane: snowell: Ahh, thanks. I'll remember that.

8:24 gfredericks: ,(doc constantly)

8:24 clojurebot: "([x]); Returns a function that takes any number of arguments and returns x."

8:24 snowell: That would have been more helpful, yes :)

8:33 kwladyka: (defn figures-validation [king queen bishop rook knight]) <- how can i check in most elegant way if all input values are integer and > 0 ?

8:34 I know i can use :as in map input, but is it possible to catch all this input and simple run > 0 for vector with all input or something like that?

8:34 but still i want check if all was given

8:36 gfredericks: ,(defn pos-int? [x] (and (integer? x) (pos? x)))

8:36 clojurebot: #'sandbox/pos-int?

8:37 gfredericks: ,(defn figures-validation [& args] (and (= 5 (count args)) (every? pos-int? args)))

8:37 clojurebot: #'sandbox/figures-validation

8:40 kwladyka: gfredericks, mmm but is it possible to do something like (defn f [a b c d e :as all])?

8:40 because i want it to be readable which position is which figure

8:41 gfredericks: ,(defn figures-validation [& [king queen bishop rook knight :as args]] (and (= 5 (count args)) (every? pos-int? args)))

8:41 clojurebot: #'sandbox/figures-validation

8:41 kwladyka: hmmm.... i thought it doesn't work in that way... ouh...

8:41 thank you

8:41 namra: cool

8:41 gfredericks: maybe you forgot the &

8:42 kwladyka: yes i didn't know i can do this like that

8:42 gfredericks: the downside to that kind of destructuring is your function can take any number of args

8:43 kwladyka: yes, but still is nice to know about that solution

8:48 how to use every? with > ?

8:48 is it possible?

8:49 i mean (> 5 3)

8:49 something like (every? (> % 0) [1 2 3 4])

8:50 snowell: (> % 0) => pos?

8:50 ,(doc pos?)

8:50 clojurebot: "([x]); Returns true if num is greater than zero, else false"

8:50 kwladyka: oh...

8:50 and another solution is anonymous function

8:50 namra: (every? pos? [1 2 3 4])

8:51 ,(every? pos? [1 2 3 4])

8:51 clojurebot: true

8:51 namra: ,(every? #(> % 3) [1 2 3 4])

8:51 clojurebot: false

8:55 kwladyka: ((every-pred pos? integer?) king queen bishop rook knight) <- i end with this line

9:07 piranha: hey all! That is not strictly on-topic, but maybe somebody can share thoughts on load testing? I'm trying to get Grinder up and running and that process is a bit painful, so I'm wondering what do people use for load testing...

9:09 kwladyka: is any shortcut to make test file in intellij?

10:17 justin_smith: kwladyka: if the options were integer or nil, you could use #(some-> % pos?)

10:25 ,(map #(some-> % pos?) [1 nil -1 2 nil false 3])

10:25 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Number>

10:25 justin_smith: ergh

10:26 ,(map #(some-> % pos?) [1 nil -1 2 nil 3])

10:26 clojurebot: (true nil false true nil ...)

10:26 justin_smith: some-> doesn't deal with false, I forgot

11:18 zacts: must I use the seq abstraction over the list?

11:18 s/over/instead/

11:18 I guess I'm so newbie that I don't understand the advantage of the seq over plain lisp lists

11:19 puredanger: a list is a seq (seq is a logical list abstraction)

11:21 zacts: well, ok

11:21 but the seq just adds contextual convenience factors right?

11:22 hm... I wonder if anyone has tried to modify CL or scheme to have a seq abstraction, as proof of concept in those languages

11:22 if you can, help me to grok what the power of the seq means

11:22 hellofunk: zacts: seq is the traditional lisp api, actually

11:22 first, rest, etc

11:22 zacts: hellofunk: oh yes? hm... that seems interesting

11:23 hellofunk: the term "seq" is not traditional necessarily

11:23 zacts: racket has first, rest, etc.... too... perhaps racket is already using a seq...

11:23 oh

11:23 ok

11:23 hellofunk: zacts: first, rest and list processing are traditional lisp features... hence "lisp" acronym

11:24 zacts: how does first, rest, and list differ from cons car and cdr?

11:25 hellofunk: zacts: clojure conveniently allows you to use the seq api on things that are not sequential, like maps and sets

11:25 zacts: clojure has cons. car is first and cdr are rest, basically.

11:25 zacts: oh, I see

11:25 so you can access unordered data types, with the same api?

11:25 hellofunk: zacts: yes

11:26 zacts: so the seq is mainly a huge convenience...

11:26 hellofunk: zacts: maps turn key/val pairs into individual seq elements

11:26 zacts: which can simplify code

11:26 hellofunk: ,(seq {:a 1 :b2})

11:26 clojurebot: #<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>

11:26 hellofunk: ,(seq {:a 1 :b 2})

11:26 clojurebot: ([:a 1] [:b 2])

11:27 zacts: ok

11:28 clgv: I have a pom.xml and a jar file from a 3rd party java library which didnt make it in any maven repository. how do I upload that one to clojars.org now that the scp method is disabled?

11:28 tcrayford____: @clgv see "uploading to maven" in the clojars wiki: https://github.com/ato/clojars-web/wiki/Pushing

11:30 clgv: tcrayford____: with that description maven tries to build the jar again...

11:32 tcrayford____: clgv: not sure how to fix that, sorry. Not a maven expert :(

11:32 clgv: and luckily that build fails although it is the release archive... O_o

11:50 kwladyka: is similar function like pos? but doing >= instead of > 0?

11:50 Bronsa: no but you can use (some-fn pos? zero?)

11:54 gfredericks: (complement neg?)

11:55 tmtwd: is it bad form to use a java library (because you're familiar with it), rather than a native clojure library?

11:55 gfredericks: not if you're the only one who ever has to deal with the code :)

11:56 clgv: tmtwd: if the java library does its job well, use it. there is no need to have a clojure wrapper for everything - sometimes it is even a waste of time

12:15 tmtwd: so whats the best way of splitting a string by a space into an array of words?

12:16 nvm

12:16 i got it

12:20 why does require require a : when defined in a namespace? (:require [clojure.string :as str])

12:22 justin_smith: tmtwd: false premise https://www.refheap.com/105434

12:23 kwladyka: tmtwd, because first argument of list by default is treated like function call and... yes there is also require function

12:23 justin_smith: the ns form allows and encourages :require, but doesn't need it

12:23 tmtwd: cool

12:23 thanks

12:24 justin_smith: I always found it a bit odd that ns encourages the :require form, when require also works and is more consistent with non-ns usage of require...

12:24 I'm sure there's a good reason I haven't noticed

12:25 Bronsa: justin_smith: I think require works by accident

12:25 justin_smith: Bronsa: oh, that's as good a reason not to do it that way as any :)

12:25 Bronsa: I guess in a macro (name :require) and (name 'require) give the same result, yeah

12:25 clojurebot: Titim gan éirí ort.

12:26 Bronsa: justin_smith: also I think require would be more confusing than :require imho. keep in mind inside the ns you don't need quoting, outside you do

12:26 justin_smith: true

12:26 Bronsa: at least :require makes it explicit that it's a different thing

12:26 justin_smith: yeah, but then you get ##(:require 'does-not.exist)

12:26 lazybot: ⇒ nil

12:26 Bronsa: also understanding why and how :require is different from require is what made me really understand macros

12:26 :P

12:27 justin_smith: heh, I learned those lessons with common lisp, so it's good to be reminded of that

12:29 Bronsa: I understood and used macros in CL for a while before starting clojure, but I never really *got* them until I understood the :require thing

12:41 dnolen: Finally Chrome will get Clojure syntax highlighting http://src.chromium.org/viewvc/blink?view=revision&revision=198504

12:49 johannbestowrous: huzzah :)

12:57 kwladyka: Operation on matrix are optimal?

12:57 i mean about performance

12:58 i need to do algorithm with good performance

12:58 justin_smith: kwladyka: have you looked at core.matrix?

12:58 kwladyka: and i am not sure matrix are good way or not

12:59 justin_smith, not yet. I am thinking how should i count this.

12:59 The problem is to find all unique configurations of a set of normal chess pieces on

12:59 a chess board with dimensions M×N where none of the pieces is in a position to take any of the

12:59 others. Assume the colour of the piece does not matter, and that there are no pawns among the

12:59 pieces.

12:59 wow sorry for multilines

13:01 so i have to create list of chess board MxN and figures combination and counting if one figure can beat down another figure

13:01 i am trying to figure out which mathematical operation will be the fastest for this problem and how should my data look for the best performance

13:02 justin_smith: kwladyka: yeah, I think there are matrix algorithms for n-queens etc.

13:02 probably you want your data in a NxN square matrix

13:02 kwladyka: justin_smith, it is my first idea

13:04 justin_smith: kwladyka: you should be able to turn the positions in board x into a projection of moves on board y, and thus turn the concept of a "safe" piece into a zero result after a matrix multiply...

13:04 of the projected moves against the positions

13:05 something like that...

13:07 hellofunk: kwladyka: i think Byrd has some minikanren solutions to n-queens problem on his github, which are translateable easily to core.logic

13:07 would be worth studying at least

13:10 * justin_smith wishes there were an established distinction between adaptor and adapter.

13:11 justin_smith: of course I'm going with adapter because that's the one ring uses, but still

13:13 kwladyka: justin_smith, yeah i want do something in that way

13:14 it is good to hear you agree with me :)

13:15 just i feel i am on good way :)

13:15 hellofunk, but i don't know his nick on github :)

13:16 hellofunk, and it is not Bryd as i see

13:18 hellofunk: kwladyka: https://github.com/miniKanren/miniKanren_org-website/blob/master/index.html and also http://martintrojer.github.io/clojure/2012/07/11/n-queens-with-corelogic-take-2/

13:20 kwladyka: hellofunk, thx maybe i will get some inspirations after read

13:23 hellofunk: kwladyka: one of those pastes was supposed to be http://minikanren.org/ which you can then scroll down to see the n queens listings

13:31 justin_smith: hellofunk: he wanted fastest though, not most convenient for programming

13:32 (I read it as fastest at runtime, not quickest way to code a solution)

13:33 hellofunk: i read it as "studying techniques to solve the problem"

13:36 kwladyka: i have to find the best readable fastest solution in short time

13:36 just do this as good as possible in Clojure

13:37 *short - 7 days

13:38 in free time :)

13:39 andyf: arrdem: Is it expected that conj.io Clojure 1.7.0 links go to 1.7.0-beta3 ?

13:41 justin_smith: kwladyka: well, I'll let your level of confidence guide your decision - if you think you can handle it, core.matrix will be much faster, logic programming techniques are notoriously slow

13:42 snowell: kwladyka: Good code, fast code, easy-to-write code. Pick 2 :D

13:42 kwladyka: good fast code of course ;)

13:43 ok, i am going train kung fu, see you later and thank you for your ideas

14:18 arrdem: aw andyf left.

14:24 justin_smith: $mail andyf is there any plan / roadmap for eastwood doing cljc?

14:24 lazybot: Message saved.

14:25 justin_smith: I made a new all-cljc lib, and was surprised that on my first linting everything passed. In reality, on first linting nothing was being checked...

14:25 arrdem: heh

14:36 justin_smith: arrdem: today I learned a bit about how to use :inline function metadata https://www.refheap.com/105437

14:36 useless toy example, of course

14:36 maybe that would have a place in grimoire

14:36 Bronsa: justin_smith: you shouldn't use :inline

14:37 justin_smith: Bronsa: oh, OK. I was so pleased to discover it.

14:37 any particular reason?

14:37 Bronsa: justin_smith: it's gonna get deprecated

14:38 justin_smith: does the method overload use case have a replacement? Improved static inference maybe?

14:38 Bronsa: justin_smith: at least that's what I was told when I created a ticket adding :inline for a bunch of predicates in core.clj. not sure if clojure/core changed idea on that though, puredanger will know better

14:38 justin_smith: (local inference that is, of course)

14:38 oh, OK, thanks for the info

14:38 (inc Bronsa)

14:38 lazybot: ⇒ 114

14:39 Bronsa: justin_smith: http://dev.clojure.org/display/design/Inlined+code

14:39 justin_smith: oh, nice, thanks for looking it up

14:39 (inc Bronsa)

14:39 lazybot: ⇒ 115

14:40 Bronsa: not much there but I'm assuming that's where design work will happen

15:08 lodin_: Anyone here with experience of https://github.com/zcaudate/ribol?

16:24 csd_: is it bad practice not to specify a buffer size for a (chan) ?

16:31 justin_smith: csd_: I'd say it's normal not to specify a buffer size

16:32 hellofunk: csd_: i only specify a size when i expect occasional but temporary bursts that exceed the channel's read speed

16:35 csd_: ok one more stupid question

16:35 is anyone aware of anecdotes of switching from mongo to datomic

16:37 hellofunk: well, i knew a guy who knew a guy... this one time, he... let me see if i can remember

16:37 csd_: :)

16:38 justin_smith: hellofunk: sounds like you went back to datomic and it dropped your data

16:38 hellofunk: i think the other shoe dropped

16:46 TimMc: csd_: Like... writing migration scripts? Or adapating the data model?

16:47 csd_: the latter

19:00 chomwitt: how can i use a backslash in a string ?

19:01 justin_smith: \\

19:02 ,(first "\\")

19:02 clojurebot: \\

19:03 chomwitt: (str ["\\a"]) => RuntimeException Unsupported escape character: \a

19:03 justin_smith: ,"\\a"

19:03 clojurebot: "\\a"

19:03 justin_smith: ,(str ["\\a"])

19:03 clojurebot: "[\"\\\\a\"]"

19:04 chomwitt: ,hi

19:04 clojurebot: #error {\n :cause "Unable to resolve symbol: hi in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: hi in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: hi in this context"...

19:05 chomwitt: sorry for that..

19:26 andyf_: justin_smith: I definitely want to enhance Eastwood to read and lint .cljc files, too, but as you discovered, today it ignores the contents of any files without a '.clj' suffix.

19:26 No target date for that. Work has been pretty busy lately, so Eastwood work has been on the back burner for a while.

19:27 I will at least add something to the README mentioning the lack of linting in .cljc files.

19:28 R0B_ROD: Hi anyone running Gentoo and have install Leiningen?

19:28 elvis4526: what are your favorites sql libraries ?

19:29 R0B_ROD: Just download it from the official website

19:30 put this in your $PATH https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein

19:31 and thats about it.

19:33 R0B_ROD: https://bpaste.net/show/0a4b36df510d

19:33 sorry

19:34 elvis4526: wrong c/p ?

19:34 R0B_ROD: wrong chan

19:34 elvis4526: ah

19:35 idk about this particular overlay, but the only linux distro i've seen with lein packaged was arch.

19:37 R0B_ROD: elvis4526: Thanks... I got it to work now missed a step in my config

19:42 elvis4526: ahh

19:43 andyf_: Possibly off-topic, except that there are now Clojure 'rooms' on Slack -- is Slack basically IRC plus built-in logs and easy searching?

19:43 elvis4526: basically yeah.

19:43 hiredman: don't forget the hype

19:44 irc has none

19:45 troydm: hehe

19:46 u can connect to slack via IRC gateway

19:48 andyf_: I mean, built-in logs and easy searching are valuable things, granted. Not trying to diss it. Just wanted to know if there was more to it than that.

20:23 arrdem: andyf_: hey

20:23 andyf_: so that's a known issue with the version sorting code. the /LATEST/ URL segment is missbehaving because it things that -beta3 is > the release.

20:24 andyf_: as a workaround if you hard code /1.7.0/ in instead that'll work just fine

20:24 hyPiRion: so what's required to put a dent in leiningen#1816?

20:25 it doesn't seem like lein has a way to tell that classfiles are "clean" besides the proposed "don't rebuild" flag.

20:43 andyf_: arrdem: Understood. I had a similar bug in some code for creating graphs for the Clojure expression benchmark results. I probably have a custom version comparator function in there somewhere. Either that or I punted on the issue by using something like 1.7.0-final as a hack.

20:44 arrdem: andyf_: yeah I hear ya. gonna try and work on that tonight or tomorrow depending on the status of other yaks

20:44 Will try and get that fixed for the new cheatsheet tho

20:48 andyf_: Ooooh. Project idea: web site showing hair length of various yaks in your pasture, to help you decide which one to shave next ...

20:48 arrdem: hehe

20:49 poll github's issue and stars count

20:49 justin_smith: andyf_: combine it with cow clicker and make bank https://www.facebook.com/dialog/oauth?client_id=111596662223307&redirect_uri=https://apps.facebook.com/cowclicker/default.aspx

20:49 arrdem: hair length is number of stars or maven downloads times issue count

20:49 maybe with some time factor since last release and commit

20:50 justin_smith: arrdem: hair length is number of PRs on the project, exponentiated by age

20:50 arrdem: justin_smith: haha

20:51 justin_smith: cow clicker was designed to be a critique of facebook games, became successful facebook game http://www.wired.com/2011/12/ff_cowclicker/all/1

20:55 andyf_: cow clicker is no Progress Quest. You actually have to click on stuff.

21:19 Seylerius: Are there clojure libs for managing virtual machines?

21:31 justin_smith: Seylerius: I know puppet uses clojure, and I think it has some clojure bindings, if that counts

21:32 Seylerius: Hmm...

21:32 justin_smith: Seylerius: also I know some puppet labs folks that hang out here time to time

21:32 Seylerius: justin_smith: I'll keep an eye out. One of my projects involves spooling up virtual machines on demand that download arbitrary files from the web and run tests on them.

21:33 justin_smith: Seylerius: maybe this https://github.com/puppetlabs/puppet-server

21:35 Seylerius: Interesting.

21:35 Thanks for the tips.

21:35 (inc justin_smith)

21:35 lazybot: ⇒ 272

22:01 lucien: join #racket

22:01 I think I spend more time reading about programming than programming

22:35 elvis4526: what's the official way to write docstring in clojure ?

22:35 I'm trying to use codox and it doesn't seem to parse my docstring.

22:36 ah the vector containing the arguments must be AFTER the docstring

22:37 justin_smith: elvis4526: yeah, this is because of multiple arities

22:37 you still need to have just one doc string

23:00 TEttinger: lucien: it's uh more fun the other way

23:01 re: spending more time reading about programming than programming

23:02 loke: Depends on what one reads

23:02 TEttinger: I don't think either is as fun as code golf

23:02 loke: TEttinger: Yeah, that's fun. Especially to look at people trying to get their solutions down below, say, 100 characters and then come in and post a 15 character APL solution. :-)

23:04 TEttinger: I'm curious about making an APL style library for Clojure, actually. I tried once a long time ago

23:04 not the one-char names so much as the behavior around rank

23:08 I think being able to use clojure's existing collection-affecting fns for flat or irregularly nested sequences, and an array programming approach (likely using core.matrix) for stuff that fits that would be nice

23:14 loke: TEttinger: I've had the same though, but using Common Lisp

23:14 But I would write an APL language parser on top of it

23:55 elvis4526: Is there a way to use slashes in function names ?

23:56 yeah okay that's a dumb question - sorry

Logging service provided by n01se.net