#clojure log - Oct 02 2015

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

2:35 loram: Hi

2:35 Is there any tips for lowering memory consumption?

2:36 Doing clojure web dev on my machine is close to impossible

2:36 due to the high memory consumption

2:36 Chromium needs ~ 1Gb

2:36 Jvm anotheer ~1gb

2:36 and the machine only has 4gbs of ram

2:37 running ubuntu 14.04

2:37 Often I have to reisub things

2:37 As the machine just hangs

2:37 any advice?

2:43 dseitz: offload the running to a server

2:43 or get a better machine

2:44 loram: that's not practical

2:47 dseitz: What isn't? Renting a more powerful machine which you can test on locally is practical.

3:11 amalloy: loram is gone now, but the jvm doens't need anything close to 1GB

5:49 sveri19: test

6:02 SysRq: question about string iteration: what is the fastest way to do this in Clojure?

6:02 I did some tests here: http://pastebin.com/9sjdvdFV

6:03 also noticed that destructuring somehow made it way slower

6:13 a pure java parsing library will parse the same string in 20 ms, clojure takes 4 times longer at best just going through the string

6:18 roelof: Hello, Is there a way that I can see which value a variable has in lighttable. Then maybe I could figure out how this one works : (let [{x 3 y 8} [12 0 0 -18 44 6 0 0 1]] (+ x y))

6:18 clojurebot: Gabh mo leithscéal?

6:18 oddcully: SysRq: you want know if the body contains a nil?

6:18 roelof: sorry. I mean this one : http://lpaste.net/142127

6:19 SysRq: no I just want to traverse the string character by character

6:19 I built a simple parser but noticed performance issues, and my conclusion is that it's caused by slow iteration on the characters

6:22 Bronsa: SysRq: reduce will be much faster

6:22 SysRq: the parser needs context information, for example when parsing a string literal

6:23 Bronsa: you can hold that context in the reduce accumulator

6:23 SysRq: that's true

6:23 I'll look into it

6:27 roelof: when I have this (let [{x 3 y 8} [12 0 0 -18 44 6 0 0 1]] does let { x 3} mean the thirth number of the array ?

6:27 luma: yes

6:28 actually, fourth

6:28 oddcully: the fourth

6:29 ionthas: I'm trying to find a more idiomatic way to do a operation with vectors. https://gist.github.com/marcsolanadal/7d47558dadf90a808e0f Can anyone give me some ideas? Is it possible to do the operation using the -> macro?

6:31 roelof: oke, so there is a difference between let [ v 1 ] which means the variable v is 1 and let [

6:32 { x 3) which means take the fourth value out of a array

6:32 Do I understand this well ?

6:32 luma: {x 3} is a destructuring which means to take the item with key 3 from the input

6:32 TEttinger: ,[(let [v 1] v) (let [[v][1]] v)]

6:33 oddcully: ~destructuring

6:33 clojurebot: [1 1]

6:33 destructuring is http://clojure.org/special_forms#binding-forms

6:33 luma: it can be any associative collection, not necessarily a vector

6:33 TEttinger: ,[(let [v 1] v) (let [{k 3}[1 2 3 4]] v)]

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

6:33 TEttinger: ,[(let [v 1] v) (let [{v 3}[1 2 3 4]] v)]

6:33 clojurebot: [1 4]

6:34 roelof: IM studing the destructering in clojure programming book and this are examples that I first did not understand

6:34 TEttinger: yeah it can be tricky at first

6:34 luma: ,(let [{x 3} {3 :foo}] x)

6:34 clojurebot: :foo

6:34 TEttinger: you never really NEED destructuring, you can always write equivalent results without it

6:34 roelof: so (let [v 1] is assining and (let { v 1}) is destructering

6:35 TEttinger: no

6:35 roelof: :(

6:35 TEttinger: let always has square brackets

6:35 you can have {} within the square brackets

6:35 then is a destructuring, yes

6:35 roelof: oke, typed to quick

6:36 and without the {} it is assigning

6:36 TEttinger: you seem to have gotten this pretty quick, it took me... a while

6:37 roelof: what do you call quick, Im busy with this for 2 days and a lot of questions here and on reddit

6:39 TEttinger: I didn

6:40 I didn't notice, was too busy figuring out what the hell these papers on hilbert curves and gray codes are trying to say :P

6:40 troydm: let's say I have a function that takes number, how do i create a lazy array of application of that function over a range?

6:40 TEttinger: map?

6:40 clojurebot: map is lazy

6:40 troydm: I mean sequence not array, sorry sometimes I use both this terms interexchangably

6:41 TEttinger: ,(take 20 (map inc (range)))

6:41 clojurebot: (1 2 3 4 5 ...)

6:41 Bronsa: ,(map inc (range 10))

6:41 clojurebot: (1 2 3 4 5 ...)

6:41 TEttinger: ,(count (take 20 (map inc (range)))) ;; so you know it is calculating 20 only

6:41 clojurebot: 20

6:41 troydm: ,(take 3 (map (fn [x] (* x 2)) (range 10)))

6:41 clojurebot: (0 2 4)

6:42 troydm: ic

6:42 thx

6:42 TEttinger: troydm: if you do (map inc (range)) in a REPL it will run infinitely, or until it runs out of room

6:42 take stops it from evaluating all of it

6:43 (range 10) is not lazy

6:43 it's a regular seq of 0 -9

6:43 0 to 9

6:44 luma: it most certainly is lazy

6:44 TEttinger: oh sorry, not infinite

6:44 luma: the reason it will run infinitely is that your REPL tries to print the whole sequence for you

6:44 both map and range return lazy sequences

6:45 TEttinger: luma: (range 10) won't return an infinite seq

6:46 troydm: ic, thank you everybody

6:46 luma: right

6:54 roelof: Also thanks frome. It's lunch time here

8:22 triss: so why is this nil then?

8:22 ,(vals [])

8:22 clojurebot: nil

8:22 triss: when this goes boom

8:22 ,(vals [10])

8:22 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry>

8:23 snowell: Because nil/nothing CAN be cast to a MapEntry?

8:23 triss: oh...

8:24 hmmm. why would you do that?

8:26 snowell: Actually, looks like vals just returns nil if (empty? arg) returns true

8:26 ,(vals "")

8:26 clojurebot: nil

8:26 snowell: ,(vals #{})

8:26 clojurebot: nil

8:27 triss: is that desired behaviour? throwing feels nicer to me today...

8:27 being as thats what happens for other invalid inputs.

8:27 or am i missing something?

8:32 snowell: vals coerces a seq out of its arg

8:32 Then attempts to get a Map from that

8:33 If the seq is empty, there aren't any entries in the "map," so you get nil

8:43 sveri: Hi, I have java application which offers REST services via Jersey and I wonder if it would be possible to combine existing services with compojure routing, all in one code base (java and clojure mixed). In the end that stuff is put into a war file and then exposed on an application server. Did someone ever try that and succeed?

9:29 troydm: let's say I've defined some type using deftype

9:29 how do I check if object is of that type?

9:29 does Clojure automaticly defines function called typename?

9:30 ,(do (deftype foo [bar]) (foo? (foo. "bar")))

9:30 clojurebot: #error {\n :cause "Unable to resolve symbol: foo? in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: foo? in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: foo? in this co...

9:30 troydm: seems no

9:46 roelof: hello, for a exercise of 4clojure I have to implement max but Im not allowed to use the function max. So I thought it could be done by using loop. But how can I tell loop to end when a list is empty ?

9:47 snowell: As one of the args to loop, pass the list, then recur with (rest list)

9:47 Once you can't take the first element from it, you're done, and return your value

9:48 roelof: snowell: sorry , I do not fully understand what you mean . just do loop( ?? list)

9:49 snowell: ,(loop [myList [1 2 3] myAnswer 0] (if-let [f (first myList)] (recur (rest myList) f) myAnswer)

9:49 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

9:49 snowell: ,(loop [myList [1 2 3] myAnswer 0] (if-let [f (first myList)] (recur (rest myList) f) myAnswer))

9:49 clojurebot: 3

9:50 snowell: You pass the list into loop, then when you recur you do so with (rest list)

9:50 fehrenbach: ,(do (deftype foo [bar]) (instance? foo (foo. "bar")))

9:50 clojurebot: true

9:50 fehrenbach: troydm: ^

9:52 snowell: roelof: So you keep your max as another loop/recur parameter, and once the list is empty (i.e., the if-let [f (first list)] fails), return it, otherwise recur with (rest list) and logic to pass in the current max

9:54 roelof: snowell: oke, so loop(if-let [f (first list)] ........ recur ( (rest list) max) ??

9:54 oddcully: roelof: i'd go with a reduce here

9:54 snowell: oddcully: That would be more elegant, but roelof specifically asked how to use loop

9:55 So I'm saying it can be done :)

9:55 oddcully: i wanted to push in that direction ;)

9:55 snowell: But now you have me second guessing all my uses of loop/recur in this way :D

9:55 roelof: snowell: I thougt that loop - recur could solve it.

9:55 snowell: roelof: loop/recur absolutely can solve it. oddcully is saying that reduce would solve it even better :)

9:56 roelof: I thought reduce can be used to sum or multiply a complete list

9:57 oddcully: roelof: reduce calls the function for the prev/init value and the next one of the passed list

9:57 * snowell goes back to his code and replaces loop/recur over lists with reduce...

9:57 sveri: I think it is useful to learn how loop / recur works, as this can basically solve anything. From my point of view things like reduce and map are built around the loop / recur thinking

9:58 * roelof hits the clojure programming book to learn more about reduce

10:01 troydm: fehrenbach: ah, ic, thx

10:01 what's the most effective way to get element out of vector?

10:01 nth?

10:01 or is there more vector specific function?

10:02 snowell: By index, nth is the way to go

10:02 roelof: oddcully: oke, now trying to find out how to find the max with reduce without using max Im thinking about something like this reduce %1 > %2 ( 1 2 3)

10:03 luma: you can also use get or just call the vector as a function

10:05 roelof: nope, not working %1 is not known :(

10:06 oddcully: roelof: reduce takes a function there

10:08 roelof: hmm, I thought so but I cannot use max or map-max

10:08 snowell: roelof: So you need a function that takes 2 args and returns the greater value

10:09 roelof: I see it, I found this one at brave book : http://lpaste.net/142133

10:10 I have a idea , I wil experiment with it for the next few hours

10:11 snowell: oddcully: Thanks, you just made the code I was working on today better :D

10:12 I never remember reduce

10:17 roelof: pff , this one gives a unsported binding form : http://lpaste.net/8569532114364530688

10:18 luma: you can't put "(first list)" in the function parameter vector

10:18 snowell: roelof: You're mixing my loop/recur solution in there

10:19 roelof: luma I saw it but only list gives this one: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.PersistentList$1 RT.java:528 clojure.lang.RT.seqFrom RT.java:509 clojure.lang.RT.seq RT.java:654 clojure.lang.RT.first core.clj:55 clojure.core/first C:\Users\rwobb\Downloads\fourclojure\src\fourclojure\core.clj:6 fourclojure.core/eval6248 Comp

10:19 snowell: roelof: Start by writing a function that takes 2 args and returns whichever one is higher

10:20 roelof: snowell: I try to make that

10:20 luma: roelof, the reducing function's parameters are the last returned value, and the next item from the list

10:20 snowell: Then you can (reduce thatFunction someList) and declare victory

10:20 luma: the reducing function doesn't take the complete list as a parameter

10:20 roelof: snowell: oke, so step back you mean

10:20 moment

10:24 * roelof hits the book how to return a variable only nr1 does not work on a line

10:27 SysRq: is it possible for Clojure code to be as fast as java?

10:27 * roelof wonders whta is wrong here : http://lpaste.net/9091953704113799168

10:28 Bronsa: roelof: the compare function should return an integer

10:28 SysRq: http://pastebin.com/SAic7pkS

10:28 Bronsa: roelof: also you have some wrong wrapping there, (fn [x y]) .. instead of (fn [x y] ..)

10:29 SysRq: the json parse library cheshire is about 4 times faster in parsing json than clojure is at doing a simple check for every character

10:29 looking at the implementation I see it uses some java library https://github.com/dakrone/cheshire/blob/master/src/cheshire/core.clj#L142

10:29 roelof: Bronsa: yep, I see it , back to the ( hell :(

10:29 SysRq: does that mean if you really want something to be fast you need to do it in java?

10:31 pbx: SysRq, this is heading toward pointlessness. do you have a use case you need to optimize? otherwise this is like "does rails scale better than django" et al

10:31 Bronsa: roelof: wrong wrapping should be evident by indentation

10:32 SysRq: you're timing different operations

10:32 SysRq: I want to write a custom parser for a serialization format that's more compact than JSON, only to find out the custom parser is very slow

10:32 so I might as well end up using the more verbose JSON with a faster parser

10:32 Bronsa: SysRq: the reduce version is also wrong

10:33 SysRq: how so?

10:33 oddcully: SysRq: (= ...) in line 12?

10:33 Bronsa: look at the if

10:33 SysRq: oh yeah

10:34 roelof: Bronsa: I tried that one. I have now this : http://lpaste.net/142134 and this error : clojure.lang.Compiler$CompilerException: clojure.lang.ArityException: Wrong number of args (1) passed to: core/compare--inliner--4233, compiling:(C:\Users\rwobb\Downloads\fourclojure\src\fourclojure\core.clj:5:1)

10:34 Bronsa: roelof: you're not passing any argument to compare

10:34 roelof: clojure is more difficult then I thought. This one has costed me the whole afternoon

10:34 Bronsa: also that's really not how you indent clojure

10:34 snowell: roelof: Are you trying to define a new function called compare? If so you want (defn compare [number1 number2] …)

10:35 Bronsa: roelof: I'd suggest picking a book or a guide to understand the basics of clojure syntax before trying to write code

10:35 SysRq: the fixed version takes 2 times longer

10:35 roelof: Bronsa: Im reading now the clojure programming book and read the first 2 chapters

10:36 SysRq: so conclusion: really low level stuff with high performance requirements is better implemented directly in java?

10:37 roelof: snowell: that did the trick

10:37 snowell: Now in practise, you shouldn't overwrite compare. I'd have called it my-max or something

10:38 Bronsa: roelof: I'd suggest staring over and making sure you understood everything before moving to the next chapter. It's very obvious you don't really understand what you're doing yet

10:38 snowell: But once you have my-max, you can (reduce my-max someList) to get the max of that list

10:38 oddcully: roelof: compare is a clojure.core function. it takes two arguments (doc compare). your first version compared an basically empty function with min or nr1/2

10:38 roelof: I notices also. So more practice in this sort things

10:38 oddcully: roelof: your second attempt just passed down one argument (the anon fn with more body this time) and so your got the arity error

10:39 Bronsa: SysRq: your benchmarks are pointless. you are comparing different operations

10:39 SysRq: I'm comparing a full parse to a more primitive check

10:39 Bronsa: `time` is also no good for microbenchmarks like this one

10:39 SysRq: you don't know what json-parser/parse-string does

10:40 SysRq: by all means the primitive check should've been faster

10:42 roelof: oke, this one works : http://lpaste.net/142137

10:43 Bronsa: I can read a lot but I learn the best by doing it. My problem of live is that I can read a lot of books but doing it is then the biggest problem

10:44 SysRq: what do you mean with that Bronsa ?

10:44 roelof: your experts happy with the solution or can it be improved ?

10:44 SysRq: that I don't know what it does or how it accomplishes what it does?

10:45 Bronsa: SysRq: what it does internally and whether it actually does anything at all

10:45 SysRq: I know it does something because it returns a Clojure EDN datastructure that I can traverse

10:45 vectors for json arrays, maps for json objects

10:46 also I know it's not due to laziness because I force it to be parsed completely

10:46 it must've parsed the actual string, or is there any other explanation?

10:49 there might be caching involved because when I time it on a fresh REPL it takes 6 times longer..

10:50 Bronsa: as I said, unless you make sure you're benchmarking the same stuff those measurements are useless.

10:50 time is also completely unreliable, you should use criterium to get meaningless benchmarks

10:51 and if you still find out that the reduce version is slower than whatever json library method (and I doubt it), there are ways to make the clojure code faster

10:54 xemdetia: "you should use criterium to get meaningless benchmarks" <-- is this a feature :)

10:54 Bronsa: err, meaningful*

10:54 :)

10:56 * roelof call it a day. Thanks all for the lessons and patience with me

10:59 Bronsa: SysRq: for example, if you're using clojure >=1.7, this will be much faster (into [] (filter (fn [ch] (= ^char ch \space))) (:body json-qry)))

11:02 SysRq: that is indeed significantly faster

11:07 BobSchack: Bronsa: Is there a good Clojure profiling tool or should I look at the Java based ones?

11:07 Bronsa: BobSchack: criterium is a good clojure lib for benchmarks (https://github.com/hugoduncan/criterium), as far as profiling goes any jvm profiler will do

11:08 I've been using YourKit for a while for my OSS projects

11:09 BobSchack: Are there good docs for hooking up yourkit to a running JVM process?

11:17 justin_smith: BobSchack: with visualvm it shows a list of processes you can double click to connect to, I would be surprised if yourkit did not offer that feature

11:18 SysRq: why is (into [] (filter ...)) faster than (filter ...) ?

11:19 Bronsa: SysRq: http://clojure.org/transducers

11:19 it's a quite advanced new abstraction introduced in 1.7

11:19 justin_smith: BobSchack: the hilarious thing, I was working on a tool that connects to the debug port on a running vm, and wanted that "list vms to connect to feature" so I looked at the visualvm source to see how they did it - they literally knock on every port on your box, trying to connect as if it was a jvm debug port, then it returns the ones that answered nicely, LOL

11:20 Bronsa: SysRq: you don't really need to use/know transducers for your usecase to get the same performance, you can do with plain reduce+transients

11:20 using into + a transducers automatically uses transients internally, that's the only reason I did it that way

11:22 BobSchack: justin_smith: Wow I thought it would be a bit more sophisticated then that.

11:23 Bronsa: justin_smith: yeah it does

11:24 BobSchack: there's plently of docs on how to profile jvm apps on the internet

11:24 everything that works for profiling java applications also applies for clojure

11:32 fuuduCoder: our team uses visualvm a lot.

11:33 to profile our clojure applications.

11:34 justin_smith: the one thing with profiling heap usage with clojure, is I often wish I had more direct access to which specific parts of the code were creating / using this heap, and the fact that it's all arrays inside persistenthashmaps and persistentvectors doesn't really provide any info. It's made me want to switch more things to records just for the extra profiling info sometimes.

11:35 or maybe there's a secret sauce to figuring out which blocks of code are doing the allocating that I just don't know about yet

11:35 SysRq: is there a way to make this faster http://pastebin.com/hmtVfTrm

11:36 Bronsa: justin_smith: yeah I have the same issue

11:36 SysRq: (case ^char ch (\newline \tab \space \return) true false) might be faster

11:37 justin_smith: SysRq: I would think a whitespace regex would be faster

11:37 Bronsa: or that

11:37 it kind of sucks that clojure functions can't pass around unboxed chars

11:37 justin_smith: yeah, the case would definitely be faster than the set operation - I wonder how it would compare to the regex though

11:38 oh you need to create a string for the regex though...

11:38 or not isolate the char in the first place

11:39 SysRq: ^char means to have java interpret the value as a character so it doesn't get boxed right?

11:39 it's a character anyway

11:39 Bronsa: no

11:39 justin_smith: SysRq: it prevents reflection, but not boxing

11:39 Bronsa: it unboxes the char out of a Character

11:39 and does primitive ops

11:39 if possible

11:40 boxing/unboxing always happens with chars unfortunately

11:41 oddcully: no clue on the performance, but there is alos Character/isWhitespace

11:42 justin_smith: oddcully: that's another one to compare for sure

11:44 oddcully: a hair faster than Bronsa 's version, according to criterium.core/quick-bench

11:45 and the regex match is slower than the set lookup

11:45 (!)

12:29 noncom: where can i specify jvm-opts for a lein plugin in project.clj?

12:29 justin_smith: :jvm-opts should do it? or is this a plugin that gets its own jvm?

12:30 noncom: yes, jvm-opts. you mean that the global jvm-opts for the project.clj will affect, say, "lein figwheel" ?

12:31 justin_smith: hmm, I think? you may need to set the jvm-opts for the figwheel profile? but it should.

12:32 noncom: okay, i'll try that

12:34 roelof: what is wrong here : (reduce (fn [number1 number2] (if (< number1 number2) number2 number1)) list)

12:35 noncom: roelof: does not seem wrong. why?

12:36 ,(reduce (fn [number1 number2] (if (< number1 number2) number2 number1)) [1 -2 -3 4 -5])

12:36 clojurebot: 4

12:36 noncom: isn't this what you want?

12:39 roelof: noncom : wierd, when I do (reduce (fn [number1 number2] (if (< number1 number2) number2 number1)) list) I see this error message : java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.PersistentList$1

12:39 or is my error that I have to put it into a function ?

12:40 noncom: roelof: umm

12:40 ,list

12:40 clojurebot: #object[clojure.lang.PersistentList$Primordial 0x323fcc03 "clojure.lang.PersistentList$Primordial@323fcc03"]

12:40 noncom: ,(reduce (fn [number1 number2] (if (< number1 number2) number2 number1)) list)

12:40 clojurebot: #error {\n :cause "Don't know how to create ISeq from: clojure.lang.PersistentList$Primordial"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.PersistentList$Primordial"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.core$seq__...

12:40 noncom: your problem is that you're passing it the function "list"

12:40 instad of something sequable

12:41 ,(reduce (fn [number1 number2] (if (< number1 number2) number2 number1)) +)

12:41 clojurebot: #error {\n :cause "Don't know how to create ISeq from: clojure.core$_PLUS_"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.core$_PLUS_"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.core$seq__4116 invokeStatic "core.clj" 137]\n [...

12:41 noncom: see

12:41 you can redefine "list" but it is likely that you didn't

12:41 roelof: oke, I mean the variable list instead of a function. I try to solve this one : https://www.4clojure.com/problem/38

12:42 noncom: in your case 'list refers to the function from clojure.core

12:42 ,list

12:42 clojurebot: #object[clojure.lang.PersistentList$Primordial 0x323fcc03 "clojure.lang.PersistentList$Primordial@323fcc03"]

12:42 noncom: ,(def list [1 2 3 4 ])

12:42 clojurebot: #error {\n :cause "denied"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojureb...

12:42 noncom: oh

12:42 roelof: oke, how can I solve this ?

12:43 noncom: well, it says that you have to "write a function". you did not yet write it

12:43 (reduce ..) is a call to reduce

12:43 a function would be (fn [... )

12:44 roelof: I know

12:44 BRB, dinner is ready

12:44 noncom: so if you write (fn [list] (reduce ...) it will likely work

12:45 oddcully: [& list] ?

12:45 noncom: maybe. idk. i never went through 4clojure :(

12:45 Bronsa: roelof: btw that's just (reduce max your-list)

12:46 oddcully: Bronsa: max is not allowed for this

12:47 Bronsa: ah ok

12:48 dzhus`: I've just enabled log4j using clj-logging-config.log4j for my code and now it produces lots of debugging output to the console: http://dpaste.com/0H61T2A.txt. Does anybody know how to switch these off?

12:57 rlb`: Is there a way I can set up a lein fixture that wraps the entire test run? i.e. to start up a DB at the beginning and tear it down at the end of *all* of the tests in the current "lein test" run?

12:57 across all the namspaces, etc.

13:11 roelof: noncom: for as far I know reduce works like this ( reduce function list) , This is right ?

13:12 oddcully: roelof: yes

13:12 noncom: roelof: (reduce f acc seq)

13:12 acc is optional

13:12 roelof: can list then not be a variable ?

13:12 noncom: but in generall, as oddcully says, this is right

13:12 roelof: it can, but you have to define it first

13:12 oddcully: roelof: list can be a variable, but first of all its a core function

13:13 noncom: by default "list" is defined to the core function "list"

13:13 ,(list 1 2 3)

13:13 oddcully: roelof: you are shadowing it by having your own

13:13 clojurebot: (1 2 3)

13:13 roelof: oke, when I change list to lijst which is not in core. I see that the symbol lijst is not found

13:13 noncom: true

13:14 roelof: so how can I do (reduce function x) where x is a variable ?

13:14 oddcully: roelof: the _ in that function takes all that numbers as params. so you have to deal with this

13:15 roelof: oddcully: where does the _ come from ?

13:16 oddcully: roelof: the _ from the 4clojure problem

13:16 roelof: I know. that is what I try to find. This afternoon we have made a version with a helper function but def is also not allowed on 4clojure

13:17 so I try to find a way to work around it

13:18 oddcully: you got the reduce part already right. now you have to turn it into a function itself, that takes any amount of params

13:18 noncom: roelof: 4clojure expects that your function be placed instead of the _

13:18 (_ 1 2 3) => (your-fn 1 2 3)

13:19 roelof: soooo, ((fn *magic*) 1 2 3) is what required from you..

13:20 roelof: oke, that is this part : (fn [number1 number2] (if (< number1 number2) number2 number1))

13:20 noncom: roelof: nope

13:20 roelof: :(

13:21 noncom: as oddcully said, you got it correctly with reduce

13:21 oddcully: this is the function you pass down to reduce. everything about the reduce is already right

13:21 noncom: now you only have to wrap your reduce form into a fn

13:21 thsig_: Hey guys, this question is a bit general, but here goes: How would you rate the maturity of the library/tooling ecosystem for web development in Clojure as of now?

13:21 roelof: oke, back to the books (clojure progremming how to do so

13:22 thsig_: Are there significant bald spots in comparison with e.g. Python or Ruby, or is it quite robust these days?

13:22 noncom: thsig_: robust, very. and continues to be even better

13:22 thsig_: Do you often wish you had a library that solved your problem where you'd be able to easily find a library in Python or Ruby?

13:22 noncom: thsig_: never

13:22 thsig_: noncom: That's the feeling I get.

13:23 noncom: we have all the java libs and all js libs at our disposal

13:23 and all clojure libs and all cljs libs

13:23 thsig_: I'm about to start a new project and am pushing hard for Clojure as it would be a perfect fit (concurrency and efficient use of severs are a big plus).

13:23 noncom: roelof: hey, that's not what hard

13:23 sveri: thsig_ I have been doing REST for the last two weeks in java with jersey and jax-rs. Men, I really wish I could use clojure I would be don already, compared to java where I am not even half way through. I say this coding Java every day at my job

13:24 thsig_: sveri: Yeah, I can imagine.

13:24 noncom: roelof: just wrap what you showed us into an (fn) form!

13:24 roelof: you have to make a callable function out of your code

13:24 thsig_: Are people still mostly using a minimalist base (Ring, and then cherry-picking libraries together)?

13:25 noncom: thsig_: well, i use luminus as a base, but there are more solid things like pedestal or hoplon

13:25 sveri: thsig_ I put my own template together providing component integration and a basic user management out of the box, but in the end it's all put together from small libs

13:25 thsig_: I'd be interested in any relatively up-to-date links that cover what the industry-standard libraries are that are used in almost all web projects.

13:26 (I've been Googling, of course - just thought I'd ask directly as well)

13:26 noncom: thsig_: try looking at what libs are mentioned in luminus docs

13:26 (for starters)

13:26 sveri: thsig_ https://github.com/sveri/closp it's based on luminus, but currently, when you create a new template, you have to fix one namespace. However, I also integrated transit for cljs workflow and cljs-ajax for instance

13:27 thsig_: noncom, sveri: Ah, I remember that one. Was poking around with it the other day.

13:28 noncom: sveri: luminus now has transit and cljs-ajax integrated too :)

13:28 sveri: thsig_ its comprehensive, but this is what I came out with after over a year figuring out which libs to use

13:28 thsig_: Thanks! I'll look through this.

13:28 noncom: thsig_: take a look at hoplon and pedestal too

13:28 sveri: noncom nice to hear, I also read lately that he thinks about integrating components too

13:28 thsig_: I've been aware of those too, but wasn't sure how much adoption they had.

13:29 I know the Cognitect guys are using Pedestal in production.

13:29 noncom: i'd start my current project in hoplon if i had some previous exp with it, but i had to start quick so i chose luminus since i'm pretty familiar with its stack. and it sets up figwheel for you too

13:30 yazirian: We're using Pedestal in production here too and are pretty big fans of it.

13:30 sveri: noncom closp has figwheel support too ;-) and all compiles to an uberjar with advanced compilation ;-)

13:30 noncom: sveri: then you've got the spot i'm still missing

13:30 sveri: yazirian did you evaluate against compojure / ring? What are the pros in your opinion?

13:30 noncom: when i uberjar my app, it does not work :/

13:30 thsig_: I don't think we'll be using Clojurescript for this project as the frontend will be mostly native mobile. I'd love to, though.

13:31 yarizan: I'd be interested in your answer as well.

13:31 yazirian: sveri: I just completed migrating a medium sized microservice from compojure to pedestal, specifically because it's better.

13:31 noncom: thsig_: you can use clojure for native mobile (if its not c++ ofc)

13:31 thsig_: ... yazirian, sorry :)

13:31 yazirian: The primary drivers are:

13:31 noncom: pedestal is nextgen comparing to compojure

13:31 thsig_: noncom: iOS and Android is the plan.

13:31 yazirian: 1. interceptors are sweet, not that middleware doesn't cover the 90/10 case but interceptors are very flexible

13:31 noncom: thsig_: yes, you can do it clojure

13:32 yazirian: 2. pedestal's route definitions are both more easy to work with and more 'correct' and strict in disallowing things that compojure can 'accidentally allow' such as non-unique routes with bound vars in the pth

13:32 path*

13:32 3. compojure's macros, just holy... have you looked at them closely? they're in cronenberg territory :)

13:33 related: it's really easy on a team developing over a period of time to end up with scattered route definitions that are difficult to piece together once you have a lot of endpoints, pedestal has a defined best practice that keeps the full URL structure together

13:33 rhg135: I use bidi

13:33 noncom: sveri: so, closp is a template, originally based on luminus, but currently improved?

13:33 yazirian: that CAN result in a really big defroutes structure

13:33 sveri: yazirian 3. striked me too from time to time and I never really liked them

13:33 thsig_: noncom: I've seen a few libraries around Obj C and Android development, but do you know of anyone who's using those in production? I seem to recall there being performance problems with this method on Android, but that info may be out of date.

13:34 yazirian: but the tradeoff is worth it IMO

13:34 noncom: thsig_: there's actually a bunch of apps made with clojure in android play market

13:34 thsig_: yazirian: How lightweight/heavyweight is it with respect to resource consumption etc. in comparison to the smaller frameworks?

13:34 noncom: thsig_: iOS part is done with help of robovm.

13:35 thsig_: maybe you could find it worth researching or maybe not, but they are there

13:35 yazirian: With the caveat that we've had no need to look closely since we're running on normal EC2 instances and not in teeny environments or anything, it's totally fine

13:35 0.4.x in particular included new work to speed up routing as well

13:36 it's ring under the hood anyway

13:36 noncom: thsig_: theres also #clojure-android

13:36 thsig_: noncom: Interesting. Definitely sounds tempting to write the thing in Clojure. I'd have to find some direct experience reports on it first.

13:36 sveri: noncom Yea, that was the idea behind. Little things like restarting the server when I change my routes (solved by integrating components, so I can just call the reset function and "restart" in like 0.5s instead of 20)

13:36 thsig_: noncom: Ah, cool! I'll ask around there.

13:36 yazirian: Sounds good!

13:37 noncom: thsig_: https://github.com/oakes/lein-fruit - so this is made by zach oakes too. zach has much experience with android clojure and probably iOS clojure since he's rolling out lein-fruit. you could pm/mail him

13:38 thsig_: maybe you won't find many reports right away (although i remember there were some in the net)

13:39 sveri: that's very interesting

13:39 roelof: sorry for the late respons. Daugther needs attention. So I have to put the whole part (reduce (fn [number1 number2] (if (< number1 number2) number2 number1) into a fn ?

13:39 sveri: noncom I spent a lot of time optimizing development experience, I find it a pain to have to wait during restarts and things

13:39 noncom: roelof: sure! you have to make a callable function out of your piece of code, just as any other language

13:40 oddcully: roelof: yes, you have to turn it into a function that takes any amount of params

13:40 noncom: ... and passes it into your reduce thing

13:40 as the list

13:40 yazirian: Actually that is one thing to be aware of with pedestal, if you want i.e. cider recompiles to take notice of changes to your handlers you have to define your service with ::bootstrap/routes #(deref #'routes)

13:40 notice the deref there

13:40 and recompile the ns with the defroutes macro in it

13:40 noncom: sveri: true :/

13:40 yazirian: if you take those steps though it works fine

13:42 roelof: ??? now im confused . I think that noncom and oddcully says something different

13:42 oddcully: no we are saying the same

13:43 noncom: yes

13:43 same

13:43 listen, you wrap your piece of code into a fn that accepts arg(s) and just use these args in your piece of code

13:43 rather basic thing..

13:43 i'm sure you know that

13:43 same as in C or Java

13:45 roelof: oke , so (fn [(number1, number2] (if (< number1 number2) number2 number1) ) ??

13:45 noncom: roelof: nooooope :)

13:45 eh

13:45 ok

13:45 clojurebot: Huh?

13:46 noncom: (fn [lst] (your-code lst)) makes sense? :)

13:46 why you replace reduce with fn? you should not

13:46 reduce is there for a reason

13:47 (some code x) -> wrap into fn -> (fn [x] (some code x))

13:47 this way you shadow x

13:47 and "shadow x" sounds cool

13:48 roelof: oke, this will have no errors : (fn[list] (reduce (fn [number1 number2] (if (< number1 number2) number2 number1)) list))

13:48 thsig_: yazirian: Would you generally recommend Pedestal for new projects? This won't be a huge architecture, but it will need to handle lots of requests, connect to several databases, pass along lots of file IO etc.

13:48 noncom: roelof: is that clear to you now?

13:48 thsig_: Or is your recommendation more specific for certain shapes of project?

13:48 roelof: yes, now I see it , it is clear

13:49 noncom: good :)

13:50 roelof: and because fn creates a function object, and you place it in the first position of the list, it automatically turns into the function to accept the list

13:50 roelof: but remember, as oddcully said, you must have a varargs fn in this current occasion

13:50 roelof: pfff, I did enter this into 4clojure : (fn[list] (reduce (fn [number1 number2] (if (< number1 number2) number2 number1)) list)) and see this error : clojure.lang.ArityException: Wrong number of args (4) passed to: sandbox4852$eval522084$fn

13:50 noncom: exactly

13:50 read above ^

13:51 roelof: oke, the book was talking about varargs

13:51 noncom: (f [1 2 3]) and (f 1 2 3) - the first one takes 1 arg. the second one takes 3 args OR varags

13:51 yazirian: thsig_: I would use it myself, so I guess "yes" :)

13:53 roelof: solved it , finnaly with (fn[ & list] (reduce (fn [number1 number2] (if (< number1 number2) number2 number1)) list))

13:53 sveri: yazirian how about authentication / authorization, what are you using and are there docs on it?

13:53 noncom: roelof: congratulations! :)

13:54 roelof: it took me thw whole day but learned a lot

13:54 noncom: roelof: yeah, that's really useful. soon you will know and understand it all.

13:56 roelof: noncom: I hope so, I try to follow the clojure programming book with 4 clojure

13:57 so im still busy the next few weeks

13:57 noncom: roelof: i'm sure as you go through this, the speed will increase

13:58 i wish there was a clojure version of scheme bricks....

13:59 roelof: I think so, I now have seen how things are done so 4 clojure accepts it

14:01 yazirian: sveri: I can't answer that, we aren't using anything at that layer -- we have a whole proxy auth service and load balancing layer above it that's separate

14:09 roelof: last question before I call it a day : I have this problem : (= (__ (map inc (take 3 (drop 2 [2 5 4 1 3 6])))) (->> [2 5 4 1 3 6] (drop 2) (take 3) (map inc) (__)) 11)

14:10 noncom: ok, what's with it?

14:10 roelof: according to me the solution is '(5 2 4 ) but when I enter it into 4clojure I see this messsage : java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn

14:11 noncom: roelof: yes

14:11 because a list is not a function

14:11 ,((list 1 2) 1 2)

14:11 clojurebot: #error {\n :cause "clojure.lang.PersistentList cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentList cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler ...

14:11 roelof: correct , that is why I put a ' before it ,

14:12 noncom: roelof: that does not change much

14:12 roelof: '( 1 2 3 )

14:12 noncom: ,(type '(1 2 3))

14:12 clojurebot: clojure.lang.PersistentList

14:12 roelof: , '( 1 2 3 )

14:12 clojurebot: (1 2 3)

14:12 noncom: it did not became a fn

14:12 roelof: oke, the same probllem as before

14:12 noncom: no

14:13 well, somewhat alike

14:13 but different

14:13 roelof: :(

14:13 noncom: let's follow

14:13 (->> [2 5 4 1 3 6] (drop 2) (take 3) (map inc) (__))

14:13 becomes:

14:13 [4 1 3 6]

14:13 [4 1 3]

14:13 [5 2 4]

14:14 and then something happens that it becomes 11

14:14 roelof: yes, I figured that out

14:14 noncom: (+ 5 2 4)

14:14 clojurebot: *suffusion of yellow*

14:14 noncom: ,(+ 5 2 4)

14:14 clojurebot: 11

14:14 roelof: oke, I missed that part. So it had to add up

14:14 noncom: yes, but here's again arg/vararg thing

14:15 roelof: so (reduce + ( 5 2 4)

14:15 noncom: ,(reduce = [5 2 4])

14:15 clojurebot: false

14:15 noncom: ,(reduce + [5 2 4])

14:15 clojurebot: 11

14:15 noncom: yep :)

14:16 roelof: fyo, (apply + [5 2 4]) would also work, ut idk if this is allowed in this 4clojure task

14:16 snowell: ,(apply + [5 2 4]) ; This totally works too

14:16 clojurebot: 11

14:16 snowell: grrrr

14:16 noncom: :D

14:16 but it was simultaneous :D

14:16 snowell: I was debating whether or not to say it

14:17 noncom: for 2 seconds :)

14:17 roelof: (apply + [5 2 4]) gives this error message : java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

14:18 oddcully: roelof: if you enter it like that, then it will result in 11, and next will be called as a function

14:19 roelof: ???

14:19 oddcully: ,((apply + [1 2 3]) 42)

14:19 clojurebot: #error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval283 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval283 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval283 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 69...

14:19 noncom: yes, like:

14:20 ,(11 42)

14:20 clojurebot: #error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval307 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval307 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval307 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 69...

14:20 noncom: 11 is not a function

14:20 roelof: nope, it a value

14:20 snowell: Not with that attitude it's not

14:20 roelof: snowell: ?

14:21 what attirude ?

14:21 snowell: Just me trying to be funny :)

14:21 noncom: it could be a function with some other attitude :)

14:21 snowell: Implying that 11 could be a function if you tried hard enough

14:21 noncom: ,(symbol 11)

14:21 clojurebot: #error {\n :cause "java.lang.Long cannot be cast to java.lang.String"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to java.lang.String"\n :at [clojure.core$symbol invokeStatic "core.clj" 555]}]\n :trace\n [[clojure.core$symbol invokeStatic "core.clj" 555]\n [clojure.core$symbol invoke "core.clj" -1]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]...

14:22 noncom: ,(symbol "11")

14:22 clojurebot: 11

14:22 noncom: could be a start for a nice macro!

14:22 ,11

14:22 clojurebot: 11

14:22 noncom: ,(type 11)

14:22 clojurebot: java.lang.Long

14:22 roelof: but what has this to do with my problem ?

14:23 noncom: roelof: nothing related to your problem, except that in this particular case 11 is strictly not a function

14:23 we're just making some fun out of math flexibility :)

14:24 roelof: oke, can then someone help me how to fix this ?

14:24 noncom: roelof: fix the thing with apply?

14:25 ,(->> [2 5 4 1 3 6] (drop 2) (take 3) (map inc) (apply +))

14:25 clojurebot: 11

14:25 noncom: ,(->> [2 5 4 1 3 6] (drop 2) (take 3) (map inc) (reduce +))

14:25 clojurebot: 11

14:29 justin_smith: apply + is basically reduce + anyway if you look at the source of +

14:31 roelof: very confusing what 4clojure expecting apply + without a argument

14:33 noncom: roelof: how you say so? there is the argument

14:33 roelof: ->> ensures that what was computed before is the 2nd argment for the apply

14:33 and in the left part, the.. umm.. argumentation is explici

14:33 t

14:34 roelof: oke, so the outcome of drop take is passed on to the apply function. Time to read the chapter about macros I think

14:34 noncom: so in the right part you get (apply + [what-was-computed-before])

14:35 roelof: ->> is a very simple macro that places each result to the LAST position in the next form, evaluates it, and goes on like that until the end

14:35 roelof: noncom: thanks

14:35 noncom: roelof: it effectively unwraps the whole thing into what this task has on the left side

14:35 np

14:39 roelof: All thanks for the lessons and patience with me and have a nice day

14:39 noncom: roelof: you too!

14:42 juanjo: hi there

14:42 i'm learning clojure

14:42 i'm getting this error when trying to use the 'is' function

14:42 user=> (is 1 2)

14:42 CompilerException java.lang.RuntimeException: Unable to resolve symbol: is in this context, compiling:(NO_SOURCE_PATH:1:1)

14:44 justin_smith: juanjo: is is from clojure.test

14:44 fuuduCoder: ,(is 1 2)

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

14:44 justin_smith: juanjo: fuuduCoder: you need to use or require / refer clojure.test or is will not work

14:44 juanjo: how do i do that?

14:45 justin_smith: ,(use 'clojure.test)

14:45 clojurebot: nil

14:45 justin_smith: ,(is 1 2)

14:45 clojurebot: 1

14:45 fuuduCoder: NO_SOURCE_PATH:0:0) this should be your hint

14:45 justin_smith: also, that's the wrong way to call is

14:45 ,(is true false)

14:45 clojurebot: true

14:45 justin_smith: ,(is (= true false))

14:45 clojurebot: false

14:45 justin_smith: that's the right way ^

14:46 juanjo: ok justin_smith

14:46 thanks

15:10 sveri: yazirian ok, thank you

16:43 rasmusto: should I include my clojure (ring) and clojurescript in the same project? The ring stuff should be generic enough that it's not 1:1 coupled with the UI

16:43 this is mostly just a style question

17:25 akkad: should you?

17:35 irctc: Hi everyone.

17:36 Has anyone had experience with OAuth?

17:37 I am trying to pull a list of user's friends from Goodreads and it requires OAuth but I have no idea how to configure it as I am completely new to it.

17:37 rhg135: not positive ones

17:38 rippy:

17:38 rhg135: I used python though

17:39 irctc: I found this question/answer and am trying to use the answer as a template to configure my OAuth access to Goodreads but I can't seem to get anything back from Goodreads: http://stackoverflow.com/questions/32107730/oauth1-in-clojure

17:41 rhg135: in my experiance, OAuth us about as standaraized as "rest"

17:42 irctc: Btw, I don't even know if I can get the list of friends back to my application at localhost.

17:42 I mean will OAuth even work with localhost?

17:42 rhg135: or "the cloud"

17:43 I thin so

17:44 irctc: Well I put everything in my application from that answer and replaced the key with my key and the secret with my secret from Goodreads and tried to put in the address to get the info back but it does nothing.

17:44 rhg135: How else do desktop apps work?

17:45 unless you host a server

17:45 irctc: Well that's why I was still hoping that it will work, so it seems that I just don't know how to configure this OAuth access then.

17:46 {blake}: Is Java in the browser still a thing? I've never heard a Clojure guy talk about it. And I keep hearing it's going to be killed. But it seems like it could be really useful.

17:46 luma: it hasn't been a thing for years

17:46 rhg135: It's also really insecure

17:47 {blake}: Bummer. I could get a lot of mileage out of it if it were a thing.

17:47 rhg135: without a whitelist

17:48 Imagine, java based popups

17:49 irctc: I'm off to bed. Take care everyone.

17:49 rhg135: peace

17:50 {blake}: Well, I'm using POI. Having that in the browser would be amazing. If it worked.

17:52 rhg135: for every 100 good users there is one abuser

17:57 at least on linux writing to /dev/mem is forbidden, unless the kernel is buggy, or you run your browser as root

17:59 `File("/home/user/important").remove()

18:19 {blake}: rhg135: You say that like it's a bad thing.

18:19 Heh. No, I'd do all the disk stuff as server calls, but the calculations being done in browser would be cool.

18:21 rhg135: It's a good idea, but someone always ruins it

18:21 {blake}: Right? This is why we can't have nice things.

18:21 And also why we get ants.

18:21 rhg135: yup

18:22 luma: could we just get leiningens instead of ants

20:57 triss: is there a nicer way of saying #(%2 %1)?

20:57 rhg135: I don't think so

20:58 triss: as in apply second arg to first? I'm forever (condp #(%2 %1)....)'ing

20:58 is there not a built in fn for this?

20:58 ah okies rhg135

20:59 rhg135: luckily #() is so nice

20:59 triss: i guess multimethods + dispatch or something.

21:00 rhg135 i think they're kinda ugly

21:00 pull out partial/comp all over the place

21:01 which can be kinda ugly too...

21:02 rhg135: (fn ...) is worse imo

22:43 triss: ,(apply list [1 2 3])

22:43 clojurebot: (1 2 3)

22:43 triss: ,(apply list nil)

22:43 clojurebot: ()

22:44 triss: ,(apply list 1)

22:44 clojurebot: #error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.core$seq__4116 invokeStatic "core.clj" 137]\n [clojure.co...

22:44 triss: ,(list 1)

22:44 clojurebot: (1)

22:44 triss: Why the whopping great error message when I apply list with 1 argument?

22:45 hiredman: ,(doc apply)

22:45 clojurebot: "([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."

22:46 triss: ok...

22:47 amalloy: triss: because 1 isn't a sequence

22:47 triss: ,(apply list 1 nil)

22:47 clojurebot: (1)

22:47 amalloy: and apply takes a sequence of args

22:47 ,(apply list '(1))

22:47 clojurebot: (1)

22:47 triss: so i can (map #(apply list % nil) boom)!!!!!

22:48 hiredman: you don't need apply

22:48 triss: i do today

22:48 hiredman: (map list boom)

22:49 if you always have the same number of arguments you don't need apply

22:49 triss: 1 sec. I want to treat everything in a list of collections and values as a list of seqs

22:50 hiredman: (although, with a large number of fixed arguments it can be less of a pain to use apply)

22:50 triss: idea is to go (1 (2 3) 4) -> ((1) (2) (3) (4))

22:51 hiredman: you don't need apply, you need if

22:51 triss: well -> 1 2 3 4 eventually

22:51 hiredman: (if (coll? x) x (list x))

22:55 rhg135: ,(mapcat #(if (coll? %) % [%]) '(1 (2 3) 4))

22:55 clojurebot: (1 2 3 4)

23:22 tehgeekmeister: is there a way to set environment variables for projects you run in cider mode?

23:37 justin_smith: tehgeekmeister: I'm not sure if there is a config, but there is M-x setenv for setting the emacs env, C-u M-x cider to specify a command, followed by using env VAR=VALUE lein repl as the command, and finally you can start a lein repl in a terminal, then use M-x cider-connect to connect to the port it opens

23:37 tehgeekmeister: whooo! options.

23:37 I figured out the M-x setenv thing

23:37 but those others are news

23:37 thanks!

23:37 justin_smith: np

Logging service provided by n01se.net