#clojure log - Apr 01 2015

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

0:00 justin_smith: codesine: fyi you can do (repeat 10 [])

0:00 codesine: [[] [] [] [] [] [] [] [] [] []] how would i change the 0th element of this, and also modifying the whole list

0:00 OH

0:00 bbloom: codesine: if you have a vector, you can use assoc

0:00 codesine: (into [] (repeat 10 []))

0:00 bbloom: ,(vec (range 10 []))

0:00 clojurebot: #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...

0:00 justin_smith: ,(update-in (vec (repeat 10 [])) [3] conj :a)

0:00 clojurebot: [[] [] [] [:a] [] ...]

0:01 codesine: ah i was using (into [])

0:01 vec looks cleaner

0:01 justin_smith: codesine: either way

0:01 that's not the important part here

0:02 codesine: arghhh i was struggling with this for a day xD

0:02 justin_smith: assoc, as bbloom suggests, is decent if you are replacing an index

0:02 codesine: glad we could help

0:02 codesine: cuz when i was conj it naturally would just return a single element and not return the whole thing

0:02 bbloom: ,(assoc [0 0 0] 1 5)

0:02 clojurebot: [0 5 0]

0:02 bbloom: ,(update [0 0 0] 1 inc)

0:02 clojurebot: [0 1 0]

0:02 codesine: yeah i want to add to it

0:02 the update-in thing works for me

0:02 cuz i'm doing a bucket list

0:02 xD

0:02 bbloom: oh man, i am so excited about ##(doc update)

0:02 lazybot: java.lang.RuntimeException: Unable to resolve var: update in this context

0:02 bbloom: (doc update)

0:02 clojurebot: "([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."

0:03 bbloom: hurray

0:03 justin_smith: lazybot doesn't have update yet, but clojurebot does

0:06 codesine: hi bbloom

0:06 i have (update-in) but i don't have (update)

0:06 (doc update) --> returns nil

0:06 clojurebot: "([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."

0:06 whodevil: hello, 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?

0:06 justin_smith: codesine: update is new in 1.7-alpha5 I think

0:06 codesine: OHH

0:06 so that's why bbloom's example did not work for me

0:06 justin_smith: whodevil: it's part of the name

0:06 codesine: just your update-in

0:06 kk

0:07 justin_smith: whodevil: when you call defrecord, it will create a ->YourRecord function for creating it with

0:07 also map->YourRecord for making one out of a map

0:08 whodevil: neat, 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

0:08 justin_smith: thanks

0:08 TEttinger: justin_smith, bbloom: for extreme googlability, I'm thinking of calling the dungeon crawler clochu (lochu is Polish for dungeon)

0:09 it's also a bit of a pun on the pokemon-like nature of having 200 playable characters...

0:10 justin_smith: TEttinger: only if you map nil to a mob called MissingNo

0:11 TEttinger: ha

0:11 justin_smith: and then ensure that at least one bug in the game leads to that mob being instantiated :)

0:11 TEttinger: I'll use Double/NaN as a key

0:11 justin_smith: hahahaha

0:11 TEttinger: ,(hash Double/NaN)

0:11 clojurebot: 2146959360

0:11 TEttinger: wow

0:12 justin_smith: ,(hash-map Double/NaN :a Double/NaN :b Double/NaN :c)

0:12 clojurebot: {NaN :a, NaN :b, NaN :c}

0:12 TEttinger: yesssss

0:12 justin_smith: #YOLO

0:13 ,(hash-map Double/NaN :a Double/NaN :a Double/NaN :a Double/NaN :a :BAT :MAN)

0:13 clojurebot: {NaN :a, NaN :a, NaN :a, NaN :a, :BAT :MAN}

0:14 justin_smith: stupid clojure tricks

0:15 hyPiRion: ,(hash-set Double/NaN :a Double/NaN :a Double/NaN :a Double/NaN :a :BAT :MAN)

0:15 clojurebot: #{NaN NaN NaN NaN :MAN ...}

0:15 justin_smith: that's too bad

0:16 hyPiRion: close nough

0:16 TEttinger: &(hash-set Double/NaN :a Double/NaN :a Double/NaN :a Double/NaN :a :BAT :MAN)

0:16 lazybot: ⇒ #{NaN NaN NaN NaN :MAN :BAT :a}

0:16 hyPiRion: the illusive manbat

0:16 TEttinger: I can never remember is illusive is a real word or if it's always a misspelling of elusive

0:16 justin_smith: one of the under-utilized batman characters actually

0:17 elusive: hard to find because hidden illusive: hard to find because not there

0:17 I found a great phrase the other day that should really be a rap album title:


0:17 TEttinger: (inc justin_smith's vocabulary)

0:17 lazybot: ⇒ 1

0:18 justin_smith: hyPiRion: 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

0:18 TEttinger: is illocution as to eloction as illusive is to elusive?

0:18 justin_smith: $dict illocution

0:18 lazybot: justin_smith: noun: The aim of a speaker in making an utterance as opposed to the meaning of the terms used.

0:18 justin_smith: it's what you meant, not what you said

0:19 TEttinger: ah!

0:19 justin_smith: illocutionary force is the pressure of the speech act

0:19 TEttinger: the heat of the beats

0:19 justin_smith: TEttinger: ill, straight up sick

0:19 TEttinger: http://ccat.sas.upenn.edu/~haroldfs/dravling/illocutionary.html

0:20 TEttinger: just make the rap album all passive aggressive gangsterism

0:21 justin_smith: TEttinger: 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

0:21 TEttinger: yep

0:22 all right, lein new app clochu

0:22 wait

0:22 some kind of namespace

0:24 lein new app ☃/clochu

0:24 I wonder if that works...

0:24 justin_smith: that's a great org

0:25 and will be a pain in the ass to require in ns forms :)

0:25 TEttinger: java.io.FileNotFoundException: C:\Users\user\Documents\GitHub\DungeonRising\clochu\src\?\clochu.clj (The system cannot find the path specified)

0:25 it gets uh confused

0:25 justin_smith: TEttinger: file system can't handle utf8?

0:25 TEttinger: and spits a long exception :-(

0:25 windows

0:25 justin_smith: or maybe something in between

0:26 TEttinger: I thought windows had decent il8n

0:26 TEttinger: I even did a chcp 65001 beforehand to use utf-8 in terminal

0:28 ebbflowgo: learning clojure, found an example https://gist.github.com/ebbflowgo/74978338a15830b3b608 ..

0:29 why would they use a set for the awards, my understanding is that a set is like a dictionary, each item can only appear once

0:29 justin_smith: right

0:29 ebbflowgo: nvm

0:29 justin_smith: ?

0:29 ebbflowgo: i didn't see the string groupings

0:29 so it's saying each string has to be unique

0:29 not each word

0:29 justin_smith: right

0:29 cfleming: justin_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

0:29 ebbflowgo: justin_smith: thanks for looking

0:30 amalloy: &dump

0:30 lazybot: java.lang.RuntimeException: Unable to resolve symbol: dump in this context

0:30 amalloy: oops

0:30 justin_smith: cfleming: makes sense I guess

0:30 cfleming: I'm waiting for illocution to be used as a transducer function at some point

0:30 justin_smith: cfleming: haha

0:30 cfleming: I just illocute my educer and I'm good to go

0:31 justin_smith: cfleming: a promise is a kind of illocution

0:31 cfleming: justin_smith: Now you're just messing with me

0:31 justin_smith: not in programming, in speech acts

0:32 cfleming: speech acts sounds like something people should do in the privacy of their own homes.

0:32 justin_smith: hehe

0:32 adu: haha

0:32 codesine: (def k 1) (def k (inc k)) <-- for updating value, is this idiomatic or no

0:32 i feel like something is wrong about it...

0:32 idk why, even tho that works :|

0:32 justin_smith: it'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 :)

0:33 so we distinguish the speech act from the linguistic construction

0:33 adu: codesine: it's fine, but you're not mutating the value, just the binding

0:33 justin_smith: codesine: no, that's not a good idea unless in a repl just doing dev

0:33 codesine: oh, i want to mutate the value

0:33 hm...

0:33 justin_smith: if a top level value needs to change, us an atom or ref or agent

0:33 adu: codesine: then you're doing it wrong

0:33 codesine: yeah i felt like i'm doing it wrong

0:34 cfleming: ,(binding [*data-readers* {'error tagged-literal}] (read-string (pr-str (Exception. "except"))))

0:34 clojurebot: #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...

0:34 codesine: ah i did read a little bit about atom, and swap! etc

0:34 but mostly from code I saw laying around -- i wasn't sure the intention of it

0:34 cfleming: Hmm, maybe clojurebot's not up to date

0:34 codesine: I will try atom

0:34 justin_smith: codesine: also, we don't often actually need that top level state - usually we can replace it with an updated arg in a recursive call

0:35 codesine: oh yes

0:35 justin_smith: ,(clojure-version)

0:35 clojurebot: "1.7.0-master-SNAPSHOT"

0:35 codesine: I think I am just breaking things around to see how to do things

0:35 justin_smith: if we could query uptime we could know which snapshot...

0:35 codesine: I'm first going to do the updating in atom, then break it down into proper recursion

0:35 cfleming: justin_smith: I guess that went it with the reader conditional fix a couple of days ago

0:36 s/went it/went in/

0:37 clojurebot: how long have you been awake?

0:37 clojurebot: Titim gan éirí ort.

0:37 cfleming: Thanks.

0:37 justin_smith: codesine: 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++

0:37 or maybe (inc println)

0:37 or whtever

0:38 codesine: yea!

0:38 for debug

0:38 on account of me being a newbie

0:38 ;_;

0:38 justin_smith: (def debug (atom [])) then inside some function (swap! debug conj x)

0:38 then you can go through @debug and see what all the values were

0:38 after some calls

0:39 and also do things to those values (eg if they were a nested json response from a server...)

0:40 TEttinger: r/askhistorians is funny right now http://www.reddit.com/r/AskHistorians/comments/30z1fi/would_king_arthur_and_his_knights_really_have_had/

0:43 TEttinger: yes.

1:06 justin_smith: oh, and https://com.google is live

1:06 it's a doorway into the mirror web

1:07 even all the images are reversed

1:07 rpaulo: heh

1:07 justin_smith: (I verified this by doing a elgoog image search for "left"

1:07 codesine: hey justin I wrote something really naiive (as a learning experience,) but I have a particular question about a result I am receiving

1:07 justin_smith: )

1:08 codesine: http://pastebin.com/0cJR4fBt

1:08 amalloy: justin_smith: sincerely disappointed it doesn't proxy all of the links i click through their search bar

1:08 codesine: when I pass (s [4]) it returns nil

1:08 and the atom is updated properly

1:08 justin_smith: amalloy: clearly half assed

1:08 codesine: but when I pass a double digit (s [44]) it updates properly

1:08 but it returns the atom result as a list (instead of nil)

1:09 sort of like when i run swap! directly

1:09 justin_smith: codesine: and what ends up in the buckets?

1:09 codesine: the proper results

1:09 [[4] [44]...

1:09 justin_smith: ahh sorry, I was typing here but reading your code

1:09 codesine: i'mjust confused why if it's scenario one i get nil, and scenario 2 i get the swap return value

1:10 justin_smith: codesine: you have two ifs

1:10 the first one returns, but you never get the value out

1:10 because the second one returns nil, and that's the return value of the function

1:10 codesine: OHHHH

1:10 cuz in clojure the last thing that runs

1:10 is what's returned

1:10 justin_smith: maybe you want an else

1:10 codesine: and since scenario 2 doesn't run

1:10 it's just nil

1:10 justin_smith: or a cond

1:10 codesine: right?

1:10 justin_smith: right

1:10 codesine: ahh!

1:11 haha xD

1:11 i will do a cond

1:11 as a challenge I am trying to implement radix sort (:

1:11 justin_smith: codesine: also, pretty please, clojure code is much easier to read when you write conventionally, and that means no hanging ) ever

1:11 thanks

1:11 codesine: shoot

1:11 i didn't know

1:12 justin_smith: codesine: I didn't assume you knew, but just letting you know, it's easier for us old timers to read "normal" code

1:13 codesine: i'm reformatting it rq and will pass it by to see if it's proper

1:13 i want to develop good habits

1:13 :D

1:13 justin_smith: codesine: lein kibit is good for that

1:13 it's a plugin that checks for good style

1:14 not 100% uncontroversial, but still helpful

1:14 codesine: http://pastebin.com/iapy3UNb

1:14 is that proper

1:14 oh ok i'll check out kibit

1:14 so I can put stuff on new line, just no hanging )'s

1:15 justin_smith: codesine: 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

1:15 right

1:15 codesine: ah I had some really nasty print statements prior

1:15 justin_smith: and it looks like you are using emacs auto-indent, or something that follows it closely enough

1:15 codesine: so I no longer need do, bot it

1:15 justin_smith: makes sense

1:15 codesine: yeah i'm doing it in emacs

1:15 but at times i did key in enter

1:16 cuz I was trying to get my bearings straight :(

1:16 so I made those unwanted )'s lol

1:16 justin_smith: it's just a convention thing, but it's nice to follow

1:16 codesine: I see no reason why I shouldn't aim to get accustomed xD

1:16 thank you thank you

1:17 justin_smith: also, (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

1:17 swap! does the chaining at the end just like update-in does

1:18 codesine: hm

1:18 so I would use (fn) when i want multiple args i guess

1:18 er

1:18 that's notrigght

1:18 disregard my last statement

1:18 sec reading

1:18 justin_smith: no, you don't need fn in that context, unless the thing swapped shouldn't be the first arg

1:19 codesine: ah!

1:19 ah chaining at the end

1:19 so it's like it called it like so

1:19 update-in <atom> [0] conj n

1:19 justin_smith: right

1:20 codesine: sweet

1:22 else

1:22 justin_smith: no no, cond

2:23 tsdh: Hi. 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?

2:31 Never 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.

2:45 TEttinger: justin_smith: can you help me out with this reflection warning?

2:45 Reflection warning, rogue/like/clochu.clj:22:16 - call to method generate can't be resolved (target class is unknown).

2:46 generate is called on a java object that I got with this: (def dg (DungeonGen.))

2:46 and I'm not sure how to type hint this or where

2:47 (should there be a type hint before the object in (.generate dg etc etc2) or should there be one when it's deffed?)

2:47 hey Bronsa

2:48 Bronsa: hi

2:48 amalloy: you can't super-easily hint def'd objects, TEttinger, iirc. i'd just put one where you call it

2:48 or let-bind it and hint the binding

2:48 TEttinger: ah ok thanks amalloy

2:48 it's used later

2:48 so def seems to make sense here

2:48 (inc amalloy)

2:48 lazybot: ⇒ 248

2:49 amalloy: i mean, suppose you are writing (.f dg) (.g dg) (.h dg)

2:49 you do'nt want to hint it three times, so you could write (let [^Whatever x dg] (.f x) (.g x) (.h x))

3:13 codesine: justin!

3:14 I'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

3:14 http://pastebin.com/frZYTfwi

3:14 if the map call is the last item in the do, it populates

3:14 or ofc if i don't place it in a do

3:15 why does the map call not populate the atom if there is another item afterwards in the do statement in the above pastebin :(

3:17 mavbozo_: codesine: map returns lazyseq

3:17 slipset: codesine: use doseq instead of map>

3:17 or if you really, really want to use map, use mapv

3:17 ~doseq

3:17 clojurebot: doseq is like for, but for side effects instead of values

3:17 codesine: ah

3:17 slipset: ~mapv

3:17 clojurebot: It's greek to me.

3:18 mavbozo_: i guess justin_smith is sleeping

3:18 slipset: @(http/get "https://www.testgjensidige.no/eai/op?TAM_OP=login_success&ERROR_CODE=0x38cf05e7&URL=%2Fpkmslogin.form&AUTHNLEVEL=" {:headers {"Cookie" "PD-S-SESSION-ID=1_EZhDA6iMReib5ZO+/iMRU0l2cKLgHxiKbYKC79WF542F8TwOmWo=_AAAAAAA=_DjPMX2eJG7eL90cloV0Y5I6MXdc=; Path=/; Secure"}})

3:18 @(http/get "https://www.testgjensidige.no/eai/op?TAM_OP=login_success&ERROR_CODE=0x38cf05e7&URL=%2Fpkmslogin.form&AUTHNLEVEL=" {:headers {"Cookie" "PD-S-SESSION-ID=1_EZhDA6iMReib5ZO+/iMRU0l2cKLgHxiKbYKC79WF542F8TwOmWo=_AAAAAAA=_DjPMX2eJG7eL90cloV0Y5I6MXdc=; Path=/; Secure"}})

3:18 @(http/get "https://www.testgjensidige.no/eai/op?TAM_OP=login_success&ERROR_CODE=0x38cf05e7&URL=%2Fpkmslogin.form&AUTHNLEVEL=" {:headers {"Cookie" "PD-S-SESSION-ID=1_EZhDA6iMReib5ZO+/iMRU0l2cKLgHxiKbYKC79WF542F8TwOmWo=_AAAAAAA=_DjPMX2eJG7eL90cloV0Y5I6MXdc=; Path=/; Secure"}})

3:18 https://clojuredocs.org/clojure.core/mapv

3:18 wow, crazy cutbuffer

3:20 mavbozo_: $grim mapv

3:22 codesine: ah, mapv works for me well in this case @slipset

3:22 doseq I would have to change things around a bit more thank you!

3:27 Seylerius: ,(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)))))

3:27 clojurebot: #'sandbox/sub-seq

3:27 Seylerius: ,(sub-seq [1 0 1 2 3 4 0 4 5])

3:27 clojurebot: [0 1 2 3 4]

3:28 Seylerius: ,(sub-seq [1 0 1 2 3 0 4 5])

3:28 clojurebot: [0 1 2 3]

3:29 Seylerius: ,(sub-seq [5 6 1 3 2 7])

3:29 clojurebot: [5 6]

3:29 Seylerius: ,(sub-seq [2 3 3 4 5])

3:29 clojurebot: [2 3]

3:30 Seylerius: ,(sub-seq [7 6 5 4])

3:30 clojurebot: [7]

3:35 Seylerius: ,(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

3:35 remainder)] longest-sub))))

3:35 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

3:51 Seylerius: ,(defn partitioner [x coll] (loop [remainder coll result []] (cond (empty? remainder) result (>= (count remainder) x) (recur (drop x remainder) (conj result (take x remainder))))))

3:51 clojurebot: #'sandbox/partitioner

3:51 Seylerius: ,(partitioner 3 (range 8))

3:51 clojurebot: nil

3:51 Seylerius: Hrm.

3:51 That's puzzling.

3:51 It works for &(partitioner 3 (range 9))

3:53 Ricardo-Arges: Seylerius: but you're not handling the < case, are you?

3:54 So there's no condition to deal with the remaining [6 7]

3:55 Seylerius: Oh... I see the problem. Yeah, it's not recurring the last time.

3:55 This whole thing can be streamlined

3:57 ,(defn partitioner [x coll] (loop [remainder coll result []] (if (>= (count remainder) x) (recur (drop x remainder) (conj result (take x remainder))) result)))

3:57 clojurebot: #'sandbox/partitioner

3:57 Seylerius: ,(partitioner 3 (range 8))

3:57 clojurebot: [(0 1 2) (3 4 5)]

3:57 Seylerius: There we go.

3:57 Also, what's the syntax to make clojurebot evaluate something in the middle of a line?

3:57 I know lazybot will handle this just file: ##(= 3 4)

3:57 lazybot: ⇒ false

3:58 Seylerius: Was it &&(partitioner 3 (range 9))?

3:58 No.

3:58 Hmm...

4:07 tsdh: How can I prevent that java.lang gets imported automatically in order to be able to import another class named Class?

4:08 Seylerius: ,(group-by identity [1 1 2 3 2 1 1])

4:08 clojurebot: {1 [1 1 1 1], 2 [2 2], 3 [3]}

4:08 tsdh: I can't find something like (:refer-java :no-please-dont) analogous to (:refer-clojure ...).

4:19 Seylerius: ,(defn counter [coll] (into {} (map count (group-by identity coll))))

4:19 clojurebot: #'sandbox/counter

4:19 Seylerius: ,(counter [1 1 2 3 2 1 1])

4:19 clojurebot: #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...

4:22 slipset: dakrone:Struggeling a bit with http-kit and :insecure

4:22 reading the code, I end up in:

4:22 Seylerius: ,(defn counter [coll] (let [groups (group-by identity coll)] (zipmap (keys groups) (map count (vals groups)))))

4:22 clojurebot: #'sandbox/counter

4:22 Seylerius: ,(counter [1 1 2 3 2 1 1])

4:22 clojurebot: {1 4, 2 2, 3 1}

4:22 slipset: conn_mgr.clj and (def insecure-socked-factory

4:23 Seylerius: ,(counter [:b :a :b :a :b])

4:23 clojurebot: {:b 3, :a 2}

4:23 slipset: https://github.com/dakrone/clj-http/blob/master/src/clj_http/conn_mgr.clj#L21

4:23 Seylerius: ,(counter '([1 2] [1 3] [1 3]))

4:23 clojurebot: {[1 2] 1, [1 3] 2}

4:24 Seylerius: There a tidier way to do that?

4:24 slipset: where you reify TrustStrategy and define (isTrusted [_ _ _] true)

4:25 never mind.

4:48 sm0ke: ,*data-readers*

4:48 clojurebot: {}

4:54 dysfun: Bronsa: is there a way to get line and col positions for everything from tools.reader, not just on collections?

4:54 (and symbols)

4:55 Bronsa: dysfun: no unfortunately, there's no place to store that info

4:56 oddcully: Seylerius: what about (defn counter [coll] (into {} (map (fn [[k v]] [k (count v)]) (group-by identity coll))))

5:27 dysfun: Bronsa: would you be interested in patches that gave you it back as a separate data structure?

5:28 Bronsa: dysfun: sure as long as it doesn't impact performances & it's an optional feature

5:28 dysfun: Bronsa: okay. i'll have a bash at it. you'll probably hear from me on github in about a week

6:48 jaen: Is 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

6:55 devll: is it possible to compute huge (mils * mils) matrix multiplications with the current available libraries?

7:00 TEttinger: devll: what type of computation needs this?

7:01 (there's probably a better way)

7:03 devll: PageRank

7:04 yeah, running computations on clusters like Spark.

7:04 I want to use pure Clojure solution if possible.

7:36 ordnungswidrig: devll: are these sparse matrixes?

8:06 slipset: jaen: it seems strange to me that you're taking from the pause channel when you've already got a result from it via alts!

8:07 jaen: ok, I see, the alts! is to start the pause, the take is to end the pause.

8:08 jaen: slipset: 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

8:08 I f that makes sense

8:09 slipset: Yes, just took me a while to wrap my head around this.

8:27 patrkris: hi 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

8:27 (i.e. operations = functions operating on those components)

8:28 justin_smith: Seylerius: counter is just frequencies

8:29 ,(frequencies '([1 2] [1 3] [1 3]))

8:29 clojurebot: {[1 2] 1, [1 3] 2}

8:30 justin_smith: patrkris: components as in stuartsierra's component lib?

8:30 patrkris: justin_smith: yes

8:32 hmm... maybe there could be a transaction component in the system, which other components could rely on. thus no global state

8:32 justin_smith: wouldn'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?

8:32 or that

8:32 patrkris: justin_smith: let's take an example where I have a orders component and a customers component

8:33 and the orders component has an operation `place-order!` and the customers component an operation `inc-order-count` (lame example)

8:33 and we want to increase the order count in the same transaction that we place the order

8:34 devll: ordnungswidrig: I was out for supper . Yes ,it is sparse

8:34 patrkris: justin_smith: how do you mean to implement your idea in that case?

8:35 justin_smith: the transaction component would have a dep on each operation it wants to carry out

8:35 but maybe I am not understanding this, because it feels like a weird fit for the component abstraction

8:37 patrkris: justin_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

8:37 mavbozo_: better just create a transaction component which contains customer component and order component

8:38 patrkris: mavbozo_: and then have the transaction component support operations that manipulate both orders and customers?

8:40 mavbozo_: no,

8:40 clojurebot: Titim gan éirí ort.

8:41 mavbozo_: there's a transaction function say purchase-order which transaction component, extract customer and order component

8:41 then calls function that directly manipulates those customer and order components

8:41 *which receives transaction component*

8:43 i assume `place-order!` receives order component and `inc-order-count` receives customer component

8:43 patrkris: mavbozo_: correct

8:44 so the transaction component is specific to the purchase-order operation, and not something general to compose other operations into a single transaction?

8:44 mavbozo_: (defn purchase-order [{:keys [customer order]}] (do (place-order! order) (inc-order-count customer)))

8:46 patrkris: where does the transaction come into the picture in your example?

8:48 mavbozo_: yeah, i forgot to put ask where do you put the db component. It's for a transaction to a single db?

8:50 patrkris: mavbozo_: yes

8:53 yellow13: hi there! which of these is more common on clojure: (deref (:debt data)) or (-> data :debt deref)

8:53 i tend to prefer the -> macro

8:53 justin_smith: @(:debt data)

8:54 would be the most frequent way to see that

8:54 mavbozo_: assuming you have a jdbc connection inside customer and order component, then you can create a connection specific for the transaction

8:54 and inject that connection to customer and order component

8:55 yellow13: cool, thankz

8:57 mavbozo_: (with-db-connection [trans-conn db] (put-order (assoc order :conn trans-conn)) (inc-order-count ...

9:08 patrkris: mavbozo_: 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

9:11 mavbozo_: patrkris, it's the design i get when following the example from the presentation slides where there is a customer and db components

9:12 justin_smith: patrkris: think of it as not a consumer using a transaction, but a transaction invoking operations

9:12 the transaction is the part that is in charge of the changes happening

9:12 because it can roll them back for example

9:12 the other parts just provide some operation that the transaction can wrap

9:13 that you pass the transaction to them is an (admittedly ugly) implementation detail

9:15 mavbozo_: patrkris: and my design breaks abstraction boundaries

9:18 patrkris: yes. maybe I am over-engieering but I feel that components should be black boxes and that a transaction mechanism should be also

9:21 I 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

9:25 noncom: does leins param :java-cmd affect the javac version used to compile java classes in the clojure project?

9:26 mavbozo_: it just occurs to me that maybe, for a jdbc transaction, it's hard to make transaction between remote objects inside a black box

9:26 technically, the transaction happens outside our process

9:28 patrkris: mavbozo_: you have a problem of "distributed" transactions in your project then?

9:29 justin_smith: patrkris: were you talking about db transactions?

9:29 mavbozo_: 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

9:29 patrkris: justin_smith: yeah... sorry if I wasn't clear about that :S

9:30 justin_smith: patrkris: 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

9:31 patrkris: justin_smith: yes. in my case I'm just interested in reusing operations that exist on components I made, but within a db transaction

9:32 justin_smith: right. But a transaction doesn't fit the OO concepts of encapsulation and separation of concerns you are citing here.

9:32 it leaks

9:33 I mean fundamentally, it can't be what it is if it doesn't

9:33 so you either don't abstract it, or it has to be the top level managing details inside it

9:33 because it's the boss

9:40 mavbozo_: so, I could just make a DbTransaction Component which by design changing the connection details inside every components which participates in transaction actions

9:53 patrkris: justin_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

9:54 and just say that all components must support unit of work, and what UoW does is then specific to the component implementations

10:11 irctc_: 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:12 I have to collect Q quarters of vectors. For instance starting at 12/2014, 9/2014, 6/2014, 3/2014, 12/2013,...

10:13 Any tips?

10:25 justin_smith: (let [ids (frequencies (mapcat (partial map id) vecs)) shared (set (keep #(when (= (val %) (count vecs)) (key %)) ids))] (mapv (partial filterv shared) vecs))

10:25 irctc_: 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:26 justin_smith: oh, the nested part makes it harder

10:27 irctc_: :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:45 tbaldridge: irctc_: seems like something a Database would be good at. Perhaps even Datomic

10:53 justin_smith: irctc_: 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:54 Bronsa: ,(->> '([1] 1) (keep empty?) first)

10:54 justin_smith: irctc_: the logic that binds items could be made a "linearize" function, and the logic that makes pruned-data could be a "delinearize" function

10:54 clojurebot: false

10:54 Bronsa: ,(->> '[[1] 1] (keep empty?) first)

10:54 clojurebot: #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:54 Bronsa: chunked seqs, yay.

10:55 justin_smith: irctc_: well, actually you'd also want to pull the group-by just before pruned-data into its def

10:55 but the idea should be clear

10:57 gfredericks: justin_smith: the biggest part of meeting internet people in person is finding out how tall they are

10:58 justin_smith: hah - some people have misleading personalities though. I knew this one woman for years before I realized she was actually short.

11:03 irctc_: just updated with that refactoring

11:07 irctc_: justin_smith: Thanks for the code.. I'll check it out and let you know..

11:08 justin_smith: there's probably a way to generalize the linearize / delinearize for arbitrary data shapes

11:08 probably something very simple that I am just blanking on

11:17 irctc_: Justin_smith: amazing stuff. would like to know your thought process ... perhaps as comments on the refheap.

11:17 justin_smith: irctc_: I pasted the original version as a one liner

11:18 basically everything but the linearize / delinearize

11:18 (but it's more readable as a let block)

11:18 the 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:19 the 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:20 irctc_: thanks.

11:22 justin_smith: irctc_: 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:22 I 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:23 then it would be generalizable as a kind of specialized reversible "leaf-seq"

11:23 maybe that would be a good name for it

11:23 clojurebot: excusez-moi

11:23 justin_smith: clojurebot: you're weird

11:23 clojurebot: Pardon?

11:48 anti-freeze: Hi 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:49 justin_smith: anti-freeze: the response should look like {:status 302 :body "http://other-url"}

11:49 if you are using the response map

11:49 anti-freeze: justin_smith: Ah, right. That should do it. Yea, I'm using standard response maps

11:56 justin_smith: Actually, the response seems to be returning an empty string

11:57 (:body response) => ""

11:57 justin_smith: anti-freeze: hmm ... one moment

11:58 anti-freeze: sorry, it's (get-in response [:headers "Location"]}

11:59 anti-freeze: justin_smith: Ah right. So something like (:headers response) => "/not-found" should return true for instance if I was being redirected to not-found

12:00 justin_smith: anti-freeze: (:headers response) would include {"Location" "/not-found"}

12:00 that's why I suggested get-in

12:00 anti-freeze: justin_smith: Oh, ok. Thanks a bunch. Seems to work fine now

12:01 justin_smith: because ring is fairly permissive, you may also have to check for ["Headers" :location] and various other combinations

12:01 jaspp: Is 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:01 justin_smith: oh, good

12:02 jaspp: sounds like a combo of select-keys and get-in

12:02 or update-in and select-keys

12:09 ,(defn prune-in [m keyv] (assoc-in {} keyv (get-in m keyv)))

12:09 clojurebot: #'sandbox/prune-in

12:10 justin_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:10 clojurebot: {:a {:e {:i {:o {:u 42}}}}}

12:27 arrdem: Anyone got a good joke on the idea of a tag? Naming a tagged value library.

12:28 gfredericks: your-it

12:29 xemdetia: wouldn't it be youre-it

12:30 justin_smith: xemdetia: thriftshop "I'm gonna pop some tags"

12:30 maybe not

12:30 arrdem: (inc xemdetia) ;; pedantism is rewarded here

12:30 lazybot: ⇒ 3

12:31 gfredericks: well I assumed "'" wasn't allowed and so was forced into a your/you're joke

12:32 if your lib name annoys the pedants, all the better I say

12:33 arrdem: Blazer? you too can dress your data nicely with tags :P

12:36 sritchie: cljc, wild news

12:36 didn’t realize that was landing in 1.7

12:37 wagjo: arrdem: guten-tag

12:37 arrdem: wagjo: hehe nice one

12:38 justin_smith: oh, I thought he was just greeting you

12:38 yeah, I like that one

12:38 (inc wagjo)

12:38 lazybot: ⇒ 5

12:38 wagjo: danke

12:38 sritchie: anyone know how to signal to leiningen or the reader which tags to keep?

12:38 justin_smith: arrdem: also, implies that of the options, your lib is the good one

12:38 sritchie: ie, are :clj, :cljs etc extensible, and how does one control the builds

12:40 justin_smith: hyPiRion: great timing for the new release

12:40 http://swearjure.com/swearjure-1.0.0/

12:43 gfredericks: 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:43 lazybot: ⇒ {NaN :a, NaN :a, NaN :a, NaN :a, :BAT :MAN}

12:45 gfredericks: hell no I did not

12:45 ,{Double/NaN 1 Double/NaN 2}

12:45 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: Double/NaN>

12:45 gfredericks: wait how does that work with hash-map

12:45 ,(hashcode Double/Nan)

12:45 clojurebot: #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:45 gfredericks: ,(hashcode Double/NaN)

12:45 clojurebot: #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:46 gfredericks: ,(hash Double/NaN)

12:46 clojurebot: 2146959360

12:46 gfredericks: ,(hash Double/NaN)

12:46 clojurebot: 2146959360

12:46 justin_smith: only works with hash-map (and probably into / conj)

12:46 hyPiRion: they hash to the same thing, but they are not equal

12:46 justin_smith: gfredericks: I think there must be a special path for numeric keys that doesn't ask for a hash?

12:46 ahh, so the hash would never get checked

12:47 or, wait...

12:47 hyPiRion: ,(conj #{} Double/NaN Double/NaN)

12:47 clojurebot: #{NaN NaN}

12:48 gfredericks: ~mystery

12:48 clojurebot: mystery is http://p.hagelb.org/mystery.gif

12:49 wagjo: today is a good day for Clojure palindrome

12:49 ,(fn O [nf fn] O nf)

12:49 clojurebot: #object[sandbox$eval165$O__166 "sandbox$eval165$O__166@7d4529d8"]

12:49 justin_smith: nice

12:50 wagjo: I can add to it and make it equivalent to first

12:50 ,((fn O [nf & fn] O nf) (range))

12:50 clojurebot: (0 1 2 3 4 ...)

12:50 justin_smith: oops

12:50 ,(apply (fn O [nf & fn] O nf) (range))

12:50 clojurebot: 0

12:50 BinaryResult: Quick reminder that Disco Melee is hiring clojure devs https://docs.google.com/document/d/1GvnrSCUbYgbY9XdFs_DUx-0QZG2bIYT8Mbr0zdpTeew/edit?usp=sharing

12:54 TimMc: ,1#!()!#1,

12:54 clojurebot: 1

12:55 TimMc: BinaryResult: Weren't you just hiring yesterday too? :-)

12:55 arrdem: TimMc: they've been hiring for a couple days. I don't mind :P

12:56 justin_smith: hourly reminders I would mind, that spanish speaking spam bot I minded, daily seems OK

12:56 BinaryResult: Yes still accepting resumes. I have been only posting once per day, if coming across as spam I will stop

12:56 Trying to catch eyes which may not have been on yesterday

12:57 TimMc: Sorry, I'm hypervigilant because I'm a reddit mod. So much spam... I get de-calibrated.

12:58 BinaryResult: No 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:59 justin_smith: my 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:00 hell, 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:01 BinaryResult: Glad I can do my part :)

13:01 arrdem: I 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:03 sobel: i'm sure there's a good reason, but i just discovered i can't nest anonymous functions

13:03 are they somehow not firstclassy enough? or is it a macro

13:04 justin_smith: sobel: how would you refer to the first arg of the inner function?

13:04 sobel: ...magic?

13:04 %% ?

13:04 justin_smith: sobel: ##(quote '#())

13:04 lazybot: ⇒ (quote (fn* [] ()))

13:04 sobel: ahunno, i just work here

13:04 justin_smith: sobel: I guess %% could hypothetically work, but it doesn't

13:05 sobel: so it's a lexical issue. i can see that gets annoying to try to solve.

13:05 annoying in the sense that you might regret the solution more than the problem

13:05 justin_smith: especially since (fn [] ) isn't so bad for the rare instances you need nesting

13:05 sobel: yeah. thanks for backboarding that. like i said, i'm sure there's a great reason. :)

13:06 when 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:07 justin_smith: sobel: definitely a different approach

13:16 dnolen: sritchie: long time coming

13:16 sritchie: yup

13:45 noncom: sobel: also, you might consider naming you anonimouse functions like (fn my-fn-name []) for better stack tracer

13:45 *tracing

13:56 * TimMc only uses pseudonymous functions

13:57 justin_smith: I use a function block chain, so that the functions can remain anonymous, but ownership is unambiguous

13:57 and fraud is forever encapsulated in the function block chain log

13:58 * TimMc sends repeated PRs until he has committed more than half of the code in justin_smith's repos, then steals his functions

13:58 justin_smith: haha

13:59 jjttjj: i 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:00 justin_smith: jjttjj: are you sure that's a vector? vectors are counted, counting just returns the count field

14:00 TimMc: Sounds like a lazy seq that you are realizing by calling count.

14:00 justin_smith: jjttjj: I assume you are holding on to the start of a lazy seq

14:01 jjttjj: woops yeah it's a lazyseq not a vector

14:01 justin_smith: and if you refactored not to hold onto the starting element, you could consume it without crashing

14:01 jjttjj: if you have a reference to the first item, it can't be gcd

14:01 if you don't, then it can be gcd so you can keep processing items as you realize them

14:02 jjttjj: I have a var in which I read it from a csv to get the data, would that hold the starting element?

14:05 TimMc: jjttjj: Possibly, depends on your code.

14:08 justin_smith: jjttjj: if the var is pointing to the lay seq, yeah

14:08 you can fix it by creating the lazy-seq locally, inside a let block

14:08 s/lay seq/lazy-seq/ of course

14:09 jjttjj: ok awesome thanks!

16:03 lexi-lambda: Hey, 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:04 justin_smith: lexi-lambda: there's reasonable clojure tooling for vim, intellij, even sublime

16:04 I forget, is lighttable built on atom?

16:04 mavbozo: lexi-lambda, what text editor you usually use?

16:04 justin_smith: because that does some cool stuff with clojure

16:04 lexi-lambda: No, I think it's its own thing.

16:04 seangrove: I hear good things about Cursive

16:05 arrdem: Cursive is awesome

16:05 edbond: lexi-lambda: +1 for cursive. IF emacs not an option

16:05 seangrove: I 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:05 arrdem: Light Table works too

16:05 mavbozo: emacs + cider is awesome

16:05 (inc cider)

16:05 lazybot: ⇒ 2

16:05 justin_smith: so yeah, lots of good options

16:05 arrdem: (inc cider)

16:05 lazybot: ⇒ 3

16:06 mavbozo: (identity cursive)

16:06 lazybot: cursive has karma 1.

16:06 lexi-lambda: I'm traditionally not an emacs user. I'm familiar with vim, but I don't really like it for larger projects.

16:06 seangrove: arrdem: Cursive seems to have trouble with anaphoric macros

16:07 justin_smith: if you're familiar with keeping things balanced and well indented in a lisp, any editor you like should work fine

16:07 though repl integration can definitely be convenient

16:07 lexi-lambda: I'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:08 If not, I'll check out other options.

16:09 seangrove: arrdem: 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:10 arrdem: that could be cool I guess

16:10 lexi-lambda: Is it safe to assume installing leiningen is what I want?

16:10 arrdem: lexi-lambda: yes you will want lein at least to start

16:10 justin_smith: lexi-lambda: yeah

16:10 just put the shell script on your path, it will take care of the rest

16:11 (when I first started I made the mistake of thinking I had to clone the repo, build, yadda yadda...)

16:11 lexi-lambda: I just ran a quick `brew install leiningen` on os x, which seemed to work fine

16:11 justin_smith: since lein is only a single file, I almost feel like using a package manager only makes it more complicated

16:14 lexi-lambda: Hmm, Atom's paredit plugin seems to be borked :/

16:35 oddcully: (inc fireplace)

16:35 lazybot: ⇒ 1

16:36 gfredericks: (inc cni)

16:36 lazybot: ⇒ 1

16:36 gfredericks: (dec ced)

16:36 lazybot: ⇒ -1

16:43 aaaaaaaaaa: hello

16:44 gfredericks: hello

16:44 aaaaaaaaaa: I 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:45 arrdem: $grim clj::clojure.repl/dir

16:46 aaaaaaaaaa: Hmm, I also tried that, but got "Unable to resolve symbol: dir in this context"

16:46 arrdem: sorry. I was trying to invoke a bot command. try this.

16:47 (do (require '[clojure.repl :as repl]) (repl/dir 'clojure.repl))

16:48 mavbozo: $grim clj::clojure.pprint/pprint

16:48 justin_smith: arrdem: the arg to dir shouldn't be quoted

16:48 arrdem: justin_smith: oh right macro

16:48 aaaaaaaaaa: make that (repl/dir clojure.repl)

16:49 justin_smith: ,(do (require 'clojure.repl) (clojure.repl/apropos #"^unchecked.*"))

16:49 clojurebot: (clojure.core/unchecked-add clojure.core/unchecked-add-int clojure.core/unchecked-byte clojure.core/unchecked-char clojure.core/unchecked-dec ...)

16:49 kaiyin: what is wrong with this function?

16:49 https://gist.github.com/kindlychung/3c8e0f45017102df64cc

16:49 aaaaaaaaaa: hmm, ok, so that I got my namespace, and what exactly this command returns?

16:50 justin_smith: kaiyin: the param vector to let should not be in parens

16:50 aaaaaaaaaa: the methods inside the namespace?

16:50 kaiyin: oh, my bad.

16:50 justin_smith: aaaaaaaaaa: the vars defined in the namespace

16:50 aaaaaaaaaa: vars and functions are not methods, they are objects

16:51 that's why we can use them as first class values

16:51 aaaaaaaaaa: hmm, and how could i check the values of that vars?

16:51 justin_smith: aaaaaaaaaa: anything at the top level of the repl will return its value

16:51 aaaaaaaaaa: more likely though you want to look at the doc string, or the source

16:51 aaaaaaaaaa: let's say I got namespace test.a.b and your command/function(?) returns me variable xyz

16:52 joe124: hi everyone i want to make a copy of freecell in clojure. Is javafx a good gui for clojure projects?

16:53 justin_smith: aaaaaaaaaa: wait, was that a question?

16:53 kaiyin: (def ^:dynamic t-edges (take 4 (repeatedly #(sample-2diff-nodes)))) what does the # do here?

16:53 justin_smith: kaiyin: introduces an anonymous function of no arguments

16:53 ,(#(print 'OK))

16:53 clojurebot: OK

16:54 aaaaaaaaaa: (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:54 justin_smith: aaaaaaaaaa: it cannot return nil. it prints xyz and returns nil

16:54 err, sorry, that was incoherent

16:54 it returns nil, xyz is the thing defined

16:54 and printed

16:54 kaiyin: justin_smith: how do you make a anonymous function with args then?

16:55 justin_smith: aaaaaaaaaa: if it exists, it has a value

16:55 aaaaaaaaaa: oh, ok. So xyz is the name of the variable in the namespace test.a.b ?

16:55 justin_smith: aaaaaaaaaa: like I said, type it into your repl, and hit return, and you will see the value

16:55 aaaaaaaaaa: yes

16:55 so in the repl, enter test.a.b/xyz

16:55 and you will see the value

16:56 kaiyin: oh, like this (#(str %) "Eh")

16:56 justin_smith: kaiyin: ##(#(print % "is the word") "the bird")

16:56 lazybot: ⇒ the bird is the wordnil

16:56 danlentz: ,(def foo (agent {:foo 0}))

16:56 clojurebot: #'sandbox/foo

16:56 danlentz: ,foo

16:56 clojurebot: #<Agent@3a5da873: {:foo 0}>

16:56 justin_smith: which is equivalent to ##((fn [x] (print x "is the word")) "the bird")

16:57 lazybot: ⇒ the bird is the wordnil

16:57 justin_smith: but more succinct

16:57 kaiyin: cool

16:58 gfredericks: ~the bird is the wordnil

16:58 clojurebot: Roger.

16:59 justin_smith: haha

16:59 aaaaaaaaaa: justin_smith: generates me some rubbish like: #<b$xyz test.a.b$xyz@{some hex}>

16:59 what is that?

17:00 justin_smith: an unreadable object, try (type test.a.b/xyz)

17:00 the class will be hidden in that weird stuff

17:01 danlentz: ,(send foo update-in [:foo] inc)

17:01 aaaaaaaaaa: got test.a.b$xyz

17:01 clojurebot: #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:01 danlentz: ,(def foo (agent {:foo 0}))

17:01 clojurebot: #'sandbox/foo

17:01 danlentz: ,(send foo update-in [:foo] inc)

17:01 clojurebot: #<Agent@6d83ddf6: {:foo 0}>

17:01 aaaaaaaaaa: what does exactly mean?

17:01 justin_smith: aaaaaaaaaa: that means it's probably a function - functions are an instance of a class, usually the only instance of that class

17:01 danlentz: ,foo

17:01 clojurebot: #<Agent@6d83ddf6: {:foo 0}>

17:02 danlentz: ,(send-off foo update-in [:foo] inc)

17:02 clojurebot: #<Agent@6d83ddf6: {:foo 0}>

17:02 aaaaaaaaaa: justin_smith: so it means that (do (require '[clojure.repl :as repl]) (repl/dir 'clojure.repl)) returns not only vars, but also functions?

17:02 danlentz: ,foo

17:02 clojurebot: #<Agent@6d83ddf6: {:foo 0}>

17:02 justin_smith: aaaaaaaaaa: vars can hold any class

17:02 including functions

17:02 arrdem: [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:03 justin_smith: nice

17:03 aaaaaaaaaa: vars are just containers that hold values

17:03 gfredericks: ~vars

17:03 clojurebot: vars are a linking construct

17:03 gfredericks: ~vars

17:03 clojurebot: vars are a linking construct

17:03 danlentz: i guess its wise not to give us threads

17:03 aaaaaaaaaa: justin_smith: oh, ok :). So in that case, how should I call this xyz function in the context of test.a.b ?

17:03 kaiyin: https://gist.github.com/kindlychung/d529b518cb1e87bd83a0 it seems concat has no effect here?

17:04 justin_smith: aaaaaaaaaa: 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:04 danlentz: kaiyin: awesome land of lisp

17:04 justin_smith: aaaaaaaaaa: try (repl/doc test.a.b/xyz)

17:04 aaaaaaaaaa: and/or (repl/source test.a.b/xyz)

17:04 kaiyin: danlentz: yeah, that's it!

17:06 danlentz: so, you have to prn t-edges within the scope of the binding expression

17:06 aaaaaaaaaa: hmm, source not found - does it mean, that xyz is also not a function? What else could it be?

17:07 justin_smith: it means that xyz either wasn't created via defn, or it wasn't loaded via a file reader

17:08 danlentz: binding only "temporarily" alters a var within the dynamic scope of the binding form

17:08 justin_smith: you can make functions without defn, but only defn (or defmacro) automatically add the source metadata

17:08 aaaaaaaaaa: can you show me an example, how to create function without defn? Just curious

17:08 justin_smith: ,(defn foo [] 42)

17:08 clojurebot: #'sandbox/foo

17:09 justin_smith: ,(foo)

17:09 clojurebot: 42

17:09 justin_smith: ,(def foo (constantly 42))

17:09 clojurebot: #'sandbox/foo

17:09 kaiyin: in case anyone could have a look: http://stackoverflow.com/questions/29400886/why-doesnt-concat-take-effect-here

17:09 justin_smith: ,(foo)

17:09 clojurebot: 42

17:09 justin_smith: ,(def foo (fn [] 42))

17:09 clojurebot: #'sandbox/foo

17:09 aaaaaaaaaa: justin_smith: err, you said without defn?

17:09 oh, ok

17:10 danlentz: kaiyin: binding only "temporarily" alters a var within the dynamic scope of the binding form

17:10 aaaaaaaaaa: so in that case should I call that test.a.b/xyz to return me anything?

17:10 justin_smith: aaaaaaaaaa: there are a number of ways to create a function, only one of them is defn

17:10 aaaaaaaaaa: sure, but it would probably be helpful to look at the source

17:10 if (source whatever) doesn't work

17:11 the file should be somewhere you can find it - inside a jar or on github at least

17:12 aaaaaaaaaa: lol, looks like after a few minutes on irc, i'll know more than after hours of reading tutorials :D

17:12 justin_smith: aaaaaaaaaa: I really need to work on my own guide (in progress)

17:12 danlentz: aaaaaaaaaa: this place really is an amazing resource

17:12 kaiyin: danlentz: ok, i'll give it another try.

17:14 danlentz: kaiyin: https://clojuredocs.org/clojure.core/binding

17:14 $doc binding

17:14 how does that work?

17:14 justin_smith: lazybot: work

17:14 danlentz: ,(doc binding)

17:14 clojurebot: "([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:14 Bronsa: arrdem: what's the point of ITaggedVal?

17:15 kaiyin: danlentz: here: https://gist.github.com/kindlychung/d529b518cb1e87bd83a0#file-new-clj-L58-L63

17:15 * arrdem points to 0.1.0-SNAPSHOT

17:15 arrdem: Bronsa: I'd rather have an interface and not use it than stick people with no interface to roll their own tagged structures.

17:15 not sure it makes sense but it doesn't cost anything worth mentioning

17:15 Bronsa: arrdem: satisfies? is really slow

17:17 aaaaaaaaaa: hmm, ok guys, thanks a lot for help :)

17:17 Bronsa: arrdem: also a minor nitpick but what's the point of (.t self) when you can just write t?

17:20 arrdem: Bronsa: thanks good catches

17:21 Bronsa: np, looks interesting btw

17:22 arrdem: I'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:22 smart constructors have saved my arse several times now

17:24 oddcully: justin_smith: wordnil? ;p

17:24 now that song is stuck again in my head...

17:26 justin_smith: so sorry

17:26 ,(print 'sorry)

17:26 clojurebot: sorry

17:27 justin_smith: &(print 'sorry)

17:27 lazybot: ⇒ sorrynil

17:27 justin_smith: ahh, that was the culprit

17:30 kaiyin: what is the equivalent of `where` statement in haskell ?

17:30 amalloy: kaiyin: there's just let

17:30 kaiyin: ok

17:30 justin_smith: I guess we could do a "backwards let" with the body first, then the bindings

17:30 gfredericks: ,(defmacro where [expr lettings] `(let ~lettings expr))

17:30 clojurebot: #'sandbox/where

17:30 justin_smith: fun beginner macro exercise

17:31 gfredericks: ,(where (inc x) [x 12])

17:31 clojurebot: #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:31 amalloy: justin_smith: nobody is ever happy with that suggestion though

17:31 justin_smith: heh

17:31 gfredericks: whoopsiedoodle

17:31 ,(defmacro where [expr lettings] `(let ~lettings ~expr))

17:31 clojurebot: #'sandbox/where

17:31 gfredericks: ,(where (inc x) [x 12])

17:31 clojurebot: 13

17:31 justin_smith: also you need a ~@ I think

17:31 amalloy: wasn't gfredericks trying to do something like that but calling it footnotes?

17:31 gfredericks: huh?

17:31 this is news to me

17:31 amalloy: i thought it was you. annotations? something like that

17:32 gfredericks: just for the poirpose of inverting let?

17:32 aaaaaaaaaa: one more question. Does clojure have something like global variables? Is it also a way to list them all?

17:33 gfredericks: no globals, just vars in namespaces

17:33 which are global in a more limited sense

17:33 amalloy: oh it was timmc

17:33 gfredericks: ~TimMc is the other gfredericks

17:33 clojurebot: A nod, you know, is as good as a wink to a blind horse.

17:33 justin_smith: gfredericks: hmm, depending how we mean it, you could call reader magic global

17:33 or some of it at least

17:34 aaaaaaaaaa: so is there any main namespace, so i could create globals for N namespaces?

17:34 not only for one

17:34 gfredericks: justin_smith: eh? what kind of reader magic?

17:34 justin_smith: ~gfredericks is the other gfredericks.

17:34 clojurebot: 'Sea, mhuise.

17:34 gfredericks: aaaaaaaaaa: what's your use case?

17:34 justin_smith: gfredericks: reader macros that aren't namespaced

17:34 gfredericks: inst & uuid?

17:34 justin_smith: etc.

17:34 yeah

17:34 aaaaaaaaaa: gfredericks: no use-case. Just asking if something like that exists in clojure

17:34 gfredericks: I dunno they're kinda static

17:34 aaaaaaaaaa: then no

17:35 justin_smith: yeah, they don't vary, but are global / unnamespaced

17:35 gfredericks: as is 42

17:35 justin_smith: another global!

17:35 gfredericks: ~42 is the global 42

17:35 clojurebot: Roger.

17:35 amalloy: gfredericks: 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:35 gfredericks: I'm going to have to answer for every crim TimMc has committed

17:36 justin_smith: gfredericks: since it is less than 128, and greater than -129, it really is a global mutable :)

17:36 danlentz: vinyasa seems to have introduced the convention of using namespace "." for global functions

17:36 intended for interactive use

17:36 amalloy: gfredericks: who commits crims? crimeinals?

17:36 aaaaaaaaaa: gfredericks: so namescapes can't also share the same vars/functions between each other?

17:37 justin_smith: amalloy: crims are acts caried out while criming

17:37 gfredericks: aaaaaaaaaa: they can share things but it's always explicit

17:37 amalloy: justin_smith: who told you carie is a crimeinal? this is slander

17:37 aaaaaaaaaa: like I defn function in namespace A, then do I have to defn it also in B if I wanna use it there

17:37 ambrosebs: are protocols backed by interfaces in clojure 1.7?

17:37 gfredericks: aaaaaaaaaa: nope, that's what require in the (ns ...) form does

17:38 (inc amalloy)

17:38 lazybot: ⇒ 249

17:38 Chousuke: aaaaaaaaaa: you would generally use namespace A from namespace B as a dependency. that's kind of the point :P

17:39 aaaaaaaaaa: ok

17:39 Chousuke: unless they're two different functions with the same name

17:39 which does happen, but tends to cause trouble

17:40 kaiyin: isn't `apply concat` the same as `mapcat identity`?

17:40 justin_smith: pretty much

17:40 amalloy: kaiyin: they are identical, yes

17:40 gfredericks: are they identically lazy?

17:40 amalloy: as is mapcat seq

17:40 justin_smith: (source mapcat)

17:40 amalloy: gfredericks: i think so, but i'm not sure

17:40 ~def mapcat

17:41 justin_smith: kaiyin: ^ see above

17:41 amalloy: mapcat just calls apply concat

17:41 gfredericks: $gimme what mapcat done look like

17:41 which is why mapcat is less lazy than it might be

17:41 amalloy: right, but it's the same as apply concat, isn't it

17:41 gfredericks: yep

17:42 which is also not so lazy but less surprisingly

17:42 kaiyin: (apply map f colls) looks weird, why not just (map f colls)?

17:42 gfredericks: because those are different

17:43 kaiyin: gfredericks: in what way?

17:43 gfredericks: ,(def colls [[:a :b] [:c :d]])

17:43 clojurebot: #'sandbox/colls

17:43 gfredericks: ,(map list colls)

17:43 clojurebot: (([:a :b]) ([:c :d]))

17:43 gfredericks: ,(apply map list colls)

17:43 clojurebot: ((:a :c) (:b :d))

17:44 gfredericks: ,(map list [:a :b] [:c :d])

17:44 clojurebot: ((:a :c) (:b :d))

17:44 gfredericks: ^ map with three args

17:45 amalloy: kaiyin: map in clojure is also zipWith, and zipWith3, and...

17:46 kaiyin: ok

17:46 gfredericks: what exactly does (apply map list colls) do here?

17:47 Chousuke: "zips" all sequences in colls using the list function

17:48 gfredericks: ,(def colls [[1 2 3] [4 6 9] [72 72 72]])

17:48 clojurebot: #'sandbox/colls

17:48 gfredericks: (apply map + colls)

17:48 ,(apply map + colls)

17:48 clojurebot: (77 80 84)

17:48 justin_smith: kaiyin: compare ##(apply map set colls)

17:48 lazybot: java.lang.RuntimeException: Unable to resolve symbol: colls in this context

17:48 justin_smith: err

17:48 ,(apply map set colls)

17:48 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core/set>

17:48 justin_smith: :I

17:49 gfredericks: ,(apply map hash-set colls)

17:49 clojurebot: (#{72 1 4} #{72 6 2} #{72 3 9})

17:50 kaiyin: from the docs: apply Applies fn f to the argument list formed by prepending intervening arguments to args.

17:50 don't quite understand what it means.

17:51 mavbozo: ,(doc apply)

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

17:52 amalloy: kaiyin: apply passes a list of things as individual arguments to a function

17:52 kaiyin: yes

17:52 amalloy: (let [xs '(1 2 3)] (+ xs)) doesn't work, because + expects numbers, not a list

17:52 mavbozo: ,(max '(1 2 3))

17:52 clojurebot: (1 2 3)

17:52 gfredericks: there's a few layers going on here

17:52 amalloy: so (let [xs '(1 2 3)] (apply + xs)) does work

17:53 kaiyin: yes

17:53 mavbozo: ,(max 1 2 '(3 4))

17:53 clojurebot: #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:53 Chousuke: kaiyin: in (apply map f colls) the function f is map, and the argument list is (conj f (seq colls))

17:53 mavbozo: ,(apply max 1 2 '(3 4))

17:53 clojurebot: 4

17:53 amalloy: in 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:54 because 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:55 kaiyin: Chousuke: did you mean cons?

17:55 amalloy: kaiyin: yes

17:56 kaiyin: ok, now i see.

17:56 mavbozo: in (apply max 1 2 '(3 4))

17:56 max, 1, and 2 intervenes apply and '(3 4)

17:57 or sits in-between apply and '(3 4)

17:57 kaiyin: yeah

17:57 mavbozo: that's my interpretation of 'intervenes'

17:59 for me, it took decent english mastery to comprehend clojure official docs

18:00 kaiyin: mavbozo: I feel the same way.

18:04 justin_smith: mavbozo: kaiyin: I dunno, you should have learned "educe" in first year english.

18:04 (not really)

18:04 (most native speakers don't think it's a word)

18:04 mavbozo: is it SAT word? or GRE word?

18:04 justin_smith: GRE+

18:05 I would be surprised if GRE even expected you to know it

18:05 kaiyin: :D

18:05 amalloy: can confirm, grew up speaking english and though rich was making up educe

18:05 arrdem: +1 educe is a pack of lies

18:06 mavbozo: (dec educe)

18:06 lazybot: ⇒ -1

18:06 gfredericks: ~educe is a typo

18:06 clojurebot: Roger.

18:09 justin_smith: http://www.icbld.com/wordnet?q=search&sid=1997258

18:09 I wonder if it has any hyponyms

18:10 amalloy: $dict hyponym

18:10 lazybot: amalloy: noun: A more specific term; a subordinate grouping word or phrase.

18:10 justin_smith: amalloy: wordnet has cool searches via hypernym / hyponym

18:11 like a mix of a graph db and a thesaurus

18:11 with edges that have directional specificity

18:12 seangrove: I 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:12 justin_smith: $ wn educe -hypov ... => etymologize, etymologise

18:12 (hyponym, verb)

18:14 well that's kinda meta

18:16 seangrove: And 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:16 justin_smith: seangrove: are you sure it invokes lein clean?

18:17 also, clean can be controlled by profile

18:17 so you can make sure the uberjar relevant profiles don't touch the thing you care about, right?

18:18 seangrove: tcrayford had this conversation with technomancy last year http://www.raynes.me/logs/irc.freenode.net/leiningen/2014-05-28.txt

18:18 justin_smith: Hrm, not sure - where can I read more about controlling lein clean for a given profile?

18:18 kaiyin: what does it mean to complement a list of numbers? https://gist.github.com/kindlychung/f33f6f73f5b08e0e5b90#file-x-clj-L61-L64

18:19 justin_smith: seangrove: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L309

18:19 seangrove: this may be what you want actually! https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L392

18:20 seangrove: justin_smith: Ah yes! Interesting

18:20 justin_smith: anyway, that file is my lein bible

18:21 seangrove: Obviously 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:21 thanks justin_smith, I'll go through this

18:27 mavbozo: ,(doc complement)

18:27 clojurebot: "([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:28 mavbozo: ,((complement zero?) 0)

18:28 clojurebot: false

18:29 mavbozo: kaiyin, set is the return type of get-connected

18:29 kaiyin: mavbozo: yeah, i kind of got it now.

18:30 like the complement set operation.

18:30 mavbozo: kaiyin, in clojure hashmap and set can be put in the function position

18:30 kaiyin: cool

18:30 mavbozo: ,(#{1 2 3} 3)

18:30 clojurebot: 3

18:31 mavbozo: ,(#{1 2 3} 4)

18:31 clojurebot: nil

18:36 ambrosebs: was there a bugfix to iterate recently?

18:36 amalloy: ,(class (iterate inc 1))

18:36 clojurebot: clojure.lang.Cons

18:36 amalloy: ambrosebs: no

18:36 ambrosebs: ,*clojure-version*

18:36 clojurebot: {:major 1, :minor 7, :incremental 0, :qualifier "master", :interim true}

18:36 amalloy: what makes you think iterate would be bugfixed?

18:36 ambrosebs: ,(take 1 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))

18:36 clojurebot: (1)

18:36 ambrosebs: hmm

18:37 now I'm confused.

18:37 in alpha6 this seems to print "PR" 1 also

18:38 amalloy: &(take 1 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))

18:38 lazybot: ⇒ (1)

18:38 amalloy: &*clojure-version*

18:38 lazybot: ⇒ {:major 1, :minor 7, :incremental 0, :qualifier "alpha1"}

18:38 amalloy: wait for reals?

18:38 ambrosebs: according to my local repl

18:38 amalloy: i thought lazybot was on a super old version. cool that it's on a 1.7 alpha

18:38 joe124: lazybot isn't so lazy

18:39 Bronsa: ambrosebs: yeah there were changes to iterate in alpha6

18:39 amalloy: ~def iterate

18:39 aaaaaaaaaa: hey 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:39 amalloy: oh goodness, there's an Iterate class now

18:39 ambrosebs: Bronsa: I don't understand the new side effect.

18:40 does it throw the result away?

18:40 Bronsa: amalloy: and a repeat and cycle one aswell

18:41 mavbozo: &(take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))

18:41 lazybot: ⇒ ("PR1"

18:42 mavbozo: ,(take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1))

18:42 clojurebot: ("PR1"\n1 2)

18:42 Bronsa: ambrosebs: I'm not a fan of the new iterate

18:43 not 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:43 joe124: i like functional programming, does c++ have good support for that style?

18:44 mavbozo: (def yolo (take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1)))

18:44 ,(def yolo (take 2 (iterate (fn [a] (prn (str "PR" a)) (inc a)) 1)))

18:44 clojurebot: #'sandbox/yolo

18:44 mavbozo: ,yolo

18:44 clojurebot: ("PR1"\n1 2)

18:45 mavbozo: ,yolo

18:45 clojurebot: (1 2)

18:45 ambrosebs: Bronsa: recompute?

18:46 so iterate is no longer immutable with reduce?

18:56 cfleming: seangrove: The issue is how to analyse code without evaluating it - Cursive works purely from source to avoid that

18:56 seangrove: cfleming: Is abstract interpretation evaluation, though?

18:56 cfleming: seangrove: Which gives it problems with macros, right - a solution is coming for that

18:56 seangrove: Somewhere in the middle, I'd argue

18:57 cfleming: seangrove: 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:57 joe124: i have a question is OOP going out of style?

18:57 seangrove: cfleming: I agree that's the challenge, especially in an unconstrained system

18:57 cfleming: seangrove: And having it be performant - Cursive has to index the whole project at first startup

18:58 seangrove: (e.g. reading/writing files in macros, etc.)

18:58 cfleming: Yeah, that's the biggest concern with AI/SE, but I think it's not insurmountable

18:58 ambrosebs: ,(def b (iterate (fn [_] (rand)) 1))

18:58 clojurebot: #'sandbox/b

18:58 ambrosebs: ,(reduce (fn [l r] (prn r) (assert nil "kill")) b)

18:58 clojurebot: 0.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:58 ambrosebs: ,(reduce (fn [l r] (prn r) (assert nil "kill")) b)

18:58 clojurebot: 0.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:58 ambrosebs: ,(reduce (fn [l r] (prn r) (assert nil "kill")) b)

18:58 clojurebot: 0.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:58 cfleming: seangrove: 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:59 ambrosebs: in alpha6, this is obviously a different number each time

18:59 GAH

18:59 seangrove: cfleming: 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:59 cfleming: But I understand that's not an entirely reasonable thing to ask for :)

19:00 cfleming: seangrove: 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:01 seangrove: 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:01 mavbozo: ambrosebs: yes, i just tried

19:01 ambrosebs: "In many cases, the new implementations are also faster for lazy sequences"

19:01 cfleming: seangrove: There's an extension API coming that will allow you to teach Cursive about such things

19:02 seangrove: Are these macros from a public project, or internal?

19:02 seangrove: cfleming: 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:03 cfleming: seangrove: There are a surprising number of edge cases and people do some crazy stuff :)

19:04 seangrove: cfleming: Yeup, agree with that.

19:04 cfleming: seangrove: I'd like to be able to get closer automatically and require less code to be written with the extension API, for sure

19:05 mavbozo: joe124, no. everyday more codes get written in PHP, Ruby, C#, Java

19:06 cfleming: seangrove: Are your problematic macros internal to your project?

19:06 seangrove: cfleming: Yeah

19:06 cfleming: seangrove: Ok, you'll need the API then.

19:07 joe124: mavbozo 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:08 i know there is a -> macro but i just dont like how it looks i guess lol

19:08 cfleming: seangrove: 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:09 bja: joe124: you're free to write (foo (bar (baz (qux (quux (spam eggs)))))) instead of (-> eggs spam quux qux baz bar foo)

19:09 Bronsa: cfleming: 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:10 bja: or do that matter (let [result-of-spam (spam eggs) result-of-quux (quux result-of-spam) result-of-qux (qux result-of-quux) .....] )

19:10 but I wouldn't personally

19:11 cfleming: Bronsa: 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:11 mavbozo: joe124: :) I avoided those threading macros too. but after a while, i can not code without them

19:13 Bronsa: gah, lisps

19:17 pmonks: joe124: I'm the same - the -> macro breaks my (arguably deficient) mental parser

19:17 fwiw parens don't bother me much, if at all

19:18 * arrdem uses the threading macros whenever possible, thinks they're gr8

19:18 * cfleming too

19:18 {blake}: mavbozo, joe124: Oh, yeah, me too. Threading macros just seemed wrong somehow at first. Now I find them cool.

19:18 pmonks: (inc arrdem); (inc cfleming); (dec pmonks)

19:18 lazybot: ⇒ 41

19:18 pmonks: doh

19:18 (inc cfleming)

19:18 lazybot: ⇒ 14

19:18 pmonks: (dec pmonks)

19:18 lazybot: You can't adjust your own karma.

19:18 arrdem: pmonks: well you commented out cfleming :P

19:19 * cfleming sniff sniff

19:19 pmonks: yeah - it's more than my parser that's deficient ;-(

19:19 mavbozo: joe124: 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:19 pmonks: Can someone dec me plz? Apparently I can't adjust my own karma

19:19 arrdem: (inc pmonks) ;; ur not alf bad

19:19 lazybot: ⇒ 2

19:19 pmonks: HEY!

19:19 * arrdem ducks

19:19 joe124: what are some other good functional languages? i know of f# is that good

19:20 cfleming: (- 2 pmonks)

19:20 pmonks: yay!

19:20 joe124: i dont need it to be 100% pure like haskell or anything

19:20 mavbozo: joe124: 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:20 pmonks: joe124 I'm having a blast with pixie, though it's inspired by clojure so might not be what you're looking for

19:24 wei: what’s a good way to connect to a repl, execute a command and return its output, as a shell script?

19:28 mavbozo: joe124: 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:29 mavbozo: wei: grenchman https://github.com/technomancy/grenchman

19:29 wei: thanks!

19:30 aaaaaaaaaa: hey 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:31 mavbozo: joe124: erlang is immutable too without those parenthesis

19:33 gfredericks: instead of parentheses it has all this context-sensitive punctuation

19:35 joe124: i have a question if the functional paradigm reduces bugs and is more efficient and such why is OOP so much more popular

19:35 wouldnt 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:38 klyed2: joe124: imo because there are way less people who are good at functional programming

19:39 mavbozo: joe124: well, lots of big silicon valley companies use functional languages. twitter scala, whatsapp erlang, apple swift, facebook hack?

19:40 thomasfuston: joe124: its not oop vs functional, its more imperative "vs" functional programming

19:45 pmonks: (inc thomasfuston)

19:45 lazybot: ⇒ 1

19:45 ntaylor: right, 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:46 brehaut: VHS

19:46 its gotta be better than betamax right?

19:46 oddcully: windows ;P

19:46 brehaut: instant coffee

19:46 also betamax vs video 2000

19:47 ntaylor: on 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:47 brehaut: PHP vs anthing

19:49 personally i think its just taht popular things are popular because they are popular

19:49 ntaylor: yep

19:53 brehaut: http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html

19:54 * akkad hunts for tools to debug a hung jvm

19:55 * ibash hangs a jvm

19:55 akkad: Jesus Virtual Machine?

19:57 so a jvm hangs, what sort of tools other than jstat/jmap/jstack can one use to profile the cause?

19:58 ntaylor: possibly gdb?

19:58 if you're running native code, that might be helpful

19:58 brehaut: strace?

20:00 ntaylor: possibly, though Hotspot's use of signal delivery might make strace a bit noisy

20:00 brehaut: true

20:00 http://unix.stackexchange.com/questions/56940/how-to-trace-a-java-program looks potentially useful

20:00 ambrosebs: is it safe to use the latest core.async master?

20:00 ntaylor: (also if you're blocked on a read or something, you won't ever see anything from a mutator thread)

20:01 brehaut: nice find

20:11 justin_smith: akkad: visualvm

20:12 akkad: assuming you need to have jmx port avail for that

20:12 justin_smith: and jdb

20:12 no

20:12 oh jdb? maybe

20:13 but sure, can't hurt to have jmx open

20:17 akkad: k

20:19 ambrosebs: Bronsa: any known issues with AOT compilation and (:refer-clojure :exclude [update]) then (def update ..)? Spitting a warning at me.

20:19 Bronsa: ambrosebs: not that i'm aware of

20:19 ambrosebs: Bronsa: ok I'll dig further

20:26 Bronsa: nvm, was complaining about foo.test.bar namespace and I read foo.bar

20:33 akkad: visualvm is pretty much a stripped down jconsole. unless I missing a magical options menu

20:38 pmonks: Actually it's a superset, as it can load jconsole plugins.

20:38 (as well as its own)

20:38 justin_smith: I bet we could make some clojure plugins

20:39 like shortcuts to look at clojures resources like the agent pool and such...

20:39 maybe other things?

20:39 pmonks: Prettifying the stack traces too

20:39 justin_smith: oh yeah, extracting the data that is more relevant to clojure

20:39 for sure

20:39 pmonks: oh, and looking at clojure locals

20:40 pmonks: BTW TDA (which has a VisualVM plugin) is one of my all time favourite debugging tools.

20:40 You can "diff" separate thread dumps and it'll infer which ones are hung.

20:40 justin_smith: wow

20:40 pmonks: It can also read thread dumps out of "dirty" log files, which is awesome.

20:40 So 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:40 justin_smith: ahh, so it's just arbitrary output from the vm, and it finds and analyzes the thread dumps?

20:40 pmonks: That alone is worth the price of admission.

20:40 justin_smith: right, right

20:41 very cool

20:41 pmonks: There's a sdtandalone version too, but it seems to want JVM 6 (which I can't get on Mac OSuX any more ;-(

20:41 justin_smith: pmonks: I am having trouble finding tda in the googles

20:42 thread dump analyzer?

20:50 pmonks: yep that's the one

20:53 TEttinger: pmonks: there's an openjdk 6 build for mac

20:54 pmonks: Yah for some reason I've struggled to install it on Yosemite. ;-(

20:54 TEttinger: not osx 64-bit it seems

20:54 http://community.openscg.com/se/openjdk/archive.jsp

21:04 pmonks: Yeah that might be my problem

21:04 But at least I can use it from inside visualvm

21:05 It's here btw: https://java.net/projects/tda #lazyweb

21:12 justin_smith: pmonks: thanks

21:13 pmonks: I think part of the issue with searching for tda is that like most tlas it's a bit overloaded

21:15 pmonks: tru

21:15 #seewhatididthere

21:15 justin_smith: $google tla shortage

21:15 lazybot: [Tumescent Local Anesthesia TLA Tumescent Information and ...] http://www.tumescent.org/

21:15 justin_smith: umm

21:15 demonstrates the problem, but not the link I had in mind

21:16 amalloy: hahaha

21:16 pmonks: I had a tumescence once. It was followed soon after by a restraining order. ;-(

21:18 justin_smith: this is the one http://softwaresafari.typepad.com/software_safari_premium_b/2008/01/another-to-pass.html

21:28 akkad: anyone 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:29 justin_smith: akkad: this reminds me of the reloading protocols / reloading records thing

23:12 joe124: hi 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:12 doesn't have to be filter btw just the first thing that came to mind

23:12 amalloy: ,(doc take-nth)

23:12 clojurebot: "([n] [n coll]); Returns a lazy seq of every nth item in coll. Returns a stateful transducer when no collection is provided."

23:13 joe124: yah take nth could work for the even elements

23:13 amalloy: joe124: it can't be filter, because filter is only passed the items in the sequence, not their indexes

23:13 uh, it works for the odd ones too

23:13 justin_smith: joe124: filter doesn't really work, since "every other" isn't a property of the individual item

23:13 joe124: ahh ok

23:13 amalloy: (take-nth 2 (rest xs))

23:13 joe124: oh wow lol that was easy thanks amalloy

23:14 if 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:14 justin_smith: joe124: I would use a recursive function which takes the updated decks and hands as arguments

23:15 and then gets the user input (in whatever way) before displaying, then recurring again

23:17 joe124: im trying to imagine how that would work

23:18 just the overall layout of the update

23:18 justin_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:19 where update-hands and update-deck have the logic for where the cards end up

23:19 you probably want an if wrapping the occur, checking if the game is over

23:20 s/occur/recur

23:20 joe124: pretty much identical to your imperative while loop

23:21 joe124: and before the play-round function i would do a let to define the opening hands right

23:22 justin_smith: the opening hands would be passed in at the start

23:22 joe124: yah

23:22 justin_smith: and each round would be a recur, yeah

23:22 you would maybe also pass in the GUI or network hooks to interact with the players at the start

23:23 that way it's totally isolated, one server can have as many games going on as it can handle connections from players

23:24 you 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:27 ebbflowgo: hi.. 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:29 joe124: is 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:29 justin_smith: sure, and I assume that would pass forward a hash-map with all your hands and deck etc.

23:29 amalloy: ebbflowgo: i don't know about jruby, but clojure's maps implement java.lang.Map

23:30 so you could iterate over their entryset or whatever

23:30 justin_smith: ebbflowgo: yeah, PersistentArrayMap is not an array type, it is a hashmap type

23:30 joe124: if a user wants to start a new game then he just calls game-loop again recursively?

23:31 justin_smith: joe124: or from the top level

23:31 joe124: 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:32 joe124: yeah currently im just doing a single player console based version

23:32 when 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:33 or are they contained in a let and once i leave the let they dissapear?

23:41 justin_smith: joe124: 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:42 so 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:42 joe124: better change my defs to lets then

23:42 ok thanks a ton justin and everyone g2g cya later

Logging service provided by n01se.net