#clojure log - Jun 14 2014

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

0:07 umpa: Why does this work ?

0:08 ,(map #(set/intersection #{1 2 3} %) (map set (partition 3 (range 10))))

0:08 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>

0:09 umpa: and this doesnt ?

0:10 (#(set/intersection #{1 2 3} %) (map set (partition 3 (range 10))) and this doesnt?

0:11 ,(:require [clojure.set :as set]))

0:11 clojurebot: #<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>

0:12 catern: because (#(set/intersection #{1 2 3} %) thing) is equivalent to (set/intersection #{1 2 3} thing)

0:12 muhuk: umpa: what does map do?

0:13 umpa: (doc map)

0:13 clojurebot: "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."

0:13 muhuk: umpa: I know what map does.

0:13 umpa: what's the difference between (f [a b c]) and (map f [a b c]) ?

0:14 dbasch: muhuk: if you’re asking that question, you don’t know what map does :P

0:14 umpa: mhuk: f is short for function I assume ?

0:15 catern: umpa: do you see why this doesn't work:

0:15 ,(set/intersection #{1 2 3} (map set (partition 3 (range 10))))

0:15 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>

0:15 catern: ,(clojure.set/intersection #{1 2 3} (map set (partition 3 (range 10))))

0:15 clojurebot: #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>

0:15 catern: er

0:15 anyway

0:16 dbasch: umpa: long story short, you’re trying to intersect a set with a sequence of sets

0:18 muhuk: dbasch: I'm asking the question to make umpa think about his problem, to help him debug.

0:19 umpa: I understand what its doing conceptually but not logically

0:20 johnwalker: what is defcurried in core reducers?

0:21 catern: umpa: er, what's the difference between those ways of understanding?

0:21 johnwalker: oh nevermind, i see what its doing

0:22 muhuk: umpa: try stepping through the code in your head maybe

0:22 umpa: how many calls are made to f with and without map?

0:25 dbasch: muhuk: gotcha :P

0:25 umpa: muhuk: i am not sure of the question but think that map is called 2 times

0:27 muhuk: umpa: practise your LISP-fu, you need

0:28 umpa: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/

0:29 umpa: muhuk: so as far as I gather (map set (partition 3 (range 10)) is acting as a variable for the first map and for intersection

0:30 johnwalker: oh please

0:31 thats like the worst course you could ever suggest as an introduction

0:32 umpa: magic

0:32 johnwalker: umpa: the idea is that (map f [1 2 3 4 5]) is like [(f 1) (f 2) (f 3) (f 4) (f 5)]

0:32 f is a function, you're right about that

0:33 map returns a sequence of f called on each element in the second argument

0:34 umpa: so f is called twice in this case

0:34 johnwalker: which case are you referring to?

0:35 ,(partition 3 (range 10))

0:35 clojurebot: ((0 1 2) (3 4 5) (6 7 8))

0:35 johnwalker: ?

0:35 umpa: (map #(set/intersection #{1 2 3} %) (map set (partition 3 (range 10))))

0:35 johnwalker: which two things is f being called on?

0:36 there are two maps in there

0:36 umpa: (map set (partition 3 (range 10)))

0:36 is f

0:37 dbasch: umpa: no, that’s coll

0:37 johnwalker: ok, separate these out

0:37 ,(def foo (map set (partition 3 (range 10))))

0:37 clojurebot: #'sandbox/foo

0:37 dbasch: umpa: conceptually, what you have is (map f1 (map f2 coll))

0:38 johnwalker: ,(count foo)

0:38 clojurebot: 3

0:38 johnwalker: foo contains 3 elements, so a non-lazy map should call f 3 times

0:39 catern: blow his mind even more by modifying it to (map #(set/intersection #{1 2 3} (set %)) (partition 3 (range 10)))

0:41 dbasch: umpa: what’s the confusing part at this point?

0:42 umpa: my perseption was that maps usually come in a flavor of (map f coll)

0:43 catern: yes, and what you posted was in that flavor

0:44 dbasch: umpa: all you need to do is identify f and coll in your example

0:44 which has the form of (map f1 (map f2 coll))

0:44 and could also be (map g coll) where g is (comp f1 f2)

0:45 umpa: *lightbolb*

0:46 johnwalker: i think you got it already, but this might provide some more insight

0:46 http://www.braveclojure.com/core-functions-in-depth/#2_2_1__map

0:47 umpa: those mit vids are good

0:48 i've been meaning to go through braveclojure tuts for a while

0:50 muhuk: umpa: SICP starts with substitution model, will help you a lot figuring out s-expressions.

0:56 umpa: mhuk: is the whole series about lisp, intor sure is

0:56 intro*

0:59 muhuk: umpa: LISP and computation in general. It's good, you won't come back to me asking for your 20 hours back (or however long it is)

1:03 umpa: muhuk: have you watched all of em ? I am interested in states and wonder if they will have bits on that

1:10 DrFukt: hello

1:15 Dude tries to land a happy ending at the local Korean massage parlor but has difficulty getting past the language barrier. Even a hilarious visual demonstration fails to get his point across. "Happy Ending Fail" - http://efukt.com/20751_Happy_Ending_Fail.html

1:16 mdeboard: what the fuck?

1:16 Where are all these shitty spammers coming from

1:16 DrFukt: huh?

1:16 mdeboard: I mean, spamming IRC? srs?

1:17 DrFukt: do you have a problem with something?

1:17 mdeboard: Yes, why are you spamming IRC?

1:17 DrFukt: i am not

1:17 mdeboard: Except random click bait that has nothing to do with Clojure, or programming, or anything?

1:17 catern: i know what you mean though mdeboard, i've seen them too

1:18 pretty weird

1:18 mdeboard: considering this guy joined then instantly pasted clickbait

1:18 DrFukt: what

1:18 mdeboard: Is IRC like the great undiscovered advertising frontier or what

1:19 DrFukt: I am just sharing a funny clip with my friends. do you have a problem with that?

1:19 mdeboard: yes

1:19 catern: I guess freenode's taken venture capital funding and is feeling the pressure to monetize

1:19 mdeboard: obviously

1:19 DrFukt: you need to learn how this channel works, then

1:19 mdeboard: DrFukt: ok

1:19 advice noted and discarded

1:20 DrFukt: good. next time I won't just warn you

1:20 mdeboard: catern: that's not true though, right? Please?

1:20 DrFukt: ok

1:20 DrFukt: Thanks for being so lenient

1:20 catern: mdeboard: lol, no, it's not true

1:22 mdeboard: catern: whew

1:27 DrFukt: If there's a book out there on what NOT to do during intercourse, I'd say this dude just paved the way for a fucking trilogy. Nevermind his Rosie O'Donnell-like figure, or his unsettling fetish for floppy disks. The real prize is at the 2.48 mark. Ladies and gentleman, this motherfucker just single-handedly brought back Planking. "The Creepiest Motherfucker in Porn" - http://efukt.com/21065_The_Creepiest_Motherfucker_in_Porn.html

1:27 mdeboard: lol

1:27 Not a spammer here

1:27 technomancy: ^

3:29 muhuk: Is there a way to destructure first two elements of a vector to a vector? For some vector ['a 'b 'c], I'd like to destructure into ['a 'b] and 'c

3:29 Like (subvec v 0 2)

3:33 TEttinger: (take 2 ['a 'b 'c])

3:33 ,(take 2 ['a 'b 'c]) ;returns a seq

3:33 clojurebot: (a b)

3:34 TEttinger: http://clojuredocs.org/clojure_core/clojure.core/subvec

3:34 muhuk: **destructure**

3:34 TEttinger: ,(subvec ['a 'b 'c] 2) ;returns a seq

3:34 clojurebot: [c]

3:35 TEttinger: oh I wasn't sure what you meant

3:36 actually I'm still not sure what the context is

3:38 http://clojure.org/special_forms at the bottom is destructuring, it is possible

3:38 muhuk: TEttinger: are you sure it is possible, considering you're not sure what I'm asking

3:38 (let [[a b & c] v, a-and-b [a b]] ...)

3:39 I don't want the second assignment. I want to destructure in one step.

3:39 TEttinger: well let me check in privmsgs to lazybot

3:41 jarodzz: hi, guys

3:49 TEttinger: muhuk: I can't find a way to do it within destructuring, (I didn't realize it was so small), but you can just do ##(let [[a b c] [1 2 3] v [a b]] v)

3:49 lazybot: ⇒ [1 2]

3:50 TEttinger: ##(let [[a b c] [1 2 3] v [a b]] (println "v is " v ", c is " c)

3:50 ##(let [[a b c] [1 2 3] v [a b]] (println "v is " v ", c is " c))

3:50 lazybot: ⇒ v is [1 2] , c is 3 nil

4:24 ptcek: Is there any lib that makes it easy to authenticate agains Active Directory?

4:32 dbushenko: you'd better search for a java lib

5:09 yunfan: are there any forth related apps on iOS devices?

5:30 amalloy: &(let [[_ _ :as first-two] '(a b c d)] first-two) muhuk

5:30 lazybot: ⇒ (a b c d)

5:30 amalloy: hm

5:32 no, i guess you can't do it. that vector never existed, so there's no destructuring form to bind it

5:46 muhuk: clojars looking sexy.

6:05 clgv: amalloy: I thin :as is always meant to bind the original data (on the right). maybe with the exception of map destructuring where it binds the thing on the right after it was converted to a map

6:05 muhuk: I don't even know if lein supports plugins to provide an exit value, but here goes https://github.com/jonase/lein-kibit/issues/2

6:06 clgv: muhuk: maybe also look at leiningen directly and if there is such an issue already over there

6:07 muhuk: clgv: what issue?

6:07 clgv: muhuk: exit value for plugins

6:07 muhuk: clgv: maybe.

6:08 clgv: muhuk: I think thats something that is important for "lein test" or similar as well

6:09 muhuk: clgv: I'm pretty sure lein test etc. returns a non-zero value. Didn't remember that 1 minute ago though. :/

6:09 so it is possible.

6:22 mi6x3m: Are the mappings established by refer private in the current namespace?

6:26 muhuk: mi6x3m: yes, if I understand your question correctly.

6:26 mi6x3m: thanks :)

6:26 muhuk: mi6x3m: you can't :refer :all to another ns and then use the stuff it's referring to.

6:27 yw

6:27 mi6x3m: muhuk: well if i :use something in namespace X i cannot see it in Y, this was the question

6:28 muhuk: mi6x3m: right, the answer is still no

6:28 mi6x3m: very well

6:29 muhuk: mi6x3m: to collect stuff in sub-modules into a parent module, what I do is to create vars in the parent module. A bit more typing but explicit is better than implicit.

6:36 clgv: mi6x3m: but you can use 'in-ns on the repl to switch to the namepsace and to be able to use everything the is imported to that namespace

8:26 kzar: How do I return a new version of an array map with a key added?

8:26 (Is something like (merge {:a 1} {:b 2}) the best way?)

8:28 Glenjamin: ,(doc assoc)

8:28 clojurebot: "([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)."

8:28 Glenjamin: oh, you mean specifically an array map?

8:29 kzar: Glenjamin: Ah that looks better

8:29 Glenjamin: ,(assoc {:a 1} :b 2)

8:29 clojurebot: {:b 2, :a 1}

8:29 Glenjamin: ,(assoc {:a 1} :b 2 :c 3)

8:29 kzar: ty :)

8:29 clojurebot: {:c 3, :b 2, :a 1}

8:29 Glenjamin: skimming http://clojure.org/cheatsheet is usually a good way to find such things

8:34 clgv: $findfn {:a 1} :b 2 {:a 1 :b 2}

8:34 lazybot: [clojure.core/assoc]

8:34 clgv: Glenjamin: kzar: or asking lazybot for simple functions ^^

8:35 kzar: clgv: How does that work?

8:35 clgv: kzar: black magic - voodoo in fact ;)

8:35 kzar: $findfn "a" "b" "ab"

8:35 lazybot: [clojure.core/str]

8:36 kzar: mark me impressed

8:36 clgv: has its limits though ;)

8:36 $findfn inc [1 2 3] [2 3 4]

8:37 lazybot: []

8:37 clgv: there is fails already :(

8:37 *it

8:37 kzar: $findfn (range 10) inc (range 1 11)

8:37 lazybot: []

8:37 kzar: oh we did the same thing pretty much

8:38 clgv: it doesnt try argument permutations, so you have to guess the right order^^

8:38 kzar: $findfn inc (range 10) (range 1 11)

8:38 lazybot: []

8:38 kzar: ,(= (map inc (range 10)) (range 1 11))

8:38 clojurebot: true

8:38 clgv: but somehow it is not able to find `map` here. maybe it is due to providing a function

8:39 $findfn first [[1 2] [5 6]] [1 5]

8:40 lazybot: []

8:40 jonasen: $findfn nil nil

8:40 lazybot: [clojure.set/union clojure.set/intersection clojure.set/difference clojure.core/list* clojure.core/booleans clojure.core/longs clojure.core/shorts clojure.core/empty clojure.core/dorun clojure.core/time clojure.core/second clojure.core/letfn clojure.core/keys clojure... https://www.refheap.com/86585

8:40 kzar: (We should have a game whereby you have to name the function before the bot)

8:40 and it keeps score

8:42 clgv: $findarg map % [1 2 3] [2 3 4]

8:42 lazybot: []

8:45 clgv: $movie avengers

8:45 lazybot: 2012 - Marvel's The Avengers | rating: 92 | consensus: With a script that never forgets its heroes' humanity and no shortage of superpowered set pieces, The Avengers lives up to its hype -- and raises the bar for Marvel at the movies. | link: http://www.rottentomatoes.com/m/marvels_the_avengers/

8:45 clgv: oh that one is activated as well

8:45 kzar: $movie The room

8:45 lazybot: 1998 - The Room | rating: 33 | consensus: A bona fide classic of midnight cinema, Tommy Wiseau's misguided masterpiece subverts the rules of filmmaking with a boundless enthusiasm that renders such mundanities as acting, screenwriting, and cinematography utterly irrelevant. You will never see a football the same way again. | link: http://www.rottentomatoes.com/m/room/

8:45 clgv: $playing

8:50 ppppaul: the room is great

8:51 so is troll2

8:52 kzar: We watched it the other day, or attempted to, on our projector

8:52 I think we lasted about half way

9:05 ppppaul: need more alcohol

9:05 kzar: heh

9:05 ppppaul: i watch the movie sober, somehow. also, with a bunch of people who didn't know what it was

9:06 kzar: you're a better man than I

9:07 ppppaul: i thought it was really entertaining

9:37 kzar: Is there a way to get the absolute path to my project's root?

9:41 roppongininja: fellows, is anyone here programming in intellij idea using 'la clojure'?

9:41 anna_: nop

9:42 i use sublime only ...

10:04 kandinski: can anybody help me with this error (Wrong number of args(2) passed), I can't make sense of it. http://paste.lisp.org/display/142882

10:10 clgv: kandinski: a function you pass to `reduce` must have a 2-arity implementation

10:10 kandinski: yes, I noticed

10:10 it's (and (map ...)) that I was looking for

10:10 thanks

10:10 clgv: what? not really

10:11 kandinski: you are looking for (every? binarytree? ...)

10:11 kandinski: of course

10:11 clgv: kandinski: btw. convert the `if` to an `or`

10:12 (or (nil? node) (and ...))

10:12 kandinski: isn't that the same?

10:12 (if a true b) is equivalent to (or a b) isn't it?

10:12 clgv: kandinski: functionally yes, but yours is more complex

10:13 explicitely returning true/false in a then/else case is seldom concise

10:13 kandinski: I mean, you are right, but that's not what is buggy in this code

10:13 is hwat I meant

10:13 thanks

10:14 clgv: yeah. the reduce was. but that is detected already ;)

10:14 kandinski: and more things

10:14 clgv: since you seem to be new, I just added a few more hints ;)

10:14 kandinski: I am new

10:19 kzar: jekyll to stasis is proving to be a pita

11:57 sveri: hi, I have trouble using test.check correctly. I try to have multiple "defspec" in my test file, but only the last one will be executed. Does someone have some code where he executes multiple checkers in one file?

11:58 bob2: did you give them the same name?

11:58 eflynn: is there a way to make a function like (fn [arg1 arg2] …) that returns a map of the arg names and their values?

11:58 sveri: bob2: jeez, well, what should I say, stupidity is all around me :D

11:59 thank you

12:00 bob2: heh

12:01 did that last week

12:01 eflynn: anyone know

12:01 should i make a macro

12:01 bob2: are you sure this is a thing you want

12:02 rather than just using like the normal arg syntax

12:02 ddellacosta: eflynn: I'm confused as to what you're trying to do--if you know the names, just name the hash-map the same way...? (fn [a b] {:a ... :b ...})

12:02 eflynn: ddellacosta: yeah but i thought it would be baked into the language or something

12:02 ddellacosta: eflynn: well, you have the name of the args--you're the one defining the function.

12:03 bob2: is this for debugging?

12:03 eflynn: ddellacosta: i want a constructor like Type(val1, val2, val3)

12:03 ddellacosta: eflynn: ...Clojure is not OO...?

12:03 bob2: which in clojure would most likely be (whatever val1 val2 val3)

12:03 how do you feel a map is involved?

12:03 eflynn: ddellacosta: ok, (Type val1 val2 val3)

12:04 ddellacosta: eflynn: well, I suppose you could use a protocol and defrecord, which gives you a map of the args.

12:04 cbp: eflynn: (defrecord Type [val1 val2 val3])

12:05 mi6x3m: what's the idiomatic way of getting system properties?

12:05 cbp: System/getProperties

12:05 mi6x3m: damn

12:09 ambrosebs: what are the interfaces I need to implement to make my own ISeq?

12:10 this is a great discussion of what's needed for a map http://zeroem.github.io/pages/sometimes-you-feel-like-a-map.html

12:10 anything for seqs?

12:11 Bronsa: ambrosebs: IObj, ISeq and maybe Sequential

12:12 there's not much needed, really

12:12 also IHashEq I guess

12:12 ambrosebs: what I really want is to wrap existing ISeqs

12:12 I guess that means ASeqs

12:13 ,(ancestors clojure.lang.ASeq)

12:13 clojurebot: #{clojure.lang.IPersistentCollection clojure.lang.IMeta clojure.lang.Seqable clojure.lang.IObj java.io.Serializable ...}

12:15 Bronsa: so IHashEq, ISeq, Seqable, IObj, IPersistentCollection, IMeta, Sequential

12:15 ddellacosta: ambrosebs: does this help? public abstract class ASeq extends Obj implements ISeq, Sequential, List, Serializable, IHashEq {

12:15 Bronsa: ambrosebs: assuming you don't want to implement all the java.util.* ones too

12:15 ddellacosta: jeez that java code is kinda ugly

12:16 Bronsa: just don't look at it

12:16 ddellacosta: Bronsa: haha

12:16 ambrosebs: ok. I want the wrapper to do everything a normal seq can do.

12:18 Bronsa: then you want to implement (filter #(.isInterface %) (ancestors clojure.lang.ASeq)) :P

12:18 ambrosebs: makes sense

12:19 I assume the descendants of ASeq don't implement anything else usually?

12:19 Bronsa: well

12:19 IPersistentList implements Counted for example

12:20 no wait only PersistentList

12:21 ambrosebs: ah

12:21 Bronsa: IPL implements IPersistentStack, PL implements Coutned, IReduce, IPL

12:21 Counted*

12:21 ambrosebs: ok cheers, I can work with that.

12:22 Bronsa: ambrosebs: those should just change the performance of some operations though

12:23 ambrosebs: I'm willing to break things like (= (class seq) PersistentList) but not (counted? seq)

12:23 ,counted?

12:23 clojurebot: #<core$counted_QMARK_ clojure.core$counted_QMARK_@1a38598>

12:43 toxmeister: quick Q about: cljs.core.number?… shouldn't (number? (js/parseInt nil)) return false? (Since parseInt return NaN in this case)

12:44 i know that goog.isNumber returns true for that case too, but just wondering what the reasoning was/is?

12:45 seems like the only other way to check for valid parse results is to use (.isNaN js/Number x)

12:48 Glenjamin: NaN is of type "number"

12:49 toxmeister: technically yes, but semantically no...

12:49 Glenjamin: so is Infinity

12:50 what is the number for? you might be better off with a range check if you can manage it

12:50 Bronsa: ,(number? Double/NaN)

12:50 clojurebot: true

12:50 toxmeister: am working on some angular directives and parse attribute vals, but want to default to fixed vals if attribs are gibberish

12:51 as i wrote, i know i can use the Number.isNaN way, but wondered about `number?`… np

12:55 LangeOortjes: Is someone succesfully using C2 0.2.3 in a ClojureScript project? When I try to use it in my project, compilation fails (due to some errors in the dependencies). https://gist.github.com/anonymous/d83598ac39eb3a26f606

12:56 ddellacosta: LangeOortjes: I've had a lot of trouble with C2, to be honest. I ended up having better luck with two other approaches: simply calling D3 functions directly, and using Om w/SVG.

12:56 LangeOortjes: and no, I never ended up getting it working.

13:25 toxmeister: Bronsa: in clojure itself number parsing throws an exception for invalid input though, so it's easy to catch. guess, my main issue is that there's a constant literally meaning "not a number", but it's associated with number types in both Java/JavaScript

13:33 umpa: How do I make each item in seq a list ? (#{1 2} #{3} #{} #{3} #{1} #{2} #{} #{2})

13:34 hyPiRion: (map seq my-list)

13:34 "list"

13:40 umpa: hyPiRion: cool

13:47 jinks_-: I'm looking for a simple (file-based) data store with a NoSQL-like interface. (I'm trying to ween a project off MongoDB because it's clearly overkill to have an external server, but it would be nice to keep the API somewhat similar)

13:48 any suggestions?

13:53 umpa: How do I filter sets with >= 2 items ([0 #{1 2}] [1 #{3}] [2 #{}] [3 #{3}] [4 #{1}] [5 #{2}] [6 #{}] [7 #{2}])

14:05 danneu: umpa: (for [[k v] coll, :when (<= 2 (count v))] v)

14:14 mi6x3m: are keywords always comparable?

14:14 I have a weird issue possibly related to that

14:14 umpa: danneu: nice

14:14 mi6x3m: (t/simple-tree-model #(not= (first %) :example-group) last [[:example-group]]) gives an exception

14:15 the method is not supposed to branch out on something starting with :example-group

14:15 but it does

14:16 danneu: umpa: just saw your prev question. what are you trying to do in general?

14:20 umpa: danneu: give me a second to phrase it

14:25 sveri: I am trying to combine deftest and defspec (from test.check) in one testfile, now, whenever I do (is (thrown? in the deftest the defspec fails and I cannot figure out why that combination does not work, any Ideas?

14:27 umpa: danneu: conditional select from a nested list (partition 3 (range 10))

14:27 ,(partition 3 (range 10))

14:27 clojurebot: ((0 1 2) (3 4 5) (6 7 8))

14:30 danneu: umpa: so all you need to do is write `my-fn` so that (my-fn [a b c]) returns true or false?

14:30 so that you can (filter my-fn coll)

14:35 umpa: danneu: there is a caviat, the select depends on count of interection coll with list A

14:36 danneu: so you can write `my-fn` so that you also pass in List A (the dependency) so that it can intersect each element of the coll youre filtering?

14:36 umpa: danneu: acutally what you said is exactly right

14:36 danneu: (filter (partial my-fn list-A) coll)

14:37 (defn my-fn [the-list element] ...)

14:40 umpa: danneu: just a sec

14:44 kzar: yogthos: With Selmer can you have a custom tag that avoids HTML escaping like you can with custom filters?

14:46 whodidthis: {{my-tag|safe}}

14:47 kzar: I mean from within the tag definition, I don't really want to change all my existing content

14:47 I tried wrapping the result of my tag function with [:safe ...] but no luck

14:49 umpa: danneu: what does partial do in this context ?

15:08 deathknight: Is a simple way to send JSON/Make an API call to use clj-http and cheshire together?

15:12 danneu: umpa: it returns a new function that's pretty much the original function but with list-A passed in as the first argument

15:13 umpa: (defn add [a b] (+ a b)), ((partial add 3) 7) => 10

15:14 you can also write my filter example above as (filter #(my-fn list-A %) coll)

15:24 yogthos: kzar: there isn't a way to mark tag content as safe at the moment

15:29 kzar: :/ OK

15:37 Glenjamin: deathknight: in theory you can add request middleware to clj-http, but i don't know if such a thing exists

15:38 deathknight: Glenjamin: Where is the starting point for understanding how to send JSON with an HTTP request to interact with another services API?

15:39 I followed the REST API tutorial (http://blog.interlinked.org/programming/clojure_rest.html) as a testbed to try to then interact with it via HTTP requests but have had so far no luck

15:39 Glenjamin: well, it should be as simple as calling whatever to-json function cheshire provides to generate the :body for clj-http

15:39 deathknight: clj-http: is :body referring to the actual <body> HTML element?

15:40 I've made super basic GET requests with clj-http

15:40 Glenjamin: no, the body of an HTTP request

15:47 umpa: danneu: gotcha

15:47 deathknight: Thank you for the help, Glenjamin

15:59 patrickod: I'm having a sub-dependency issue with core.async in a project of mine. https://gist.github.com/patrickod/1453740dbdb768f7f474

15:59 where core.memoize is refering to clojure.core.cache/through which doesn't exist

16:00 I'm using clojure 1.6.0 with the latest async according to the github page.

16:00 Glenjamin: patrickod: if you run "lein deps :tree" it should tell you what is conflicting

16:08 patrickod: yep that's it. cemerick.friend has a conflicting version

16:10 using the :excludes parameter in the dependency definition though hasn't fixed the issue.

16:11 Glenjamin: try putting an explicit core.cache version in your project.clj

16:14 johnwalker: how do you run tests under a separate clojure version?

16:14 for example, a project written against 1.5.1 with tests running in 1.6.0

16:14 patrickod: @Glenjamin that worked! thanks so much

16:15 johnwalker: for reference, this is the issue: https://github.com/quil/quil/issues/88

16:16 Glenjamin: johnwalker: take a look at https://github.com/xeqi/kerodon/blob/master/project.clj

16:18 johnwalker: which lines? i'm familiar with multiple profiles, but doesn't that keep the code and the tests on the same clojure version?

16:18 Glenjamin: so you can run "lein with-profile +1.5 test", and it runs tests on 1.5

16:19 and "lein all test" runs on 1.4, 1.5 and 1.6 in that example

16:19 is that what you wanted?

16:19 johnwalker: in this example, is the core code still in 1.4?

16:19 when it's being tested in 1.6 and 1.5?

16:20 Glenjamin: i don't get what you mean, the code works on 1.4, 1.5 and 1.6

16:21 johnwalker: nbeloglazov asked that quil be simultaneously compiled in 1.5.1 and tested in 1.6.0

16:21 Glenjamin: oh, i have no idea about AOT

16:21 i see what you mean now

16:22 johnwalker: thanks though, that was my first interpretation as well

16:22 Glenjamin: do you know why i needs to aot?

16:23 *it

16:23 johnwalker: i don't, i wish i knew

16:23 it's probably related to opengl

16:29 umpa: How do I pull out list value according to index ? ,(map nth (partition 3 (range 10)) (0 1 2))

16:29 ,(map nth (partition 3 (range 10)) (0 1 2))

16:29 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

16:30 johnwalker: thats right

16:31 but

16:31 replace (0 1 2) with [0 1 2] or '(0 1 2)

16:31 umpa: ,(map nth (partition 3 (range 10)) '(0 1 2))

16:31 clojurebot: (0 4 8)

16:31 umpa: johnwalker: nice

16:32 johnwalker: any time

16:35 umpa: ,(partition 3 (range 10))

16:35 clojurebot: ((0 1 2) (3 4 5) (6 7 8))

16:36 umpa: I need to get lists given index

16:38 if (def index '(0 1)) output should be ((0 1 2) (3 4 5))

16:43 gfredericks: ,(def my-lists '[(0 1 2) (3 4 5) (6 7 8)])

16:43 clojurebot: #'sandbox/my-lists

16:43 gfredericks: ,(def index '(0 1))

16:43 clojurebot: #'sandbox/index

16:43 gfredericks: ,(map my-lists index)

16:43 clojurebot: ((0 1 2) (3 4 5))

16:43 gfredericks: ^ depends on my-lists being a vector

16:45 umpa: gfredericks: got it

17:36 kzar: yogthos|away: So there isn't a way to mark tag content as safe directly, is there a way to use filters with block tags? Trying to do this doesn't seem to work {% highlight clojure | safe %}...{% endhighlight%} . (Highlight is a block-tag I defined myself that returns HTML.)

17:53 * gfredericks lein new dot-slash

18:52 gfredericks: Now you too can have a namespace called .

18:52 https://github.com/gfredericks/dot-slash

19:09 TimMc: ...

19:10 Ah, so this is avoiding the problem of actually having to load .clj from the classpath.

19:11 gfredericks: and also avoids needing a specific project just for that

19:11 separation of concerns and all that

19:11 I was doing it in a user.clj from my repl-utils lib before

19:12 but that means nobody else can do it unless they want the exact same set of functions/macros that I had there

19:16 * gfredericks tries to figure out how to extend potemkin

19:29 michaniskin: "I made this for me stop trying to want it."

19:29 lol

19:29 i like how weird your github is dude

19:31 gfredericks: I was just thinking about trying to make that repo something somebody might think of using

19:31 I'm having a hard time not talking about that bg macro all the time

19:32 michaniskin: yup, i hear ya

19:33 i have also done something similar in my build tool

19:33 super useful

19:35 i like how you have a sort of job control even

19:35 i didn't go that far with it :)

19:35 but it's surprisingly similar: https://github.com/tailrecursion/boot-ng/blob/master/boot-core/src/tailrecursion/boot/util.clj#L243-L248

19:36 you even have a with-pre-wrap macro in a core namespace

19:37 gfredericks: yeah mine is oriented toward regular repl usage

19:37 it's basically a future but with lots of repl sugar

19:39 michaniskin: A+

19:39 would evaluate again

19:40 gfredericks: in the Future some nrepl middleware should make it possible to background things after they've already started evaling

19:41 michaniskin: you could have it just background everything, maybe?

19:41 like every expression, and then deref the future

19:41 which would then be interruptible?

19:42 i guess that would be crazy because you couldn't interrupt the evaluation anymore lol

19:43 gfredericks: yeah; there's a lot of subtleties

19:43 Glenjamin: (cancel *1)

19:44 somethink akin to bash job control would be neat

19:44 michaniskin: i think a lot of unnecessary limitations are imposed by the line-oriented terminal display, too

19:44 gfredericks: the flipside is you could also have unrelated threads (e.g., a web server) pause and expose debug repls that you could hook into

19:44 michaniskin: this whole issue of bg vs fg is mostly just an artifact of that

19:45 gfredericks: hmmm

19:45 michaniskin: if the repl interface was in something document oriented like a webpage, you'd be able to just do each evaluation async

19:45 gfredericks: yeah I can see how something like session would remove that distinction

19:45 michaniskin: it could insert the result in between any subsequent expressions, whenever it completes

19:45 Glenjamin: it is generally much easier to think linearly though

19:46 michaniskin: it's still linear

19:46 it just updates the view async

19:46 but you still get a sequential record of what you did

19:46 Glenjamin: i suppose you could do it a bit like light-table

19:46 gfredericks: with my bg macro if something takes an hour it prints when it's done, no matter how much you've been doing in the interim

19:46 Glenjamin: where the result appears next to the command

19:47 gfredericks: so you don't have to do find the result

19:47 Glenjamin: in fact, LT is already set up reasonably well for this

19:47 except it only evals one thing at once

19:48 michaniskin: i've had some performance issues with it, like if i accidentally evaluate something that returns a large amount of data

19:48 it locks up for a while as it figures out how to print it all, i guess

19:48 Glenjamin: yeah, i've had that a bit

19:49 it seems to know about infinite sequences, and truncate

19:49 but generally large things are a bit annoying

19:49 michaniskin: i was working with xml, which can get pretty huge for a pretty-printer to handle

19:49 Glenjamin: i had about 600k items in a map :D

19:50 michaniskin: good greif

19:50 *grief

19:50 Glenjamin: surprisingly, it coped ok

19:50 gfredericks: the new cider inspect feature is supposed to make that better

19:51 Glenjamin: is that done as nrepl middleware?

19:51 i'm hoping the plugin api docs will improve soon for LT, then i can really start hacking on it properly

19:51 michaniskin: is anyone here experienced with immutant, by any chance?

19:52 * gfredericks turns on the jcrossley3-away signal

19:54 * michaniskin (into mouth foot)

19:55 jcrossley3-away: michaniskin: gfredericks: weirdly, i happen to be noodling with some Killer Queen tab, so i'm here. wassup? :)

19:55 umpa: ,(filter #(not= '(or 0 1) %)'((0 1 2) (3 4 1) (6 7 8)))

19:55 clojurebot: ((0 1 2) (3 4 1) (6 7 8))

19:56 umpa: How do I filter based on multi conditions ?

19:56 michaniskin: jcrossley3-away: are there any docs or examples of using immutant without leiningen?

19:57 Glenjamin: ,(filter #(or (not= 1 %) (not= 0 %))'((0 1 2) (3 4 1) (6 7 8)))

19:57 clojurebot: ((0 1 2) (3 4 1) (6 7 8))

19:58 umpa: Glenjamin: my code is not clear, I need to yank any lists with those numbers

19:58 jcrossley3-away: michaniskin: i assume you're referring to immutant 1.x. thedeuce will be far less reliant on lein. using immutant without lein is essntially just using jboss :)

19:58 noonian: but you're comparing lists with numbers so they'll never be equal

19:59 michaniskin: jcrossley3-away: i'm interested in immutant primarily because of the work you guys did with getting the classloader isolation to work with clojure

19:59 noonian: ,(for [l '{(0 1 2) (3 4 1) (6 7 9))] (filter #(or (not= 1 %) (not= 0 %)) l))

19:59 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>

19:59 metellus: ,(filter #{0 1} '((0 1 2) (3 4 1) (6 7 8)))

19:59 clojurebot: ()

19:59 Glenjamin: ,(remove #(or (.indexOf % 0) (.indexOf % 1)) '((0 1 2) (3 4 1) (6 7 8)))

19:59 clojurebot: ()

20:00 michaniskin: jcrossley3-away: it looks like under clojure 1.6 you can add and remove applications at runtime all day long and not have memory leaks

20:00 jcrossley3-away: michaniskin: correct. they accepted tcrawley-away's patch that cleared those thread locals

20:00 umpa: can the dependancy be a list ?

20:00 Glenjamin: umpa: clojure doesn't have efficient tests for something contained in a list, as this cannot be done efficiently - could you use sets?

20:01 noonian: ,(filter (partial not-any? #{0 1}) '((0 1 2) (3 4 1) (6 7 8)))

20:01 clojurebot: ((6 7 8))

20:01 TEttinger: (inc noonian)

20:01 lazybot: ⇒ 5

20:01 Glenjamin: oh, neat

20:01 umpa: nice

20:02 michaniskin: jcrossley3-away: basically i am thinking about launching immutant as a general purpose application container; i'd have a simple frontend java program that communicates with immutant, sending it a clojure "script" to evaluate in an isolated classloader. that script would be able to pull in maven deps etc via the repl tools

20:03 jcrossley3-away: it's basically a way to run clojure scripts without the jvm startup penalty of clojure

20:03 noonian: ,(map (partial filter (comp not #{0 1})) '((0 1 2) (3 4 1) (6 7 8)))

20:03 clojurebot: ((2) (3 4) (6 7 8))

20:04 jcrossley3-away: michaniskin: that could work. you might also take a look at https://github.com/projectodd/shimdandy. i believe tcrawley-away abstracted out all the classloader isolation into that library.

20:05 michaniskin: jcrossley3-away: thanks!

20:05 jcrossley3-away: michaniskin: np. good luck!

20:10 umpa: noonian: nice, I don't get how partial works here

20:12 noonian: its mapping filter onto each element list, like (for [sublist '((0 1 2) (3 4 1))] (filter (comp not #{0 1}) sublist))

20:12 you could use #(filter (comp not #{0 1}) %) instead of the partial

20:15 gfredericks: (remove #{0 1} %)

20:16 noonian: nice

20:19 umpa: ,(map (remove #{0 1} %) '((0 1 2) (3 4 1) (6 7 8)))

20:19 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0:0)>

20:19 noonian: #(remove #{0 1} %)

20:20 umpa: nice

21:00 whilo: is it safe to use an externally updated atom as app state in om, that is which is not updated through om/transact! ?

21:14 nDuff: whilo, absolutely.

21:15 whilo: nDuff: cool,have you done it as well? seems to work so far

21:17 nDuff: whilo, yes.

21:18 umpa: why does this work ?

21:18 ,(filter (partial not-any? #{100}) '((5000) (100 50)))

21:19 clojurebot: ((5000))

21:19 umpa: and this doesnt

21:19 ,(filter (partial not-any? #{100}) '((5000 100 50))

21:19 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

21:19 whilo: nDuff: thx, what do you build with om?

21:19 nDuff: whilo, something that isn't public.

21:20 umpa: noonian:

21:21 nDuff: umpa, well, you're only asking not-any? about a single list, and one member of that list is 100

21:21 umpa, ...so, of course nothing matches.

21:21 ,(filter (partial not-any? #{100}) '((5000 100 50)))

21:21 clojurebot: ()

21:22 nDuff: ,(filter (partial not-any? #{100}) '((5000 50)))

21:22 clojurebot: ((5000 50))

21:22 noonian: just missing an ending paren i think

21:23 johnwalker: ,(

21:23 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

21:23 johnwalker: ,(,)

21:23 clojurebot: ()

21:25 umpa: so this should work then

21:25 ,(filter (partial not-any? #{100}) '(5000 100 50))

21:25 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

21:26 gfredericks: ,(doc not-any?)

21:26 clojurebot: "([pred coll]); Returns false if (pred x) is logical true for any x in coll, else true."

21:26 johnwalker: ,(not-any? #{100} '(1 2 3))

21:26 clojurebot: true

21:26 johnwalker: ,(not-any? #{100} '(100))

21:26 clojurebot: false

21:27 johnwalker: ,(filter (not-any? #{100}) '((5000 100 50)))

21:27 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/some>

21:27 johnwalker: oh, yeah thats what it's for

21:27 umpa: ?

21:28 johnwalker: the partial at the beginning

21:28 umpa: ,(filter (not-any? #{100}) '((5000 100 50)))

21:28 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/some>

21:28 johnwalker: right, throw the partial back in and it works

21:29 umpa: ,(filter (partial not-any? #{100}) '(5000 100 50))

21:29 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

21:29 johnwalker: no, you threw out the parens

21:29 umpa: ,(filter (not-any? #{100}) '(5000 100 50))

21:29 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/some>

21:29 johnwalker: ,(filter (partial not-any? #{100}) '((5000 100 50)))

21:29 clojurebot: ()

21:30 umpa: yeah, trying to figure whats going on

21:31 johnwalker: filter asks for all elements for which the predicate is true

21:31 you're asking for all elements that don't contain 100

21:31 noonian: ,(filter (partial not-any? #{100}) (list (5000 100 50)))

21:31 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

21:31 johnwalker: ,(filter (partial not-any? #{100}) '((5000 100 50) (1 2 3)))

21:31 clojurebot: ((1 2 3))

21:32 johnwalker: so the second one list doesn't contain 100 and is returned

21:32 second list *

21:32 noonian: ,(filter (partial not-any? #{100}) [[1 2 3]])

21:32 clojurebot: ([1 2 3])

21:32 noonian: yeah, lists are annoying in examples because you have to quote them

21:33 umpa: ,(filter (not-any? #{100}) '(5000 100 50)) this should return ()

21:33 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/some>

21:33 noonian: ,(not-any? #{100} [100 50 500])

21:33 clojurebot: false

21:33 noonian: you left out partial there, not-any? expects two arguments

21:34 and the list should be a list of lists, missing the outer parens

21:35 umpa: ,(filter #(not-any? #{100} %) '(5000 100 50))

21:35 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

21:35 noonian: '(5000 100 50) should be '((5000 100 50))

21:35 umpa: ,(filter #(not-any? #{100} %) '((5000 100 50)))

21:35 clojurebot: ()

21:40 umpa: (doc not-any?)

21:40 clojurebot: "([pred coll]); Returns false if (pred x) is logical true for any x in coll, else true."

21:40 umpa: ,(#(not-any? #{100} %) '(5000 100 50))

21:40 clojurebot: false

21:41 umpa: ,(#(not-any? #{100} %) '((5000 100 50)))

21:41 clojurebot: true

21:43 umpa: (source not-any?)

21:43 ,(source not-any?)

21:43 clojurebot: #<SecurityException java.lang.SecurityException: denied>

21:51 deathknight: gonna need some virtual friends that stay up all night as I slam energy drinks and do some 'grammin

21:53 umpa: (doc grammin)

21:53 clojurebot: Cool story bro.

21:53 deathknight: what does doc do?

21:53 umpa: (doc doc)

21:53 clojurebot: "([name]); Prints documentation for a var or special form given its name"

21:53 deathknight: better question: where can I find out so I dont have to ask?

21:53 nice, thanks for answering

21:53 (inc doc)

21:53 lazybot: ⇒ 1

21:54 deathknight: (doc inc)

21:54 clojurebot: "([x]); Returns a number one greater than num. Does not auto-promote longs, will throw on overflow. See also: inc'"

21:54 deathknight: :)

21:54 assuming you use emacs - whats your favorite color theme?

21:56 umpa: deathknight: darkula

22:11 deathknight: currently working on authing with Google...following knoldus' guide (http://blog.knoldus.com/2014/04/05/google-sign-in-using-clojure/). Has anyone else crossed this bridge?

22:12 cbp`: i like leuven

22:12 deathknight: what is leuven?

22:13 cbp`: a color theme

22:13 deathknight: ooh

22:18 amalloy: i use tty-dark, deathknight

22:18 but i imagine that's not very popular

22:20 deathknight: looks neat. some colors are a bit too lego-ish for me

22:20 but glad you have one you enjoy :D

22:23 does this (http://blog.knoldus.com/2014/04/05/google-sign-in-using-clojure/) need to be built on top of a compojure app to be used?

22:23 clojurebot: It's greek to me.

22:27 MD223: Hey all, QQ that's bugging me: I've got a 'large' list of lists of bools e.g. "((true false true true) (false true false true)". I want to cast the bools to an int (so true => 1, false => 0) for counting. the following works on small sets but is giving me stack overflow on the full data set: "(map #(map (fn [winner?] (if winner? 1 0)) %) all-result

22:27 s)" - any suggestions on alternative solutions?

22:38 amalloy: that code won't overflow the stack. you're doing something else weird that you haven't included in the problem statement

22:39 if nothing else, MD223, a real stacktrace would be helpful, for example pasted to refheap.com. code would be nice too, if you can

22:51 john2x: how do I selectively update items in a list? something like this: https://www.refheap.com/86595

22:54 bob2: are you sure you don't want a map instead

22:55 noonian: john2x: https://www.refheap.com/86597

23:57 umpa: ,(partition 3 (range 10))

23:57 clojurebot: ((0 1 2) (3 4 5) (6 7 8))

23:57 umpa: ,(let [x (partition 3 (range 10))](concat (list (ffirst x) (first (last x))) (list (last (first x)) (last (last x)))))

23:58 clojurebot: (0 6 2 8)

23:58 umpa: any better way to get those values ?

Logging service provided by n01se.net