#clojure log - Oct 01 2015

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

0:11 justin_smith: lein do clean, check, eastwood, test, repl

0:48 tmtwd: in cljs, why do we do put! instead of >! ?

0:52 wmealing: tmtwd: i assumed i'd have seen it here https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure

0:53 but its not mentioned

0:53 and its really hard to google those characaters

0:55 may just not be implemented.

0:59 seancorfield: tmtwd: put! and >! do different things...

1:01 amalloy: seancorfield: would it be wrong to say that they do the same thing (or similar things), but in a different context?

1:02 wmealing: characters, man i need a break.

1:03 seancorfield: amalloy: well, they can also take different arguments :)

1:03 rhg135: Technically, >! tells the state machine to pause then resume on successful put

1:04 The symbol

1:04 seancorfield: It's been a while since I've worked with core.async but as I recall >! is blocking and needs to be in a thread or a go block, whereas put! is async on its own.

1:05 amalloy: is that a correct summary?

1:06 amalloy: "blocking" is the wrong word. it has to be in a go block because it parks

1:06 rhg135: put! Just puts stuff on a channel, and calls a callback when done iirc

1:07 seancorfield: amalloy: yes, true, that was sloppy wording :)

1:07 amalloy: "async on its own" i'm not sure what you mean, but i'm also not really sure how put! behaves so you are probably right

1:08 the thing i know about put! is that it's the most primitive putting operation supported by the platform, which has different semantics in jvm vs js

1:23 elvis4526: Anyone has a good tutorial/explanations for monads? I've read all the interesting stuff that I found the first 1-2 pages on Google :p

2:23 aztak: morning all!

2:29 anyone want to have a look at some newbie code and let me know what can be improved? https://gist.github.com/metamorph/bdb90be62e9d242eebf3

2:35 sveri: aztak, I wonder, why would you want to have an extra entity for a removed node?

2:36 s/entity/record

2:55 sm0ke: is there a way to change tools.logging root log level on repl?

3:05 aztak: sveri: perhaps that's a bit too much?

3:06 sveri: aztak, depends on the need, but why would I want to keep a node that's removed from a tree (I am not saying this is invalid, just curious for the usecase)

3:06 aztak: sveri: the idea was to model each possible 'state' as a separate record. The Node record could be created with a flag indicating if it was a 'deleted' node or not, sure.

3:06 sveri: aztak, if it's deleted, remove it from the tree

3:07 aztak: sveri: It's a binary tree, so you still need to be able to find its leaf nodes that are *not* deleted.

3:07 sveri: In that case you would need to rebalance the tree (which could be done, of course).

3:07 sveri: AFAIR trees will have to be rebalanced after removal of node

3:07 aztak: yeah, that's it :)

3:08 sveri: I mean, there might always be cases where it is useful to mark a node as "removed" and leave it in the tree

3:08 aztak: I agree (and I'm working on a re-balancing function) but in this scope I'd say the code would become *more* complex if I introduce re-balancing on removal. Maybe :)

3:09 thanks for the input though :) Any ideas on how to minimize the repetitive code. Each implementation of insert/member? etc. basically follows the same 'pattern'.

3:10 sveri: Well, my first step would be to get rid of the removed node

3:10 aztak: Check if it's "this" - do one thing. Check if it's gt than 'this' then do something else.

3:10 sveri: and then factor the delete / insert methoud out into it's own method

3:10 and pass in the "action" functions

3:10 aztak: sveri: like a 'template class' functional style?

3:11 sveri: Not sure what a template class is :D

3:11 aztak: hehe

3:11 sveri: Sounds like C#

3:11 Or some other C :D

3:11 aztak: (defn do-branch [current-value incoming-value on-eql-fn on-lt-fn on-gt-fn] ...) ?

3:12 (template method might be the correct name.. )

3:12 https://en.wikipedia.org/wiki/Template_method_pattern -- very OO.

3:12 sveri: yea, like that

3:13 and see what it looks like

3:13 aztak: I'll give it a spin this evening :) Thanks for taking time looking at the code!

3:14 sveri: Yea, np, and dont take my words to serious, I just like to poke at things and see if I like it better afterwards. Dont have that much clojure experience myself ;-)

4:05 marshzor: I would like to build a ring request with a html Date header, is there a preferred way of doing this in clojure?

4:11 mavbozo: marshzor, you can use ring-mock https://github.com/ring-clojure/ring-mock to build the request

4:12 and then use ring.util.time/format-date to format your date

4:13 marshzor: thanks, I'll give that a try

4:24 hmm I guess ring-mock doesn't really help me since the api I'm using just wants a method, uri and headers map. Good to know about though, thanks mavbozo

4:44 lnostdal: anyone tried clojure 1.8 yet? .. i keep getting this weird exception when compiling: https://www.refheap.com/110150

4:50 neoncontrails: I'm sort of unclear on something: what does leiningen proceed to do when invoked from within a subdirectory?

4:50 (Say, when you call "lein repl")

4:51 I'm trying to diagnose why I'm getting errors in some directories which should be a-ok

4:51 But it runs fine elsewhere

4:54 I reckon it's a dependency issue of some sort, but I'm not familiar with some of the libraries that show up in the stack trace... i.e. plexus

5:09 sveri: neoncontrails, I am not sure, but my guess is, when you invoke lein repl from a folder where you have a project.clj it reads that one and sets up the environment, but from every other folder it just reads the %USER%/.lein/profile.clj and just starts a repl

5:12 neoncontrails: Hmm. That makes sense, because running "lein repl" elsewhere on my server works fine whether there's a project.clj or no

5:14 But I'm not sure what the problem could be, in that case. The problem dir is just a straight-up git clone of this git repo, which works perfectly on my local setup: https://github.com/bhauman/flappy-bird-demo

5:15 ls

5:15 oops sorry. Similar windows :)

5:20 sveri: neoncontrails, how about you pastebin the error?

5:22 neoncontrails: Sure thing. There's errors like it on the web, but those point to Heroku issues that are not an issue in this case. One sec

5:24 http://pastebin.com/YA97Pi8d

5:26 I see elsewhere that this can be caused by a conflicting ~/.lein/profiles.clj file, but I don't appear to have one in that dir's ~/.lein folder

5:36 oddcully: neoncontrails: i cloned the repo from gh and tried with the same lein version. works here

5:36 mavbozo: neoncontrails, what is inside subproject.clj ?

5:37 neoncontrails, is it a file inside flappy-bird-demo/ ?

5:37 oddcully: mavbozo: not according to the clone or the "ls" in the refheap

5:37 neoncontrails: Got it. What eventually solved the problem was "apt-get remove leiningen" and manual install to /usr/bin/dir (I'd previously installed it to /bin/, which might my user might not have had access to)

5:38 TEttinger: phew, glad the birds can be flappy

5:38 nXqd: hi guys, I have a bit problem regarding working with clojurescript. When I develop with figwheel, everything works just fine

5:38 oddcully: neoncontrails: that would have been my next question ;)

5:38 nXqd: but when I compile the project for production with lein uberjar. The javascript has error :(

5:40 mavbozo: nXqd, try lein deps :tree and see if there are any confusing dependencies

5:40 oddcully: nXqd: are/where you "Guest52" over in #clojurescript? the problem with .offsetX on nil?

5:40 nXqd: oddcully: ah no. I'm not

5:40 mavbozo: I will try

5:40 neoncontrails: oddcully: I run into dumb Unix obstacles like these pretty frequently, but I have yet to find a good overview of how to rock the command line. Any leads?

5:41 oddcully: neoncontrails: `which lein` to find out what you call. never ever install build-tools from your distri unless you know it's always uptodate

5:41 neoncontrails: Occasionally I'll ask someone, 'hey, how'd you get so good at Unix.' I've never met anyone who has an answer to that

5:42 nXqd: mavbozo: it seems to be a giant list of deps, I see some advice regarding putting exclusions. on lein-fighweel

5:42 hmm, I don't think it's the solution. Do you have any ideas

5:42 I work with the lein reagent template.

5:43 oddcully: nXqd: often the problems arise with different compiler settings

5:43 neoncontrails: is `which lein` an alias of lein --help?

5:43 The output is the same

5:43 oddcully: nXqd: can you provide the error in a gist/refheap/...

5:44 nXqd: oddcully: yes I will. I'm trying with the :none optimization, maybe I can see some hint from it.

5:44 TEttinger: neoncontrails: odd. which is a command that should list where the lein executable is on the filesystem?

5:44 oddcully: neoncontrails: which tells you, where the binary is located. if you call `which lein` and see /usr/bin/lein, you see, that you use the system one. your own install would rather show up as ~/bin/lein

5:45 nXqd: oddcully: hmm, I have another error which is goog is not defined.

5:45 neoncontrails: Oh, got it. I was treating the quotes too literally

5:45 nXqd: the the overall is : I get the app working with dev optimizations none.

5:45 neoncontrails: "`which lein'"

5:45 TEttinger: heh

5:46 nXqd: when I use uberjar, the app seems to work, but the interaction with javascript doesn't work. I change uberjar compiler's settings to none, then I get goog is not defined

5:46 oddcully: neoncontrails: `which lein` would execute the result. its basically the same as just running lein (if it's in path)

5:46 nXqd: interaction using javascript*

5:48 oddcully: nXqd: i can not comment on uberjars. but goog missing is most likely not having a main defined or no goog required or wrong stuff in your jar (e.g. only the generated.js instead of the whole out dir)

5:48 nXqd: oddcully: thanks for your comment. I think there is something wrong with my code. I just run uberjar on clean reagent template, everything seems to work fine

5:49 oddcully: nXqd: and if you have problems with full optimazations and external libs, then names get mangled

5:49 TEttinger: oddcully: but `which lein' with the straight quote at the end would not

5:49 oddcully: nXqd: the error would be something like "document has no method .XaJ" where XaJ is something that had a nice name before the compiler optimized it

5:49 TEttinger: that's an odd custom to do quotes like that, I think it was related to some clients rendering it as proper curved quotes?

5:50 oddcully: TEttinger: OP wrote it wrong here. if he had the lein help he called `...`

5:50 nXqd: oddcully: yeah, but I don't have that problem. I have this one Use of undeclared Var clojure.set/intersection

5:51 I believe that it's correct to use clojure.set in clojurescript.

5:51 TEttinger: it may need to be required first?

5:51 ,(clojure.set/intersection #{1 2 3} {1 4 5})

5:51 oddcully: nXqd: maybe figwheel requires it in its underbelly or some plugin

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

5:52 TEttinger: ,(clojure.set/intersection #{1 2 3} #{1 4 5})

5:52 clojurebot: #error {\n :cause "clojure.set"\n :via\n [{:type java.lang.ClassNotFoundException\n :message "clojure.set"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLClassLoader$1 run "URLClassLoader.java" 366]\n [java.net.URLClassLoader$1 run "URLClassLoader.java" 355]\n [java.security.AccessController doPrivileged "AccessController.java" -2]\n [java.net.URL...

5:52 TEttinger: ,(require 'clojure.set)

5:52 clojurebot: nil

5:52 TEttinger: ,(clojure.set/intersection #{1 2 3} #{1 4 5})

5:52 clojurebot: #{1}

6:03 mavbozo: i'm using clojure 1.8.0-alpha5 and clojurescript 1.7.122 and I get this error Exception in thread "main" java.lang.VerifyError: (class: cljs/util$last_modified, method: invokeStatic signature: (Ljava/lang/Object;)Ljava/lang/Object;) Can only throw Throwable objects, compiling:(util.cljc:142:1)

6:07 oddcully: lnostdal mentioned the same error earlier

7:10 lnostdal: oddcully, might be related to this: https://groups.google.com/forum/#!topic/clojure/2t120_atPR8

7:12 mavbozo: lnostdal, what a coincidence, about an hour ago i got the similar problem

7:12 Exception in thread "main" java.lang.VerifyError: (class: cljs/util$last_modified, method: invokeStatic signature: (Ljava/lang/Object;)Ljava/lang/Object;) Can only throw Throwable objects, compiling:(util.cljc:142:1)

7:12 this time with clojurescript 1.7.122

7:12 and clojure 1.8.0-alpha5

7:21 puredanger: That's clj-1809

7:22 nXqd: oddcully: it seems the problem is because of the clojure.set function

7:22 puredanger: It's a bug in the new direct linking stuff

7:34 oddcully: nXqd: i tried earlier. the function works when fired in figwheel without require. have you tried requiring it?

7:34 nXqd: no, I just use it directly without requiring

7:34 it works well in figwheel

7:34 oddcully: because figwheel requires it and so it works in figwheel

7:35 nXqd: but when I uberjar, the minified version of javascript doesn't work

7:35 oddcully: put it in your require where you use it and it should work also outside of figwheel

7:35 nXqd: ah, i get it

7:35 hmm, some how it's a bit trouble some with the repl isn't it :D

7:46 oddcully: sometimes, I get really weird problem with the figwheel repl like, when I first use the application, it seems to not work. But after making figwheel hotreload, it works. How can we address this kind of problem quickly ?

7:49 oddcully: nXqd: how do you handle the reload? are you doing your stuff in the on-something-i-forgot-reload hook? iirc this does not get called on initial load but only when figwheel handles the reload

7:50 roelof_: Hello, Is living clojure together with 4clojure and the wonderland katas a good way to learn clojure ?

7:50 nXqd: oddcully: hmm, I don't have any custom reload hook here in my project.

7:51 the error when I first used ( in development ) is the exact error I get when I use uberjar version of javascript

7:52 oddcully: the error with the set? i thought that you got fixed with requiring?

7:54 nXqd: oddcully: ah no. other ones

7:54 the error with set is fixed. But is it considered an error with the clojure.set

7:54 it should be ok if I use directly with namespace, shouldn't it ?

7:54 or if we use clojure lib in clojurescript, we have to require first ?

7:56 oddcully: nXqd: this is not like in e.g. java. you have to require

7:58 spacebug_: mpenet: for a uuid in cassandra, is there any reason prefer your uuid (alia, datastax uuid) over the standard java java.util.UUID/randomUUID

7:58 nXqd: oddcully: ah, yes.

8:02 sveri: Hi, lets say I have an arbitrary map {:id 1 :b {:id 2 :children [{:id 4 :foo :bar}...]}} with an :id key that always has a unique value and I want to update a map somewhere inside the map while only knowing the id, but not the path to the map. How would I do that?

8:06 mavbozo: roelof_, i don't know about living clojure or the wonderland katas, but I found doing the first 80-100 4clojure problems helps me familiarize myself with clojure syntax and frequently used clojure.core functions

8:06 roelof_: mavbozo: oke, thanks

8:08 mavbozo: you do nt have used any book to learn clojure

8:08 oddcully: sveri: i just play around with specter. transform with a walker works there

8:08 mavbozo: roelof_, and besides syntax and core functions, also clojure's special forms

8:09 sveri: oddcully, funny, I also tried specter, but couldn't make it work

8:09 Maybe you have a small example please?

8:09 oddcully: sveri: https://www.refheap.com/3b6eed2bb3ab1e74f760c24a9

8:10 mavbozo: roelof_, i feel comfortable reading Clojure Programming

8:10 roelof_: oke, that is a book I know only with no exercises

8:11 oddcully: sveri: lacks the (use ...) sorry

8:11 sveri: oddcully, np, I try it now

8:11 mavbozo: roelof_, i exercised using 4clojure

8:12 roelof_: oke, and when reading. You can start very soon exercising 4clojure ?

8:13 mavbozo: roelof_, i felt comfortable with Clojure Programming because I have a job as a programmer and i felt that book was written for me

8:15 roelof_, yes, I can directly jump to 4clojure because I have previous programming background with language with repl as ruby or python

8:15 sveri: oddcully, great that works, somehow I assumed a simple selector would do it, but walker is exactly what I was missing

8:17 mavbozo: roelof_, and I started learning python and ruby by playing at the repl and they both have similar exercise tools like 4clojure

8:17 roelof_: oke, then for me the same. I have some experience in ruby

8:17 sveri: I have to admit, specter seems really useful

8:21 roelof_: Oke, then I will try that way. The way with the MOOC from the university of Helsinki does not work for me

8:22 mavbozo: roelof_, what is the name of the MOOC?

8:22 opqdonut: http://mooc.fi/courses/2014/clojure/

8:22 I guess

8:37 roelof_: opqdonut yes, that one

8:45 crocket: Has anyone here migrated from haskell land?

8:46 roelof_: mavbozo yes, the one that opqdonut said

8:50 opqdonut: crocket: I use both

8:51 crocket: opqdonut, What is your verdict on those languages?

8:52 opqdonut: both are very nice

8:52 I like haskell more, but clojure is more practical

8:52 both emphasize purity, which I think is very important

8:55 sveri: crocket, you want to hear the opinion of someone who tried three times to get into haskell?

8:55 crocket: opqdonut, That is it?

8:55 sveri, Do state your opinion

8:55 I'm not really sure about what I will use clojure for.

8:55 Clojure can't certainly be used to write MySQL.

8:55 Maybe, I can.

8:56 If I can bear clojure's extravagant memory usage,....

8:57 sveri: crocket, My experience is, that the tooling is not comparable to clojure land. there is nothing comparable to leiningen, which makes it hard to start for beginners. (I know, inbetween there is stack, but it still cannot reach leiningen). Also the IDE support is not close clojure (emacs aside, which I don't want to learn). Everytime I tried it I ran into some setup troubles or problems with cabal or some other problems specific to windows

8:57 roelof_: pity. I cloned the offline github for 4clojure and it fails with ava.lang.UnsupportedOperationException: Unknown Collection type when I do lein run -m offline-4clojure.p1

8:57 sveri: I cannot say much about productivity, as I never got that far

8:57 crocket: emacs is ok

8:58 I use emacs and paredit

8:59 sveri: Even when I tried emacs I ran into a problem which made me have to restart ghci and emacs all the time I wanted to switch the buffer I was evaluating, there even was a known defect for this which had no simple fix available

8:59 crocket: I mean emacs and clojure mix well

8:59 not haskell

8:59 roelof_: what I missed what a very nice introduction. I found no good beginners haskell books

9:00 sveri: roelof_, Exactly, that's another point, as a beginner it is really hard to get started at all

9:00 crocket: It may be different now

9:00 Haskell is pretty mature at this point

9:01 roelof_: exactly. the "experts" say begin with CIS194 course where the second assignment is to solve the towers of hanoi recursive

9:01 sveri: The language surely is, but the tooling and editor support is not, from my point of view

9:01 roelof_: but can someone help me with my unknown collection type error

9:02 justin_smith: sveri: there's a common attitude amongst haskell folks that tooling and editor support are symptoms of a shitty language

9:02 "your language is so bad it needs special editor plugins before you can be productive programming in it'

9:02 sveri: justin_smith, hm, I would have to disagree with this. Especially in larger projects tooling and editor stuff will become so important

9:02 crocket: towers of hanoi?

9:02 roelof_: but I have to leave for some 30 min. My daughter school is out now

9:03 justin_smith: sveri: I'm just reporting that this attitude is prevalent, I don't neccessarily agree

9:03 sveri: and this might explain some of the lack of tooling

9:03 crocket: That sounds elitist

9:03 sveri: justin_smith, Yea, understood, it was an argument against that saying, not you :-)

9:03 justin_smith: crocket: haskell, sound elitist? never!

9:03 crocket: It also sounds exclusionary

9:05 sveri: Gradle for instance, needs two lines of configuration to get a working java project with build, jar and test tasks + support for eclipse or intellij with auto generation of IDE files. 6 lines more will get you dependencies included. Leiningen has the same story, it is so easy to get started with leiningens templates

9:05 crocket: Gradle is more complex than leiningen.

9:05 You need to know some gradle

9:05 sveri: crocket, You can keep it simple as well

9:06 true

9:06 crocket: I mean you need to know some groovy to handle gradle well

9:06 It's groovy

9:06 sveri: OTOH that gives you a lot of options

9:06 But, my point was, it is very easy to get started

9:07 whereas in haskell, for a beginner, the easiest thing is to go to fpcomplete

9:08 crocket: I believe there are ebooks that you can download.

9:28 marshzor: anyone know a good way to trim whitespace before and after a string? (trim " stuff ") returns "stuff" ?

9:28 justin_smith: ,(clojure.string/trim " this stuff \n \t")

9:28 clojurebot: "this stuff"

9:28 marshzor: oh ...haha, right

9:28 sorry

9:28 ty

9:29 justin_smith: you even had the name :)

9:29 marshzor: I just tried (trim " stuff ") in repl, asked here, then went to google... I think step 2 and 3 need to be reversed :)

9:29 I smell a bad habbit forming

9:29 justin_smith: (clojure.repl/apropos "trim")

9:30 ,(clojure.repl/apropos "trim")

9:30 clojurebot: (clojure.string/trim clojure.string/trim-newline clojure.string/triml clojure.string/trimr)

9:30 sveri: Hm, in a distributed system and an ideal world the order should not matter :D

9:30 justin_smith: marshzor: apropos helps :)

9:30 sveri: eventual competency

9:32 sveri: justin_smith, hehe, I have to memorize that

9:45 Jeez, I could cry, I am working for 2 weeks now figuring out a REST API + some objects and tests in JAVA. Just for the fun I took myself 60 minutes now to do the same in clojure. These endless discussions about the object structure and interfaces and abstract classes. Back and forth where it could be so easy.

9:45 Kind of frustrating if you have the direct comparison - /rant off

9:46 justin_smith: crocket: regarding your comment on another channel about clojurescript output size, are you using a minified output? because it makes a big difference

9:46 roelof_: one last question : Is there a way I could make 4clojure with my own editor ?

9:46 justin_smith: roelof_: there's an emacs mode for loading and testing 4clojure problems

9:47 sveri: roelof_, I always copied it into lighttable and then copied back. Not to much of an overhead, I think

9:48 roelof_: justin_smith: I tried that one on my cloud ide but I saw this error : unknown collection type error

9:48 sveri: roelof_, if you use vimperator for firefox you can also open a real vim instance in textareas from the browser

9:49 roelof_: sveri: oke, I use now nitrious.io cloud enviroment

9:50 crocket: justin_smith, I'm aware of advanced optimization mode.

9:51 sveri: roelof_, looks cool, didn't know that one, however, maybe its a problem in their environment?

9:52 roelof_: I do not know, I downloaded the offline-4clojure github and that is giving me the problems

9:53 sveri: roelof_, For learning clojure I would take lighttable. you have instant feedback on your code, giving you the fastest turnaround you possibly can have

9:54 Also you dont need the offline repo, like I said, just copy and paste the functions from 4clojure

9:54 roelof_: oke, I have then I think install linux . Im running now Win 10

9:54 sveri: Hm, I am using clojure on W7 for two years now (except for boot) everything works fine. Don't know why it shouldnt work on W10

9:55 roelof_: sveri: oke, is it easy to install clojure and work with clojure on windows

9:56 sveri: roelof_, you have a JDK installed already?

9:56 roelof_: sveri: I do not think so. I have a bare Windows 10

9:57 I thought for clojure you need linux or a mac

9:57 wombawomba: Is there any way to mix the (fn [& {a :a b :b :as kwargs}] ...) and the (fn [& {a :a b :b :or {a 1 b 2}}]) syntaxes?

9:57 noncom: roelof_: clojure works under win like a charm!

9:57 sveri: Ok, so the process is like this: 1. Download and install latest JDK, 2. set JAVA_HOME variable in windows, 3. include the java bin folder in the PATH environment variable. 4. install leiningen 5. download and run lighttable

9:57 roelof_, if you know what you are doing and have a fast connection you are done in 15 minutes

9:58 noncom: wombawomba: what you need these syntaxes for?

9:58 roelof_: sveri: for point 2 and 3 are there any manuals

9:58 sveri: roelof_, http://www.mkyong.com/java/how-to-set-java_home-on-windows-10/

9:58 noncom: wombawomba: destructuring works for the varargs, so not sure, what's your problem aside from the strange {a :a} form instad of {:keys [a]}

9:59 sveri: roelof_, I have not done it on W10, but it should be straight forward too

9:59 justin_smith: ,((fn [& {a :a :or {a 10} :as kwargs}] a)) ; wombawomba

9:59 clojurebot: 10

9:59 noncom: wow

9:59 justin_smith: ,((fn [& {a :a :or {a 10} :as kwargs}] a) :a "I hate kwargs and you should too") ; wombawomba

9:59 clojurebot: "I hate kwargs and you should too"

9:59 roelof_: oke, thanks all

9:59 sveri: roelof_, good luck!

10:00 roelof_, I am here for 20 more minutes if you have some questions

10:00 roelof_: light table has a repl for itself ??

10:00 tdammers: hah, on the bright side, I have now successfully demonstrated that loop/recur does indeed run in constant memory

10:00 sveri: roelof_, it's inside the editor

10:00 wombawomba: noncom: I want a function that has default arguments, and where I get a binding to all arguments

10:00 roelof_: I have to leave in a few minutes. Daugther has to go to swimming lessons

10:00 tdammers: (fn [blah] (loop [blub blah] (if (empty? blah) nil (recur (rest blah)))))

10:00 ouch

10:01 justin_smith: noncom: {a :a} is the base / more general form, {:keys [a]} is a sugar (which is less useful when keys of more than one map match in one destructure)

10:01 noncom: ah, that's what

10:02 wombawomba: ,((fn [& {a :a :or {a 10} :as kwargs}] kwargs) :a "asdfg")

10:02 clojurebot: {:a "asdfg"}

10:02 roelof_: Thanks all and have a good evening

10:02 wombawomba: ,((fn [& {a :a :or {a 10} :as kwargs}] kwargs))

10:02 clojurebot: nil

10:02 wombawomba: justin_smith: ^ doesn't work

10:04 justin_smith: wombawomba: you supplied no args!

10:04 ,((fn [& {a :a :or {a 10} :as kwargs}] kwargs) :an :arg)

10:04 clojurebot: {:an :arg}

10:04 justin_smith: oh, but there was also no a

10:06 wombawomba: so yeah, I guess that doesn't work

10:06 wombawomba: justin_smith: I want kwargs to be set to the default args by default

10:06 justin_smith: ,(let [{{:keys [a b]} :c :keys [d e]} {:c {:a 0 :b 1} :d 2 :e 3}] [a b d e]) ; but this does

10:06 clojurebot: [0 1 2 3]

10:06 wombawomba: yeah

10:06 justin_smith: wombawomba: kwargs are terrible

10:06 wombawomba: ha

12:04 bja: does reader eval support special forms?

12:06 justin_smith: ,(eval (read-string "(if true :OK)"))

12:06 clojurebot: :OK

12:06 justin_smith: I don't know if that is what you mean by reader eval, but it was a read followed by an eval

12:06 and the special form was supported in that it executed properly

12:08 bja: (binding [*read-eval* true] (read-string "#=(if true :OK)"))

12:09 which doesn't work afaict (although I'm probably doing something wrong)

12:09 justin_smith: interesting, can't resolve if

12:09 bja: but (+ 1 5) returns a 6

12:09 justin_smith: haha, if you try "when" instead, you get "wrong number of args"

12:09 because it is calling the macro as a function

12:10 bja: https://www.refheap.com/110173

12:11 bja: nice

12:11 justin_smith: so if you called str on that, and called read-string/eval on that...

12:11 lol

12:11 your half way to a very stupid compiler at that point

12:12 bja: hmm

12:14 I think I just need to reconsider what I'm doing. (binding [*read-eval* true *print-dub* true] ....) is madness

12:16 *print-dup*, although printing code arranged as dub-step would be neat

12:18 justin_smith: bja: simple - attach the wires of your tty to a speaker, then print the code to the tty, instant dubstep

12:20 bja: probably don't want to do that in the office though. they already think I perform black magic with parens.

13:18 justin_smith: bja: speaking of black magic, I literally did a (defn foo [x] (fn [y] (fn [] ...))) today

13:19 it was totally called for though, I swear!

13:19 bja: you actually wanted the clojure and not a partial?

13:19 *closure

13:19 justin_smith: bja: the non-partial form would never be used

13:20 bja: fair enough

13:20 thunks ftw

13:20 justin_smith: I mean yeah, partial would construct the same thing, more idiomatically I guess

13:23 bja: whenever I tink the non-partial form will never be used, I want to debug something in a repl in some remote place

13:23 where I don't want to construct an entire system just to investigate something

13:23 (which is why I refactored almost all of my code that was returning functions to be partials awhile back)

13:38 roelof: sveri: are you here to help me with Lighttable ?

13:47 anyon who is using light table with clojure and who can explain why I see this output #'fourclojure.core/-main instead of hello world on this code : http://lpaste.net/142085

13:48 justin_smith: roelof: that line does not call -main, it defines it

13:48 the return value of defining a function in your namespace is the var that was defined

13:49 roelof: if you added on the next line (-main) you would see the result of calling it

13:49 hiredman: a function only runs when you invoke it

13:49 roelof: justin_smith: oke, so I have to do (main) to see hello world ?

13:49 justin_smith: (-main)

13:49 yes

13:51 roelof: justin_smith: when I do (-main) I see as output nil

13:52 justin_smith: roelof: println returns nil

13:52 try adding "hello" as the last line of the function

13:52 you should see it return "hello"

13:53 roelof: justin_smith: I should ad just "hello" as the last line of -main.

13:54 oke, that works, so I cannot see the output of println in a repl of light table ?

13:55 wombawomba: So I'm writing a set of integration tests (currently using midje), and I want some way of stating that all tests will *eventually* (at least within some period of time) pass, i.e. I want to do something like (eventually "30s" (fact (make-some-api-call) => 4)). In other words, I want to repeatedly perform the check, and have the whole thing pass without failures if the check eventually passes. Does anyb

13:55 ody have any suggestions for how to approach this?

13:58 roelof: justin_smith: is there a way I can see the hello world output somewhere in light table ?

14:00 justin_smith: roelof: my first guess would be the terminal where you started light table, if you started from a terminal...

14:00 maybe it has a tab that shows clojure stdout?

14:00 roelof: justin_smith: thanks I will look if there is a console somewhere. I totally new to lighttable

14:01 justin_smith: roelof: "from the view menu, select console" https://www.safaribooksonline.com/blog/2013/09/11/light-table-workflow-for-interactive-clojure-development/

14:03 roelof: Thanks, now I can try to solve the exercises of 4 clojure.

14:05 Anyony body knows how I can reset 4clojure so I can start all over again

14:06 wombawomba: Actually, I think my question is this: What should I use to test lazy sequences?

14:06 Midje seems to eagerly evaluate everything, so it might not be optimal?

14:07 justin_smith: wombawomba: I just use clojure.test, and a simple property based test (eg (is (= (first l) :foo)))

14:08 blake_: roelof: You could just create a new ID.

14:09 roelof: But I use all my email adresses, so a new id cannot be done

14:11 xemdetia: roelof, do you use gmail? could try the roelof+tryagain@gmail.com trick

14:11 roelof: xemdetia: I do not use gmail , only one hotmail account

14:12 xemdetia: so it sounds like you just need to make a random new account and use that

14:12 it's not painful

14:15 matthavener: you can always use mailinator.com too, or something like that

14:16 roelof: I have made a gmail account so I can start working on the exercises and work with lighttable Thanks all

14:22 hmm, why is this not good : (= (list :a :b: :c) '(:a :b :c))

14:29 bja: roelof: (not= :b: :b)

14:29 blake_: ,(= '(:a :b :c) (list :a :b :c))

14:29 clojurebot: true

14:30 blake_: ,(= (list :a :b: :c) '(:a :b :c))

14:30 clojurebot: #<RuntimeException java.lang.RuntimeException: Invalid token: :b:>

14:30 roelof: blake : the repl of lighttable says false. 4 clojure is happy with the answer. Very wierd

14:31 found it I made a typo :b: instead of :b

14:31 blake_: oh! lol

14:31 roelof: sorry for the noise on this channel

14:32 sveri: roelof, Hi, did you get it running?

14:32 roelof: sveri: yes, right now I solve the first challenges. The first 10 are very simple

14:32 sveri: roelof, awesome

14:33 blake_: Is there a way to access a vector of vectors other then ((vecs 5) 5)? I know about make-2d-array, I'm talking about just this particular structure.

14:34 justin_smith: ,(get-in [[[[1]]]] [0 0 0 0])

14:34 clojurebot: 1

14:34 justin_smith: blake_: ^

14:35 blake_: justin_smith: I thought so! For some reason, I thought it was (get-in vecs 2 2).

14:36 justin_smith: there should be a <- macro

14:36 with the <- macro, at each step it would call the return value of the previous

14:36 so it would be (<- [[[[1]]]] 0 0 0 0)

14:36 wombawomba: what's the best way to force clojure not to chunk a sequence?

14:37 justin_smith: wombawomba: use doseq or run! if you want side effects, then chunking doesn't matter

14:37 (usually)

14:38 wombawomba: justin_smith: I want to evaluate a sequence of (really slow) sequence calls, returning the first that fulfills a predicate

14:38 blake_: *some restrictions apply

14:39 wombawomba: and I really don't want to evaluate more than I have to (because slow)

14:39 blake_: justin_smith: Oh, that's clever. I wonder how generally useful that would be. Seems symmetrically necessary somehow.

14:39 roelof: sveri: I have done the first 10 exercises , I call it a day

14:40 sveri: roelof, nice, its a good start. Do you like lighttable?

14:40 justin_smith: wombawomba: in that case, there's a gist out there for a dechunk function (I think it was written by chouser)

14:40 roelof: sveri: yes, I helps well when im stuck

14:40 justin_smith: wombawomba: I just bring up run! and doseq because they are not effected by chunking problems, and are often the better choice if you care about chunking

14:41 sveri: roelof, Yea, thats my experience too. Tremendously helpful to see so fast what a function or expression returns

14:41 roelof: Thanks all and have a nice evening

14:41 sveri: roelof, bye

14:45 wombawomba: justin_smith: alright, thanks

15:06 blake_: Is there a performance/memory use to using Java arrays or is to-array and to-array-2d more about interoperability?

15:07 amalloy: blake_: well, what do you think?

15:09 blake_: amalloy: I can't see a memory improvement. I could see a slight speed improvement if it weren't (potentially) ragged.

15:09 amalloy: blake_: compared to what? lists? vectors?

15:09 blake_: Like, byte-array, I can see both.

15:10 justin_smith: blake_: java arrays use less memory, because they have a lot less structure than our immutable stuff

15:10 blake_: Vectors. I think that's the correct analogue, i.e., vectors are as close to what Clojure has as arrays.

15:10 justin_smith: also perf if they are arrays of primitives, because of cache effects

15:11 blake_: java arrays are contiguous in the heap, clojure vectors are not

15:11 blake_: justin_smith: 2d arrays, though?

15:11 But wait...vectors are not?

15:11 justin_smith: java doesn't have real 2d arrays, so it would depend on which implementation you are using

15:11 blake_: I'm looking at to-array-2d.

15:12 justin_smith: blake_: vectors use a tree structure in order to allow efficient sharing

15:12 blake_: justin_smith: I suppose it would have to.

15:13 justin_smith: oh yeah, to-array-2d is just a ragged array of object

15:13 so it's not the same sort of thing that eg. a fortran programmer would call a 2d array

15:13 blake_: Right.

15:14 So, wait, what makes a vector a vector? I sort of envisioned it as an...array. Heh. But that can't be. Still it must be different from a list under the covers.

15:15 justin_smith: blake_: hyPiRion wrote some really excellent blog posts about how vectors are implemented

15:15 blake_: http://hypirion.com/musings/understanding-persistent-vector-pt-1

15:15 thearthur: blake_: it's a trei

15:16 blake_: Oh, I looked at that a while ago. Maybe I can understand it now. =P

15:16 justin_smith: thearthur: when you type "trei" do you intend that to be trei, tree, or trie?

15:16 (we have terrible names in the programming world don't we though)

15:17 blake_: So there's going to be some memory disadvantage, and also some speed disadvantage because of the immutability.

15:17 justin_smith: trieu, we do

15:22 thearthur: justin_smith: I gave up long ago on anyone agreeing on a spelling pronounciation combination for these. i mean the type of tree use in clojure's vectors and maps

15:24 lgas: can anyone point me in the direction of what I'm doing wrong with this macro? Why is ~fields coming up nil? https://www.refheap.com/110182

15:24 blake_: But actually, I think the heart of my question is not really if Java arrays are more efficient but if that's what the various to-array functions is about. Like, I've never used Java arrays in Clojure. I'm all about the immutability.

15:24 justin_smith: ,(apply str (shuffle (seq "trie")))

15:24 blake_: er, are about.

15:24 clojurebot: "irte"

15:25 amalloy: justin_smith: a 12% chance of getting an actual word out of that i think

15:25 justin_smith: sounds about right

15:25 *rite

15:25 thearthur: justin_smith: it's official irte is the new name for "exactly the thing that clojure uses"

15:26 pronounced "er-tee"

15:26 blake_: Is it a sop? Is it the only way to use certain Java libraries?

15:26 amalloy: blake_: there are a few occasions where clojure programs use arrays instead of something more reasonable, for performance, but mostly it is for working with java programs that demand an array

15:27 blake_: amalloy: Thanks. That makes sense.

15:27 justin_smith: ,(let [a "a"] `(~a))

15:27 clojurebot: ("a")

15:29 justin_smith: lgas: (:a :b) evaluates to nil

15:29 ,(:a :b)

15:29 clojurebot: nil

15:29 justin_smith: lgas: that's what I think is happening

15:29 try (debug {:fields '~fields})

15:30 lgas: ah that was it. thanks, justin_smith.

15:30 justin_smith: you probably don't even need the ~

15:31 (or the ')

15:31 lgas: without the ~ it comes back as {:fields work.temp/fields}

15:31 justin_smith: ahh

15:31 lgas: without either it doesn't compile because it can't find work.temp/fields

15:32 but '~fields does what I need.

15:55 blake_: If I have a web app that's accessing a Java object, and multiple users of the web app are accessing the same object--let's say it's a calculator with a persistent set of numbers to work on, but users can change the numbers--what happens when two of them try to access it at the same time?

15:56 Let's say that the operations are atomic: The user makes a request of the calculator, the web app sets all the values at once and returns the result.

15:56 So impersistent state doesn't matter because each person sets all the values every time.

15:56 But could it be that they're both changing the underlying Java object safely, but simultaneously? So that the result comes out wrong?

15:57 Seems like that would be a possible thing.

15:59 Otherwise, the object would have to be locked and users would have to wait.

15:59 thearthur: blake_: if you can really say the opperations are attomic(as a group rather than individually) then it's safe

16:00 if each value is set atomically, though without regard to the others then it's not gona be fun time

16:00 blake_: Well, not atomically in the sense of atoms. Java object. I have to make a call to set each value.

16:01 Atomically in the sense of: Each call into the web app contains all the information, the calculator is always in a neutral state, the values are always all put in and the results immediately returned.

16:03 I could lock the object myself, I suppose. That'd be safe. If people start complaining about response time I could...clone the object, I guess. =/

16:06 amalloy: that's pretty much the only thing you can do if you need to perform multiple coordinated updates to a mutable object

16:07 blake_: Yeah, I was coming to that conclusion. I find myself resenting Java's mutability.

17:03 rasmusto: why is it that transducer composition is reversed from normal function composition?

17:05 akkad: rasmusto: example?

17:07 justin_smith: rasmusto: comp is transforming the functions, not the data

17:07 rasmusto: ,(sequence (comp (map inc) (map #(* 2 %))) (range 1))

17:07 clojurebot: (2)

17:07 rasmusto: ,((comp inc #(* 2 %)) 0)

17:07 clojurebot: 1

17:07 justin_smith: rasmusto: (map inc) is a function that can take a transducer, and returns one

17:08 Bronsa: rasmusto: transducers are not "normal" functions, composing transducers builds a transformation stack

17:08 justin_smith: rasmusto: so the comp is happening in order in terms of function production, but reverse in terms of the data flow

17:08 rasmusto: alright, I think that makes sense

17:08 justin_smith: right, what Bronsa said

17:09 rasmusto: it's actually pretty convenient that I can turn (->> (range) (map inc) (map dec)) into (sequence (comp (map inc) (map dec)) (range))

17:10 since threading is inside-out as well

18:59 noncom|2: does anyone here have experience working with transit?

18:59 specifically json enc/dec with non-latin chars

19:00 justin_smith: noncom|2: it handles my utf8 OK, I'm fond of throwing snowmen around

19:01 noncom|2: heh :)

19:01 strange thing - on one machine there's no trouble. on another one - there is trouble

19:01 specifically java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0xe0

19:01 google says this error is almost as ancient as jackson

19:03 solutions aren't really solutions for me

19:03 justin_smith: so someone is creating utf8 that jackson refuses to handle?

19:03 noncom|2: justin_smith: it's actually me, yes

19:04 amalloy: your non-working computer is probably creating characters using an encoding other than utf-8

19:04 eg like latin-1 or some other garbage

19:04 justin_smith: yeah, a linux or mac box will default utf8 for most stuff, windows will not

19:04 amalloy: and then you take those bytes and tell jackson "hey mate here's some utf-8"

19:05 noncom|2: i create a webform and set :accept-charset "utf-8" then i send this back to clojure server with transit over a ws

19:05 same webform, same html. both PCs are win-7 (different editions though but it should not matter)

19:06 chrome browser encoding is set to utf-8...

19:06 i don't get where it falls out from utf-8...

19:06 it's all utf-8 over and through

19:06 justin_smith: until it isn't?

19:06 noncom|2: yeah!

19:07 could it be that transit somehow encodes it with non-utf-8 on cljs side?

19:07 also, the eclipse console, when i println what's coming from the ws, shows correct text

19:07 it's non-latin chars, but it is perfectly there

19:08 idk even where to start digging :/

19:09 justin_smith: noncom|2: it could be that your terminal accepts utf8 bytes that jackson does not, a well behaved terminal should not throw errors when random junk gets printed right?

19:10 noncom|2: right

19:10 are there various kinds of utf-8?

19:12 i thought that the whole point of the "U" letter was to leave all that behind...

19:12 * the u letter in the acronym

19:21 amalloy: justin_smith: alright, i had to specify "utf-8" in (.getBytes ws-message "utf-8") so that the correct bytes are given to transit

19:21 i'm still in wonder why it works on one PC but not the other

19:22 amalloy: the other one has a different default character encoding set

19:22 noncom|2: with explicit encoding it now works ok

19:22 amalloy: but.. how? how is this possible? it must be something JVM-wide or OS-wide, but this is near crazy

19:22 amalloy: OS

19:24 noncom|2: it would probably not hurt you to do some research on character encodings in general and utf-8 in specific, if you are confused by this issue

19:24 noncom|2: well, i had lots of play with them in the past, so not a total newb.. i'd say i get amazed each time something like that happens though

19:25 but i will surely try to find the roots of this one occasion

19:25 what that could be in windows doing this

19:29 amalloy: http://stackoverflow.com/questions/9312816/java-platforms-default-charset-on-different-platforms

19:33 triss: would core.logic be a good place to store a list of musical facts?

19:33 well not a list

19:33 like midi notes convert to hz

19:34 hz convert to midi notes

19:34 major scale has these degrees

19:34 noncom|2: triss: it depends

19:34 hiredman: core.logic doesn't have storage

19:34 noncom|2: triss: on what you gonna do with tose facts

19:35 triss: so I've got a map of paramaters

19:35 noncom|2: and yes, it does not store anything. you could define rules to define them - i meant that

19:36 triss: better use midi -> hz map

19:36 triss: so i've got a map of paramaters... some of the values in the map can be derived from over values in the map and vice versa

19:36 noncom|2: or look into the pink library

19:36 or minim for java

19:37 hiredman: that sounds sort of like something you might do with core.logic

19:37 triss: I'm not looking for those functions

19:37 got them out of overtone

19:37 noncom|2: what's your aim, triss?

19:38 triss: I'm wondering how useful something like converso could be: https://github.com/JeremS/Converso/blob/master/src/converso/core.clj

19:38 but for music

19:38 hiredman: core.logic works more or less like: I have some that I know information and some information that I don't know, I have defined some relationships between different parts of the information, please derive the information that I don't know

19:38 justin_smith: so fill in the rest of this fugue...

19:40 hiredman: if that sounds like what you want, then there you go

19:40 triss: I'm gonna have to take the plunge...

19:40 hiredman: for conversion stuff, if you sort of a closed world of conversions, and you know all the information for the conversions, you may as well directly generate all possible conversions

19:40 triss: I'm a few chapters in to reasoned schemer

19:40 but still have no clue how to impliment

19:41 I'll have a proper look over converso...

20:20 rplevy: did prismatic/schema used to have functions related to walking, and were they removed?

20:20 if so, what's the story on that, is it now advised to be done differently?

20:57 nm figured it out

21:44 irctc: hello?

21:44 clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline irctc

21:45 wmealing: yeah, what he said.

21:45 irctc: lol

21:45 hello world?

21:58 TEttinger: ,(println "Hello, World!")

21:59 clojurebot: Hello, World!\n

21:59 TEttinger: ,"Hello, World!"

21:59 clojurebot: "Hello, World!"

23:49 cfleming: Does anyone know if Clojars just got a new cert deployed?

23:50 I can't connect from JDK6: “Could not generate DH keypair”, which means that the server requires a DH keypair of > 1024 bits, which JDK6 doesn’t support.

23:55 nathanial: I'm running a dev server with lein ring using nohup but for some reason the way I'm doing it the output isn't going to nohup.out. Is there a way with lein ring or in the application code itself I can specify a log file for all output instead of standard out?

Logging service provided by n01se.net