#clojure logs

2015-04-01

00:00justin_smithcodesine: fyi you can do (repeat 10 [])
00:00codesine[[] [] [] [] [] [] [] [] [] []] how would i change the 0th element of this, and also modifying the whole list
00:00codesineOH
00:00bbloomcodesine: if you have a vector, you can use assoc
00:00codesine(into [] (repeat 10 []))
00:00bbloom,(vec (range 10 []))
00:00clojurebot#error{:cause "clojure.lang.PersistentVector cannot be cast to java.lang.Number", :via [{:type java.lang.ClassCastException, :message "clojure.lang.PersistentVector cannot be cast to java.lang.Number", :at [clojure.lang.Numbers lt "Numbers.java" 221]}], :trace [[clojure.lang.Numbers lt "Numbers.java" 221] [clojure.core$_LT_ invoke "core.clj" 870] [clojure.core$range$fn__4592 invoke "core.clj" 2899...
00:00justin_smith,(update-in (vec (repeat 10 [])) [3] conj :a)
00:00clojurebot[[] [] [] [:a] [] ...]
00:01codesineah i was using (into [])
00:01codesinevec looks cleaner
00:01justin_smithcodesine: either way
00:01justin_smiththat's not the important part here
00:02codesinearghhh i was struggling with this for a day xD
00:02justin_smithassoc, as bbloom suggests, is decent if you are replacing an index
00:02justin_smithcodesine: glad we could help
00:02codesinecuz when i was conj it naturally would just return a single element and not return the whole thing
00:02bbloom,(assoc [0 0 0] 1 5)
00:02clojurebot[0 5 0]
00:02bbloom,(update [0 0 0] 1 inc)
00:02clojurebot[0 1 0]
00:02codesineyeah i want to add to it
00:02codesinethe update-in thing works for me
00:02codesinecuz i'm doing a bucket list
00:02codesinexD
00:02bbloomoh man, i am so excited about ##(doc update)
00:02lazybotjava.lang.RuntimeException: Unable to resolve var: update in this context
00:02bbloom(doc update)
00:02clojurebot"([m k f] [m k f x] [m k f x y] [m k f x y ...] [m k f x y ...]); 'Updates' a value in an associative structure, where k is a key and f is a function that will take the old value and any supplied args and return the new value, and returns a new structure. If the key does not exist, nil is passed as the old value."
00:03bbloomhurray
00:03justin_smithlazybot doesn't have update yet, but clojurebot does
00:06codesinehi bbloom
00:06codesinei have (update-in) but i don't have (update)
00:06codesine(doc update) --> returns nil
00:06clojurebot"([m k f] [m k f x] [m k f x y] [m k f x y ...] [m k f x y ...]); 'Updates' a value in an associative structure, where k is a key and f is a function that will take the old value and any supplied args and return the new value, and returns a new structure. If the key does not exist, nil is passed as the old value."
00:06whodevilhello, I was just watching a video on clojure programming where the guy put an arrow on a defrecord, specifically (defrecord some-record [state]) and then he called it like (->some-record the-state). My question is, does the arrow have some sort of significance here?
00:06justin_smithcodesine: update is new in 1.7-alpha5 I think
00:06codesineOHH
00:06codesineso that's why bbloom's example did not work for me
00:06justin_smithwhodevil: it's part of the name
00:06codesinejust your update-in
00:06codesinekk
00:07justin_smithwhodevil: when you call defrecord, it will create a ->YourRecord function for creating it with
00:07justin_smithalso map->YourRecord for making one out of a map
00:08whodevilneat, I wonder where I could find better documentation on that. I was looking at the protocols section of the clojure.org site, and it didn't have anything about it. I suppose I should really be looking at the defrecord section
00:08whodeviljustin_smith: thanks
00:08TEttingerjustin_smith, bbloom: for extreme googlability, I'm thinking of calling the dungeon crawler clochu (lochu is Polish for dungeon)
00:09TEttingerit's also a bit of a pun on the pokemon-like nature of having 200 playable characters...
00:10justin_smithTEttinger: only if you map nil to a mob called MissingNo
00:11TEttingerha
00:11justin_smithand then ensure that at least one bug in the game leads to that mob being instantiated :)
00:11TEttingerI'll use Double/NaN as a key
00:11justin_smithhahahaha
00:11TEttinger,(hash Double/NaN)
00:11clojurebot2146959360
00:11TEttingerwow
00:12justin_smith,(hash-map Double/NaN :a Double/NaN :b Double/NaN :c)
00:12clojurebot{NaN :a, NaN :b, NaN :c}
00:12TEttingeryesssss
00:12justin_smith#YOLO
00:13justin_smith,(hash-map Double/NaN :a Double/NaN :a Double/NaN :a Double/NaN :a :BAT :MAN)
00:13clojurebot{NaN :a, NaN :a, NaN :a, NaN :a, :BAT :MAN}
00:14justin_smithstupid clojure tricks
00:15hyPiRion,(hash-set Double/NaN :a Double/NaN :a Double/NaN :a Double/NaN :a :BAT :MAN)
00:15clojurebot#{NaN NaN NaN NaN :MAN ...}
00:15justin_smiththat's too bad
00:16hyPiRionclose nough
00:16TEttinger&(hash-set Double/NaN :a Double/NaN :a Double/NaN :a Double/NaN :a :BAT :MAN)
00:16lazybot⇒ #{NaN NaN NaN NaN :MAN :BAT :a}
00:16hyPiRionthe illusive manbat
00:16TEttingerI can never remember is illusive is a real word or if it's always a misspelling of elusive
00:16justin_smithone of the under-utilized batman characters actually
00:17justin_smithelusive: hard to find because hidden illusive: hard to find because not there
00:17justin_smithI found a great phrase the other day that should really be a rap album title:
00:17justin_smithILLOCUTIONARY FORCE
00:17TEttinger(inc justin_smith's vocabulary)
00:17lazybot⇒ 1
00:18justin_smithhyPiRion: TEttinger: man-bat http://th09.deviantart.net/fs71/300W/f/2011/338/9/e/wsc_041211_my_dcnu___man_bat_no_1_by_eiledon-d4i6ddl.jpg
00:18TEttingeris illocution as to eloction as illusive is to elusive?
00:18justin_smith$dict illocution
00:18lazybotjustin_smith: noun: The aim of a speaker in making an utterance as opposed to the meaning of the terms used.
00:18justin_smithit's what you meant, not what you said
00:19TEttingerah!
00:19justin_smithillocutionary force is the pressure of the speech act
00:19TEttingerthe heat of the beats
00:19justin_smithTEttinger: ill, straight up sick
00:19justin_smithTEttinger: http://ccat.sas.upenn.edu/~haroldfs/dravling/illocutionary.html
00:20TEttingerjust make the rap album all passive aggressive gangsterism
00:21justin_smithTEttinger: it's actually very apropriate to rap, despite the silly pun, because rap is all about valuing the illocutionary force over any prescriptive definition or logic
00:21TEttingeryep
00:22TEttingerall right, lein new app clochu
00:22TEttingerwait
00:22TEttingersome kind of namespace
00:24TEttingerlein new app ☃/clochu
00:24TEttingerI wonder if that works...
00:24justin_smiththat's a great org
00:25justin_smithand will be a pain in the ass to require in ns forms :)
00:25TEttingerjava.io.FileNotFoundException: C:\Users\user\Documents\GitHub\DungeonRising\clochu\src\?\clochu.clj (The system cannot find the path specified)
00:25TEttingerit gets uh confused
00:25justin_smithTEttinger: file system can't handle utf8?
00:25TEttingerand spits a long exception :-(
00:25TEttingerwindows
00:25justin_smithor maybe something in between
00:26justin_smithTEttinger: I thought windows had decent il8n
00:26TEttingerI even did a chcp 65001 beforehand to use utf-8 in terminal
00:28ebbflowgolearning clojure, found an example https://gist.github.com/ebbflowgo/74978338a15830b3b608 ..
00:29ebbflowgowhy would they use a set for the awards, my understanding is that a set is like a dictionary, each item can only appear once
00:29justin_smithright
00:29ebbflowgonvm
00:29justin_smith?
00:29ebbflowgoi didn't see the string groupings
00:29ebbflowgoso it's saying each string has to be unique
00:29ebbflowgonot each word
00:29justin_smithright
00:29cflemingjustin_smith amalloy: So according to puredanger on the ML, there's no plan to make #object and #error readable, but tagged-literal should be able to be used to get the data out
00:29ebbflowgojustin_smith: thanks for looking
00:30amalloy&dump
00:30lazybotjava.lang.RuntimeException: Unable to resolve symbol: dump in this context
00:30amalloyoops
00:30justin_smithcfleming: makes sense I guess
00:30cflemingI'm waiting for illocution to be used as a transducer function at some point
00:30justin_smithcfleming: haha
00:30cflemingI just illocute my educer and I'm good to go
00:31justin_smithcfleming: a promise is a kind of illocution
00:31cflemingjustin_smith: Now you're just messing with me
00:31justin_smithnot in programming, in speech acts
00:32cflemingspeech acts sounds like something people should do in the privacy of their own homes.
00:32justin_smithhehe
00:32aduhaha
00:32codesine(def k 1) (def k (inc k)) <-- for updating value, is this idiomatic or no
00:32codesinei feel like something is wrong about it...
00:32codesineidk why, even tho that works :|
00:32justin_smithit's the messiness that linguists need to deal with because they must distinguish what the language says things mean formally, and what native speakers in some context know it means :)
00:33justin_smithso we distinguish the speech act from the linguistic construction
00:33aducodesine: it's fine, but you're not mutating the value, just the binding
00:33justin_smithcodesine: no, that's not a good idea unless in a repl just doing dev
00:33codesineoh, i want to mutate the value
00:33codesinehm...
00:33justin_smithif a top level value needs to change, us an atom or ref or agent
00:33aducodesine: then you're doing it wrong
00:33codesineyeah i felt like i'm doing it wrong
00:34cfleming,(binding [*data-readers* {'error tagged-literal}] (read-string (pr-str (Exception. "except"))))
00:34clojurebot#error{:cause "Unable to resolve symbol: tagged-literal in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: tagged-literal in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: tagged-literal...
00:34codesineah i did read a little bit about atom, and swap! etc
00:34codesinebut mostly from code I saw laying around -- i wasn't sure the intention of it
00:34cflemingHmm, maybe clojurebot's not up to date
00:34codesineI will try atom
00:34justin_smithcodesine: also, we don't often actually need that top level state - usually we can replace it with an updated arg in a recursive call
00:35codesineoh yes
00:35justin_smith,(clojure-version)
00:35clojurebot"1.7.0-master-SNAPSHOT"
00:35codesineI think I am just breaking things around to see how to do things
00:35justin_smithif we could query uptime we could know which snapshot...
00:35codesineI'm first going to do the updating in atom, then break it down into proper recursion
00:35cflemingjustin_smith: I guess that went it with the reader conditional fix a couple of days ago
00:36cflemings/went it/went in/
00:37cflemingclojurebot: how long have you been awake?
00:37clojurebotTitim gan éirí ort.
00:37cflemingThanks.
00:37justin_smithcodesine: makes sense. Most of the time when I use an atom I am creating a debug container to put locals into. It's like println++
00:37justin_smithor maybe (inc println)
00:37justin_smithor whtever
00:38codesineyea!
00:38codesinefor debug
00:38codesineon account of me being a newbie
00:38codesine;_;
00:38justin_smith(def debug (atom [])) then inside some function (swap! debug conj x)
00:38justin_smiththen you can go through @debug and see what all the values were
00:38justin_smithafter some calls
00:39justin_smithand also do things to those values (eg if they were a nested json response from a server...)
00:40justin_smithTEttinger: r/askhistorians is funny right now http://www.reddit.com/r/AskHistorians/comments/30z1fi/would_king_arthur_and_his_knights_really_have_had/
00:43TEttingeryes.
01:06justin_smithoh, and https://com.google is live
01:06justin_smithit's a doorway into the mirror web
01:07justin_smitheven all the images are reversed
01:07rpauloheh
01:07justin_smith(I verified this by doing a elgoog image search for "left"
01:07codesinehey justin I wrote something really naiive (as a learning experience,) but I have a particular question about a result I am receiving
01:07justin_smith)
01:08codesinehttp://pastebin.com/0cJR4fBt
01:08amalloyjustin_smith: sincerely disappointed it doesn't proxy all of the links i click through their search bar
01:08codesinewhen I pass (s [4]) it returns nil
01:08codesineand the atom is updated properly
01:08justin_smithamalloy: clearly half assed
01:08codesinebut when I pass a double digit (s [44]) it updates properly
01:08codesinebut it returns the atom result as a list (instead of nil)
01:09codesinesort of like when i run swap! directly
01:09justin_smithcodesine: and what ends up in the buckets?
01:09codesinethe proper results
01:09codesine[[4] [44]...
01:09justin_smithahh sorry, I was typing here but reading your code
01:09codesinei'mjust confused why if it's scenario one i get nil, and scenario 2 i get the swap return value
01:10justin_smithcodesine: you have two ifs
01:10justin_smiththe first one returns, but you never get the value out
01:10justin_smithbecause the second one returns nil, and that's the return value of the function
01:10codesineOHHHH
01:10codesinecuz in clojure the last thing that runs
01:10codesineis what's returned
01:10justin_smithmaybe you want an else
01:10codesineand since scenario 2 doesn't run
01:10codesineit's just nil
01:10justin_smithor a cond
01:10codesineright?
01:10justin_smithright
01:10codesineahh!
01:11codesinehaha xD
01:11codesinei will do a cond
01:11codesineas a challenge I am trying to implement radix sort (:
01:11justin_smithcodesine: also, pretty please, clojure code is much easier to read when you write conventionally, and that means no hanging ) ever
01:11justin_smiththanks
01:11codesineshoot
01:11codesinei didn't know
01:12justin_smithcodesine: I didn't assume you knew, but just letting you know, it's easier for us old timers to read "normal" code
01:13codesinei'm reformatting it rq and will pass it by to see if it's proper
01:13codesinei want to develop good habits
01:13codesine:D
01:13justin_smithcodesine: lein kibit is good for that
01:13justin_smithit's a plugin that checks for good style
01:14justin_smithnot 100% uncontroversial, but still helpful
01:14codesinehttp://pastebin.com/iapy3UNb
01:14codesineis that proper
01:14codesineoh ok i'll check out kibit
01:14codesineso I can put stuff on new line, just no hanging )'s
01:15justin_smithcodesine: the two things I'd change are that the (do ...) blocks are redundant when they only have one item in them, and the ) starting line 10 belongs on the line above
01:15justin_smithright
01:15codesineah I had some really nasty print statements prior
01:15justin_smithand it looks like you are using emacs auto-indent, or something that follows it closely enough
01:15codesineso I no longer need do, bot it
01:15justin_smithmakes sense
01:15codesineyeah i'm doing it in emacs
01:15codesinebut at times i did key in enter
01:16codesinecuz I was trying to get my bearings straight :(
01:16codesineso I made those unwanted )'s lol
01:16justin_smithit's just a convention thing, but it's nice to follow
01:16codesineI see no reason why I shouldn't aim to get accustomed xD
01:16codesinethank you thank you
01:17justin_smithalso, (swap! buckets (fn [b] (update-in b [0] conj n)) is the same as (swap! buckets update-in [0] conj n) and I think the latter is nicer
01:17justin_smithswap! does the chaining at the end just like update-in does
01:18codesinehm
01:18codesineso I would use (fn) when i want multiple args i guess
01:18codesineer
01:18codesinethat's notrigght
01:18codesinedisregard my last statement
01:18codesinesec reading
01:18justin_smithno, you don't need fn in that context, unless the thing swapped shouldn't be the first arg
01:19codesineah!
01:19codesineah chaining at the end
01:19codesineso it's like it called it like so
01:19codesineupdate-in <atom> [0] conj n
01:19justin_smithright
01:20codesinesweet
01:22codesineelse
01:22justin_smithno no, cond
02:23tsdhHi. Can anyone tell me the difference between sequence and eduction? From what I can see, they are interchangeable and both compute their result lazily. Is the only diff that sequence returns a lazy seq which caches its contents whereas with eduction the returned eduction will re-compute its contents on every call?
02:31tsdhNever mind. I'll ask on the list. I guess other's will have the same question and then that's easier to access than an IRC log.
02:45TEttingerjustin_smith: can you help me out with this reflection warning?
02:45TEttingerReflection warning, rogue/like/clochu.clj:22:16 - call to method generate can't be resolved (target class is unknown).
02:46TEttingergenerate is called on a java object that I got with this: (def dg (DungeonGen.))
02:46TEttingerand I'm not sure how to type hint this or where
02:47TEttinger(should there be a type hint before the object in (.generate dg etc etc2) or should there be one when it's deffed?)
02:47TEttingerhey Bronsa
02:48Bronsahi
02:48amalloyyou can't super-easily hint def'd objects, TEttinger, iirc. i'd just put one where you call it
02:48amalloyor let-bind it and hint the binding
02:48TEttingerah ok thanks amalloy
02:48TEttingerit's used later
02:48TEttingerso def seems to make sense here
02:48TEttinger(inc amalloy)
02:48lazybot⇒ 248
02:49amalloyi mean, suppose you are writing (.f dg) (.g dg) (.h dg)
02:49amalloyyou do'nt want to hint it three times, so you could write (let [^Whatever x dg] (.f x) (.g x) (.h x))
03:13codesinejustin!
03:14codesineI'm doing a learning test and for some reason if place a do with a map call then a comment, the atom doesn't get populated
03:14codesinehttp://pastebin.com/frZYTfwi
03:14codesineif the map call is the last item in the do, it populates
03:14codesineor ofc if i don't place it in a do
03:15codesinewhy does the map call not populate the atom if there is another item afterwards in the do statement in the above pastebin :(
03:17mavbozo_codesine: map returns lazyseq
03:17slipsetcodesine: use doseq instead of map>
03:17slipsetor if you really, really want to use map, use mapv
03:17slipset~doseq
03:17clojurebotdoseq is like for, but for side effects instead of values
03:17codesineah
03:17slipset~mapv
03:17clojurebotIt's greek to me.
03:18mavbozo_i guess justin_smith is sleeping
03:18slipset@(http/get "https://www.testgjensidige.no/eai/op?TAM_OP=login_success&amp;ERROR_CODE=0x38cf05e7&amp;URL=%2Fpkmslogin.form&amp;AUTHNLEVEL=&quot; {:headers {"Cookie" "PD-S-SESSION-ID=1_EZhDA6iMReib5ZO+/iMRU0l2cKLgHxiKbYKC79WF542F8TwOmWo=_AAAAAAA=_DjPMX2eJG7eL90cloV0Y5I6MXdc=; Path=/; Secure"}})
03:18slipset@(http/get "https://www.testgjensidige.no/eai/op?TAM_OP=login_success&amp;ERROR_CODE=0x38cf05e7&amp;URL=%2Fpkmslogin.form&amp;AUTHNLEVEL=&quot; {:headers {"Cookie" "PD-S-SESSION-ID=1_EZhDA6iMReib5ZO+/iMRU0l2cKLgHxiKbYKC79WF542F8TwOmWo=_AAAAAAA=_DjPMX2eJG7eL90cloV0Y5I6MXdc=; Path=/; Secure"}})
03:18slipset@(http/get "https://www.testgjensidige.no/eai/op?TAM_OP=login_success&amp;ERROR_CODE=0x38cf05e7&amp;URL=%2Fpkmslogin.form&amp;AUTHNLEVEL=&quot; {:headers {"Cookie" "PD-S-SESSION-ID=1_EZhDA6iMReib5ZO+/iMRU0l2cKLgHxiKbYKC79WF542F8TwOmWo=_AAAAAAA=_DjPMX2eJG7eL90cloV0Y5I6MXdc=; Path=/; Secure"}})
03:18slipsethttps://clojuredocs.org/clojure.core/mapv
03:18slipsetwow, crazy cutbuffer
03:20mavbozo_$grim mapv
03:22codesineah, mapv works for me well in this case @slipset
03:22codesinedoseq I would have to change things around a bit more thank you!
03:27Seylerius,(defn sub-seq [coll] (loop [remainder coll sub [] longest-sub []] (cond (empty? remainder) longest-sub (empty? sub) (recur (rest remainder) [(first remainder)] longest-sub) (> (first remainder) (last sub)) (recur (rest remainder) (conj sub (first remainder)) (if (> (count sub) (count longest-sub)) sub longest-sub)) :else (recur (rest remainder) [(first remainder)] (if (> (count sub) (count longest-sub)) sub longest-sub)))))
03:27clojurebot#'sandbox/sub-seq
03:27Seylerius,(sub-seq [1 0 1 2 3 4 0 4 5])
03:27clojurebot[0 1 2 3 4]
03:28Seylerius,(sub-seq [1 0 1 2 3 0 4 5])
03:28clojurebot[0 1 2 3]
03:29Seylerius,(sub-seq [5 6 1 3 2 7])
03:29clojurebot[5 6]
03:29Seylerius,(sub-seq [2 3 3 4 5])
03:29clojurebot[2 3]
03:30Seylerius,(sub-seq [7 6 5 4])
03:30clojurebot[7]
03:35Seylerius,(defn sub-seq [coll] (loop [remainder coll sub [] longest-sub []] (cond (empty? remainder) longest-sub (empty? sub) (recur (rest remainder) [(first remainder)] longest-sub) (> (first remainder) (last sub)) (recur (rest remainder) (conj sub (first remainder)) (if (and (> (count (conj sub (first remainder))) (count longest-sub)) (> (count (conj sub (first remainder))) 2)) sub longest-sub)) :else (recur (rest remainder) [(first
03:35Seyleriusremainder)] longest-sub))))
03:35clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
03:51Seylerius,(defn partitioner [x coll] (loop [remainder coll result []] (cond (empty? remainder) result (>= (count remainder) x) (recur (drop x remainder) (conj result (take x remainder))))))
03:51clojurebot#'sandbox/partitioner
03:51Seylerius,(partitioner 3 (range 8))
03:51clojurebotnil
03:51SeyleriusHrm.
03:51SeyleriusThat's puzzling.
03:51SeyleriusIt works for &(partitioner 3 (range 9))
03:53Ricardo-ArgesSeylerius: but you're not handling the < case, are you?
03:54Ricardo-ArgesSo there's no condition to deal with the remaining [6 7]
03:55SeyleriusOh... I see the problem. Yeah, it's not recurring the last time.
03:55SeyleriusThis whole thing can be streamlined
03:57Seylerius,(defn partitioner [x coll] (loop [remainder coll result []] (if (>= (count remainder) x) (recur (drop x remainder) (conj result (take x remainder))) result)))
03:57clojurebot#'sandbox/partitioner
03:57Seylerius,(partitioner 3 (range 8))
03:57clojurebot[(0 1 2) (3 4 5)]
03:57SeyleriusThere we go.
03:57SeyleriusAlso, what's the syntax to make clojurebot evaluate something in the middle of a line?
03:57SeyleriusI know lazybot will handle this just file: ##(= 3 4)
03:57lazybot⇒ false
03:58SeyleriusWas it &&(partitioner 3 (range 9))?
03:58SeyleriusNo.
03:58SeyleriusHmm...
04:07tsdhHow can I prevent that java.lang gets imported automatically in order to be able to import another class named Class?
04:08Seylerius,(group-by identity [1 1 2 3 2 1 1])
04:08clojurebot{1 [1 1 1 1], 2 [2 2], 3 [3]}
04:08tsdhI can't find something like (:refer-java :no-please-dont) analogous to (:refer-clojure ...).
04:19Seylerius,(defn counter [coll] (into {} (map count (group-by identity coll))))
04:19clojurebot#'sandbox/counter
04:19Seylerius,(counter [1 1 2 3 2 1 1])
04:19clojurebot#error{:cause "Don't know how to create ISeq from: java.lang.Integer", :via [{:type java.lang.IllegalArgumentException, :message "Don't know how to create ISeq from: java.lang.Integer", :at [clojure.lang.RT seqFrom "RT.java" 506]}], :trace [[clojure.lang.RT seqFrom "RT.java" 506] [clojure.lang.RT seq "RT.java" 487] [clojure.lang.ATransientMap conj "ATransientMap.java" 42] [clojure.lang.ATransientM...
04:22slipsetdakrone:Struggeling a bit with http-kit and :insecure
04:22slipsetreading the code, I end up in:
04:22Seylerius,(defn counter [coll] (let [groups (group-by identity coll)] (zipmap (keys groups) (map count (vals groups)))))
04:22clojurebot#'sandbox/counter
04:22Seylerius,(counter [1 1 2 3 2 1 1])
04:22clojurebot{1 4, 2 2, 3 1}
04:22slipsetconn_mgr.clj and (def insecure-socked-factory
04:23Seylerius,(counter [:b :a :b :a :b])
04:23clojurebot{:b 3, :a 2}
04:23slipsethttps://github.com/dakrone/clj-http/blob/master/src/clj_http/conn_mgr.clj#L21
04:23Seylerius,(counter '([1 2] [1 3] [1 3]))
04:23clojurebot{[1 2] 1, [1 3] 2}
04:24SeyleriusThere a tidier way to do that?
04:24slipsetwhere you reify TrustStrategy and define (isTrusted [_ _ _] true)
04:25slipsetnever mind.
04:48sm0ke,*data-readers*
04:48clojurebot{}
04:54dysfunBronsa: is there a way to get line and col positions for everything from tools.reader, not just on collections?
04:54dysfun(and symbols)
04:55Bronsadysfun: no unfortunately, there's no place to store that info
04:56oddcullySeylerius: what about (defn counter [coll] (into {} (map (fn [[k v]] [k (count v)]) (group-by identity coll))))
05:27dysfunBronsa: would you be interested in patches that gave you it back as a separate data structure?
05:28Bronsadysfun: sure as long as it doesn't impact performances & it's an optional feature
05:28dysfunBronsa: okay. i'll have a bash at it. you'll probably hear from me on github in about a week
06:48jaenIs this a sensible way to pause a go-loop or is there something wrong with this approach/there's a better one - https://gist.github.com/jaen/047a57e5273fd7b7c920
06:55devllis it possible to compute huge (mils * mils) matrix multiplications with the current available libraries?
07:00TEttingerdevll: what type of computation needs this?
07:01TEttinger(there's probably a better way)
07:03devllPageRank
07:04devllyeah, running computations on clusters like Spark.
07:04devllI want to use pure Clojure solution if possible.
07:36ordnungswidrigdevll: are these sparse matrixes?
08:06slipsetjaen: it seems strange to me that you're taking from the pause channel when you've already got a result from it via alts!
08:07slipsetjaen: ok, I see, the alts! is to start the pause, the take is to end the pause.
08:08jaenslipset: yeah, I use alts to not block on the channel that delivers channels I then pause on, and then I do a blocking take on the channel I get from that to pause
08:08jaenI f that makes sense
08:09slipsetYes, just took me a while to wrap my head around this.
08:27patrkrishi everyone. has anyone here tried designing a system of components, where different components can participate in the same database transaction over multiple different operations? one way is to use a dynamic var to hold the transaction, which all components rely on - but it feels awkward
08:27patrkris(i.e. operations = functions operating on those components)
08:28justin_smithSeylerius: counter is just frequencies
08:29justin_smith,(frequencies '([1 2] [1 3] [1 3]))
08:29clojurebot{[1 2] 1, [1 3] 2}
08:30justin_smithpatrkris: components as in stuartsierra's component lib?
08:30patrkrisjustin_smith: yes
08:32patrkrishmm... maybe there could be a transaction component in the system, which other components could rely on. thus no global state
08:32justin_smithwouldn't it be easier to flip it, so that the thing that created the transaction relied on all the things to do in that transaction?
08:32justin_smithor that
08:32patrkrisjustin_smith: let's take an example where I have a orders component and a customers component
08:33patrkrisand the orders component has an operation `place-order!` and the customers component an operation `inc-order-count` (lame example)
08:33patrkrisand we want to increase the order count in the same transaction that we place the order
08:34devllordnungswidrig: I was out for supper . Yes ,it is sparse
08:34patrkrisjustin_smith: how do you mean to implement your idea in that case?
08:35justin_smiththe transaction component would have a dep on each operation it wants to carry out
08:35justin_smithbut maybe I am not understanding this, because it feels like a weird fit for the component abstraction
08:37patrkrisjustin_smith: you are probably right. In the system I am building, I thought it would be nice to separate concerns by having an orders component and a customers component, but in some cases I need to perform data manipulation for both orders and customers in the same transaction
08:37mavbozo_better just create a transaction component which contains customer component and order component
08:38patrkrismavbozo_: and then have the transaction component support operations that manipulate both orders and customers?
08:40mavbozo_no,
08:40clojurebotTitim gan éirí ort.
08:41mavbozo_there's a transaction function say purchase-order which transaction component, extract customer and order component
08:41mavbozo_then calls function that directly manipulates those customer and order components
08:41mavbozo_*which receives transaction component*
08:43mavbozo_i assume `place-order!` receives order component and `inc-order-count` receives customer component
08:43patrkrismavbozo_: correct
08:44patrkrisso the transaction component is specific to the purchase-order operation, and not something general to compose other operations into a single transaction?
08:44mavbozo_(defn purchase-order [{:keys [customer order]}] (do (place-order! order) (inc-order-count customer)))
08:46patrkriswhere does the transaction come into the picture in your example?
08:48mavbozo_yeah, i forgot to put ask where do you put the db component. It's for a transaction to a single db?
08:50patrkrismavbozo_: yes
08:53yellow13hi there! which of these is more common on clojure: (deref (:debt data)) or (-> data :debt deref)
08:53yellow13i tend to prefer the -> macro
08:53justin_smith@(:debt data)
08:54justin_smithwould be the most frequent way to see that
08:54mavbozo_assuming you have a jdbc connection inside customer and order component, then you can create a connection specific for the transaction
08:54mavbozo_and inject that connection to customer and order component
08:55yellow13cool, thankz
08:57mavbozo_(with-db-connection [trans-conn db] (put-order (assoc order :conn trans-conn)) (inc-order-count ...
09:08patrkrismavbozo_: yes, that was one of my thoughts. but you could say that the actual database connection is an implementation detail of those components, which shouldn't be known by the consumer. it would feel like manipulating a private variable of a class. but I have a feeling that I am viewing this in a wrong way
09:11mavbozo_patrkris, it's the design i get when following the example from the presentation slides where there is a customer and db components
09:12justin_smithpatrkris: think of it as not a consumer using a transaction, but a transaction invoking operations
09:12justin_smiththe transaction is the part that is in charge of the changes happening
09:12justin_smithbecause it can roll them back for example
09:12justin_smiththe other parts just provide some operation that the transaction can wrap
09:13justin_smiththat you pass the transaction to them is an (admittedly ugly) implementation detail
09:15mavbozo_patrkris: and my design breaks abstraction boundaries
09:18patrkrisyes. maybe I am over-engieering but I feel that components should be black boxes and that a transaction mechanism should be also
09:21patrkrisI mean there may be a transaction component (implementing a protocol) that specifically knows how to handle the transaction concept for specific component implementations of orders and customers
09:25noncomdoes leins param :java-cmd affect the javac version used to compile java classes in the clojure project?
09:26mavbozo_it just occurs to me that maybe, for a jdbc transaction, it's hard to make transaction between remote objects inside a black box
09:26mavbozo_technically, the transaction happens outside our process
09:28patrkrismavbozo_: you have a problem of "distributed" transactions in your project then?
09:29justin_smithpatrkris: were you talking about db transactions?
09:29mavbozo_patrkris: i almost made a problem become a "distributed" transaction where in a sign-up process i almost made transaction rolled back if the email failed to send
09:29patrkrisjustin_smith: yeah... sorry if I wasn't clear about that :S
09:30justin_smithpatrkris: just clarifying, because if you want to get super architecturally correct here, the big problem is that a "transaction" is a messy thing that doesn't solely belong to your db or your app
09:31patrkrisjustin_smith: yes. in my case I'm just interested in reusing operations that exist on components I made, but within a db transaction
09:32justin_smithright. But a transaction doesn't fit the OO concepts of encapsulation and separation of concerns you are citing here.
09:32justin_smithit leaks
09:33justin_smithI mean fundamentally, it can't be what it is if it doesn't
09:33justin_smithso you either don't abstract it, or it has to be the top level managing details inside it
09:33justin_smithbecause it's the boss
09:40mavbozo_so, I could just make a DbTransaction Component which by design changing the connection details inside every components which participates in transaction actions
09:53patrkrisjustin_smith: I guess you're right. I could of course create a transaction concept by implementing something like Unit of Work which is sufficiently abstract
09:54patrkrisand just say that all components must support unit of work, and what UoW does is then specific to the component implementations
10:11irctc_I have N vectors with roughly the same number of maps in them (some 68 - 70 maps in each vector). I have to remove the maps that are not in common with all the other vectors. Let's say each map in all vectors has [{:id 1} {:id 2} {:id 3} ...] in the map, etc., but some vectors are missing some ids, those have to be removed from the vector. The vectors are in a nested map by year and month integer {2015 {12 {"CC" [{} {} {}] }}} where
10:12irctc_I have to collect Q quarters of vectors. For instance starting at 12/2014, 9/2014, 6/2014, 3/2014, 12/2013,...
10:13irctc_Any tips?
10:25justin_smith(let [ids (frequencies (mapcat (partial map id) vecs)) shared (set (keep #(when (= (val %) (count vecs)) (key %)) ids))] (mapv (partial filterv shared) vecs))
10:25irctc_Was thinking to build a range of year/month vector pairs to use as the get-in vectors to navigate to the vectors, doing two passes of the vectors. Once using intersection to get a set of common keys then a second pass conjing the map if it's key is in the intersection set.
10:26justin_smithoh, the nested part makes it harder
10:27irctc_:justin_smith: I could leave the data as one large vector, but that seems unwieldy, given I'd have about 20 GB under one vector of maps.
10:45tbaldridgeirctc_: seems like something a Database would be good at. Perhaps even Datomic
10:53justin_smithirctc_: there is probably a simpler way to do this, but if any month has no duplicate ids this is correct https://www.refheap.com/99126
10:54Bronsa,(->> '([1] 1) (keep empty?) first)
10:54justin_smithirctc_: the logic that binds items could be made a "linearize" function, and the logic that makes pruned-data could be a "delinearize" function
10:54clojurebotfalse
10:54Bronsa,(->> '[[1] 1] (keep empty?) first)
10:54clojurebot#error{:cause "Don't know how to create ISeq from: java.lang.Long", :via [{:type java.lang.IllegalArgumentException, :message "Don't know how to create ISeq from: java.lang.Long", :at [clojure.lang.RT seqFrom "RT.java" 506]}], :trace [[clojure.lang.RT seqFrom "RT.java" 506] [clojure.lang.RT seq "RT.java" 487] [clojure.core$seq__4079 invoke "core.clj" 135] [clojure.core$empty_QMARK_ invoke "core.cl...
10:54Bronsachunked seqs, yay.
10:55justin_smithirctc_: well, actually you'd also want to pull the group-by just before pruned-data into its def
10:55justin_smithbut the idea should be clear
10:57gfredericksjustin_smith: the biggest part of meeting internet people in person is finding out how tall they are
10:58justin_smithhah - some people have misleading personalities though. I knew this one woman for years before I realized she was actually short.
11:03justin_smithirctc_: just updated with that refactoring
11:07irctc_justin_smith: Thanks for the code.. I'll check it out and let you know..
11:08justin_smiththere's probably a way to generalize the linearize / delinearize for arbitrary data shapes
11:08justin_smithprobably something very simple that I am just blanking on
11:17irctc_Justin_smith: amazing stuff. would like to know your thought process ... perhaps as comments on the refheap.
11:17justin_smithirctc_: I pasted the original version as a one liner
11:18justin_smithbasically everything but the linearize / delinearize
11:18justin_smith(but it's more readable as a let block)
11:18justin_smiththe idea with linearize, is to extract every piece of data as a single item, but attach all the info you need to put it back where it came from
11:19justin_smiththe idea with delinearize, is to put it back in the same shape (based on that info that was attached) and remove the now unused info
11:20irctc_thanks.
11:22justin_smithirctc_: the bad part is that the deconstructing / rebuilding is all code, not data driven, so you would need to rewrite both those functions if the shape of the input changed
11:22justin_smithI think there is a way to simplify it, and have linearize and delinearize both follow the same "template" describing how to unpack / pack the data structure
11:23justin_smiththen it would be generalizable as a kind of specialized reversible "leaf-seq"
11:23justin_smithmaybe that would be a good name for it
11:23clojurebotexcusez-moi
11:23justin_smithclojurebot: you're weird
11:23clojurebotPardon?
11:48anti-freezeHi everyone. Is there a way to check where a response is redirecting to on a 302 status? This is for the purpose of tests.
11:49justin_smithanti-freeze: the response should look like {:status 302 :body "http://other-url&quot;}
11:49justin_smithif you are using the response map
11:49anti-freezejustin_smith: Ah, right. That should do it. Yea, I'm using standard response maps
11:56anti-freezejustin_smith: Actually, the response seems to be returning an empty string
11:57anti-freeze(:body response) => ""
11:57justin_smithanti-freeze: hmm ... one moment
11:58justin_smithanti-freeze: sorry, it's (get-in response [:headers "Location"]}
11:59anti-freezejustin_smith: Ah right. So something like (:headers response) => "/not-found" should return true for instance if I was being redirected to not-found
12:00justin_smithanti-freeze: (:headers response) would include {"Location" "/not-found"}
12:00justin_smiththat's why I suggested get-in
12:00anti-freezejustin_smith: Oh, ok. Thanks a bunch. Seems to work fine now
12:01justin_smithbecause ring is fairly permissive, you may also have to check for ["Headers" :location] and various other combinations
12:01jasppIs there an core function to copy parts of a nested map? Like (copy-in nested-map [:outer-key :inner1-key :inner2-key]) where the resulting map has the same nesting.
12:01justin_smithoh, good
12:02justin_smithjaspp: sounds like a combo of select-keys and get-in
12:02justin_smithor update-in and select-keys
12:09justin_smith,(defn prune-in [m keyv] (assoc-in {} keyv (get-in m keyv)))
12:09clojurebot#'sandbox/prune-in
12:10justin_smith,(prune-in {:a {:b [:c :d] :e {:f {:g :h} :i {:j 1 :k 2 :l {:m :n} :o {:p {:q nil :r 1 :s 5 :t {}} :u 42} :v 8}} :w Double/NaN} :x 1 :y 1 :z 1} [:a :e :i :o :u])
12:10clojurebot{:a {:e {:i {:o {:u 42}}}}}
12:27arrdemAnyone got a good joke on the idea of a tag? Naming a tagged value library.
12:28gfredericksyour-it
12:29xemdetiawouldn't it be youre-it
12:30justin_smithxemdetia: thriftshop "I'm gonna pop some tags"
12:30justin_smithmaybe not
12:30arrdem(inc xemdetia) ;; pedantism is rewarded here
12:30lazybot⇒ 3
12:31gfrederickswell I assumed "'" wasn't allowed and so was forced into a your/you're joke
12:32gfredericksif your lib name annoys the pedants, all the better I say
12:33arrdemBlazer? you too can dress your data nicely with tags :P
12:36sritchiecljc, wild news
12:36sritchiedidn’t realize that was landing in 1.7
12:37wagjoarrdem: guten-tag
12:37arrdemwagjo: hehe nice one
12:38justin_smithoh, I thought he was just greeting you
12:38justin_smithyeah, I like that one
12:38justin_smith(inc wagjo)
12:38lazybot⇒ 5
12:38wagjodanke
12:38sritchieanyone know how to signal to leiningen or the reader which tags to keep?
12:38justin_smitharrdem: also, implies that of the options, your lib is the good one
12:38sritchieie, are :clj, :cljs etc extensible, and how does one control the builds
12:40justin_smithhyPiRion: great timing for the new release
12:40justin_smithhttp://swearjure.com/swearjure-1.0.0/
12:43justin_smithgfredericks: speaking of stupid Clojure tricks, did you see this one? ##(hash-map Double/NaN :a Double/NaN :a Double/NaN :a Double/NaN :a :BAT :MAN)
12:43lazybot⇒ {NaN :a, NaN :a, NaN :a, NaN :a, :BAT :MAN}
12:45gfrederickshell no I did not
12:45gfredericks,{Double/NaN 1 Double/NaN 2}
12:45clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: Double/NaN>
12:45gfrederickswait how does that work with hash-map
12:45gfredericks,(hashcode Double/Nan)
12:45clojurebot#error{:cause "Unable to resolve symbol: hashcode in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: hashcode in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: hashcode in this context",...
12:45gfredericks,(hashcode Double/NaN)
12:45clojurebot#error{:cause "Unable to resolve symbol: hashcode in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: hashcode in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: hashcode in this context",...
12:46gfredericks,(hash Double/NaN)
12:46clojurebot2146959360
12:46gfredericks,(hash Double/NaN)
12:46clojurebot2146959360
12:46justin_smithonly works with hash-map (and probably into / conj)
12:46hyPiRionthey hash to the same thing, but they are not equal
12:46justin_smithgfredericks: I think there must be a special path for numeric keys that doesn't ask for a hash?
12:46justin_smithahh, so the hash would never get checked
12:47justin_smithor, wait...
12:47hyPiRion,(conj #{} Double/NaN Double/NaN)
12:47clojurebot#{NaN NaN}
12:48gfredericks~mystery
12:48clojurebotmystery is http://p.hagelb.org/mystery.gif
12:49wagjotoday is a good day for Clojure palindrome
12:49wagjo,(fn O [nf fn] O nf)
12:49clojurebot#object[sandbox$eval165$O__166 "sandbox$eval165$O__166@7d4529d8"]
12:49justin_smithnice
12:50justin_smithwagjo: I can add to it and make it equivalent to first
12:50justin_smith,((fn O [nf & fn] O nf) (range))
12:50clojurebot(0 1 2 3 4 ...)
12:50justin_smithoops
12:50justin_smith,(apply (fn O [nf & fn] O nf) (range))
12:50clojurebot0
12:50BinaryResultQuick reminder that Disco Melee is hiring clojure devs https://docs.google.com/document/d/1GvnrSCUbYgbY9XdFs_DUx-0QZG2bIYT8Mbr0zdpTeew/edit?usp=sharing
12:54TimMc,1#!()!#1,
12:54clojurebot1
12:55TimMcBinaryResult: Weren't you just hiring yesterday too? :-)
12:55arrdemTimMc: they've been hiring for a couple days. I don't mind :P
12:56justin_smithhourly reminders I would mind, that spanish speaking spam bot I minded, daily seems OK
12:56BinaryResultYes still accepting resumes. I have been only posting once per day, if coming across as spam I will stop
12:56BinaryResultTrying to catch eyes which may not have been on yesterday
12:57TimMcSorry, I'm hypervigilant because I'm a reddit mod. So much spam... I get de-calibrated.
12:58BinaryResultNo worries, let me know if it's getting annoying this is your space after all, I'm only a visitor. Having a meeting this evening to go through the applicant up to this point.
12:59justin_smithmy hunch is we could make a #clojure-jobs channel if we get like 20 companies wanting to reach out, but if it's just a few, with daily updates at most, that seems OK to me
13:00justin_smithhell, if we had so many people coming here to look for employees that we needed to make rules about it, I'd brag about that really. That would be great news for Clojure.
13:01BinaryResultGlad I can do my part :)
13:01arrdemI don't even think the Haskell folks have a -jobs chan and they have the most aggressive content filtering of #<lang> for on-topic and short I'm aware of
13:03sobeli'm sure there's a good reason, but i just discovered i can't nest anonymous functions
13:03sobelare they somehow not firstclassy enough? or is it a macro
13:04justin_smithsobel: how would you refer to the first arg of the inner function?
13:04sobel...magic?
13:04sobel%% ?
13:04justin_smithsobel: ##(quote '#())
13:04lazybot⇒ (quote (fn* [] ()))
13:04sobelahunno, i just work here
13:04justin_smithsobel: I guess %% could hypothetically work, but it doesn't
13:05sobelso it's a lexical issue. i can see that gets annoying to try to solve.
13:05sobelannoying in the sense that you might regret the solution more than the problem
13:05justin_smithespecially since (fn [] ) isn't so bad for the rare instances you need nesting
13:05sobelyeah. thanks for backboarding that. like i said, i'm sure there's a great reason. :)
13:06sobelwhen i coded sql i protected my runtime from exceptions by data constraints. i could guarantee my inputs. i'm trying to figure out my sweet spot for clojure.
13:07justin_smithsobel: definitely a different approach
13:16dnolensritchie: long time coming
13:16sritchieyup
13:45noncomsobel: also, you might consider naming you anonimouse functions like (fn my-fn-name []) for better stack tracer
13:45noncom*tracing
13:57justin_smithI use a function block chain, so that the functions can remain anonymous, but ownership is unambiguous
13:57justin_smithand fraud is forever encapsulated in the function block chain log
13:58justin_smithhaha
13:59jjttjji have a massive vector of maps so large that calling count on it freezes my comp. I'd like to run add them to the db one by one and print some indication of progress without realizing the whole sequence. for some reason using map and doseq are both crashing my comp. Anything obvious im missing about dealing with huge amounts of data?
14:00justin_smithjjttjj: are you sure that's a vector? vectors are counted, counting just returns the count field
14:00TimMcSounds like a lazy seq that you are realizing by calling count.
14:00justin_smithjjttjj: I assume you are holding on to the start of a lazy seq
14:01jjttjjwoops yeah it's a lazyseq not a vector
14:01justin_smithand if you refactored not to hold onto the starting element, you could consume it without crashing
14:01justin_smithjjttjj: if you have a reference to the first item, it can't be gcd
14:01justin_smithif you don't, then it can be gcd so you can keep processing items as you realize them
14:02jjttjjI have a var in which I read it from a csv to get the data, would that hold the starting element?
14:05TimMcjjttjj: Possibly, depends on your code.
14:08justin_smithjjttjj: if the var is pointing to the lay seq, yeah
14:08justin_smithyou can fix it by creating the lazy-seq locally, inside a let block
14:08justin_smiths/lay seq/lazy-seq/ of course
14:09jjttjjok awesome thanks!
16:03lexi-lambdaHey, all. I'm a Schemer getting seriously into Clojure for the first time. I don't use Emacs, so is Atom a reasonable editor for Clojure? What tools should I install to get started?
16:04justin_smithlexi-lambda: there's reasonable clojure tooling for vim, intellij, even sublime
16:04justin_smithI forget, is lighttable built on atom?
16:04mavbozolexi-lambda, what text editor you usually use?
16:04justin_smithbecause that does some cool stuff with clojure
16:04lexi-lambdaNo, I think it's its own thing.
16:04seangroveI hear good things about Cursive
16:05arrdemCursive is awesome
16:05edbondlexi-lambda: +1 for cursive. IF emacs not an option
16:05seangroveI haven't been able to get it to work with some of the larger projects I use, but I assume that's our code-base's problem
16:05arrdemLight Table works too
16:05mavbozoemacs + cider is awesome
16:05mavbozo(inc cider)
16:05lazybot⇒ 2
16:05justin_smithso yeah, lots of good options
16:05arrdem(inc cider)
16:05lazybot⇒ 3
16:06mavbozo(identity cursive)
16:06lazybotcursive has karma 1.
16:06lexi-lambdaI'm traditionally not an emacs user. I'm familiar with vim, but I don't really like it for larger projects.
16:06seangrovearrdem: Cursive seems to have trouble with anaphoric macros
16:07justin_smithif you're familiar with keeping things balanced and well indented in a lisp, any editor you like should work fine
16:07justin_smiththough repl integration can definitely be convenient
16:07lexi-lambdaI'm currently enjoying Atom, so I'll see if I can get a set of plugins to the point where I feel comfortable working in it.
16:08lexi-lambdaIf not, I'll check out other options.
16:09seangrovearrdem: I'd like to see bbloom's eclj used as a Abstract Interpreter to drive the analysis for Cursive and friends, should be much easier to handle cases like that
16:10arrdemthat could be cool I guess
16:10lexi-lambdaIs it safe to assume installing leiningen is what I want?
16:10arrdemlexi-lambda: yes you will want lein at least to start
16:10justin_smithlexi-lambda: yeah
16:10justin_smithjust put the shell script on your path, it will take care of the rest
16:11justin_smith(when I first started I made the mistake of thinking I had to clone the repo, build, yadda yadda...)
16:11lexi-lambdaI just ran a quick `brew install leiningen` on os x, which seemed to work fine
16:11justin_smithsince lein is only a single file, I almost feel like using a package manager only makes it more complicated
16:14lexi-lambdaHmm, Atom's paredit plugin seems to be borked :/
16:35oddcully(inc fireplace)
16:35lazybot⇒ 1
16:36gfredericks(inc cni)
16:36lazybot⇒ 1
16:36gfredericks(dec ced)
16:36lazybot⇒ -1
16:43aaaaaaaaaahello
16:44gfrederickshello
16:44aaaaaaaaaaI started to learn clojure and I was wondering is there any way to list all stuff, which namespace contains. The first stuff I found was "ns-publics". Is it a good way to examina the whole namespace? Are there any other ways to do that?
16:45arrdem$grim clj::clojure.repl/dir
16:46aaaaaaaaaaHmm, I also tried that, but got "Unable to resolve symbol: dir in this context"
16:46arrdemsorry. I was trying to invoke a bot command. try this.
16:47arrdem(do (require '[clojure.repl :as repl]) (repl/dir 'clojure.repl))
16:48mavbozo$grim clj::clojure.pprint/pprint
16:48justin_smitharrdem: the arg to dir shouldn't be quoted
16:48arrdemjustin_smith: oh right macro
16:48arrdemaaaaaaaaaa: make that (repl/dir clojure.repl)
16:49justin_smith,(do (require 'clojure.repl) (clojure.repl/apropos #"^unchecked.*"))
16:49clojurebot(clojure.core/unchecked-add clojure.core/unchecked-add-int clojure.core/unchecked-byte clojure.core/unchecked-char clojure.core/unchecked-dec ...)
16:49kaiyinwhat is wrong with this function?
16:49kaiyinhttps://gist.github.com/kindlychung/3c8e0f45017102df64cc
16:49aaaaaaaaaahmm, ok, so that I got my namespace, and what exactly this command returns?
16:50justin_smithkaiyin: the param vector to let should not be in parens
16:50aaaaaaaaaathe methods inside the namespace?
16:50kaiyinoh, my bad.
16:50justin_smithaaaaaaaaaa: the vars defined in the namespace
16:50justin_smithaaaaaaaaaa: vars and functions are not methods, they are objects
16:51justin_smiththat's why we can use them as first class values
16:51aaaaaaaaaahmm, and how could i check the values of that vars?
16:51justin_smithaaaaaaaaaa: anything at the top level of the repl will return its value
16:51justin_smithaaaaaaaaaa: more likely though you want to look at the doc string, or the source
16:51aaaaaaaaaalet's say I got namespace test.a.b and your command/function(?) returns me variable xyz
16:52joe124hi everyone i want to make a copy of freecell in clojure. Is javafx a good gui for clojure projects?
16:53justin_smithaaaaaaaaaa: wait, was that a question?
16:53kaiyin(def ^:dynamic t-edges (take 4 (repeatedly #(sample-2diff-nodes)))) what does the # do here?
16:53justin_smithkaiyin: introduces an anonymous function of no arguments
16:53justin_smith,(#(print 'OK))
16:53clojurebotOK
16:54aaaaaaaaaa(do (require '[clojure.repl :as repl]) (repl/dir test.a.b)) Let's say it returns me two values: xyz and nil. What exactly is that xyz (how should I call it). Does it have any value? If yes, how can I check this value
16:54justin_smithaaaaaaaaaa: it cannot return nil. it prints xyz and returns nil
16:54justin_smitherr, sorry, that was incoherent
16:54justin_smithit returns nil, xyz is the thing defined
16:54justin_smithand printed
16:54kaiyinjustin_smith: how do you make a anonymous function with args then?
16:55justin_smithaaaaaaaaaa: if it exists, it has a value
16:55aaaaaaaaaaoh, ok. So xyz is the name of the variable in the namespace test.a.b ?
16:55justin_smithaaaaaaaaaa: like I said, type it into your repl, and hit return, and you will see the value
16:55justin_smithaaaaaaaaaa: yes
16:55justin_smithso in the repl, enter test.a.b/xyz
16:55justin_smithand you will see the value
16:56kaiyinoh, like this (#(str %) "Eh")
16:56justin_smithkaiyin: ##(#(print % "is the word") "the bird")
16:56lazybot⇒ the bird is the wordnil
16:56danlentz,(def foo (agent {:foo 0}))
16:56clojurebot#'sandbox/foo
16:56danlentz,foo
16:56clojurebot#<Agent@3a5da873: {:foo 0}>
16:56justin_smithwhich is equivalent to ##((fn [x] (print x "is the word")) "the bird")
16:57lazybot⇒ the bird is the wordnil
16:57justin_smithbut more succinct
16:57kaiyincool
16:58gfredericks~the bird is the wordnil
16:58clojurebotRoger.
16:59justin_smithhaha
16:59aaaaaaaaaajustin_smith: generates me some rubbish like: #<b$xyz test.a.b$xyz@{some hex}>
16:59aaaaaaaaaawhat is that?
17:00justin_smithan unreadable object, try (type test.a.b/xyz)
17:00justin_smiththe class will be hidden in that weird stuff
17:01danlentz,(send foo update-in [:foo] inc)
17:01aaaaaaaaaagot test.a.b$xyz
17:01clojurebot#error{:cause "Unable to resolve symbol: foo in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: foo in this context", :at [clojure.l...
17:01danlentz,(def foo (agent {:foo 0}))
17:01clojurebot#'sandbox/foo
17:01danlentz,(send foo update-in [:foo] inc)
17:01clojurebot#<Agent@6d83ddf6: {:foo 0}>
17:01aaaaaaaaaawhat does exactly mean?
17:01justin_smithaaaaaaaaaa: that means it's probably a function - functions are an instance of a class, usually the only instance of that class
17:01danlentz,foo
17:01clojurebot#<Agent@6d83ddf6: {:foo 0}>
17:02danlentz,(send-off foo update-in [:foo] inc)
17:02clojurebot#<Agent@6d83ddf6: {:foo 0}>
17:02aaaaaaaaaajustin_smith: so it means that (do (require '[clojure.repl :as repl]) (repl/dir 'clojure.repl)) returns not only vars, but also functions?
17:02danlentz,foo
17:02clojurebot#<Agent@6d83ddf6: {:foo 0}>
17:02justin_smithaaaaaaaaaa: vars can hold any class
17:02justin_smithincluding functions
17:02arrdem[ann] https://github.com/arrdem/guten-tag, a tiny library for doing jneen's tagged value pattern with destructuring and updating idiom support. Also usable for smart constructors :D
17:03justin_smithnice
17:03justin_smithaaaaaaaaaa: vars are just containers that hold values
17:03gfredericks~vars
17:03clojurebotvars are a linking construct
17:03gfredericks~vars
17:03clojurebotvars are a linking construct
17:03danlentzi guess its wise not to give us threads
17:03aaaaaaaaaajustin_smith: oh, ok :). So in that case, how should I call this xyz function in the context of test.a.b ?
17:03kaiyinhttps://gist.github.com/kindlychung/d529b518cb1e87bd83a0 it seems concat has no effect here?
17:04justin_smithaaaaaaaaaa: also, you only need to require clojure.repl once in a namespace, I put it in a 'do' to be more succinct in using the bot
17:04danlentzkaiyin: awesome land of lisp
17:04justin_smithaaaaaaaaaa: try (repl/doc test.a.b/xyz)
17:04justin_smithaaaaaaaaaa: and/or (repl/source test.a.b/xyz)
17:04kaiyindanlentz: yeah, that's it!
17:06danlentzso, you have to prn t-edges within the scope of the binding expression
17:06aaaaaaaaaahmm, source not found - does it mean, that xyz is also not a function? What else could it be?
17:07justin_smithit means that xyz either wasn't created via defn, or it wasn't loaded via a file reader
17:08danlentzbinding only "temporarily" alters a var within the dynamic scope of the binding form
17:08justin_smithyou can make functions without defn, but only defn (or defmacro) automatically add the source metadata
17:08aaaaaaaaaacan you show me an example, how to create function without defn? Just curious
17:08justin_smith,(defn foo [] 42)
17:08clojurebot#'sandbox/foo
17:09justin_smith,(foo)
17:09clojurebot42
17:09justin_smith,(def foo (constantly 42))
17:09clojurebot#'sandbox/foo
17:09kaiyinin case anyone could have a look: http://stackoverflow.com/questions/29400886/why-doesnt-concat-take-effect-here
17:09justin_smith,(foo)
17:09clojurebot42
17:09justin_smith,(def foo (fn [] 42))
17:09clojurebot#'sandbox/foo
17:09aaaaaaaaaajustin_smith: err, you said without defn?
17:09aaaaaaaaaaoh, ok
17:10danlentzkaiyin: binding only "temporarily" alters a var within the dynamic scope of the binding form
17:10aaaaaaaaaaso in that case should I call that test.a.b/xyz to return me anything?
17:10justin_smithaaaaaaaaaa: there are a number of ways to create a function, only one of them is defn
17:10justin_smithaaaaaaaaaa: sure, but it would probably be helpful to look at the source
17:10justin_smithif (source whatever) doesn't work
17:11justin_smiththe file should be somewhere you can find it - inside a jar or on github at least
17:12aaaaaaaaaalol, looks like after a few minutes on irc, i'll know more than after hours of reading tutorials :D
17:12justin_smithaaaaaaaaaa: I really need to work on my own guide (in progress)
17:12danlentzaaaaaaaaaa: this place really is an amazing resource
17:12kaiyindanlentz: ok, i'll give it another try.
17:14danlentzkaiyin: https://clojuredocs.org/clojure.core/binding
17:14danlentz$doc binding
17:14danlentzhow does that work?
17:14justin_smithlazybot: work
17:14danlentz,(doc binding)
17:14clojurebot"([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made in parallel (unlike let); all init-exprs are evaluated before the vars are bound to their new values."
17:14Bronsaarrdem: what's the point of ITaggedVal?
17:15kaiyindanlentz: here: https://gist.github.com/kindlychung/d529b518cb1e87bd83a0#file-new-clj-L58-L63
17:15arrdemBronsa: I'd rather have an interface and not use it than stick people with no interface to roll their own tagged structures.
17:15arrdemnot sure it makes sense but it doesn't cost anything worth mentioning
17:15Bronsaarrdem: satisfies? is really slow
17:17aaaaaaaaaahmm, ok guys, thanks a lot for help :)
17:17Bronsaarrdem: also a minor nitpick but what's the point of (.t self) when you can just write t?
17:20arrdemBronsa: thanks good catches
17:21Bronsanp, looks interesting btw
17:22arrdemI've had that code in my detritus "bits and bats" lib for a while, loved using it in lib-grimoire, plan to use that pattern everywhere. Highly recommend you try it.
17:22arrdemsmart constructors have saved my arse several times now
17:24oddcullyjustin_smith: wordnil? ;p
17:24oddcullynow that song is stuck again in my head...
17:26justin_smithso sorry
17:26justin_smith,(print 'sorry)
17:26clojurebotsorry
17:27justin_smith&(print 'sorry)
17:27lazybot⇒ sorrynil
17:27justin_smithahh, that was the culprit
17:30kaiyinwhat is the equivalent of `where` statement in haskell ?
17:30amalloykaiyin: there's just let
17:30kaiyinok
17:30justin_smithI guess we could do a "backwards let" with the body first, then the bindings
17:30gfredericks,(defmacro where [expr lettings] `(let ~lettings expr))
17:30clojurebot#'sandbox/where
17:30justin_smithfun beginner macro exercise
17:31gfredericks,(where (inc x) [x 12])
17:31clojurebot#error{:cause "No such var: sandbox/expr", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: No such var: sandbox/expr, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "No such var: sandbox/expr", :at [clojure.lang.Util runtimeException "Util.java" 221]}], :trace [[cloju...
17:31amalloyjustin_smith: nobody is ever happy with that suggestion though
17:31justin_smithheh
17:31gfrederickswhoopsiedoodle
17:31gfredericks,(defmacro where [expr lettings] `(let ~lettings ~expr))
17:31clojurebot#'sandbox/where
17:31gfredericks,(where (inc x) [x 12])
17:31clojurebot13
17:31justin_smithalso you need a ~@ I think
17:31amalloywasn't gfredericks trying to do something like that but calling it footnotes?
17:31gfrederickshuh?
17:31gfredericksthis is news to me
17:31amalloyi thought it was you. annotations? something like that
17:32gfredericksjust for the poirpose of inverting let?
17:32aaaaaaaaaaone more question. Does clojure have something like global variables? Is it also a way to list them all?
17:33gfredericksno globals, just vars in namespaces
17:33gfrederickswhich are global in a more limited sense
17:33amalloyoh it was timmc
17:33gfredericks~TimMc is the other gfredericks
17:33clojurebotA nod, you know, is as good as a wink to a blind horse.
17:33justin_smithgfredericks: hmm, depending how we mean it, you could call reader magic global
17:33justin_smithor some of it at least
17:34aaaaaaaaaaso is there any main namespace, so i could create globals for N namespaces?
17:34aaaaaaaaaanot only for one
17:34gfredericksjustin_smith: eh? what kind of reader magic?
17:34justin_smith~gfredericks is the other gfredericks.
17:34clojurebot'Sea, mhuise.
17:34gfredericksaaaaaaaaaa: what's your use case?
17:34justin_smithgfredericks: reader macros that aren't namespaced
17:34gfredericksinst & uuid?
17:34justin_smithetc.
17:34justin_smithyeah
17:34aaaaaaaaaagfredericks: no use-case. Just asking if something like that exists in clojure
17:34gfredericksI dunno they're kinda static
17:34gfredericksaaaaaaaaaa: then no
17:35justin_smithyeah, they don't vary, but are global / unnamespaced
17:35gfredericksas is 42
17:35justin_smithanother global!
17:35gfredericks~42 is the global 42
17:35clojurebotRoger.
17:35amalloygfredericks: search http://logs.lazybot.org/irc.freenode.net/%23clojure/2015-02-27.txt for [16:04:03] if you are interested in the conversation where i thought TimMc was you apparently
17:35gfredericksI'm going to have to answer for every crim TimMc has committed
17:36justin_smithgfredericks: since it is less than 128, and greater than -129, it really is a global mutable :)
17:36danlentzvinyasa seems to have introduced the convention of using namespace "." for global functions
17:36danlentzintended for interactive use
17:36amalloygfredericks: who commits crims? crimeinals?
17:36aaaaaaaaaagfredericks: so namescapes can't also share the same vars/functions between each other?
17:37justin_smithamalloy: crims are acts caried out while criming
17:37gfredericksaaaaaaaaaa: they can share things but it's always explicit
17:37amalloyjustin_smith: who told you carie is a crimeinal? this is slander
17:37aaaaaaaaaalike I defn function in namespace A, then do I have to defn it also in B if I wanna use it there
17:37ambrosebsare protocols backed by interfaces in clojure 1.7?
17:37gfredericksaaaaaaaaaa: nope, that's what require in the (ns ...) form does
17:38gfredericks(inc amalloy)
17:38lazybot⇒ 249
17:38Chousukeaaaaaaaaaa: you would generally use namespace A from namespace B as a dependency. that's kind of the point :P
17:39aaaaaaaaaaok
17:39Chousukeunless they're two different functions with the same name
17:39Chousukewhich does happen, but tends to cause trouble
17:40kaiyinisn't `apply concat` the same as `mapcat identity`?
17:40justin_smithpretty much
17:40amalloykaiyin: they are identical, yes
17:40gfredericksare they identically lazy?
17:40amalloyas is mapcat seq
17:40justin_smith(source mapcat)
17:40amalloygfredericks: i think so, but i'm not sure
17:40amalloy~def mapcat
17:41justin_smithkaiyin: ^ see above
17:41amalloymapcat just calls apply concat
17:41gfredericks$gimme what mapcat done look like
17:41gfrederickswhich is why mapcat is less lazy than it might be
17:41amalloyright, but it's the same as apply concat, isn't it
17:41gfredericksyep
17:42gfrederickswhich is also not so lazy but less surprisingly
17:42kaiyin(apply map f colls) looks weird, why not just (map f colls)?
17:42gfredericksbecause those are different
17:43kaiyingfredericks: in what way?
17:43gfredericks,(def colls [[:a :b] [:c :d]])
17:43clojurebot#'sandbox/colls
17:43gfredericks,(map list colls)
17:43clojurebot(([:a :b]) ([:c :d]))
17:43gfredericks,(apply map list colls)
17:43clojurebot((:a :c) (:b :d))
17:44gfredericks,(map list [:a :b] [:c :d])
17:44clojurebot((:a :c) (:b :d))
17:44gfredericks^ map with three args
17:45amalloykaiyin: map in clojure is also zipWith, and zipWith3, and...
17:46kaiyinok
17:46kaiyingfredericks: what exactly does (apply map list colls) do here?
17:47Chousuke"zips" all sequences in colls using the list function
17:48gfredericks,(def colls [[1 2 3] [4 6 9] [72 72 72]])
17:48clojurebot#'sandbox/colls
17:48gfredericks(apply map + colls)
17:48gfredericks,(apply map + colls)
17:48clojurebot(77 80 84)
17:48justin_smithkaiyin: compare ##(apply map set colls)
17:48lazybotjava.lang.RuntimeException: Unable to resolve symbol: colls in this context
17:48justin_smitherr
17:48justin_smith,(apply map set colls)
17:48clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core/set>
17:48justin_smith:I
17:49gfredericks,(apply map hash-set colls)
17:49clojurebot(#{72 1 4} #{72 6 2} #{72 3 9})
17:50kaiyinfrom the docs: apply Applies fn f to the argument list formed by prepending intervening arguments to args.
17:50kaiyindon't quite understand what it means.
17:51mavbozo,(doc apply)
17:51clojurebot"([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."
17:52amalloykaiyin: apply passes a list of things as individual arguments to a function
17:52kaiyinyes
17:52amalloy(let [xs '(1 2 3)] (+ xs)) doesn't work, because + expects numbers, not a list
17:52mavbozo,(max '(1 2 3))
17:52clojurebot(1 2 3)
17:52gfredericksthere's a few layers going on here
17:52amalloyso (let [xs '(1 2 3)] (apply + xs)) does work
17:53kaiyinyes
17:53mavbozo,(max 1 2 '(3 4))
17:53clojurebot#error{:cause "clojure.lang.PersistentList cannot be cast to java.lang.Number", :via [{:type java.lang.ClassCastException, :message "clojure.lang.PersistentList cannot be cast to java.lang.Number", :at [clojure.lang.Numbers gt "Numbers.java" 229]}], :trace [[clojure.lang.Numbers gt "Numbers.java" 229] [clojure.lang.Numbers gt "Numbers.java" 3860] [clojure.lang.Numbers max "Numbers.java" 3990] [san...
17:53Chousukekaiyin: in (apply map f colls) the function f is map, and the argument list is (conj f (seq colls))
17:53mavbozo,(apply max 1 2 '(3 4))
17:53clojurebot4
17:53amalloyin mapcat, the apply is used so that (mapcat f xs ys) can translate to (apply concat (map f xs ys)), but for any number of xs/ys/zs args
17:54amalloybecause all of the xs/ys/zs are captured in a single list, args, and need to be unrolled again in order to pass them to map
17:55kaiyinChousuke: did you mean cons?
17:55amalloykaiyin: yes
17:56kaiyinok, now i see.
17:56mavbozoin (apply max 1 2 '(3 4))
17:56mavbozomax, 1, and 2 intervenes apply and '(3 4)
17:57mavbozoor sits in-between apply and '(3 4)
17:57kaiyinyeah
17:57mavbozothat's my interpretation of 'intervenes'
17:59mavbozofor me, it took decent english mastery to comprehend clojure official docs
18:00kaiyinmavbozo: I feel the same way.
18:04justin_smithmavbozo: kaiyin: I dunno, you should have learned "educe" in first year english.
18:04justin_smith(not really)
18:04justin_smith(most native speakers don't think it's a word)
18:04mavbozois it SAT word? or GRE word?
18:04justin_smithGRE+
18:05justin_smithI would be surprised if GRE even expected you to know it
18:05kaiyin:D
18:05amalloycan confirm, grew up speaking english and though rich was making up educe
18:05arrdem+1 educe is a pack of lies
18:06mavbozo(dec educe)
18:06lazybot⇒ -1
18:06gfredericks~educe is a typo
18:06clojurebotRoger.
18:09justin_smithhttp://www.icbld.com/wordnet?q=search&amp;sid=1997258
18:09justin_smithI wonder if it has any hyponyms
18:10amalloy$dict hyponym
18:10lazybotamalloy: noun: A more specific term; a subordinate grouping word or phrase.
18:10justin_smithamalloy: wordnet has cool searches via hypernym / hyponym
18:11justin_smithlike a mix of a graph db and a thesaurus
18:11justin_smithwith edges that have directional specificity
18:12seangroveI have a directory I want cleaned when I run lein clean, but that shouldn't get cleaned when running lein uberjar - am I out of luck?
18:12justin_smith$ wn educe -hypov ... => etymologize, etymologise
18:12justin_smith(hyponym, verb)
18:14justin_smithwell that's kinda meta
18:16seangroveAnd assuming that lein uberjar does implicitely invoke lein clean, what's the reasoning behind that? Would like to understand so I'm not shooting myself in the foot
18:16justin_smithseangrove: are you sure it invokes lein clean?
18:17justin_smithalso, clean can be controlled by profile
18:17justin_smithso you can make sure the uberjar relevant profiles don't touch the thing you care about, right?
18:18seangrovetcrayford had this conversation with technomancy last year http://www.raynes.me/logs/irc.freenode.net/leiningen/2014-05-28.txt
18:18seangrovejustin_smith: Hrm, not sure - where can I read more about controlling lein clean for a given profile?
18:18kaiyinwhat does it mean to complement a list of numbers? https://gist.github.com/kindlychung/f33f6f73f5b08e0e5b90#file-x-clj-L61-L64
18:19justin_smithseangrove: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L309
18:19justin_smithseangrove: this may be what you want actually! https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L392
18:20seangrovejustin_smith: Ah yes! Interesting
18:20justin_smithanyway, that file is my lein bible
18:21seangroveObviously slightly terrifying to turn off, heh. But I have cljs assets I need precompiled and added to the resources directory to be included in the lein uberjar stuff, and I would still like the cljs files to be cleaned when running lein clean
18:21seangrovethanks justin_smith, I'll go through this
18:27mavbozo,(doc complement)
18:27clojurebot"([f]); Takes a fn f and returns a fn that takes the same arguments as f, has the same effects, if any, and returns the opposite truth value."
18:28mavbozo,((complement zero?) 0)
18:28clojurebotfalse
18:29mavbozokaiyin, set is the return type of get-connected
18:29kaiyinmavbozo: yeah, i kind of got it now.
18:30kaiyinlike the complement set operation.
18:30mavbozokaiyin, in clojure hashmap and set can be put in the function position
18:30kaiyincool
18:30mavbozo,(#{1 2 3} 3)
18:30clojurebot3
18:31mavbozo,(#{1 2 3} 4)
18:31clojurebotnil
18:36ambrosebswas there a bugfix to iterate recently?
18:36amalloy,(class (iterate inc 1))
18:36clojurebotclojure.lang.Cons
18:36amalloyambrosebs: no
18:36ambrosebs,*clojure-version*
18:36clojurebot{:major 1, :minor 7, :incremental 0, :qualifier "master", :interim true}
18:36amalloywhat makes you think iterate would be bugfixed?
18:36ambrosebs,(take 1 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))
18:36clojurebot(1)
18:36ambrosebshmm
18:37ambrosebsnow I'm confused.
18:37ambrosebsin alpha6 this seems to print "PR" 1 also
18:38amalloy&(take 1 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))
18:38lazybot⇒ (1)
18:38amalloy&*clojure-version*
18:38lazybot⇒ {:major 1, :minor 7, :incremental 0, :qualifier "alpha1"}
18:38amalloywait for reals?
18:38ambrosebsaccording to my local repl
18:38amalloyi thought lazybot was on a super old version. cool that it's on a 1.7 alpha
18:38joe124lazybot isn't so lazy
18:39Bronsaambrosebs: yeah there were changes to iterate in alpha6
18:39amalloy~def iterate
18:39aaaaaaaaaahey once again. I've googled a little about the line you gave me: (do (require '[clojure.repl :as repl]) (repl/dir 'clojure.repl)) and I'm just wondering, how it works at all. I mean how clojure sees the variables in the namespace? Is there anyway to hide some variables from /repl/dir ?
18:39amalloyoh goodness, there's an Iterate class now
18:39ambrosebsBronsa: I don't understand the new side effect.
18:40ambrosebsdoes it throw the result away?
18:40Bronsaamalloy: and a repeat and cycle one aswell
18:41mavbozo&(take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))
18:41lazybot⇒ ("PR1"
18:42mavbozo,(take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))
18:42clojurebot("PR1"\n1 2)
18:42Bronsaambrosebs: I'm not a fan of the new iterate
18:43Bronsanot 100% sure what's going on but I don't like at all the fact that reducing n times an iterate will recompute it every time
18:43joe124i like functional programming, does c++ have good support for that style?
18:44mavbozo(def yolo (take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1)))
18:44mavbozo,(def yolo (take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1)))
18:44clojurebot#'sandbox/yolo
18:44mavbozo,yolo
18:44clojurebot("PR1"\n1 2)
18:45mavbozo,yolo
18:45clojurebot(1 2)
18:45ambrosebsBronsa: recompute?
18:46ambrosebsso iterate is no longer immutable with reduce?
18:56cflemingseangrove: The issue is how to analyse code without evaluating it - Cursive works purely from source to avoid that
18:56seangrovecfleming: Is abstract interpretation evaluation, though?
18:56cflemingseangrove: Which gives it problems with macros, right - a solution is coming for that
18:56seangroveSomewhere in the middle, I'd argue
18:57cflemingseangrove: I guess the question is whether you can get enough of the behaviour you need to extract the information you want, while prohibiting side effects
18:57joe124i have a question is OOP going out of style?
18:57seangrovecfleming: I agree that's the challenge, especially in an unconstrained system
18:57cflemingseangrove: And having it be performant - Cursive has to index the whole project at first startup
18:58seangrove(e.g. reading/writing files in macros, etc.)
18:58seangrovecfleming: Yeah, that's the biggest concern with AI/SE, but I think it's not insurmountable
18:58ambrosebs,(def b (iterate (fn [_] (rand)) 1))
18:58clojurebot#'sandbox/b
18:58ambrosebs,(reduce (fn [l r] (prn r) (assert nil "kill")) b)
18:58clojurebot0.469655463114088\n#error{:cause "Assert failed: kill\nnil", :via [{:type java.lang.AssertionError, :message "Assert failed: kill\nnil", :at [sandbox$eval49$fn__50 invoke "NO_SOURCE_FILE" 0]}], :trace [[sandbox$eval49$fn__50 invoke "NO_SOURCE_FILE" 0] [clojure.core.protocols$fn__6439 invoke "protocols.clj" 135] [clojure.core.protocols$fn__6401$G__6396__6410 invoke "protocols.clj" 19] [clojure.core...
18:58ambrosebs,(reduce (fn [l r] (prn r) (assert nil "kill")) b)
18:58clojurebot0.469655463114088\n#error{:cause "Assert failed: kill\nnil", :via [{:type java.lang.AssertionError, :message "Assert failed: kill\nnil", :at [sandbox$eval75$fn__76 invoke "NO_SOURCE_FILE" 0]}], :trace [[sandbox$eval75$fn__76 invoke "NO_SOURCE_FILE" 0] [clojure.core.protocols$fn__6439 invoke "protocols.clj" 135] [clojure.core.protocols$fn__6401$G__6396__6410 invoke "protocols.clj" 19] [clojure.core...
18:58ambrosebs,(reduce (fn [l r] (prn r) (assert nil "kill")) b)
18:58clojurebot0.469655463114088\n#error{:cause "Assert failed: kill\nnil", :via [{:type java.lang.AssertionError, :message "Assert failed: kill\nnil", :at [sandbox$eval101$fn__102 invoke "NO_SOURCE_FILE" 0]}], :trace [[sandbox$eval101$fn__102 invoke "NO_SOURCE_FILE" 0] [clojure.core.protocols$fn__6439 invoke "protocols.clj" 135] [clojure.core.protocols$fn__6401$G__6396__6410 invoke "protocols.clj" 19] [clojure....
18:58cflemingseangrove: Yeah - I attended the Scheme workshop before the conj, and someone there told me about a Scheme macro that shelled out to a C compiler during macroexpansion
18:59ambrosebsin alpha6, this is obviously a different number each time
18:59ambrosebsGAH
18:59seangrovecfleming: The codebase I tried cursive on uses anaphoric macros and some other crazy things to get circular references, totally kills cursive's ability to give me the info I was looking for
18:59seangrovecfleming: But I understand that's not an entirely reasonable thing to ask for :)
19:00cflemingseangrove: There are other issues too - Storm, for example, reflects on a class from the project, and creates vars from its public fields (for config I think) - there's really no way for Cursive to be able to analyse that in any automatic way
19:01cflemingseangrove: You'd have to a) detect that that was what it was doing b) determine that the class came from the project c) either translate that code into something that uses the class AST or compile and load the class into a sandbox
19:01mavbozoambrosebs: yes, i just tried
19:01ambrosebs"In many cases, the new implementations are also faster for lazy sequences"
19:01cflemingseangrove: There's an extension API coming that will allow you to teach Cursive about such things
19:02cflemingseangrove: Are these macros from a public project, or internal?
19:02seangrovecfleming: While I agree with that, I think programaticaly-driven AI/SE with dynamic effect handlers and configurable analysis passes would get you a lot further with less effort, long-term. That said, I haven't actually implemented it (maybe while at Recurse), so I could be spouting nonsense :)
19:03cflemingseangrove: There are a surprising number of edge cases and people do some crazy stuff :)
19:04seangrovecfleming: Yeup, agree with that.
19:04cflemingseangrove: I'd like to be able to get closer automatically and require less code to be written with the extension API, for sure
19:05mavbozojoe124, no. everyday more codes get written in PHP, Ruby, C#, Java
19:06cflemingseangrove: Are your problematic macros internal to your project?
19:06seangrovecfleming: Yeah
19:06cflemingseangrove: Ok, you'll need the API then.
19:07joe124mavbozo i want to learn a functional language but when i see a bunch of functions stacked together in clojure it gives me a headache
19:08joe124i know there is a -> macro but i just dont like how it looks i guess lol
19:08cflemingseangrove: Would you mind dropping me a mail at cursive@cursiveclojure.com with a quick description of how they work, so I can make sure I can support them? I'm always interested to see more macro craziness.
19:09bjajoe124: you're free to write (foo (bar (baz (qux (quux (spam eggs)))))) instead of (-> eggs spam quux qux baz bar foo)
19:09Bronsacfleming: what if the user is ok with evaluating the project or if they have a repl connected & the project is loaded? then you would be able to know how to macroexpand & figure out the bindings right?
19:10bjaor do that matter (let [result-of-spam (spam eggs) result-of-quux (quux result-of-spam) result-of-qux (qux result-of-quux) .....] )
19:10bjabut I wouldn't personally
19:11cflemingBronsa: It's still tough, since Cursive indexes the whole project - you'd have to be able to load the entire project and all its deps, then introspect the whole thing. It's a) slow b) difficult to do repeatedly (Cursive reindexes a file whenever it changes) and c) doesn't help you with local bindings
19:11mavbozojoe124: :) I avoided those threading macros too. but after a while, i can not code without them
19:13Bronsagah, lisps
19:17pmonksjoe124: I'm the same - the -> macro breaks my (arguably deficient) mental parser
19:17pmonksfwiw parens don't bother me much, if at all
19:18{blake}mavbozo, joe124: Oh, yeah, me too. Threading macros just seemed wrong somehow at first. Now I find them cool.
19:18pmonks(inc arrdem); (inc cfleming); (dec pmonks)
19:18lazybot⇒ 41
19:18pmonksdoh
19:18pmonks(inc cfleming)
19:18lazybot⇒ 14
19:18pmonks(dec pmonks)
19:18lazybotYou can't adjust your own karma.
19:18arrdempmonks: well you commented out cfleming :P
19:19pmonksyeah - it's more than my parser that's deficient ;-(
19:19mavbozojoe124: after doing clojure and try to use functional programming style in PHP programming, I think immutability is the absolute minimum requirement for a good support for a functional programming style. I still cannot fathom doing it in C++ with its manual memory management.
19:19pmonksCan someone dec me plz? Apparently I can't adjust my own karma
19:19arrdem(inc pmonks) ;; ur not alf bad
19:19lazybot⇒ 2
19:19pmonksHEY!
19:19joe124what are some other good functional languages? i know of f# is that good
19:20cfleming(- 2 pmonks)
19:20pmonksyay!
19:20joe124i dont need it to be 100% pure like haskell or anything
19:20mavbozojoe124: although some C++ gurus like John Carmack tries to use functional programming style in his C++ coding. http://gamasutra.com/view/news/169296/Indepth_Functional_programming_in_C.php
19:20pmonksjoe124 I'm having a blast with pixie, though it's inspired by clojure so might not be what you're looking for
19:24weiwhat’s a good way to connect to a repl, execute a command and return its output, as a shell script?
19:28mavbozojoe124: umm, erlang
19:29{blake}I'd love to see a good clojure-esque game language. But I'm far from testing the limits of play-clj just yet.
19:29mavbozowei: grenchman https://github.com/technomancy/grenchman
19:29weithanks!
19:30aaaaaaaaaahey once again. I've googled a little about the line you gave me: (do (require '[clojure.repl :as repl]) (repl/dir 'clojure.repl)) and I'm just wondering, how it works at all. I mean how clojure sees the variables in the namespace? Is there anyway to hide some variables from /repl/dir ?
19:31mavbozojoe124: erlang is immutable too without those parenthesis
19:33gfredericksinstead of parentheses it has all this context-sensitive punctuation
19:35joe124i have a question if the functional paradigm reduces bugs and is more efficient and such why is OOP so much more popular
19:35joe124wouldnt startups just only hire people to program in functional languages
19:38{blake}joe124: OO programming is really easy. (I mean, up until it's not.)
19:38klyed2joe124: imo because there are way less people who are good at functional programming
19:39mavbozojoe124: well, lots of big silicon valley companies use functional languages. twitter scala, whatsapp erlang, apple swift, facebook hack?
19:40thomasfustonjoe124: its not oop vs functional, its more imperative "vs" functional programming
19:45pmonks(inc thomasfuston)
19:45lazybot⇒ 1
19:45ntaylorright, thomasfuston has it. It's a spectrum, not a binary "either/or" thing. You can write very imperative Scala just like you can write very functional Java. Or Ruby, or Perl, or...
19:46brehautVHS
19:46brehautits gotta be better than betamax right?
19:46oddcullywindows ;P
19:46brehautinstant coffee
19:46brehautalso betamax vs video 2000
19:47ntayloron the startup side: I'd wager a big barrier there is that there's no peer to Rails for getting a webapp up and running quickly
19:47brehautPHP vs anthing
19:49brehautpersonally i think its just taht popular things are popular because they are popular
19:49ntayloryep
19:53brehauthttp://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
19:55akkadJesus Virtual Machine?
19:57akkadso a jvm hangs, what sort of tools other than jstat/jmap/jstack can one use to profile the cause?
19:58ntaylorpossibly gdb?
19:58ntaylorif you're running native code, that might be helpful
19:58brehautstrace?
20:00ntaylorpossibly, though Hotspot's use of signal delivery might make strace a bit noisy
20:00brehauttrue
20:00brehauthttp://unix.stackexchange.com/questions/56940/how-to-trace-a-java-program looks potentially useful
20:00ambrosebsis it safe to use the latest core.async master?
20:00ntaylor(also if you're blocked on a read or something, you won't ever see anything from a mutator thread)
20:01ntaylorbrehaut: nice find
20:11justin_smithakkad: visualvm
20:12akkadassuming you need to have jmx port avail for that
20:12justin_smithand jdb
20:12justin_smithno
20:12justin_smithoh jdb? maybe
20:13justin_smithbut sure, can't hurt to have jmx open
20:17akkadk
20:19ambrosebsBronsa: any known issues with AOT compilation and (:refer-clojure :exclude [update]) then (def update ..)? Spitting a warning at me.
20:19Bronsaambrosebs: not that i'm aware of
20:19ambrosebsBronsa: ok I'll dig further
20:26ambrosebsBronsa: nvm, was complaining about foo.test.bar namespace and I read foo.bar
20:33akkadvisualvm is pretty much a stripped down jconsole. unless I missing a magical options menu
20:38pmonksActually it's a superset, as it can load jconsole plugins.
20:38pmonks(as well as its own)
20:38justin_smithI bet we could make some clojure plugins
20:39justin_smithlike shortcuts to look at clojures resources like the agent pool and such...
20:39justin_smithmaybe other things?
20:39pmonksPrettifying the stack traces too
20:39justin_smithoh yeah, extracting the data that is more relevant to clojure
20:39justin_smithfor sure
20:39justin_smithpmonks: oh, and looking at clojure locals
20:40pmonksBTW TDA (which has a VisualVM plugin) is one of my all time favourite debugging tools.
20:40pmonksYou can "diff" separate thread dumps and it'll infer which ones are hung.
20:40justin_smithwow
20:40pmonksIt can also read thread dumps out of "dirty" log files, which is awesome.
20:40pmonksSo you can just SIGQUIT your JVM every minute for a few minutes then load up a single log file into TDA and it'll extract each of the dumps.
20:40justin_smithahh, so it's just arbitrary output from the vm, and it finds and analyzes the thread dumps?
20:40pmonksThat alone is worth the price of admission.
20:40justin_smithright, right
20:41justin_smithvery cool
20:41pmonksThere's a sdtandalone version too, but it seems to want JVM 6 (which I can't get on Mac OSuX any more ;-(
20:41justin_smithpmonks: I am having trouble finding tda in the googles
20:42justin_smiththread dump analyzer?
20:50pmonksyep that's the one
20:53TEttingerpmonks: there's an openjdk 6 build for mac
20:54pmonksYah for some reason I've struggled to install it on Yosemite. ;-(
20:54TEttingernot osx 64-bit it seems
20:54TEttingerhttp://community.openscg.com/se/openjdk/archive.jsp
21:04pmonksYeah that might be my problem
21:04pmonksBut at least I can use it from inside visualvm
21:05pmonksIt's here btw: https://java.net/projects/tda #lazyweb
21:12justin_smithpmonks: thanks
21:13justin_smithpmonks: I think part of the issue with searching for tda is that like most tlas it's a bit overloaded
21:15pmonkstru
21:15pmonks#seewhatididthere
21:15justin_smith$google tla shortage
21:15lazybot[Tumescent Local Anesthesia TLA Tumescent Information and ...] http://www.tumescent.org/
21:15justin_smithumm
21:15justin_smithdemonstrates the problem, but not the link I had in mind
21:16amalloyhahaha
21:16pmonksI had a tumescence once. It was followed soon after by a restraining order. ;-(
21:18justin_smiththis is the one http://softwaresafari.typepad.com/software_safari_premium_b/2008/01/another-to-pass.html
21:28akkadanyone ever see cases where using an uberjar with some AOT of classes, you see cases of undefined class, for something that it clearly has in the uberjar, but some how lost through gc, or something.
21:29justin_smithakkad: this reminds me of the reloading protocols / reloading records thing
23:12joe124hi if i have a vector how would I use filter to get every other element? as in elements 0 2 4... and how would I use filter to get elements 1 3 5...? Thank you
23:12joe124doesn't have to be filter btw just the first thing that came to mind
23:12amalloy,(doc take-nth)
23:12clojurebot"([n] [n coll]); Returns a lazy seq of every nth item in coll. Returns a stateful transducer when no collection is provided."
23:13joe124yah take nth could work for the even elements
23:13amalloyjoe124: it can't be filter, because filter is only passed the items in the sequence, not their indexes
23:13amalloyuh, it works for the odd ones too
23:13justin_smithjoe124: filter doesn't really work, since "every other" isn't a property of the individual item
23:13joe124ahh ok
23:13amalloy(take-nth 2 (rest xs))
23:13joe124oh wow lol that was easy thanks amalloy
23:14joe124if I have a card game that has a users hand and computer hand, how would i update their hands? would i keep doing def or let?
23:14justin_smithjoe124: I would use a recursive function which takes the updated decks and hands as arguments
23:15justin_smithand then gets the user input (in whatever way) before displaying, then recurring again
23:17joe124im trying to imagine how that would work
23:18joe124just the overall layout of the update
23:18justin_smith(defn play-round [hands deck] (let [play (get-inputs) hands (update-hands play hands) deck (update-deck play)] (recur hands deck))) something like this
23:19justin_smithwhere update-hands and update-deck have the logic for where the cards end up
23:19justin_smithyou probably want an if wrapping the occur, checking if the game is over
23:20justin_smiths/occur/recur
23:20justin_smithjoe124: pretty much identical to your imperative while loop
23:21joe124and before the play-round function i would do a let to define the opening hands right
23:22justin_smiththe opening hands would be passed in at the start
23:22joe124yah
23:22justin_smithand each round would be a recur, yeah
23:22justin_smithyou would maybe also pass in the GUI or network hooks to interact with the players at the start
23:23justin_smiththat way it's totally isolated, one server can have as many games going on as it can handle connections from players
23:24justin_smithyou don't have to do it that general / large scale - I just tried to set you up with the version that would scale best if you wanted to
23:27ebbflowgohi.. i'm using jruby with a clojure file... one of my variables returns an array in clojure but with the jrclj it returns a Java::Clojure::PersistentArrayMay I'm struggling with converting this to a ruby array https://gist.github.com/ebbflowgo/12ccaf0a0b783de984d7
23:29joe124is it a good idea to do it like (defn game-loop [] (-> (setup-game) (play-rounds) (ask-to-play-again))) and then have a bunch of smaller functions in each of these 3 bigger functions?
23:29justin_smithsure, and I assume that would pass forward a hash-map with all your hands and deck etc.
23:29amalloyebbflowgo: i don't know about jruby, but clojure's maps implement java.lang.Map
23:30amalloyso you could iterate over their entryset or whatever
23:30justin_smithebbflowgo: yeah, PersistentArrayMap is not an array type, it is a hashmap type
23:30joe124if a user wants to start a new game then he just calls game-loop again recursively?
23:31justin_smithjoe124: or from the top level
23:31justin_smithjoe124: depends what you want the entry point to be - for example you could start new games with a network request, or a click of a button on the gui, or a command or hitting return in the console
23:32joe124yeah currently im just doing a single player console based version
23:32joe124when a user starts a new game how do I garbage collect or whatever its called the old game's hands and decks and such?
23:33joe124or are they contained in a let and once i leave the let they dissapear?
23:41justin_smithjoe124: yeah, if there is no accessible binding to a value, the gc is allowed to clean it up, and will likely do so, eventually
23:42justin_smithso unless you assign a def to a game, or return it from the let, it will just be gone when the let block exits
23:42joe124better change my defs to lets then
23:42joe124ok thanks a ton justin and everyone g2g cya later