#clojure logs

2014-06-14

00:07umpaWhy does this work ?
00:08umpa,(map #(set/intersection #{1 2 3} %) (map set (partition 3 (range 10))))
00:08clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>
00:09umpaand this doesnt ?
00:10umpa(#(set/intersection #{1 2 3} %) (map set (partition 3 (range 10))) and this doesnt?
00:11umpa,(:require [clojure.set :as set]))
00:11clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>
00:12caternbecause (#(set/intersection #{1 2 3} %) thing) is equivalent to (set/intersection #{1 2 3} thing)
00:12muhukumpa: what does map do?
00:13umpa(doc map)
00:13clojurebot"([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."
00:13muhukumpa: I know what map does.
00:13muhukumpa: what's the difference between (f [a b c]) and (map f [a b c]) ?
00:14dbaschmuhuk: if you’re asking that question, you don’t know what map does :P
00:14umpamhuk: f is short for function I assume ?
00:15caternumpa: do you see why this doesn't work:
00:15catern,(set/intersection #{1 2 3} (map set (partition 3 (range 10))))
00:15clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>
00:15catern,(clojure.set/intersection #{1 2 3} (map set (partition 3 (range 10))))
00:15clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>
00:15caterner
00:15caternanyway
00:16dbaschumpa: long story short, you’re trying to intersect a set with a sequence of sets
00:18muhukdbasch: I'm asking the question to make umpa think about his problem, to help him debug.
00:19umpaI understand what its doing conceptually but not logically
00:20johnwalkerwhat is defcurried in core reducers?
00:21caternumpa: er, what's the difference between those ways of understanding?
00:21johnwalkeroh nevermind, i see what its doing
00:22muhukumpa: try stepping through the code in your head maybe
00:22muhukumpa: how many calls are made to f with and without map?
00:25dbaschmuhuk: gotcha :P
00:25umpamuhuk: i am not sure of the question but think that map is called 2 times
00:27muhukumpa: practise your LISP-fu, you need
00:28muhukumpa: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/
00:29umpamuhuk: so as far as I gather (map set (partition 3 (range 10)) is acting as a variable for the first map and for intersection
00:30johnwalkeroh please
00:31johnwalkerthats like the worst course you could ever suggest as an introduction
00:32umpamagic
00:32johnwalkerumpa: the idea is that (map f [1 2 3 4 5]) is like [(f 1) (f 2) (f 3) (f 4) (f 5)]
00:32johnwalkerf is a function, you're right about that
00:33johnwalkermap returns a sequence of f called on each element in the second argument
00:34umpaso f is called twice in this case
00:34johnwalkerwhich case are you referring to?
00:35johnwalker,(partition 3 (range 10))
00:35clojurebot((0 1 2) (3 4 5) (6 7 8))
00:35johnwalker?
00:35umpa(map #(set/intersection #{1 2 3} %) (map set (partition 3 (range 10))))
00:35johnwalkerwhich two things is f being called on?
00:36johnwalkerthere are two maps in there
00:36umpa(map set (partition 3 (range 10)))
00:36umpais f
00:37dbaschumpa: no, that’s coll
00:37johnwalkerok, separate these out
00:37johnwalker,(def foo (map set (partition 3 (range 10))))
00:37clojurebot#'sandbox/foo
00:37dbaschumpa: conceptually, what you have is (map f1 (map f2 coll))
00:38johnwalker,(count foo)
00:38clojurebot3
00:38johnwalkerfoo contains 3 elements, so a non-lazy map should call f 3 times
00:39caternblow his mind even more by modifying it to (map #(set/intersection #{1 2 3} (set %)) (partition 3 (range 10)))
00:41dbaschumpa: what’s the confusing part at this point?
00:42umpamy perseption was that maps usually come in a flavor of (map f coll)
00:43caternyes, and what you posted was in that flavor
00:44dbaschumpa: all you need to do is identify f and coll in your example
00:44dbaschwhich has the form of (map f1 (map f2 coll))
00:44dbaschand could also be (map g coll) where g is (comp f1 f2)
00:45umpa*lightbolb*
00:46johnwalkeri think you got it already, but this might provide some more insight
00:46johnwalkerhttp://www.braveclojure.com/core-functions-in-depth/#2_2_1__map
00:47umpathose mit vids are good
00:48umpai've been meaning to go through braveclojure tuts for a while
00:50muhukumpa: SICP starts with substitution model, will help you a lot figuring out s-expressions.
00:56umpamhuk: is the whole series about lisp, intor sure is
00:56umpaintro*
00:59muhukumpa: 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)
01:03umpamuhuk: have you watched all of em ? I am interested in states and wonder if they will have bits on that
01:10DrFukthello
01:15DrFuktDude 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
01:16mdeboardwhat the fuck?
01:16mdeboardWhere are all these shitty spammers coming from
01:16DrFukthuh?
01:16mdeboardI mean, spamming IRC? srs?
01:17DrFuktdo you have a problem with something?
01:17mdeboardYes, why are you spamming IRC?
01:17DrFukti am not
01:17mdeboardExcept random click bait that has nothing to do with Clojure, or programming, or anything?
01:17caterni know what you mean though mdeboard, i've seen them too
01:18caternpretty weird
01:18mdeboardconsidering this guy joined then instantly pasted clickbait
01:18DrFuktwhat
01:18mdeboardIs IRC like the great undiscovered advertising frontier or what
01:19DrFuktI am just sharing a funny clip with my friends. do you have a problem with that?
01:19mdeboardyes
01:19caternI guess freenode's taken venture capital funding and is feeling the pressure to monetize
01:19mdeboardobviously
01:19DrFuktyou need to learn how this channel works, then
01:19mdeboardDrFukt: ok
01:19mdeboardadvice noted and discarded
01:20DrFuktgood. next time I won't just warn you
01:20mdeboardcatern: that's not true though, right? Please?
01:20mdeboardDrFukt: ok
01:20mdeboardDrFukt: Thanks for being so lenient
01:20caternmdeboard: lol, no, it's not true
01:22mdeboardcatern: whew
01:27DrFuktIf 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
01:27mdeboardlol
01:27mdeboardNot a spammer here
01:27mdeboardtechnomancy: ^
03:29muhukIs 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
03:29muhukLike (subvec v 0 2)
03:33TEttinger(take 2 ['a 'b 'c])
03:33TEttinger,(take 2 ['a 'b 'c]) ;returns a seq
03:33clojurebot(a b)
03:34TEttingerhttp://clojuredocs.org/clojure_core/clojure.core/subvec
03:34muhuk**destructure**
03:34TEttinger,(subvec ['a 'b 'c] 2) ;returns a seq
03:34clojurebot[c]
03:35TEttingeroh I wasn't sure what you meant
03:36TEttingeractually I'm still not sure what the context is
03:38TEttingerhttp://clojure.org/special_forms at the bottom is destructuring, it is possible
03:38muhukTEttinger: are you sure it is possible, considering you're not sure what I'm asking
03:38muhuk(let [[a b & c] v, a-and-b [a b]] ...)
03:39muhukI don't want the second assignment. I want to destructure in one step.
03:39TEttingerwell let me check in privmsgs to lazybot
03:41jarodzzhi, guys
03:49TEttingermuhuk: 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)
03:49lazybot⇒ [1 2]
03:50TEttinger##(let [[a b c] [1 2 3] v [a b]] (println "v is " v ", c is " c)
03:50TEttinger##(let [[a b c] [1 2 3] v [a b]] (println "v is " v ", c is " c))
03:50lazybot⇒ v is [1 2] , c is 3 nil
04:24ptcekIs there any lib that makes it easy to authenticate agains Active Directory?
04:32dbushenkoyou'd better search for a java lib
05:09yunfanare there any forth related apps on iOS devices?
05:30amalloy&(let [[_ _ :as first-two] '(a b c d)] first-two) muhuk
05:30lazybot⇒ (a b c d)
05:30amalloyhm
05:32amalloyno, i guess you can't do it. that vector never existed, so there's no destructuring form to bind it
05:46muhukclojars looking sexy.
06:05clgvamalloy: 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
06:05muhukI don't even know if lein supports plugins to provide an exit value, but here goes https://github.com/jonase/lein-kibit/issues/2
06:06clgvmuhuk: maybe also look at leiningen directly and if there is such an issue already over there
06:07muhukclgv: what issue?
06:07clgvmuhuk: exit value for plugins
06:07muhukclgv: maybe.
06:08clgvmuhuk: I think thats something that is important for "lein test" or similar as well
06:09muhukclgv: I'm pretty sure lein test etc. returns a non-zero value. Didn't remember that 1 minute ago though. :/
06:09muhukso it is possible.
06:22mi6x3mAre the mappings established by refer private in the current namespace?
06:26muhukmi6x3m: yes, if I understand your question correctly.
06:26mi6x3mthanks :)
06:26muhukmi6x3m: you can't :refer :all to another ns and then use the stuff it's referring to.
06:27muhukyw
06:27mi6x3mmuhuk: well if i :use something in namespace X i cannot see it in Y, this was the question
06:28muhukmi6x3m: right, the answer is still no
06:28mi6x3mvery well
06:29muhukmi6x3m: 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.
06:36clgvmi6x3m: 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
08:26kzarHow do I return a new version of an array map with a key added?
08:26kzar(Is something like (merge {:a 1} {:b 2}) the best way?)
08:28Glenjamin,(doc assoc)
08:28clojurebot"([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)."
08:28Glenjaminoh, you mean specifically an array map?
08:29kzarGlenjamin: Ah that looks better
08:29Glenjamin,(assoc {:a 1} :b 2)
08:29clojurebot{:b 2, :a 1}
08:29Glenjamin,(assoc {:a 1} :b 2 :c 3)
08:29kzarty :)
08:29clojurebot{:c 3, :b 2, :a 1}
08:29Glenjaminskimming http://clojure.org/cheatsheet is usually a good way to find such things
08:34clgv$findfn {:a 1} :b 2 {:a 1 :b 2}
08:34lazybot[clojure.core/assoc]
08:34clgvGlenjamin: kzar: or asking lazybot for simple functions ^^
08:35kzarclgv: How does that work?
08:35clgvkzar: black magic - voodoo in fact ;)
08:35kzar$findfn "a" "b" "ab"
08:35lazybot[clojure.core/str]
08:36kzarmark me impressed
08:36clgvhas its limits though ;)
08:36clgv$findfn inc [1 2 3] [2 3 4]
08:37lazybot[]
08:37clgvthere is fails already :(
08:37clgv*it
08:37kzar$findfn (range 10) inc (range 1 11)
08:37lazybot[]
08:37kzaroh we did the same thing pretty much
08:38clgvit doesnt try argument permutations, so you have to guess the right order^^
08:38kzar$findfn inc (range 10) (range 1 11)
08:38lazybot[]
08:38kzar,(= (map inc (range 10)) (range 1 11))
08:38clojurebottrue
08:38clgvbut somehow it is not able to find `map` here. maybe it is due to providing a function
08:39clgv$findfn first [[1 2] [5 6]] [1 5]
08:40lazybot[]
08:40jonasen$findfn nil nil
08:40lazybot[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
08:40kzar(We should have a game whereby you have to name the function before the bot)
08:40kzarand it keeps score
08:42clgv$findarg map % [1 2 3] [2 3 4]
08:42lazybot[]
08:45clgv$movie avengers
08:45lazybot2012 - 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/
08:45clgvoh that one is activated as well
08:45kzar$movie The room
08:45lazybot1998 - 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/
08:45clgv$playing
08:50ppppaulthe room is great
08:51ppppaulso is troll2
08:52kzarWe watched it the other day, or attempted to, on our projector
08:52kzarI think we lasted about half way
09:05ppppaulneed more alcohol
09:05kzarheh
09:05ppppauli watch the movie sober, somehow. also, with a bunch of people who didn't know what it was
09:06kzaryou're a better man than I
09:07ppppauli thought it was really entertaining
09:37kzarIs there a way to get the absolute path to my project's root?
09:41roppongininjafellows, is anyone here programming in intellij idea using 'la clojure'?
09:41anna_nop
09:42anna_i use sublime only ...
10:04kandinskican 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:10clgvkandinski: a function you pass to `reduce` must have a 2-arity implementation
10:10kandinskiyes, I noticed
10:10kandinskiit's (and (map ...)) that I was looking for
10:10kandinskithanks
10:10clgvwhat? not really
10:11clgvkandinski: you are looking for (every? binarytree? ...)
10:11kandinskiof course
10:11clgvkandinski: btw. convert the `if` to an `or`
10:12clgv(or (nil? node) (and ...))
10:12kandinskiisn't that the same?
10:12kandinski(if a true b) is equivalent to (or a b) isn't it?
10:12clgvkandinski: functionally yes, but yours is more complex
10:13clgvexplicitely returning true/false in a then/else case is seldom concise
10:13kandinskiI mean, you are right, but that's not what is buggy in this code
10:13kandinskiis hwat I meant
10:13kandinskithanks
10:14clgvyeah. the reduce was. but that is detected already ;)
10:14kandinskiand more things
10:14clgvsince you seem to be new, I just added a few more hints ;)
10:14kandinskiI am new
10:19kzarjekyll to stasis is proving to be a pita
11:57sverihi, 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:58bob2did you give them the same name?
11:58eflynnis there a way to make a function like (fn [arg1 arg2] …) that returns a map of the arg names and their values?
11:58sveribob2: jeez, well, what should I say, stupidity is all around me :D
11:59sverithank you
12:00bob2heh
12:01bob2did that last week
12:01eflynnanyone know
12:01eflynnshould i make a macro
12:01bob2are you sure this is a thing you want
12:02bob2rather than just using like the normal arg syntax
12:02ddellacostaeflynn: 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:02eflynnddellacosta: yeah but i thought it would be baked into the language or something
12:02ddellacostaeflynn: well, you have the name of the args--you're the one defining the function.
12:03bob2is this for debugging?
12:03eflynnddellacosta: i want a constructor like Type(val1, val2, val3)
12:03ddellacostaeflynn: ...Clojure is not OO...?
12:03bob2which in clojure would most likely be (whatever val1 val2 val3)
12:03bob2how do you feel a map is involved?
12:03eflynnddellacosta: ok, (Type val1 val2 val3)
12:04ddellacostaeflynn: well, I suppose you could use a protocol and defrecord, which gives you a map of the args.
12:04cbpeflynn: (defrecord Type [val1 val2 val3])
12:05mi6x3mwhat's the idiomatic way of getting system properties?
12:05cbpSystem/getProperties
12:05mi6x3mdamn
12:09ambrosebswhat are the interfaces I need to implement to make my own ISeq?
12:10ambrosebsthis is a great discussion of what's needed for a map http://zeroem.github.io/pages/sometimes-you-feel-like-a-map.html
12:10ambrosebsanything for seqs?
12:11Bronsaambrosebs: IObj, ISeq and maybe Sequential
12:12Bronsathere's not much needed, really
12:12Bronsaalso IHashEq I guess
12:12ambrosebswhat I really want is to wrap existing ISeqs
12:12ambrosebsI guess that means ASeqs
12:13ambrosebs,(ancestors clojure.lang.ASeq)
12:13clojurebot#{clojure.lang.IPersistentCollection clojure.lang.IMeta clojure.lang.Seqable clojure.lang.IObj java.io.Serializable ...}
12:15Bronsaso IHashEq, ISeq, Seqable, IObj, IPersistentCollection, IMeta, Sequential
12:15ddellacostaambrosebs: does this help? public abstract class ASeq extends Obj implements ISeq, Sequential, List, Serializable, IHashEq {
12:15Bronsaambrosebs: assuming you don't want to implement all the java.util.* ones too
12:15ddellacostajeez that java code is kinda ugly
12:16Bronsajust don't look at it
12:16ddellacostaBronsa: haha
12:16ambrosebsok. I want the wrapper to do everything a normal seq can do.
12:18Bronsathen you want to implement (filter #(.isInterface %) (ancestors clojure.lang.ASeq)) :P
12:18ambrosebsmakes sense
12:19ambrosebsI assume the descendants of ASeq don't implement anything else usually?
12:19Bronsawell
12:19BronsaIPersistentList implements Counted for example
12:20Bronsano wait only PersistentList
12:21ambrosebsah
12:21BronsaIPL implements IPersistentStack, PL implements Coutned, IReduce, IPL
12:21BronsaCounted*
12:21ambrosebsok cheers, I can work with that.
12:22Bronsaambrosebs: those should just change the performance of some operations though
12:23ambrosebsI'm willing to break things like (= (class seq) PersistentList) but not (counted? seq)
12:23ambrosebs,counted?
12:23clojurebot#<core$counted_QMARK_ clojure.core$counted_QMARK_@1a38598>
12:43toxmeisterquick Q about: cljs.core.number?… shouldn't (number? (js/parseInt nil)) return false? (Since parseInt return NaN in this case)
12:44toxmeisteri know that goog.isNumber returns true for that case too, but just wondering what the reasoning was/is?
12:45toxmeisterseems like the only other way to check for valid parse results is to use (.isNaN js/Number x)
12:48GlenjaminNaN is of type "number"
12:49toxmeistertechnically yes, but semantically no...
12:49Glenjaminso is Infinity
12:50Glenjaminwhat is the number for? you might be better off with a range check if you can manage it
12:50Bronsa,(number? Double/NaN)
12:50clojurebottrue
12:50toxmeisteram working on some angular directives and parse attribute vals, but want to default to fixed vals if attribs are gibberish
12:51toxmeisteras i wrote, i know i can use the Number.isNaN way, but wondered about `number?`… np
12:55LangeOortjesIs 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:56ddellacostaLangeOortjes: 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:56ddellacostaLangeOortjes: and no, I never ended up getting it working.
13:25toxmeisterBronsa: 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:33umpaHow do I make each item in seq a list ? (#{1 2} #{3} #{} #{3} #{1} #{2} #{} #{2})
13:34hyPiRion(map seq my-list)
13:34hyPiRion"list"
13:40umpahyPiRion: cool
13:47jinks_-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:48jinks_-any suggestions?
13:53umpaHow do I filter sets with >= 2 items ([0 #{1 2}] [1 #{3}] [2 #{}] [3 #{3}] [4 #{1}] [5 #{2}] [6 #{}] [7 #{2}])
14:05danneuumpa: (for [[k v] coll, :when (<= 2 (count v))] v)
14:14mi6x3mare keywords always comparable?
14:14mi6x3mI have a weird issue possibly related to that
14:14umpadanneu: nice
14:14mi6x3m(t/simple-tree-model #(not= (first %) :example-group) last [[:example-group]]) gives an exception
14:15mi6x3mthe method is not supposed to branch out on something starting with :example-group
14:15mi6x3mbut it does
14:16danneuumpa: just saw your prev question. what are you trying to do in general?
14:20umpadanneu: give me a second to phrase it
14:25sveriI 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:27umpadanneu: conditional select from a nested list (partition 3 (range 10))
14:27umpa,(partition 3 (range 10))
14:27clojurebot((0 1 2) (3 4 5) (6 7 8))
14:30danneuumpa: so all you need to do is write `my-fn` so that (my-fn [a b c]) returns true or false?
14:30danneuso that you can (filter my-fn coll)
14:35umpadanneu: there is a caviat, the select depends on count of interection coll with list A
14:36danneuso 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:36umpadanneu: acutally what you said is exactly right
14:36danneu(filter (partial my-fn list-A) coll)
14:37danneu(defn my-fn [the-list element] ...)
14:40umpadanneu: just a sec
14:44kzaryogthos: With Selmer can you have a custom tag that avoids HTML escaping like you can with custom filters?
14:46whodidthis{{my-tag|safe}}
14:47kzarI mean from within the tag definition, I don't really want to change all my existing content
14:47kzarI tried wrapping the result of my tag function with [:safe ...] but no luck
14:49umpadanneu: what does partial do in this context ?
15:08deathknightIs a simple way to send JSON/Make an API call to use clj-http and cheshire together?
15:12danneuumpa: it returns a new function that's pretty much the original function but with list-A passed in as the first argument
15:13danneuumpa: (defn add [a b] (+ a b)), ((partial add 3) 7) => 10
15:14danneuyou can also write my filter example above as (filter #(my-fn list-A %) coll)
15:24yogthoskzar: there isn't a way to mark tag content as safe at the moment
15:29kzar:/ OK
15:37Glenjamindeathknight: in theory you can add request middleware to clj-http, but i don't know if such a thing exists
15:38deathknightGlenjamin: Where is the starting point for understanding how to send JSON with an HTTP request to interact with another services API?
15:39deathknightI 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:39Glenjaminwell, it should be as simple as calling whatever to-json function cheshire provides to generate the :body for clj-http
15:39deathknightclj-http: is :body referring to the actual <body> HTML element?
15:40deathknightI've made super basic GET requests with clj-http
15:40Glenjaminno, the body of an HTTP request
15:47umpadanneu: gotcha
15:47deathknightThank you for the help, Glenjamin
15:59patrickodI'm having a sub-dependency issue with core.async in a project of mine. https://gist.github.com/patrickod/1453740dbdb768f7f474
15:59patrickodwhere core.memoize is refering to clojure.core.cache/through which doesn't exist
16:00patrickodI'm using clojure 1.6.0 with the latest async according to the github page.
16:00Glenjaminpatrickod: if you run "lein deps :tree" it should tell you what is conflicting
16:08patrickodyep that's it. cemerick.friend has a conflicting version
16:10patrickodusing the :excludes parameter in the dependency definition though hasn't fixed the issue.
16:11Glenjamintry putting an explicit core.cache version in your project.clj
16:14johnwalkerhow do you run tests under a separate clojure version?
16:14johnwalkerfor example, a project written against 1.5.1 with tests running in 1.6.0
16:14patrickod@Glenjamin that worked! thanks so much
16:15johnwalkerfor reference, this is the issue: https://github.com/quil/quil/issues/88
16:16Glenjaminjohnwalker: take a look at https://github.com/xeqi/kerodon/blob/master/project.clj
16:18johnwalkerwhich lines? i'm familiar with multiple profiles, but doesn't that keep the code and the tests on the same clojure version?
16:18Glenjaminso you can run "lein with-profile +1.5 test", and it runs tests on 1.5
16:19Glenjaminand "lein all test" runs on 1.4, 1.5 and 1.6 in that example
16:19Glenjaminis that what you wanted?
16:19johnwalkerin this example, is the core code still in 1.4?
16:19johnwalkerwhen it's being tested in 1.6 and 1.5?
16:20Glenjamini don't get what you mean, the code works on 1.4, 1.5 and 1.6
16:21johnwalker nbeloglazov asked that quil be simultaneously compiled in 1.5.1 and tested in 1.6.0
16:21Glenjaminoh, i have no idea about AOT
16:21Glenjamini see what you mean now
16:22johnwalkerthanks though, that was my first interpretation as well
16:22Glenjamindo you know why i needs to aot?
16:23Glenjamin*it
16:23johnwalkeri don't, i wish i knew
16:23johnwalkerit's probably related to opengl
16:29umpaHow do I pull out list value according to index ? ,(map nth (partition 3 (range 10)) (0 1 2))
16:29umpa,(map nth (partition 3 (range 10)) (0 1 2))
16:29clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
16:30johnwalkerthats right
16:31johnwalkerbut
16:31johnwalkerreplace (0 1 2) with [0 1 2] or '(0 1 2)
16:31umpa,(map nth (partition 3 (range 10)) '(0 1 2))
16:31clojurebot(0 4 8)
16:31umpajohnwalker: nice
16:32johnwalkerany time
16:35umpa,(partition 3 (range 10))
16:35clojurebot((0 1 2) (3 4 5) (6 7 8))
16:36umpaI need to get lists given index
16:38umpaif (def index '(0 1)) output should be ((0 1 2) (3 4 5))
16:43gfredericks,(def my-lists '[(0 1 2) (3 4 5) (6 7 8)])
16:43clojurebot#'sandbox/my-lists
16:43gfredericks,(def index '(0 1))
16:43clojurebot#'sandbox/index
16:43gfredericks,(map my-lists index)
16:43clojurebot((0 1 2) (3 4 5))
16:43gfredericks^ depends on my-lists being a vector
16:45umpagfredericks: got it
17:36kzaryogthos|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.)
18:52gfredericksNow you too can have a namespace called .
18:52gfrederickshttps://github.com/gfredericks/dot-slash
19:09TimMc...
19:10TimMcAh, so this is avoiding the problem of actually having to load .clj from the classpath.
19:11gfredericksand also avoids needing a specific project just for that
19:11gfredericksseparation of concerns and all that
19:11gfredericksI was doing it in a user.clj from my repl-utils lib before
19:12gfredericksbut that means nobody else can do it unless they want the exact same set of functions/macros that I had there
19:29michaniskin"I made this for me stop trying to want it."
19:29michaniskinlol
19:29michaniskini like how weird your github is dude
19:31gfredericksI was just thinking about trying to make that repo something somebody might think of using
19:31gfredericksI'm having a hard time not talking about that bg macro all the time
19:32michaniskinyup, i hear ya
19:33michaniskini have also done something similar in my build tool
19:33michaniskinsuper useful
19:35michaniskini like how you have a sort of job control even
19:35michaniskini didn't go that far with it :)
19:35michaniskinbut it's surprisingly similar: https://github.com/tailrecursion/boot-ng/blob/master/boot-core/src/tailrecursion/boot/util.clj#L243-L248
19:36michaniskinyou even have a with-pre-wrap macro in a core namespace
19:37gfredericksyeah mine is oriented toward regular repl usage
19:37gfredericksit's basically a future but with lots of repl sugar
19:39michaniskinA+
19:39michaniskinwould evaluate again
19:40gfredericksin the Future some nrepl middleware should make it possible to background things after they've already started evaling
19:41michaniskinyou could have it just background everything, maybe?
19:41michaniskinlike every expression, and then deref the future
19:41michaniskinwhich would then be interruptible?
19:42michaniskini guess that would be crazy because you couldn't interrupt the evaluation anymore lol
19:43gfredericksyeah; there's a lot of subtleties
19:43Glenjamin(cancel *1)
19:44Glenjaminsomethink akin to bash job control would be neat
19:44michaniskini think a lot of unnecessary limitations are imposed by the line-oriented terminal display, too
19:44gfredericksthe flipside is you could also have unrelated threads (e.g., a web server) pause and expose debug repls that you could hook into
19:44michaniskinthis whole issue of bg vs fg is mostly just an artifact of that
19:45gfrederickshmmm
19:45michaniskinif the repl interface was in something document oriented like a webpage, you'd be able to just do each evaluation async
19:45gfredericksyeah I can see how something like session would remove that distinction
19:45michaniskinit could insert the result in between any subsequent expressions, whenever it completes
19:45Glenjaminit is generally much easier to think linearly though
19:46michaniskinit's still linear
19:46michaniskinit just updates the view async
19:46michaniskinbut you still get a sequential record of what you did
19:46Glenjamini suppose you could do it a bit like light-table
19:46gfrederickswith 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:46Glenjaminwhere the result appears next to the command
19:47gfredericksso you don't have to do find the result
19:47Glenjaminin fact, LT is already set up reasonably well for this
19:47Glenjaminexcept it only evals one thing at once
19:48michaniskini've had some performance issues with it, like if i accidentally evaluate something that returns a large amount of data
19:48michaniskinit locks up for a while as it figures out how to print it all, i guess
19:48Glenjaminyeah, i've had that a bit
19:49Glenjaminit seems to know about infinite sequences, and truncate
19:49Glenjaminbut generally large things are a bit annoying
19:49michaniskini was working with xml, which can get pretty huge for a pretty-printer to handle
19:49Glenjamini had about 600k items in a map :D
19:50michaniskingood greif
19:50michaniskin*grief
19:50Glenjaminsurprisingly, it coped ok
19:50gfredericksthe new cider inspect feature is supposed to make that better
19:51Glenjaminis that done as nrepl middleware?
19:51Glenjamini'm hoping the plugin api docs will improve soon for LT, then i can really start hacking on it properly
19:51michaniskinis anyone here experienced with immutant, by any chance?
19:55jcrossley3-awaymichaniskin: gfredericks: weirdly, i happen to be noodling with some Killer Queen tab, so i'm here. wassup? :)
19:55umpa,(filter #(not= '(or 0 1) %)'((0 1 2) (3 4 1) (6 7 8)))
19:55clojurebot((0 1 2) (3 4 1) (6 7 8))
19:56umpaHow do I filter based on multi conditions ?
19:56michaniskinjcrossley3-away: are there any docs or examples of using immutant without leiningen?
19:57Glenjamin,(filter #(or (not= 1 %) (not= 0 %))'((0 1 2) (3 4 1) (6 7 8)))
19:57clojurebot((0 1 2) (3 4 1) (6 7 8))
19:58umpaGlenjamin: my code is not clear, I need to yank any lists with those numbers
19:58jcrossley3-awaymichaniskin: 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:58noonianbut you're comparing lists with numbers so they'll never be equal
19:59michaniskinjcrossley3-away: i'm interested in immutant primarily because of the work you guys did with getting the classloader isolation to work with clojure
19:59noonian,(for [l '{(0 1 2) (3 4 1) (6 7 9))] (filter #(or (not= 1 %) (not= 0 %)) l))
19:59clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
19:59metellus,(filter #{0 1} '((0 1 2) (3 4 1) (6 7 8)))
19:59clojurebot()
19:59Glenjamin,(remove #(or (.indexOf % 0) (.indexOf % 1)) '((0 1 2) (3 4 1) (6 7 8)))
19:59clojurebot()
20:00michaniskinjcrossley3-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:00jcrossley3-awaymichaniskin: correct. they accepted tcrawley-away's patch that cleared those thread locals
20:00umpacan the dependancy be a list ?
20:00Glenjaminumpa: clojure doesn't have efficient tests for something contained in a list, as this cannot be done efficiently - could you use sets?
20:01noonian,(filter (partial not-any? #{0 1}) '((0 1 2) (3 4 1) (6 7 8)))
20:01clojurebot((6 7 8))
20:01TEttinger(inc noonian)
20:01lazybot⇒ 5
20:01Glenjaminoh, neat
20:01umpanice
20:02michaniskinjcrossley3-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:03michaniskinjcrossley3-away: it's basically a way to run clojure scripts without the jvm startup penalty of clojure
20:03noonian,(map (partial filter (comp not #{0 1})) '((0 1 2) (3 4 1) (6 7 8)))
20:03clojurebot((2) (3 4) (6 7 8))
20:04jcrossley3-awaymichaniskin: 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:05michaniskinjcrossley3-away: thanks!
20:05jcrossley3-awaymichaniskin: np. good luck!
20:10umpanoonian: nice, I don't get how partial works here
20:12noonianits mapping filter onto each element list, like (for [sublist '((0 1 2) (3 4 1))] (filter (comp not #{0 1}) sublist))
20:12noonianyou could use #(filter (comp not #{0 1}) %) instead of the partial
20:15gfredericks(remove #{0 1} %)
20:16nooniannice
20:19umpa,(map (remove #{0 1} %) '((0 1 2) (3 4 1) (6 7 8)))
20:19clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0:0)>
20:19noonian#(remove #{0 1} %)
20:20umpanice
21:00whilois it safe to use an externally updated atom as app state in om, that is which is not updated through om/transact! ?
21:14nDuffwhilo, absolutely.
21:15whilonDuff: cool,have you done it as well? seems to work so far
21:17nDuffwhilo, yes.
21:18umpawhy does this work ?
21:18umpa,(filter (partial not-any? #{100}) '((5000) (100 50)))
21:19clojurebot((5000))
21:19umpaand this doesnt
21:19umpa,(filter (partial not-any? #{100}) '((5000 100 50))
21:19clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:19whilonDuff: thx, what do you build with om?
21:19nDuffwhilo, something that isn't public.
21:20umpanoonian:
21:21nDuffumpa, well, you're only asking not-any? about a single list, and one member of that list is 100
21:21nDuffumpa, ...so, of course nothing matches.
21:21nDuff,(filter (partial not-any? #{100}) '((5000 100 50)))
21:21clojurebot()
21:22nDuff,(filter (partial not-any? #{100}) '((5000 50)))
21:22clojurebot((5000 50))
21:22noonianjust missing an ending paren i think
21:23johnwalker,(
21:23clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:23johnwalker,(,)
21:23clojurebot()
21:25umpaso this should work then
21:25umpa,(filter (partial not-any? #{100}) '(5000 100 50))
21:25clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
21:26gfredericks,(doc not-any?)
21:26clojurebot"([pred coll]); Returns false if (pred x) is logical true for any x in coll, else true."
21:26johnwalker,(not-any? #{100} '(1 2 3))
21:26clojurebottrue
21:26johnwalker,(not-any? #{100} '(100))
21:26clojurebotfalse
21:27johnwalker,(filter (not-any? #{100}) '((5000 100 50)))
21:27clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/some>
21:27johnwalkeroh, yeah thats what it's for
21:27umpa?
21:28johnwalkerthe partial at the beginning
21:28umpa,(filter (not-any? #{100}) '((5000 100 50)))
21:28clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/some>
21:28johnwalkerright, throw the partial back in and it works
21:29umpa,(filter (partial not-any? #{100}) '(5000 100 50))
21:29clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
21:29johnwalkerno, you threw out the parens
21:29umpa,(filter (not-any? #{100}) '(5000 100 50))
21:29clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/some>
21:29johnwalker,(filter (partial not-any? #{100}) '((5000 100 50)))
21:29clojurebot()
21:30umpayeah, trying to figure whats going on
21:31johnwalkerfilter asks for all elements for which the predicate is true
21:31johnwalkeryou're asking for all elements that don't contain 100
21:31noonian,(filter (partial not-any? #{100}) (list (5000 100 50)))
21:31clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
21:31johnwalker,(filter (partial not-any? #{100}) '((5000 100 50) (1 2 3)))
21:31clojurebot((1 2 3))
21:32johnwalkerso the second one list doesn't contain 100 and is returned
21:32johnwalkersecond list *
21:32noonian,(filter (partial not-any? #{100}) [[1 2 3]])
21:32clojurebot([1 2 3])
21:32noonianyeah, lists are annoying in examples because you have to quote them
21:33umpa,(filter (not-any? #{100}) '(5000 100 50)) this should return ()
21:33clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/some>
21:33noonian,(not-any? #{100} [100 50 500])
21:33clojurebotfalse
21:33noonianyou left out partial there, not-any? expects two arguments
21:34noonianand the list should be a list of lists, missing the outer parens
21:35umpa,(filter #(not-any? #{100} %) '(5000 100 50))
21:35clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
21:35noonian'(5000 100 50) should be '((5000 100 50))
21:35umpa,(filter #(not-any? #{100} %) '((5000 100 50)))
21:35clojurebot()
21:40umpa(doc not-any?)
21:40clojurebot"([pred coll]); Returns false if (pred x) is logical true for any x in coll, else true."
21:40umpa,(#(not-any? #{100} %) '(5000 100 50))
21:40clojurebotfalse
21:41umpa,(#(not-any? #{100} %) '((5000 100 50)))
21:41clojurebottrue
21:43umpa(source not-any?)
21:43umpa,(source not-any?)
21:43clojurebot#<SecurityException java.lang.SecurityException: denied>
21:51deathknightgonna need some virtual friends that stay up all night as I slam energy drinks and do some 'grammin
21:53umpa(doc grammin)
21:53clojurebotCool story bro.
21:53deathknightwhat does doc do?
21:53umpa(doc doc)
21:53clojurebot"([name]); Prints documentation for a var or special form given its name"
21:53deathknightbetter question: where can I find out so I dont have to ask?
21:53deathknightnice, thanks for answering
21:53deathknight(inc doc)
21:53lazybot⇒ 1
21:54deathknight(doc inc)
21:54clojurebot"([x]); Returns a number one greater than num. Does not auto-promote longs, will throw on overflow. See also: inc'"
21:54deathknight:)
21:54deathknightassuming you use emacs - whats your favorite color theme?
21:56umpadeathknight: darkula
22:11deathknightcurrently 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:12cbp`i like leuven
22:12deathknightwhat is leuven?
22:13cbp`a color theme
22:13deathknightooh
22:18amalloyi use tty-dark, deathknight
22:18amalloybut i imagine that's not very popular
22:20deathknightlooks neat. some colors are a bit too lego-ish for me
22:20deathknightbut glad you have one you enjoy :D
22:23deathknightdoes 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:23clojurebotIt's greek to me.
22:27MD223Hey 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:27MD223s)" - any suggestions on alternative solutions?
22:38amalloythat code won't overflow the stack. you're doing something else weird that you haven't included in the problem statement
22:39amalloyif nothing else, MD223, a real stacktrace would be helpful, for example pasted to refheap.com. code would be nice too, if you can
22:51john2xhow do I selectively update items in a list? something like this: https://www.refheap.com/86595
22:54bob2are you sure you don't want a map instead
22:55noonianjohn2x: https://www.refheap.com/86597
23:57umpa,(partition 3 (range 10))
23:57clojurebot((0 1 2) (3 4 5) (6 7 8))
23:57umpa,(let [x (partition 3 (range 10))](concat (list (ffirst x) (first (last x))) (list (last (first x)) (last (last x)))))
23:58clojurebot(0 6 2 8)
23:58umpaany better way to get those values ?