#clojure log - Jul 14 2012

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

0:04 xeqi: how you, uh... how you coming on that clojure -> elisp you working on?

0:08 duck1123: If I'm getting a "Don't know how to create ISeq from: clojure.lang.Symbol" in cljs, how can I find where it's happening? I don't se line numbers for any of my code from cljsbuild

0:09 technomancy: xeqi: compiling to elisp?

0:09 xeqi: I don't think it can happen; at least until elisp gets native immutability for at least strings; hopefully for lists too.

0:10 more ranting on the topic here: http://technomancy.us/159

0:11 duck1123: I would love to see a good editor taking all the best parts from emacs but built with clojure

0:12 clooj didn't cut it

0:12 technomancy: the best parts from emacs are the decades worth of elisp that's accumulated around it

0:13 you could make something that works really well for editing clojure, but you'd have to give up on magit, tramp, emacsclient, etc

0:13 duck1123: true, but the best of those modules could be converted

0:13 technomancy: sure; how much time you got? =)

0:14 akhudek: probably not worth reinventing what already works

0:15 what would emacs in clojure ultimately gain?

0:15 I guess being able to write plugins with clojure...

0:15 duck1123: a more powerful lisp system at the heart of the editor

0:16 technomancy: it's much more likely that emacs would start running on guile and you could compile to scheme instead

0:16 by which I mean not very likely, but at least possible

0:16 sjl: s/with clojure/with all of the JVM ecosystem/

0:18 eggsby: hey guys, in paredit mode how do I add a surrounding paren if I forgot one? every time I try to enter one it just puts it outside the form :/

0:18 ibdknox: Light Table = Clojure!

0:19 but she is teh young

0:19 sjl: ibdknox: call me when it can run through tmux ;)

0:19 clojurebot: excusez-moi

0:19 eggsby: I wonder if light table works in lynx...

0:19 ibdknox: lol

0:20 sjl: that's the main problem really -- there are lots of new generation editors popping around but none run in a command line

0:20 ibdknox: why would they?

0:20 sjl: so I can't use any of the pretty things like vico, st2, etc

0:20 eggsby: yes but luckily you have vi for that sjl

0:20 sjl: eggsby: heh, yeah

0:20 duck1123: So will Light Table ever get an application window, or will it always be strictly browser based?

0:21 technomancy: ibdknox: you can't run a distributed team with anything but SSH

0:21 ibdknox: technomancy: huh?

0:21 sjl: ibdknox: editing a file in a command line is not going away any time soon (when ssh'ed into a server, pairing through tmux, or just for those that live in tmux locally)

0:21 ibdknox: duck1123: yes, for mac there already is one

0:21 sjl: none of those things are strictly reliant on a command line

0:22 sjl: ibdknox: well yeah, once someone implements all their replacements we can ditch it, heh

0:22 andres-v: eggsby: M-(

0:22 technomancy: even inclusion-transformation-based GUI collaborative systems (which are really hard to get right) so far only work on a document-by-document basis

0:22 which makes them useless for pairing

0:23 sjl: I gave money to light table because I want to see where it goes and hopefully it'll kick the other editing communities a bit and prod them into making awesome stuff too

0:23 andres-v: eggsby: or mark a region and then: (

0:23 ibdknox: technomancy: a document-by-document basis?

0:23 duck1123: I was too broke to consider donating, but I wish you well, and that hast to count for something

0:24 ibdknox: technomancy: as in the entire environment isn't shared?

0:24 technomancy: ibdknox: with things like gobby you have a set of docs you're subscribed to, but it doesn't coordinate focus or repl/shell buffers

0:24 eggsby: ah, thanks andres-v

0:24 ibdknox: technomancy: sure, that's a limitation in the way people have though about the problem, not an inherent problem with a GUI solution

0:25 which is not to say I'll be working on that any time soon, but I don't think the argument should be "x can't be run on the command line" - that's not a real solution

0:26 it's a workaround

0:27 akhudek: anyone remember the days of X11 application forwarding?

0:27 technomancy: it's possible; it's just a lot of work and nobody's gotten it right yet

0:27 a lot of work for something you can already get for free

0:27 ibdknox: technomancy: no argument there :)

0:27 eh

0:28 in a limited fashion yes

0:28 duck1123: That's how I develop. My server is in the house and I'm forwarding my emacs to my mac out in the garage

0:28 ibdknox: doesn't mean we should just say fuck it, let's not innovate anymore

0:28 akhudek: ibdknox: completely agree, light table looks interesting

0:29 ibdknox: light table is infantile :)

0:30 It'll be very interesting to see where it ends up

0:30 tons of learning to do

0:31 akhudek: speaking of learning, I found the recent hacker news discussion on MVC versus finite state machines pretty interesting

0:32 sjl: so I'm guessing I just reimplemented something built-in, and probably did it poorly

0:33 https://github.com/sjl/caves/commit/cf1c6b442a70e7b207d2fef8d35a41da112a4c5f

0:33 Basically I wanted a way to give default implementations when defining a protocol

0:33 but not just define the protocol for Object, because I only want the types that specifically implement the protocol to (maybe) get the default methods

0:34 so, for example, in my game: lots of things are going to implement Mobile, and need a can-move? function. Most of those all have the same movement rules, but occasionally some will want to override

0:36 Nican: I knew I read that somewhere else, is this reference to this? http://stevelosh.com/blog/2012/07/caves-of-clojure-04/#movement

0:36 sjl: But I'm not entirely sure whether this pair of macros is going to blow up in my face later... so hopefully someone can confirm whether they're sane or not

0:37 Nican: yeah. For that entry I just defined the functions when adding the Mobile aspect to the Player

0:37 since at that point I only had a player and nothing else

0:37 but if I wanted to add another creature that moved, I'd need to copy and paste the code

0:37 or add a helper function somewhere and manually type it out each time

0:39 that (do (defprotocol Foo ...) (def Foo ...)) feels particularly filthy.

0:39 akhudek: sjl: so the only problem with using Object is that it won't throw an error if you pass it something that doesn't implement the protocol?

0:40 sjl: akhudek: well, no, implementing it on Object won't let me override just one of the methods -- either it gets all the defaults or none of them

0:40 Nican: http://clojure.org/protocols "No implementations are provided"

0:40 sjl: Nican: yeah that's what I'm trying to hack around, heh

0:41 akhudek: because if the type you give it implements Foospect, it uses the methods defined for the thing you're giving it. If the type *doesn't* implement Foospect at all, *then* it falls back to Object's implementations

0:41 I think.

0:43 akhudek: sjl: I bet you could get the behaviour you want with a multimethod

0:45 Nican: Only interesthing things I found: http://fulldisclojure.blogspot.com/2010/08/thoughts-on-protocols.html http://stackoverflow.com/questions/10732355/clojure-defprotocol-default-implementaion-not-inlined/10732895#10732895

0:45 sjl: akhudek: here's the example showing the problem with Object https://www.refheap.com/paste/3606

0:47 akhudek: I see. If hello and world were both multimethods with default implementations, then it would be easy to override just one.

0:47 sjl: Nican: yeah, that first link goes about halfway to where my code goes (my code uses the merging maps into extend trick, but defines the defaults as metadata on the protocol itself)

0:48 akhudek: yeah, but then they're not really grouped together in any special way

0:49 akhudek: plus, it doesn't solve the case of me wanting to distinguish "something that is Mobile, regardless of whether it uses the default impls" and "something that is not Mobile at all", right?

0:49 akhudek: it's too permissive, i.e. those default implementations catch too much

0:50 akhudek: sjl: that's true, but you could consider writing functions like "is-mobile?" that has no default implementation

0:50 sjl: sure... that seems a bit ugly too though

0:50 akhudek: I mean, it sounds like you are partly using protocols as a type checking system

0:51 sjl: effectively, yes

0:51 akhudek: which as I understand it, wasn't really the intention of protocols

0:51 would be nice to have an optional type system for clojure, that's for sure

0:51 sjl: https://github.com/frenchy64/typed-clojure

0:51 akhudek: yeah, I know of that, haven't checked on the progress though

0:52 sjl: seems to be active development, which is a good sign

0:52 akhudek: yeah, very!

0:52 sjl: I agree that optional static typing would be awesome

0:52 Haskell's typechecker would catch so much annoying crap

0:53 * talios has started playing with Frege - interesting. But I really need to learn more haskell

0:54 sjl: okay time to get to sleep, later

0:54 akhudek: night sjl

0:54 Nican: later

2:19 mindbender: I'm getting this error when trying to run `foreman start` from my project: java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: java.lang.Character

2:20 I read something similar @ https://groups.google.com/forum/?fromgroups#!topic/leiningen/59655dfCNJg. I'm using lein 2

2:21 technomancy: any suggestions with ^-^

2:23 tomoj: mindbender: it would help if you pasted (not in here) the full stack trace

2:23 ..probably

2:30 mindbender: tomoj: just did. Here https://gist.github.com/55acd9099967140b6605.

2:33 tomoj: try :source-paths ["src/app/clj"]

2:37 metajack: Are PersistentTreeMaps not comparable? If not, why?

2:40 ,(compare (sorted-map) (sorted-map))

2:40 clojurebot: 0

2:41 metajack: ,(compare (sorted-map-by compare) (sorted-map-by compare))

2:41 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentTreeMap cannot be cast to java.lang.Comparable>

2:41 tomoj: ,(identical? (sorted-map) (sorted-map))

2:41 clojurebot: true

2:42 metajack: so sorted-map would fail if they weren't identical?

2:42 tomoj: ,(let [x (sorted-map-by compare)] (compare x x))

2:43 yeah

2:43 how would you compare sorted maps?

2:44 assume both the keys and values are comparable?

2:44 mindbender: tomoj: worked. Thanks

2:44 metajack: keys are vectors of length 2 of longs, and values are keywords

2:44 so i believe so

2:45 tomoj: but if the values were not comparable, should PersistentTreeMap.compareTo throw an exception?

2:45 I don't know actually the answer to your question ("why?")

4:40 AtKaaZ: hi, is there a program for 3D representation of clojure programs?

4:41 rather than you know textual

4:47 some kind of 3D graph visualization of the clojure code ? possibly with editing it too

5:02 TEttinger: AtKaaZ, I think there was something done like this

5:02 AtKaaZ: I would've hoped so, can you remember more precisely ?

5:03 a name of a program

5:05 I would think that this could be applied right after the Reader part of clojure, also I've no experience with clojure just starting to read about it

5:10 TEttinger did you mean clojureatlas ?

5:10 TEttinger: sorry AtKaaZ, was helping in another channel

5:10 AtKaaZ: it's quite ok

5:10 TEttinger: I haven't tried clojureatlas, i think you need money for it

5:10 AtKaaZ: yeah looks like it :/

5:10 TEttinger: https://github.com/quil/quil maybe?

5:13 AtKaaZ: is that like clojureatlas ? it seems like it's only a 3D library for clojure?

5:13 or something to help you draw

5:15 TEttinger: http://keminglabs.com/c2/ maybe could be handled with some macros

5:16 lynaghk: ping

5:17 AtKaaZ: do you mean that by using macros I can make c2 draw graphs of the clojure code ? sort of like using the clojure source code as data for c2 to draw it?

5:17 (which is what I want btw :D)

5:17 TEttinger: yep, code is data

5:18 but you obviously need some way for it to know how to display different kinds of code

5:18 AtKaaZ: yeah for sure

5:18 can clojure create code on the fly at runtime ?

5:18 TEttinger: I think yes

5:19 AtKaaZ: is there a simple example of that maybe? that I could peek

5:19 TEttinger: not clojurescript, but clojure can

5:19 AtKaaZ: yeah the real clojure

5:19 TEttinger: well macros are "compile-time", but it compiles continuously IIRC

5:19 AtKaaZ: c2 seems definitely something I want to look into

5:19 TEttinger: you need to talk to someone who knows how to use macros, there are more qualified people here

5:20 AtKaaZ: alright thanks so far, I'll alt-tab and try read more

5:20 TEttinger: lynaghk wrote C2, might be good to stay and wait for a response

5:20 AtKaaZ: yeah I'll definitely hang in here

5:20 btw, what ide/editor do you use?

5:20 something with colors :D

5:21 TEttinger: yeah, I am having a mess of a time in #coffeescript right now explaining what I hope is the right thing to someone with very poor English-language skills

5:21 oh I use Eclipse with rainbow parens via the main plugin, CCW

5:22 but I mostly use eclipse for editing and stick to the lein2 repl

5:22 I mean Leiningen v2

5:22 the repl is better in that version, it auto-completes and other amazing stuff

5:22 AtKaaZ: i have eclipse and some clojure plugin cross something...

5:22 TEttinger: yep

5:22 counterclockwise

5:23 AtKaaZ: yeah that one

5:23 what else would I need ? rainbow parens?

5:23 TEttinger: it has it

5:23 or at least it should

5:23 AtKaaZ: ok

5:23 TEttinger: outer level is red, second nest is green, etc. (colors may have changed with newer versions)

5:23 AtKaaZ: that Liningen v2 is something outside eclipse?

5:24 TEttinger: oh yes

5:24 leiningen is the best way for managing clojure projects across OS's and IDEs

5:25 it is also one of two de facto dependency managers for clojure

5:26 https://github.com/technomancy/leiningen/ is the main tool, http://timpner.com/computing/clojure-importing-a-leiningen-project-into-eclipse/ is how to make your leiningen project work in eclipse (not the other way around though)

5:26 AtKaaZ: oh i see, btw, did I notice right that eclipse doesn't auto build my clojure project (or recompile it) when I modify the source, so I cannot know right away if I made mistakes (Project->Build auto... is on)

5:26 TEttinger: yeah, I just go into the command line i keep open at all times and just lein run

5:26 AtKaaZ: oh I see I need lein-eclipse

5:26 TEttinger: it recompiles if needed and runs

5:27 yeah, in your leiningen project file

5:27 it will automatically download it if it is a dependency or dev-dependency in your project file and you then run "lein deps"

5:28 no need to handle standalone downloads of most libs

5:29 AtKaaZ: alright so if a project doesn't have lein-eclipse as dep in the project.clj then to make it work in eclipse correctly i need to add it as dep ?

5:30 TEttinger: yup

5:30 then run lein deps and it will grab it

5:30 AtKaaZ: can I have two lines with ":dev-dependencies" or do I have to append them in one line ?

5:31 TEttinger: :dev-dependencies [[lein-eclipse "1.0.0"]]

5:31 note the nested vectors

5:32 :dev-dependencies [[lein-eclipse "1.0.0"] [some-other-thing "1.2"]]

5:32 AtKaaZ: i understand

5:32 TEttinger: lines don't matter

5:32 AtKaaZ: however I'm curious what would happen if :dev-dependencies appears twice in project.clj

5:32 error?

5:33 TEttinger: probably an error when it tries to assign different values to one map entry

5:33 AtKaaZ: it acts as a clojure keyword? the ":" ones

5:33 TEttinger: like {:a "alpha" :b "beta" :a "alpha again"}

5:33 yes

5:33 AtKaaZ: makes sense, I like it

5:33 TEttinger: leiningen projects are clojure code

5:34 AtKaaZ: so that would err then.

5:34 TEttinger: and once you can visualize clojure code you can visualize lein files :D

5:34 AtKaaZ: sounds good to me

5:35 how do I get that prompt to run lein deps

5:38 msappler: hi. It seem to be bad for transactions if I have refs which have other refs in them as pointers?

5:38 AtKaaZ: oh i see I shouldn't be in eclipse while running lein deps

5:41 msappler: I have a grid data structure (for example width and height 100) so a grid of vector 100 of vector 100 cells

5:42 and each cell is a ref of a map which also holds :adjacent-cells the other cells'refs

5:47 y3di: does clojure not have a distinct else-if form?

5:47 TEttinger: y3di: maybe you want one of the other conditional macros?

5:48 http://clojuredocs.org/quickref/Clojure%20Core#OperationsFlow+Control

5:48 AtKaaZ: i managed to run lein deps and lein eclipse :)

5:48 TEttinger: woohoo!

5:48 AtKaaZ: lein.bat was in my case on windows

5:48 TEttinger: yep

5:49 it should create the needed .project and .classpath files

5:49 AtKaaZ: there are only 3 colors in clojure code, is that right ?

5:49 TEttinger: hm?

5:49 AtKaaZ: maybe 4 with the parenthesis

5:49 yeah it probably did, I had eclipse closed just for that

5:51 y3di: TEttinger, yea i'm not seeing any elseif forms. I guess I should just use another if statement as the last argument of the first if?

5:51 TEttinger: or clojuredocs.org/clojure_core/clojure.core/cond

5:58 AtKaaZ: how do you make it show errors in eclipse ?

5:59 like there's an error on line x and marked as red

6:01 switching to edit mode restricted does help some

6:03 TEttinger: AtKaaZ: you can change colors in Eclipse with Window->Preferences->Clojure

6:03 I don't know if the clojure plugin does that

6:03 the error markers

6:04 y3di: paredit is sposed to handle closing parens for me right?

6:04 TEttinger: y3di, I don't use it, but I think so yes

6:04 AtKaaZ: y3di it does for me if I switch from unrestricted edit

6:06 TEttinger thanks, I notice the rainbow parens are also there

6:06 TEttinger: yep

6:06 they won't show in the preview thoughh

6:06 y3di: hm, i don;t think i've installed it right then

6:06 TEttinger: you probably also want to make strings and symbols not the same color

6:07 y3di: tho i swear i did

6:07 is there a way to test whether i have a certain package installed in paredit

6:17 msappler: how can i see number of retries of my transactions

6:21 y3di: does every clojure file need a namespce

6:21 AtKaaZ: i think it's the package declaration in java

6:21 like*

6:25 y3di: nvm it was an issue with swankclojure

6:25 i have a notherquestion though

6:25 currently im printing a really larger number

6:25 and its displayed 297392^M or something like that

6:25 how can I get it to print the actual number

6:26 AtKaaZ: ^M makes me think of \n\r displayed in vim

6:26 or was it \r\n :D

6:28 if Chas Emerick here?

6:28 is*

6:30 y3di: AtKaaZ, do you know how to print it normally?

6:31 AtKaaZ: I don't sorry, I'm too new to clojure to even know how to code hello world:)

6:32 but I take it the number has more digits than 297392 ?

6:32 y3di: yea

6:32 AtKaaZ: no ideas then

6:40 y3di: this seems like it should be an easy problem to solve, but ive been googling and i cant find an answer

6:41 AtKaaZ: I don't suppose you could pastebin the program code?

6:41 or a simplified version of it:)

6:45 y3di: https://gist.github.com/3110511

6:46 AtKaaZ: I get the same numbers without the ^M

6:47 y3di: oh

6:47 maybe i was just being a dumbass this entire time

6:47 AtKaaZ: lol

6:47 y3di: i tried entering that number as the solution, and it didn't work

6:48 AtKaaZ: well maybe indeed those numbers have no more digits

6:48 but the ^M seems to be the new line

6:49 if I do (println (reduce sum-if-divisible (range 1 10000))) I get 23331669

6:50 or (println (reduce + (range 1 100000))) to get 4999950000

6:50 (granted I've no idea what the program does)

6:52 y3di: nvm i figure itd out

6:53 AtKaaZ: I like knowing what the fix is, should you wish to share it:)

6:54 y3di: i did (range 1 1000) instead of (range 0 1000)

6:54 the problem was

6:54 summing up the integers between 1 and 1000 that are divisible by 3 or 5

6:55 AtKaaZ: I eventually figured from the code, tho I am very new to clojure

6:55 thanks

7:26 evildaemon: Okay, sorry but I HAD to show this to somebody.

7:26 http://forums.thedailywtf.com/forums/p/26379/297191.aspx#297191

7:59 zoldar: Hello. Why do I get integer overflow when running that taking larger sequences from that collection? https://www.refheap.com/paste/3607 (that's problem #147 from 4clojure). Shouldn't clojure automatically promote to long when needed? shouldn't it be long in the first place?

8:09 ok, found it, had to use math operator with apostrophe: http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics

8:10 seems it was going even beyond long range

8:21 daniel___: is there a function which will give me this? "123456789" -> ("147" "258" "369") ?

8:21 like partition with interleave

8:24 eagleflo: daniel___: can't you compose exactly those two functions, partition and interleave, to achieve that?

8:26 daniel___: ,(map #(apply str %) (partition 3 (apply str (apply interleave (partition 3 "123456789"))))

8:27 that should achieve it i think

8:27 &(map #(apply str %) (partition 3 (apply str (apply interleave (partition 3 "123456789"))))

8:27 lazybot: java.lang.RuntimeException: EOF while reading, starting at line 1

8:27 daniel___: &(map #(apply str %) (partition 3 (apply str (apply interleave (partition 3 "123456789")))))

8:27 lazybot: ⇒ ("147" "258" "369")

8:38 wingy: what does Attempting to call unbound fn: #'user/zipmap2 mean?

8:42 oh nvm

8:50 i wonder a thing .. looking at "and" i see its calling itself

8:50 ,(source and)

8:50 &(source and)

8:50 lazybot: java.lang.RuntimeException: Unable to resolve symbol: source in this context

8:51 wingy: here the source: https://gist.github.com/3111123

8:51 could/should the self call be replaced by recur to introduce TCO?

8:52 if one calls and with a large nr of arguments that would eat up stack space with the current implementation?

8:55 yepp .. i got a stackoverflow error when running it with a long arg list :/

9:05 isn't it possible to use recur instead in and macro?

9:07 rfgpfeiffer: has anybody got libgdx to play nicely with leiningen

9:10 yonatane: in (defmacro with-open... why does it call with-open recursively to resolve bindings? Couldn't it just call let with the entire bindings vector at once?

9:10 https://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L3376

9:23 wingy, since i'm new as well i can only guess, so i guess there's no recur point (e.g loop or function definition) in the and macro. Maybe having it there would cause other problems, and isn't worth the trouble since having so many arguments is bad style.

9:27 wingy: yonatane: a fn or loop could always be used as recur point

9:27 so if you call recur in a fn where there is no loop the fn is the recur point

9:28 i tried to use recur but an error said the argument list didnt match

9:28 yonatane: but and is a macro. i'm not sure it's the same

9:28 wingy: it expected 0 args .. i guess the first argument list (it had multiple ones) was used and that was for no args []

9:31 yonatane: well, i'm in the process of reading the clojure source. I'll tell you next year when i'm done ;)

9:31 wingy: perhaps you are right

9:32 https://gist.github.com/3111353

9:32 the fn worked but not the macro

9:33 but the error message is strange: java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 0 args, got: 1, compiling:(NO_SOURCE_PATH:2:30)||

9:33 anyway :)

9:35 yonatane: read this: https://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L406

9:36 i can't understand it yet

9:37 maybe macroexpand it to get a hint

9:47 wingy: (macroexpand '(recurme false))

9:47 ;=> (if false (recur false) "done")

9:54 ok i just understood why with-open is recursive - to match the .close to the resource and close only opened resources.

9:56 wingy: yonatane: are you new to clj as well?

9:56 just trying to get it?

10:03 yonatane: i'm not totally new. there are entire parts that i don't know at all, like macros which i just now read enough to answer you

10:06 but you can do a lot without knowing much. I have a pet facebook app using lein, noir, jdbc, sandbar, ring etc.

10:13 wingy: yeah .. but i love to get more about programming so you can create powerful, less buggy systems than your competitors

10:13 features added each week others could just dream of

10:15 this was a really good video http://blip.tv/clojure/clojure-concurrency-819147

10:15 all rich's videos are of high quality

10:18 yonatane: have you watched the reducers video?

10:19 http://vimeo.com/45561411

10:34 wingy: dont think so

10:34 ill watch it later

10:36 persistent data structures remind me about how git is working

10:42 cshell: I have a namespace (:require [google.identity :as id]) - what's the correct way to reference keywords in that namespace? :id/foo doesn't work - but :google.identity/foo does

10:50 andres-v: cshell: are you writing :id/foo or id/foo? (it shhould work with id/foo)

10:51 cshell: if i do id/foo I get a no such var

10:51 exceptiong

10:53 andres-v: cshell: I don't know that library, but what about: (require '(google [identity :as id])) and then use it like (id/foo ...)

10:53 cshell: it's just a custome on in there

10:53 that I created

10:54 it's not bound to a var so I don't think i can access it without a :

11:00 andres-v: and what is the name of the namespace, (ns google.identity) ?

11:01 inkybutton: hi everyone, i'm using js->clj on a json feed in clojurescript, but the result is a vector containing single characters of the feed string - a bug?

11:03 cshell: andres-v: yes, google.identity is the namespace

11:23 andres-v: cshell: :( I am testing a couple of simple namespaces and referencing a def from each other with require from the repl and it works but I don't know where is the difference with your code

12:04 samaaron: is it possible to catch reader exceptions when evaling arbitrary strings?

12:06 wingy: why do we buy computers with multiple cores if softwares/games dont use them

12:07 samaaron: wingy: so we can play multiple games at the same time?

12:07 wingy: :)

12:10 antoineB: hello, i don't manage to use a simple defmulti example http://pastebin.com/cVMD9rt3

12:15 duck1123: No one would write multi-core software if there were no multi-core computers

12:18 jkkramer: antoineB: that should work. if you're developing interactively and changed the definition of defmulti, you may be getting bit by its defonce semantics -- i.e., re-evaling from emacs won't change the definition

12:19 wingy: duck1123: smart :)

12:19 jkkramer: antoineB: you could try (ns-unmap *ns* 'emit) from within example.a namespace, and re-eval. or just restart repl/swank

12:21 wingy: i dont get this one: (defn map2 [f coll] (cons (f (first coll)) (map f (rest coll)))) isn't the recursion infinite since there is no base case to get out of it?

12:23 antoineB: jkkramer: i use C-c C-k i see the result expected, but when i type (emit "def") in the repl i get NullPOinterException

12:24 duck1123: wingy: there was no lazy-seq around that ?

12:24 antoineB: if i eval the last expression of the file it works (see the last expression in the paste)

12:25 wingy: duck1123: its just an example code how map works .. nothing tied to clj

12:25 jkkramer: antoineB: is your repl in the right namespace and/or requiring the right stuff?

12:25 antoineB: no

12:25 wingy: but it works .. i just dont get how it gets out of the recursion

12:26 jkkramer: wingy: the defn you pasted works, because it's not recursive: map2 called regular map

12:26 yonatane: wingy: i don't see a recursion

12:26 wingy: oh

12:26 yeah typo

12:26 zdennis: I've got two functions in my point namespace, but I always receive the warnings that I am overriding clojure-core classes, but when I require them I am excluding them. could any one help me understand what I'm doing wrong? https://gist.github.com/89d7095f77f1b7d96801

12:27 *err. not core clases, core functions

12:27 wingy: ok it didnt work

12:27 (defn map2 [f coll] (cons (f (first coll)) (map2 f (rest coll)))) fails

12:27 nvm

12:27 an example from http://vimeo.com/45561411

12:30 wii .. starting to get recursion .. you have to have a base case, this works: (defn map2 [f coll] (if (empty? coll) '() (cons (f (first coll)) (map2 f (rest coll)))))

12:30 zdennis: the core functions I am overriding are max/min

12:32 ah… I think I needed (:refer-clojure :exclude [max min]) in my point.clj ns

12:32 is that bad form to define functions that share names and then to exclude core functions?

12:32 gfredericks: zdennis: yessir

12:32 zdennis: nossir

12:33 zdennis: gratzi @gfredericks

12:35 duck1123: Does anyone know about waltz? I'm trying to find out if it's possible to define the machine with an initial state, or if I have to just set it afterwards

13:13 cshell: andres

13:13 antoineB: (case (class "aa") clojure.lang.PersistentList "p" java.lang.String "s" "A")

13:13 what is wrong with my switch?

13:16 AWizzArd: antoineB: what result do you expect?

13:17 antoineB: "s"

13:18 java.lang.String isn't a symbol

13:18 AWizzArd: case is a macro

13:19 antoineB: AWizzArd: see the doc for availble type you can check on

13:19 they talk about "(Clojure) composites thereof" i don't know what it is

13:21 (case (str (class "aa")) "class clojure.lang.PersistentList" "p" "class java.lang.String" "s" "A")

13:21 this work

13:21 notice the "class ..."

13:22 gfredericks: ,(doc case)

13:22 &(doc case)

13:22 lazybot: ⇒ "Macro ([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are not evaluated. They must be compile-time literals, and ne... https://www.refheap.com/paste/3608

13:22 AWizzArd: It must be constants.

13:23 gfredericks: antoineB: so apparently classes aren't in the set of constants you can use

13:23 AWizzArd: But fortunately there are mechanisms to do what you want.

13:23 antoineB: i hope

13:23 gfredericks: like multimethods

13:23 antoineB: my solution is very elegant

13:24 gfredericks: or cond

13:24 AWizzArd: You can try condp for example

13:24 antoineB: in fact i use this "case" in a multi method context

13:25 wingy: does anyone know why this doesnt return 6

13:25 ,(-> 1 inc (partial * 3))

13:25 AWizzArd: ,(condp instance? "aa" clojure.lang.PersistentList "p" java.lang.String "s")

13:25 cshell: it returns a function

13:26 AWizzArd: wingy: (partial (inc 1) * 3) is what you got

13:26 gfredericks: wingy: ##(-> 1 inc ((partial * 3)))

13:26 lazybot: ⇒ 6

13:26 gfredericks: or ##(-> 1 inc (* 3))

13:26 lazybot: ⇒ 6

13:27 wingy: i thought that the args should return a fn

13:27 gfredericks: $google fogus thrush

13:27 lazybot: [fogus: Thrush in Clojure – Redux] http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/

13:27 wingy: inc returns a fn

13:27 why shouldn't partial?

13:27 gfredericks: wingy: ^ that's a good read on what's going on

13:27 AWizzArd: inc should return a number

13:27 cshell: inc returns a function?

13:27 ,(inc 1)

13:27 wingy: i mean inc alone

13:27 AWizzArd: Not clojure.core.inc

13:27 cshell: inc is a function

13:27 wingy: so i guess the last one should run the function?

13:28 AWizzArd: (-> 1 inc) ==> (inc 1) ==> 2

13:28 gfredericks: wingy: -> is a macro that works syntactically; it doesn't know if something is a function or not

13:29 AWizzArd: -> takes the first argument and puts it on position two in the following list

13:29 (-> 1) take the one and return it

13:29 (-> 1 inc) take the one and “put it into inc”

13:30 (-> 1 inc dec) take the one and “put it into inc”. Take that result again and put it into dec.

13:30 (-> 1 inc dec (* 10) ) take the one and “put it into inc”. Take that result again and put it into dec. The result from that put as first arg into (* 10), making it (* 1 10)

13:31 gfredericks: ,(macroexpand '(-> 1 inc dec (* 10)))

13:31 &(macroexpand '(-> 1 inc dec (* 10)))

13:31 lazybot: ⇒ (* (clojure.core/-> (clojure.core/-> 1 inc) dec) 10)

13:31 gfredericks: &(macroexpand '(-> 1 inc dec (partial * 10)))

13:31 lazybot: ⇒ (partial (clojure.core/-> (clojure.core/-> 1 inc) dec) * 10)

13:32 gfredericks: oh those are not too helpful

13:32 &(clojure.walk/macroexpand-all '(-> 1 inc dec (* 10)))

13:32 lazybot: ⇒ (* (dec (inc 1)) 10)

13:32 gfredericks: &(clojure.walk/macroexpand-all '(-> 1 inc dec (partial * 10)))

13:32 lazybot: ⇒ (partial (dec (inc 1)) * 10)

13:32 wingy: i see

13:35 makes more sense now that i know -> is a macro

13:36 it gives a total new syntax

13:36 so if the 2nd form is a function it just wraps that one around () so it will be called with the value

13:36 (fn1 val)

13:36 gfredericks: $google github swiss-arrows

13:36 lazybot: [rplevy/swiss-arrows · GitHub] https://github.com/rplevy/swiss-arrows

13:37 AWizzArd: wingy: you can think of it as „bash pipe”

13:37 wingy: but if its already in a run form (fn1 arg2) it will put the val into it as the 1st arg (fn1 val arg2)

13:37 i thought that every fn should return itself but that wasnt the case

13:37 AWizzArd: take a thing t1 and pass it into the next function to get a thing t2. Take t2 and pass it into the next function to get thing t3. Take t3 and pass it into the next function, etc…

13:38 A fn does typically not return itself.

13:38 wingy: but it could in this case with inc

13:38 AWizzArd: The symbol clojure.core.inc when evaled returns a function.

13:38 inc is a symbol

13:38 wingy: i know

13:38 AWizzArd: no a function

13:39 not

13:39 wingy: this was the confusion: (-> 1 inc (inc) ((partial * 3)))

13:39 AWizzArd: yes

13:39 wingy: diff between inc and (inc) .. they both work

13:39 bpr: does anyone know how feature-ful nrepl/emacs is compared to slime/swank?

13:39 gfredericks: that's because -> supports both

13:39 wingy: but if you have args like in partial you have to wrap it around ()

13:39 gfredericks: it converts inc into (inc) before doing anything else

13:39 wingy: so it will know its one fn with args

13:39 yea

13:39 AWizzArd: Yes, the -> macro is nice and allows you to omit the parens, if the fn takes only one arg.

13:40 wingy: confusion gone :)

13:41 gfredericks: &((apply comp (repeat 10000 inc)) 1)

13:41 lazybot: ⇒ 10001

13:41 gfredericks: lazybot: move this pile of bricks to the other side of the yard

13:41 gnarmis: maybe it needs sudo in there?

13:42 gfredericks: &(format "%s is not in the sudoers file. This incident will be reported." "gfredericks")

13:42 lazybot: ⇒ "gfredericks is not in the sudoers file. This incident will be reported."

13:42 gnarmis: hahaha

13:49 wingy: reducers are really hard to get

13:50 aphyr: Resurrecting a very old question: does anyone know why clojure.lang.Var is *not* backed by an InheritableThreadLocal?

13:51 Seems like in almost every case where using dynamic bindings, I really want bound-fn/future's ability to carry the bindings onto threads I might spawn.

13:55 clojure-newcomer: hey guys, its a bit quiet over in the #datomic channel, can anyone help with an ec2 DDB query ?

14:04 wingy: data structures imply the collections and not the literals/symbols?

14:05 cshell: wingy: what do you mean?

14:07 wingy: when someone says data structure he means a collection (either a list, vector, map or set) and not a literal (string, boolean, number, keyword and character) right?

14:12 uvtc: wingy: "data structure" would also mean collection of collection ...

14:12 wingy: uvtc: right but never literals right?

14:13 uvtc: wingy: I think of strings, booleans, numbers, keywords, etc. as "scalars".

14:13 wingy: literls is another word for scalars?

14:14 uvtc: wingy: note that `{:a 1 :b 2}` is a map literal.

14:14 wingy: i see

14:14 then the word scalar is better to use i think

14:14 scalar vs data structures

14:14 uvtc: wingy: As opposed to (hash-map :a 1 :b 2), which is not a map literal.

14:16 daniel___: how can i calculate a sequence 0000 0001 0010 0100 1000 0011 0101... all possibilities

14:17 uvtc: wingy: Heh. It's difficult for me to put into words the definition of "literal". It means, "You can tell what this is by looking at it --- it literally is what I just typed" :)

14:17 daniel___: i suppose its binary increments, which i can just convert to a string

14:17 gfredericks: daniel___: ##(let [bs [0 1]] (for [a bs b bs c bs d bs] (str a b c d))) could work

14:17 lazybot: ⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111")

14:18 wingy: uvtc: yeah thats a good perspective

14:18 uvtc: ,(for [i (range 2) j (range 2) k (range 2) m (range 2)] (str i j k m))

14:19 ,(println (for [i (range 2) j (range 2) k (range 2) m (range 2)] (str i j k m)))

14:19 &(for [i (range 2) j (range 2) k (range 2) m (range 2)] (str i j k m))

14:19 lazybot: ⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111")

14:19 daniel___: oh lovely

14:20 uvtc: Whoops. Mine was the same as gfredericks , only I kept repeating myself. :)

14:20 clojurebot: are you there?

14:20 lazybot: what happened to clojurebot?

14:20 lazybot: It's AWWWW RIGHT!

14:22 gfredericks: &(for [i (range 16)] (subs 1 (Long/toString (+ 16 i) 2)))

14:22 lazybot: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String

14:22 gfredericks: &(for [i (range 16)] (subs (Long/toString (+ 16 i) 2) 1))

14:22 daniel___: java.lang.Long/toBinaryString?

14:22 lazybot: ⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111")

14:22 gfredericks: I win

14:22 uvtc: kahnnnnnn!

14:23 hyPiRion: ##(for [i (range 16)] (clojure.pprint/cl-format nil "~4,'0B" i))

14:23 lazybot: ⇒ ("0000" "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001" "1010" "1011" "1100" "1101" "1110" "1111")

14:24 * uvtc didn't know lazybot also responded to ##(println "this syntax")

14:24 lazybot: ⇒ this syntax nil

14:24 gfredericks: is it worth going to the conj if I'm also going to strange loop?

14:26 daniel___: the number of permutations when everything is distinct is factorial

14:26 in this case, what is it?

14:27 hyPiRion: exponential

14:27 gfredericks: 2^n

14:27 or m^n

14:27 uvtc: &(for [j (range 16)] (apply str (for [i (range 4)] (rand-int 2))))

14:27 lazybot: Execution Timed Out!

14:28 uvtc: Was going to joke, "close enough". Odd that it timed out though...

14:29 hyPiRion: uvtc: Clojail is weird like that.

14:29 uvtc: &(for [j (range 16)] (apply str (for [i (range 4)] (rand-int 2))))

14:29 lazybot: Execution Timed Out!

14:30 uvtc: hyPiRion: Ok. :)

14:31 hyPiRion: &(for [i (range 16)] (apply str (repeatedly 4 #(rand-int 2))))

14:31 lazybot: ⇒ ("0000" "1000" "0101" "0101" "1100" "1011" "0101" "1100" "1111" "0101" "1110" "1000" "0011" "0010" "0111" "0011")

14:31 hyPiRion: It's something about the for comprehension I believe.

14:33 gfredericks: &(frequencies (repeatedly 16 (rand-int 16)))

14:33 uvtc: Ah. `repeatedly`. Thanks, hyPiRion.

14:33 lazybot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

14:33 gfredericks: &(frequencies (repeatedly 16 #(rand-int 16)))

14:33 lazybot: ⇒ {2 1, 3 2, 4 3, 7 1, 8 3, 11 2, 12 1, 13 1, 15 2}

14:50 daniel___: what are the alternatives to associative arrays? i suppose nested vectors is one way, what about if you want a non integer key?

14:50 a map of lists?

14:50 a map of vectors*?

14:52 gfredericks: vectors are somewhat like maps with keys of (range n); so in that sense maps will always be more flexible. I don't quite understand the details of your question.

14:52 I must not know what an associative array is.

14:53 cshell: I'm confused too

14:56 yonatane: Is there a use-case for using protocols when java interop is not needed?

14:57 gfredericks: yes

14:58 actually I don't think protocols have very much at all to do with interop

14:58 only that you can extend a protocol to a java type

15:02 tmundal: (+ 1 2)

15:02 gfredericks: 3

15:02 tmundal: :D

15:03 gfredericks: :D

15:05 yonatane: gredericks: do you have an example?

15:06 gfredericks: sorta

15:06 yonatane: Can I define a protocol with common function names like doseq, and implement it in some random crazy way, and so existing code would behave crazily when passed my implementation?

15:07 tmundal: (loop [] (drink-more-beer) (recur))

15:07 gfredericks: the function names that belong to your protocol are vars in the namespace you define them in. So (ns foo.bar) (defprotocol FooBar (doseq [x y])) will just create foo.bar/doseq, which is not the same as clojure.core/doseq

15:08 so...no

15:08 yonatane: so an unqualified doseq outside my namespace will behave normally

15:08 gfredericks: yep

15:08 yonatane: that's no fun

15:09 gfredericks: you can redefine doseq directly if you just really want clojure to crash

15:09 aphyr: daniel___: Why can't you use a map?

15:09 gfredericks: but since it's a macro you'll only effect code that's loaded after you redefine it

15:09 yonatane: oh, doesn't matter. any other function then.

15:10 bpr: hey, i'm using lein2 and i want to do lein2 new foo and have the files/directories dumped into my current dir. I used to be able to do lein new foo . with v1.7.0, is there a way to do this in lein2?

15:10 gfredericks: yonatane: with-redefs will let you redefine stuff temporarily

15:10 yonatane: the only protocol example I care to bother dredging up is https://github.com/fredericksgary/ranguages/blob/master/src/ranguages/core.clj#L10

15:10 bpr: i clearly could just use a tmp dir and copy everything over, but why take the extra step if i don't have to :)

15:12 daniel___: sorry, something came up

15:12 aphyr: i can use a map :)

15:13 uvtc: bpr: I think `lein new foo` has always created the "foo" directory.

15:13 bpr: At least, I've never seen it do anything different from that.

15:14 yonatane: gfredericks: if you've done it without a protocol, how would it be worse?

15:14 daniel___: im used to thinking of everything in loops and arrays

15:15 gfredericks: yonatane: well you can't really use types/records without protocols; so I would've been using raw maps, and my single-location implementation would have a giant cond checking the types of the maps

15:15 it gives you the interface/implementation separation that a lot of people think is clean but I'm not smart enough to argue convincingly for

15:17 yonatane: i'm coming for OO, and had the impression that a functional language does not need OO features

15:17 *coming from

15:18 gfredericks: some people find some of the features useful. I don't think it's expected that you use protocols/records/types for most application-level stuff

15:18 they were first introduced to make clojure-in-clojure feasible

15:18 certainly clojurescript makes heavy use of them in its foundational stuff

15:18 as does core.logic

15:19 bpr: uvtc: "lein new foo ." used to put the new files in the current dir

15:19 gfredericks: I think for regular business data maps are still recommended

15:19 bpr: uvtc: this is because in v1.7.0 the third parameter was an optional one used to specify the directory to put the new project

15:19 uvtc: bpr: Oh. Didn't know that. Thanks.

15:20 bpr: yup

15:20 cshell: has anyone ever seen the IllegalArgumentException: Can't define method not in interfaces. when used in protocols?

15:22 yonatane: gfredericks: how about when you want a common persistency protocol, where you don't know if it will go to mysql or to text files, would you use the protocol mechanism?

15:22 gfredericks: cshell: you're just defining a protocol and don't have any types/records yet?

15:23 yonatane: that sounds reasonable

15:23 yonatane: I think I've done that before

15:23 cshell: I have a defrecord for the protocol

15:23 implementation

15:23 yonatane: gfredericks: any other idiomatic way to do it?

15:23 cshell: I've done a lein clean

15:23 gfredericks: yonatane: not really

15:23 cshell: i found something that said to disable don't-recompile-if-same-source but I don't know where that is

15:24 gfredericks: yonatane: protocols are also great when you want something to be extensible

15:24 daniel___: ach, earlier i meant multidimensional arrays, not associative arrays

15:24 gfredericks: daniel___: I think I've used flat maps and nested vectors in different contexts depending on exactly what sort of interface I wanted

15:24 cshell: gfredericks: it's the same problem as listed here: http://bit.ly/MpC3hL

15:25 gfredericks: ah ha

15:25 but this is presumably fixed and you're still having the problem?

15:25 cshell: yep

15:26 although a clean and repl restart isn't working

15:26 so I can't get past it

15:26 where else would lein put the compiled protocol def?

15:26 gfredericks: cshell: what's your protocol def look like?

15:26 daniel___: gfredericks: ok

15:26 yonatane: gfredericks: i recently asked how to implement an api that requires a client token throughout, and i didn't want all the functions to have the token as a parameter.

15:27 cshell: gfredericks: https://www.refheap.com/paste/3609

15:27 daniel___: im trying to write a chess engine, and generate a table of file attacks: http://chessprogramming.wikispaces.com/Rotated+Bitboards (file_attacks[R][10011011])

15:27 in this case, i suppose i want a vector of maps

15:28 cshell: it's complaingin about the update! method, that's what I just added today

15:28 gfredericks: yonatane: ...so you're asking the question again?

15:28 daniel___: [{:10010011 <attacks>}{:10100000 <attacks>}..]

15:28 cshell: yonatane: you can create a closure with the token bound

15:28 daniel___: [{:10010011 <attacks> :10100000 <attacks>}{}{}..] in fact

15:28 yonatane: gfredericks: Yeah, in light of records :). maybe a record with the token as ctor argument

15:29 gfredericks: daniel___: what does each map signify?

15:29 daniel___: the ocupancy on a given file or rank

15:29 gfredericks: yonatane: I think that kind of thing is normally handled with dynamic vars

15:29 daniel___: the key signifies that, and it maps to a bitboard with the possible attack squares

15:29 yonatane: cshell: yeah, but if i have several functions, do i create each one, or a map of functions, or some other thing?

15:29 gfredericks: daniel___: so why do you have multiple maps instead of one?

15:30 daniel___: (file_attacks[R][10011011]) the first dimension is the square that a rook is on for example, and inside that element i have a map of all the occupancies

15:30 gfredericks: cshell: looks like the sig for update! doesn't match

15:31 cshell: gfredericks: omg, that's it

15:31 thanks g

15:31 *slaps forehead*

15:31 yonatane: what I do is make the protocol with the methods and parameters (but not the token)

15:31 then I create a deftype which has a constructor that has the token

15:32 daniel___: so it will be 8 maps in a vector i suppose [{}{}{}{}{}{}{}{}]

15:32 the index signifying the square that the attacking piece is on

15:32 and then inside each map, i have an occupancy mapped to an attack board

15:33 gfredericks: cshell: doesn't that mean you have to pass around a type instead of a token?

15:33 daniel___: dont have a clue how im going to generate such a structure

15:33 gfredericks: daniel___: why 8 maps instead of 64 then?

15:34 since there are 64 squares

15:34 daniel___: because im just concentrating on a rank or file

15:34 cshell: I just call a factory method when I need the functionality and then pass that in as the this parameter on the protocols

15:34 gfredericks: cshell: right. So you have to pass in something, whether the type or the token; I can't see why that's any easier

15:34 daniel___: the attacks are going to be the same for each rank or file, given the same occupancy

15:36 yonatane: gfredericks: I should read about bindings more. I asked before about a case where i have multiple tokens to handle. Maybe I can change the binding of the token var for each one. I wonder how it handles concurrency.

15:36 cshell: yonatane: dynamic vars can get thread local bindings - so that helps with concurrency

15:36 gfredericks: yonatane: dynamic vars have thread-local values

15:36 yonatane: that's great

15:37 cshell: gfredericks: Hmm, that's a good poing gfredicks - I always did it because it took that off of the interface - the this has to be there anyway

15:37 gfredericks: and maybe I have a stubbed implementation or something which doesn't need the token to return values

15:37 yonatane: so I can call a bunch of functions with a specific value of the var.

15:37 setting the var only once

15:37 gfredericks: yonatane: ofter the dynamic var is accompanied by a with-foo macro that sets it for you

15:38 s/ofter/often/

15:38 yonatane: e.g., clojure.whatsit.jdbc's with-connection

15:38 yonatane: gfredericks: exactly!

15:39 gfredericks: it's a mildly controversial tactic since it kills function purity. but you can only put up with so much ceremony in the name of purity

15:39 also if you use a monad people stop being your friend

15:39 cshell: haha

15:40 gfredericks: on the other hand, some times you can do similar things quite succinctly using ->

15:42 uvtc: Regarding the url-shortener example in the "Clojure Programming" book (Oreilly), (page 537),

15:42 ~CPOR

15:42 it uses a Ref to refer to its `mappings` data structure (mappings of string id's to long urls).

15:42 Why does it use a Ref? My understanding is that refs are for when you want to coordinate changes to multiple refs that are connected or interdependent in some way. But here we've only got *one* ref; the mapping. It doesn't need to coordinate with any other data structures.

15:42 Why not instead use an atom here?

15:44 gfredericks: I *THINK* that there is a use case for a single ref which is

15:44 you want to read it, update it based on what you read, and also do something else with the read value

15:44 where on earth did I see this

15:44 it was in one of hiredman's codez

15:45 uvtc: imagine you wanted to use an atom to implement a queue

15:45 and have worker threads pulling stuff off to work on

15:45 think about how (defn pull-thing-off-queue [] ...) would be defined

15:46 uvtc: Ah. That's what's going on in the example I noted. You're checking the contents of `mappings`, and if a given value isn't yet in it, you assoc it.

15:46 gfredericks: well that sounds doable actually

15:46 with an atom

15:46 unless you're trying to return info on whether it was there or not

15:47 uvtc: The check to see what the mapping contains, and also the alteration, are both inside a dosync.

15:47 gfredericks: (swap! a #(if (% k) % (assoc % k v)))

15:47 I'm not sure why ^ that wouldn't work

15:48 uvtc: gfredericks: Will think on that. Thanks.

15:48 gfredericks: next time cemerick is around ask him what on earth

15:49 uvtc: Will do.

15:50 wingy: what is the :test meta doing in the meta data of a function?

15:50 gfredericks: pointing to a test?

15:51 wingy: whe is it executed?

15:51 when

15:51 manually by user?

15:52 gfredericks: or by any framework that looks for that sort of thing

15:52 I dunno which ones do

15:52 wingy: ok

15:56 dgrnbrg: is it possible to have a type hint for an array of IFns?

15:57 I tried ^"[Lclojure.lang.IFn", but it said classnotfound

15:57 gfredericks: I don't remember the syntax but I'm sure it is

15:57 dgrnbrg: i can't find it anywhere on google

15:57 i found the syntax for primitive arrays

15:58 gfredericks: $google clojure array type-hints

15:58 lazybot: [Array Type Hints in Clojure] http://asymmetrical-view.com/2009/07/02/clojure-primitive-arrays.html

15:58 dgrnbrg: that post only talk about primitive arrays

15:58 gfredericks: it says primitive but it looks like he has an example with String

15:59 dnolen: ^"[Lclojure.lang.IFn;"

15:59 daniel___: with a vector like [\X \X \O \X \O \O \X \X \X], how would i iterate over it and return two sets X #{0 1 3 6 7 8} & O #{2 4 5} with the indexes?

15:59 dnolen: ,(type (make-array clojure.lang.IFn 2))

16:00 dgrnbrg: oh, semicolon

16:00 i missed that

16:00 gfredericks: &(doc map-indexed)

16:00 lazybot: ⇒ "([f coll]); Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thus function f should accept 2 arguments, index and item."

16:00 dgrnbrg: hooray!

16:00 daniel___: map-indexed, thats the one

16:00 dgrnbrg: it was the semicolon

16:03 i just got a job writing clojure all day

16:03 it's pretty awesome

16:03 gfredericks: that sounds pretty awesome

16:05 dgrnbrg: i get to integrate things like storm, cascalog, leiningen, and incanter with our java code base

16:07 eggsby: sounds like a lot of work

16:07 but congrats :)

16:10 uvtc: dgrnbrg: nice. New job, or current one switching you to working on Clojure stuff?

16:10 dgrnbrg: it's actually the same job

16:10 i was previously working on our in-house distributed analysis framework

16:10 i made the case that clojure brings a lot to the table

16:11 so we're building an experimental system in clojure to iterate faster and explore the possibilities

16:11 uvtc: Hooo doggie. :)

16:11 dgrnbrg: that's built on our analysis framework

16:11 it's pretty awesome

16:11 we write emacs plugins, compilers, and think about new modes of interaction

16:11 like light table, but in our domain

16:13 eggsby: nice

16:13 I'm working on some analytics/continuous delivery stuff in clj for my work, a lot more fun than maintaining old groovy and spring mvc apps...

16:14 antoineB: is there a function to get the number of a list ? example: (get 3 '(a b c d)) => c

16:15 uvtc: antihero: `nth`

16:15 dnolen: antoineB: nth

16:15 dgrnbrg: ,(nth 2 '(a b c d))

16:15 uvtc: Whoops. Sorry antihero --- premature autocomplete. :)

16:15 dgrnbrg: &1

16:15 lazybot: ⇒ 1

16:15 antoineB: thanks

16:15 dgrnbrg: &(nth 2 '(a b c d))

16:15 lazybot: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number

16:15 dgrnbrg: &(nth '(a b c d) 2)

16:15 lazybot: ⇒ c

16:20 antoineB: a function for the size or lenght of a list?

16:21 eggsby: count

16:21 piotr: antoineB: you should have a look at http://clojure.org/cheatsheet

16:21 eggsby: you don't use get and count as often as you'd think antoineB

16:22 gfredericks: $findfn [1 2 3 40] 4

16:22 lazybot: [clojure.core/count]

16:22 eggsby: they aren't used as often as .length and someArray[nth]

16:22 gfredericks: ,(.length '(a b c d))

16:22 &(.length '(a b c d))

16:22 lazybot: java.lang.IllegalArgumentException: No matching field found: length for class clojure.lang.PersistentList

16:23 antoineB: what is the difference with .length ?

16:23 eggsby: rather, as often as .length and array accessors in java/imperitive langs :p

16:23 imperative even

16:23 antoineB: ok

16:23 wingy: when creating a var with def .. is that var called a variable?

16:23 or just a var

16:24 gfredericks: &(.length '[a b c d])

16:24 lazybot: ⇒ 4

16:24 gfredericks: wingy: a var

16:24 wingy: there are no variables in clj?

16:24 gfredericks: not local variables

16:24 wingy: what is a global variable?

16:25 atom, ref, var and agent?

16:25 gfredericks: well the changey things that exist are

16:25 aphyr: gfredericks: what about let frames?

16:25 uvtc: gfredericks: it seems to me that there *are* variables in Clojure, except that they're not called "variables" per se, and you don't vary them in-place, but rather modify them to refer to different values when you need to change them.

16:25 eggsby: ya, I like calling them values instead of variables

16:25 gfredericks: uvtc: how do you do int x = 12; x = 13;?

16:26 antoineB: (def x 12)

16:26 uvtc: gfredericks: I suppose create an atom with the value 12, then later swap in 13 for it.

16:26 eggsby: lol, (let [x 12] (let x [13] ;; do stuff))

16:26 it's beautiful

16:26 gfredericks: eggsby: those are two different x's

16:26 the first one doesn't change

16:26 eggsby: right

16:26 gfredericks: so clojure has explicit reference types

16:27 and the java types can have mutable fields

16:27 wingy: (i think i shall just forget the word variable)

16:27 gfredericks: but you cannot create a locally-scoped name that points to one thing and then change it to point to another thing

16:27 wingy: references are bound to values if you wanna simulate changing states/values

16:28 eggsby: ya

16:28 well you were right stuff stuff like 'atom' is closer to a var wingy

16:28 daniel___: clojure makes my brain hurt

16:28 gfredericks: ruby makes my fingers hurt

16:29 wingy: another question regarding a comment i read in the reference regaring descructuring "There are similar :strs and :syms directives for matching string and symbol keys."

16:29 eggsby: ya

16:29 uvtc: daniel___: feel the burn. Only a few ... more ... reps.

16:29 eggsby: so a hashmap can have anything as its key wingy

16:29 like strings or symbols

16:29 {"myString" 1, 'mySym 2}

16:29 antoineB: perl makes me confuse

16:29 eggsby: you could get out strings with :strs or symbs, similar to how you would get :keywords out with :keys

16:30 wingy: eggsby: ah .. i think i know what the problem was with :syms .. i didnt quote

16:30 yepp that was the problem

16:30 eggsby: thx

16:30 uvtc: gfredericks: But do you see what I mean? I think it's confusing to say that Clojure doesn't have variables. Seems more accurate to say that it has no local variables, but it's got "global variables" --- with the caveat that you can't modify them in-place; you instead change which value they refer to.

16:31 dgrnbrg: does anyone know how to get lein to stop saying "Could not find artifact org.clojure:clojure:pom:1.+ in central (http://repo1.maven.org/maven2)" ...

16:31 wingy: clojure makes my eyes, heart and brain happy

16:31 antoineB: clojure have name wich refer to an object

16:31 uvtc: antoineB: funny thing about Perl though, it seems to have at least one thing in common with Clojure: practicality.

16:31 wingy: i have become a happier person overall since 2 weeks ago

16:32 thats weird a lang can have that effect on you

16:32 gfredericks: uvtc: the question doesn't mean too much until you rigorously define variable. I think the concept I was going for is what most people mean when asking such a question.

16:32 akhudek: uvtc: you wouldn't say that if you've ever tried to build a relatively large code base in perl that remotely needs nice data structures

16:33 uvtc: akhudek: don't worry --- I stop the comparison at that. :)

16:33 eggsby: uvtc: it's fine so long as you acknowledge that global mutable state isn't bad so long as it isn't concurrently muteable, which clj enforces

16:34 s/mutea/muta

16:34 wingy: off topic question: is there anyone here from Stockholm?

16:35 gfredericks: eggsby: it can still be bad to the extent that it keeps you from using mostly pure functions

16:35 antoineB: uvtc: in perl you loose so many time to learn the many syntaxicaly ways of doing something instead of learning the different semantics ways

16:35 eggsby: gfredericks: I haven't heard a compelling argument about why pure is better than impure, is there anything I should read? :p

16:36 Squee-D: Side effects are the hardest things to debug?

16:36 gfredericks: bam

16:36 wingy: eggsby: easier to test since all the thing a pure fn need is passed as args

16:36 gfredericks: yeah, for debugging and testing, pure functions are huge

16:36 Squee-D: and im new to lisp, but thats what 'compels' me to learn it.

16:38 wingy: eggsby: i think it's also better for concurrency since now you can run that fn not caring about place and time it is run

16:38 eggsby: ya but i'm not going to start using the state monad in exchange for an atom

16:38 gfredericks: so there's this piece of code I wrote that's in production, but I'm not actively working on it. The ops guy says it crashes, and is crashing in a part of the code that is pure functions. So rather than doing all sorts of poking around on production, I just have him send me a log of the input to the pure part of the code, and I have a fully reproducible failing test in 2 seconds.

16:38 Squee-D: Otherwise you may as well be using scala :D

16:38 eggsby: I don't see practical benefit, your transformation functions can still be pure functions...

16:38 wingy: fns dependent on global states is spaghetti

16:38 bad abstractions

16:38 gfredericks: eggsby: I didn't say all pure, I said mostly pure

16:39 Squee-D: you cant do all pure

16:39 * gfredericks waits for someone to say haskell

16:39 daniel___: im hating this function but im struggling to come up with something better: https://gist.github.com/3113254

16:39 Squee-D: lol

16:39 daniel___: can anyone think of a clever way of detecting a winner (and even better, detecting the player \X or \O) in a game of tictactoe

16:40 the board is a vector of length 9: [\space \X \space \O ... ]

16:40 antoineB: i never understand the monad stuff

16:41 is it a way to force the programmer to test all the possble case?

16:41 like Option[] in scala?

16:41 eggsby: it's just a way to capture the entire notion of a computation antoineB

16:41 gfredericks: daniel___: (def in-a-rows (let [idx (partition 3 (range 9))] idx (map list idx) [[0 4 8] [2 4 6]]))

16:41 ^ then use that

16:42 antoineB: just figuring out what the possible cases are is rather difficult in a dynamic language

16:42 antoineB: what is "the entire notion of a computation"?

16:42 gfredericks: qubits!

16:43 eggsby: antoineB: http://www.scribd.com/doc/72134705/Comprehending-Monads can explain monads far better than I ever could

16:44 daniel___: gfredericks: not sure what that does exactly

16:44 ,(def in-a-rows (let [idx (partition 3 (range 9))] idx (map list idx) [[0 4 8] [2 4 6]]))

16:44 ,in-a-rows

16:45 gfredericks: &(let [idx (partition 3 (range 9))] idx (map list

16:45 idx) [[0 4 8] [2 4 6]])

16:45 lazybot: java.lang.RuntimeException: EOF while reading, starting at line 1

16:45 gfredericks: &(let [idx (partition 3 (range 9))] idx (map list idx) [[0 4 8] [2 4 6]])

16:45 lazybot: ⇒ [[0 4 8] [2 4 6]]

16:45 gfredericks: mrrrrmrmmm

16:45 ah I forgot the concat

16:45 &(let [idx (partition 3 (range 9))] (concat idx (map list idx) [[0 4 8] [2 4 6]]))

16:45 lazybot: ⇒ ((0 1 2) (3 4 5) (6 7 8) ((0 1 2)) ((3 4 5)) ((6 7 8)) [0 4 8] [2 4 6])

16:45 antoineB: eggsby: espected on irc the font isn't so uggly :)

16:45 gfredericks: man I really screwed that up

16:45 daniel___: :/

16:46 gfredericks: &(let [idx (partition 3 (range 9))] (concat idx (apply map list idx) [[0 4 8] [2 4 6]]))

16:46 lazybot: ⇒ ((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) [0 4 8] [2 4 6])

16:46 gfredericks: okay that's what I meant

16:46 then you can write functions that iterate over all 3-in-a-rows without thinking about what that structure actually is

16:48 daniel___: why are the last two vectors

16:48 the diagonals

16:48 gfredericks: cuz I gave them explicitly; isn't supposed to make a diff

16:49 daniel___: i cant think hwo to iterate over them, without using a load of if/or/and statements like before

16:50 gfredericks: (some (fn [[a b c]] (= (board a) (board b) (board c))) three-in-rows)?

16:51 daniel___: what about detecting whether it's a \X or a \O

16:52 gfredericks: use one of the indices in the result of that expression?

16:52 depends on what kind of output you're looking for exactly

16:53 daniel___: i guess either \O \X or nil

16:53 then i can test for not nil

16:53 and whatever is returned is the winner

16:53 i lack a serious amount of creativity or something

16:54 how do you arrive at the point where you can see a good solution to every problem? just doing loads of 4clojure type challenges

16:54 ?

16:54 gfredericks: (some (fn [[a b c]] (if (= (board a) (board b) (board c)) (board a))) three-in-rows)

16:54 emezeske: daniel___: Nobody can see a good solution to *every* problem ^_^

16:55 gfredericks: daniel___: I can see a good solution to these kind of silly problems because I've done them over and over.

16:55 wingy: i wanna get to that point i can read code very fast

16:55 to be thinking in code

16:56 emezeske: wingy: There's only one way to do that, AFAIK: read more code. :)

16:56 wingy: yeah

16:56 gfredericks: daniel___: where by "silly" I mean "not directly practical"

16:56 akhudek: wingy: think in datastructures, not code

16:56 wingy: akhudek: right .. everything is data

16:56 that's what you wanna say?

16:56 akhudek: pretty much

16:57 I always think in trees, lists, vectors, etc

16:57 translates to many languages easily

16:57 gfredericks: daniel___: https://github.com/fredericksgary/tictactoe/blob/master/src/ttt/core.clj#L69

16:57 akhudek: functional languages just make it easier to directly implement this kind of thinking

16:57 e.g. "transform each element in the list with function X"

16:57 wingy: akhudek: one of the fundamentals of FP is to manipulate these data structures right

16:57 i read somewhere that algorithms are overrated

16:58 akhudek: well, algorithms are not overrated

16:58 wingy: most of the things you do is to manipulate data

16:58 akhudek: but to create good algorithms you need to think about data structures

16:59 emezeske: wingy: I think the "algorithms are overrated" thing means something to the effect of "once you have the right datastructure, the right algorithm is much more obvious"

16:59 antoineB: akhudek: algorithm go with datastructure

16:59 akhudek: that's exactly right

17:00 antoineB: there is no datastructure on a side and algorithm on another side

17:00 emezeske: wingy: But the reality is that datastructures and algorithms are really just two aspects of the same thing

17:00 gfredericks: datastrorithms

17:00 wingy: hmm interesting

17:00 they go hand in hand

17:00 emezeske: gfredericks: haha

17:00 antoineB: algotucture

17:01 akhudek: and they are language independent too

17:01 for the most part

17:01 wingy: emezeske: what do you mean two aspects of the same thing

17:01 hyPiRion: emezeske: I'd say algorithms are "operations" on datastructures.

17:01 akhudek: obviously language can make particular algorithms and data structures easier or harder to write (or sometimes impossible)

17:01 gfredericks: never impossible!

17:01 wingy: hyPiRion: that seems fair

17:02 yeah .. its not a lot of fun to do FP in javascript

17:02 daniel___: my version so far: https://github.com/danielstockton/naughts-and-crosses/blob/master/src/naughts_and_crosses/core.clj

17:02 emezeske: wingy: Well, I guess I just mean that some algorithms can't be described without describing their underlying datastructure

17:02 wingy: ; function {} nightmare

17:02 i realized clj is so concise so it really fits very well as a cli lang

17:02 antoineB: hyPiRion: flat data itself a datastructure

17:03 *is itself

17:03 gfredericks: wingy: the underscore lib helps slightly

17:03 wingy: gfredericks: yeah .. but i ended up switching to livescript

17:03 cheater__: but is the data structure data?

17:03 arohner: is there a built-in fn for casting a byte to an unsigned byte? i.e. (unsigned-byte -106) => 153

17:03 antoineB: its not a lot of fun to do javascript

17:03 wingy: a better coffeescript with FP features

17:03 gfredericks: $findfn -106 153

17:03 lazybot: []

17:04 gfredericks: wingy: but now you're using cljs?

17:04 cheater__: $findfn 153 -106

17:04 lazybot: []

17:04 cheater__: interesting.

17:04 antoineB: cheater__: it's meta data or not :)

17:04 akhudek: arohner: java doesn't have unsigned types :-(

17:04 antoineB: or meta meta data

17:04 wingy: gfredericks: once i mastered server side with clj/datomic i plan to use cljs for frontend

17:04 akhudek: I think there are some convenience functions to simulate them anyways though

17:05 arohner: akhudek: I know, but I'd still like to treat it as unsigned, turning into a short or int if necessary

17:05 akhudek: arohner: I'm trying to remember where I read this, maybe it is Java7 that introduced something to handle this

17:06 ivan: Java 8 has some real unsigned ints

17:08 akhudek: ack, sorry, I can't seem to find it, but I remember that it was specific either to 1.7 or 1.8

17:08 daniel___: arohner there is unchecked-byte

17:08 oh, hes gone

17:09 hyPiRion: daniel___: that wouldn't convert it to an unsigned byte, though.

17:09 ,(unchecked-byte -106)

17:10 gfredericks: lazybot should watch for , messages and respond if clojurebot doesn't.

17:10 daniel___: hyPiRion: nope

17:10 gfredericks: maybe they should just keep tabs on eachother in the background

17:12 wingy: so once you have mastered all basic stuff in clj and cljs .. how do you ensure that you develop your skills to read and write idiomatic code. should one just pick a random lib in github and read the source code? that sounds boring

17:13 doing tasks like 4clojure all day?

17:13 gfredericks: use it for stuff and read/participate-in discussions

17:13 antoineB: try to write your own dsl in clojure?

17:13 cheater__: what is cljs?

17:14 wingy: clojurescript

17:14 cheater__: what's that do?

17:14 antoineB: it compile to javascript

17:14 cheater__: neato

17:14 emezeske: wingy: You could always contribute to an open source project, which would force you to read source code but might not be boring due to having a purpose

17:14 cheater__: does it work well in browsers?

17:14 or is it mostly for v8 & co?

17:15 wingy: antoineB: DSLs using macro seem fun .. perhaps i could write a DSL for my business domain

17:15 gfredericks: cheater__: it works well in browsers

17:15 emezeske: wingy: Plus if you contribute something useful, you might get a free code review :)

17:15 cheater__: gfredericks: even in ie7?

17:15 wingy: emezeske: yeah :)

17:15 gfredericks: cheater__: I'd be surprised if it didn't

17:16 emezeske: cheater__: CLJS uses the google closure compiler and library, which I'm pretty sure supports really old browsers

17:16 wingy: hope more books will be available .. i like reading books

17:17 would be cool if they had lynda videos for clojure .. i searched but they arent any

17:17 cheater__: lynda? hahah.

17:17 wingy: cheater_: thats what i used to learn programming back in the days :)

17:18 cheater__: at least it's not w3schools.

17:18 wingy: i just think fun stuff makes the entry easier

17:18 like head first series

17:18 so great

17:19 antoineB: i fail the first problem of 4clojure :/

17:19 wingy: like when we have light table ready to rock .. i think it will convert a lot of people to clj

17:19 the tooling is really important for a lang's survival

17:20 * Frozenlo` hugs Emacs, slime, and leiningen

17:20 antoineB: anyone who wants do an interactive test in swank? (you change the code, it change the result of your tests)

17:21 cheater__: huh?

17:21 antoineB: what problem did you fail at?

17:21 antoineB: write your tests, write your function and have directly the result of your tests

17:22 change your function, modify the result and so on

17:22 cheater__: i don't understand :)

17:23 antoineB: when you write, your function you see the tests are executed (using the current function)

17:24 and you see the result

17:24 you don't need compile/eval + run the test

17:25 cheater__: i'm sorry i see words but i don't know what they refer to

17:25 wingy: im so glad i moved on from php when i read this http://www.slideshare.net/fabpot/design-patternrevisitedphp53

17:25 cheater__: wingy: was going to click, but noticed "php" in url

17:26 gnarmis: anyone else doing a deep dive into emacs? just setup swank and all…things seem to work!

17:26 coming from vim

17:27 gfredericks: I did that 4 months ago maybe

17:27 antoineB: i just do clojure-jack-in

17:27 that all

17:31 wingy: wow, never knew about condition-map in fns .. are there good use cases for those?

17:32 when would you wanna have a certain check in a condition-map instead of putting in the function itself

17:32 gfredericks: when you want the program to crash due to programmer error

17:32 rather than some other sort of exceptional case

17:33 they're the kind of thing you should be comfortable disabling in production

17:34 cheater__: hey guys can someone explain this to me?#(+ % 5)

17:34 is % the "unshift"?

17:34 gfredericks: it's the arg

17:34 Raynes: (fn [x] (+ x 5))

17:34 wingy: cheater__: the first arg

17:34 cheater__: what if i have multiple args?

17:34 gfredericks: %1 %2

17:34 wingy: the same as %1

17:34 Raynes: #(+ % %2)

17:34 cheater__: ah k

17:35 is #() the same as function definition?

17:35 gfredericks: man we can't resist easy questions apparently

17:35 Raynes: I feel insulted when people don't answer in code.

17:35 gfredericks: cheater__: it's a reader macro; you can use read-string to see what it expands to

17:35 &(read-string "#(+ %1 %2)")

17:35 lazybot: ⇒ (fn* [p1__69903# p2__69904#] (+ p1__69903# p2__69904#))

17:35 gfredericks: Raynes: ^ there you go :P

17:36 cheater__: ok so fn defines an anonymous function?

17:36 gfredericks: yeah

17:36 cheater__: what if i do (fn add-five [x] (+ x 5)) ?

17:36 is it still anonymous?

17:36 wingy: cheater__: you should pick up the book "Programming Clojure" .. it will walk you through all this stuff

17:36 Raynes: Yes.

17:37 You can't access add-five outside the scope of add-five.

17:37 gfredericks: Raynes: say that in code

17:37 cheater__: i can't wait till a book arrives from amazon

17:37 i need to know clojure now !

17:37 :)

17:37 Raynes: thanks

17:37 Raynes: &(do (fn add-five [x] (+ x 5)) (add-five 5))

17:37 lazybot: java.lang.RuntimeException: Unable to resolve symbol: add-five in this context

17:37 Raynes: gfredericks: ^

17:37 cheater__: Raynes: i was wondering why they ever give names to anonymous functions, i guess it's only for recursion?

17:37 gfredericks: Raynes: phew

17:38 wingy: cheater__: there is an ebook i think

17:38 gfredericks: cheater__: alse I think it will leak into the compiled class name, which can be nice

17:38 cheater__: wingy: i'm just going through 4clojure since you guys linked it.

17:38 wingy: cheater__: i think basic knowledge before doing 4clojure is better

17:38 Raynes: &((fn to-five [x] (if (< 5 x) (to-five (inc x)) x)) 1)

17:38 lazybot: ⇒ 1

17:38 cheater__: i thought 4clojure was for learning basic knowledge

17:38 Raynes: I lose.

17:39 &((fn to-five [x] (if (< x 5) (to-five (inc x)) x)) 1)

17:39 lazybot: ⇒ 5

17:39 Raynes: &((fn [x] (if (< x 5) (recur (inc x)) x)) 1)

17:39 lazybot: ⇒ 5

17:39 cheater__: is "partial" the same as currying?

17:39 Raynes: No.

17:39 cheater__: what's the diff?

17:40 Raynes: One is called partial application and the other is called currying.

17:40 wingy: gfredericks: cant still create a use case in my head regarding pre and post condition map .. would you mind give me a concrete example?

17:40 cheater__: is there an actual difference?

17:40 wingy: eg. if they don't pass a wrong data type?

17:40 i mean if they pass a wrong data type?

17:40 but that would be like type checking

17:41 gfredericks: you can check arbitrary things

17:41 so it's kind of stronger than type checking

17:41 wingy: like no trailing whitespace in strings?

17:41 gfredericks: sure

17:41 emezeske: cheater__: There is a difference. Currying would mean that ((fn [a b] (+ a b) 1) would return a function like (fn [b] (+ 1 b))

17:41 Raynes: cheater__: http://stackoverflow.com/questions/218025/what-is-the-difference-between-currying-and-partial-application

17:42 emezeske: cheater__: Clojure does not support that, though, it would complain about wrong arity to the first fn

17:42 gfredericks: emezeske: http://github.com/fredericksgary/currj

17:43 wingy: gfredericks: I thought that pre condition is used for fn parameter list while post condition is used for return value .. but after reading this line "pre-expr and post-expr are boolean expressions that may refer to the parameters of the function." post condition seems to be used for parameter list as well

17:43 emezeske: gfredericks: that is super cool.

17:43 ldh: i'm struggling to configure jetty from lein-ring. I've got:

17:43 :ring {:handler my-app.core/app

17:43 :adapter { :configurator (fn [& more] (println "Configuring"))}}

17:43 which gives me : java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn

17:43 gfredericks: wingy: I imagine they're available in the post conditions, but probably most postconditions just refer to %, the return value

17:45 ldh: if i unquote the configurator function (as suggested here:http://stackoverflow.com/questions/10289617/clojure-ring-jetty-i-am-using-lein-ring-server-how-do-i-configure-the-jetty) i get ReaderException: java.lang.Exception: Unreadable form

17:45 wingy: gfredericks: i created an example: (defn constrained-sqr [x] {:pre [(pos? x)] :post [(= x 1)]} (* x x))

17:46 weavejester: ldh: Embedding functions in the project.clj file is not really what it's designed for...

17:46 wingy: what does the word :pre and :post refer to?

17:46 they both check the parameter list

17:46 weavejester: ldh: What do you need to configure?

17:46 gfredericks: wingy: :pre gets run before, :post gets run after

17:47 ldh: weavejester: i'm playing with configuring log handlers. i'd prefer not embedding it in project.clj actually, but had no luck trying to refer to a function elsewhere either

17:47 wingy: whats the exact difference? and before/after what btw? the fn body execution?

17:47 gfredericks: yes

17:47 that is the exact difference

17:47 and of course :pre can't access the return value

17:48 wingy: i see .. putting % in pre generates error

17:48 gfredericks: quite

17:48 weavejester: ldh: Hm, you might need to use the adapter directly. If you need to do a lot of work with a specific adapter, then lein-ring is probably not the right tool to use.

17:49 wingy: but is there a reason for wanting to assert the argument list again in a post conditin?

17:49 condition

17:49 seems like you are really interested in the return value

17:49 gfredericks: wingy: right; probably the only reason you can use the args at all is if you want to say something about the args and the return value together

17:50 wingy: yeah

17:50 this was a quite hidden feature .. haven't encountered it yet in 2 books

17:51 oskarth: :q

17:51 wrong winodw

17:51 ldh: weavejester: ok, thanks. i can just use 'lein run' and call run-jetty from within my main function and configure it that way, but then i lose the nice code reloading

17:51 weavejester: ldh: You can apply the "wrap-reload" middleware directly.

17:52 ldh: It's in ring.middleware.reload in the ring/ring-devel package

17:52 ldh: weavejester: i thought as much. fantastic, thanks.

17:52 Squee-D: oskarth oh i though you were licking your nose

17:52 :P

17:52 gfredericks: lol

17:53 Squee-D: thanks, I'll be here all week. With very little useful to say :D

17:53 gfredericks: ,:q

17:53 &:q

17:53 lazybot: ⇒ :q

17:54 Squee-D: im really enjoying Land Of Lisp. If anyone asks for a noob primer, this thing is great

17:55 gfredericks: apparently cljs does not have pre/post conditions

17:55 wingy: oh

17:56 i hope cljs could be as near clj as possible though

17:56 so there is no surprise

17:56 pre/post seems possible to do at least

18:07 * gfredericks rages against floats

18:07 arohner: $findfn 154 -106

18:07 lazybot: []

18:22 bpr: is there a more succinct way to do: https://www.refheap.com/paste/3610

18:25 gfredericks: bpr: that looks like a reduce

18:25 bpr: ah blah

18:25 yes

18:45 oskarth: Squee-D: lol :p

18:45 using vim with clojure is kind of like that

18:52 Squee-D: i believe it :D

18:55 wingy: seems that data structures refer to not only collections but to scalars as well: http://clojure.org/data_structures

19:47 oh my bad i think

19:47 data structures don't refer to scalars .. weird that they are mentioned in the same section though

19:49 duck1123: well, do you consider 7 to be a data structure?

19:50 wingy: watching a video where he explains data structures

19:50 gfredericks: I'm using 7 as a data structure in my cljs program :)

19:50 wingy: it seems that scalars are data structures as well

19:50 duck1123: I don't see the point of 7

19:50 and they eat all the cake

19:50 gfredericks: (extend-type js/Number IBasisVector ...)

19:51 wingy: i just wanna know if the term "data structure" refer to scalar values as well

19:52 could someone confirm that

19:52 gfredericks: I would think not

19:52 duck1123: what does it matter

19:52 clojure doesn't really concern itself with "scalar"

19:53 I mean there's things that return sequences and what not, but the concept of scalar isn't really special

19:54 If the function doesn't work with non-collections or non-seqable things, it'll say as such

20:04 wingy: but watching this video rich says that the reader reads in data structures

20:04 when you type 1 in the repl you get returned the data structure of it

20:04 which is just 1

20:05 so it seems that all numbers, strings, booleans, keywords etc are called data structures as well

20:06 duck1123: sure

20:09 gfredericks: I think he was probably being loose with his language

20:10 precisely defining data structures was not his intention at that moment

20:10 wingy: so you are saying that by data structures he mean collections

20:10 list, vector, map and set only

20:11 gfredericks: yeah

20:12 he was probably describing homoiconicity

20:12 wingy: what do we call the other ones?

20:12 gfredericks: scalars

20:12 wingy: and both scalars and data structures are forms right

20:12 gfredericks: yeah; a form is usually something evalable; or at least code-like

20:13 rather than data-like

20:13 it's a distinction of purpose

20:13 wingy: '(1 2 3) is a form?

20:13 gfredericks: probably not; depends on the purpose

20:13 wingy: but then you can probably say it evals to itself

20:13 just like :keyword is

20:13 gfredericks: no it doesn't

20:14 wingy: oh

20:14 but :keyword is?

20:14 gfredericks: :keyword does eval to itself

20:14 wingy: ok .. thought that what you saw returned in the repl was the evaluation

20:15 so its confusing the scalar values are listed in the Data Structures section

20:15 gfredericks: if '(1 2 3) evaled to itself then you could run (eval *1) all day and get the same thing

20:15 wingy: incidental confusion!

20:15 gfredericks: wingy: it's not a word meant to be stressed over

20:16 LesZedCB: why is it not a form? is it not equivalent to (quote (1 2 3))?

20:16 wingy: but when the same term is mentiond all over in books and in blogs etc you kinda wanna know what they exactly mean :)

20:16 gfredericks: it is

20:17 LesZedCB: I was using a somewhat constrained definition of form; if you meant "anything output by the reader" then yes it is

20:17 LesZedCB: well, isn't a form technically just any valid clojure data structure?

20:17 gfredericks: wingy: if you want something generally accepted look at the wikipedia article

20:17 xumingmingv: I'm trying to build this lein plugin: https://github.com/febeling/lein-junit

20:17 gfredericks: LesZedCB: it doesn't have a techincal definition that I'm aware of

20:18 xumingmingv: but seems leiningen:leiningen:jar:1.7.0 can not be found in clojars.org

20:18 anybody know why?

20:18 gfredericks: LesZedCB: I can imagine a majority of people believing what you said though, so I might just be ignorant

20:21 LesZedCB: so, i have a question about '&' used in variadic functions.

20:22 suppose (fn useless [x & rest] (println rest))

20:23 dnolen: gfredericks: wingy: LesZedCB: I think a "form" would refer to anything that is readable - that is will be accepted by the reader.

20:23 LesZedCB: how does & fit in with the language? for example I can't evaluate (type &)

20:23 dnolen: That makes sense, thanks!

20:25 wingy: i just use (read) to know what is a form

20:25 & is a form as well since it can be read

20:25 lazybot: java.lang.RuntimeException: Unable to resolve symbol: is in this context

20:26 LesZedCB: & is not a form by itself, and [x & rest] is not a form by itself

20:26 lazybot: java.lang.RuntimeException: Unable to resolve symbol: is in this context

20:26 wingy: why can i do

20:26 (read)

20:26 then type &

20:26 LesZedCB: (read &) you mean?

20:26 wingy: i returns & which means it has to be a form

20:26 no

20:26 (read) .. then & and hit enter

20:27 everything (read) can read must be a form i guess

20:28 LesZedCB: hmm. interestingly, in the lein REPL, "(read) &" does not evaluate, and in the clojure repl, it does

20:30 wingy: im in lein repl

20:30 it does read for me

20:30 lein 2

20:31 LesZedCB: oh, I see what you did

20:31 try (read-string "&")

20:31 wingy: yeah

20:31 the same

20:31 but reading a string instead of a stream

20:31 so that means & is a form right :)

20:32 LesZedCB: sorry, right. but try just "&"

20:33 dnolen: LesZedCB: my earlier definition may be too loose, seems like in other Lisps - "form" means acceptable to the reader as well being meaningful when evaluted (in terms of the core language).

20:34 wingy: ok so what gfredericks said

20:34 code like thing

20:34 LesZedCB: dnolen: yes that makes sence, if it can pass read and eval.

20:34 musicalchair: a form has evaluation semantics

20:35 wingy: could one say that a form is an expression?

20:35 on the other hand an expression could be composed of multiple forms .. i think i get it

20:35 musicalchair: I would say all forms are expressions but not all expressions are forms

20:35 wingy: yeah

20:37 gfredericks: dnolen: that's funny I would have assumed it would refer to post-read if anything

20:37 as in (defmacro fooball [form] ...)

20:38 and "s-expression" might refer to the string version

20:39 wingy: this just confirms that it doesn't matter all that much :)

20:39 wingy: yeah haha

20:40 gfredericks: &(eval (eval :foo))

20:40 lazybot: java.lang.SecurityException: You tripped the alarm! eval is bad!

20:40 gfredericks: aw poopsmith

20:41 wingy: clj is too cool

20:41 ill teach my son clj that's for sure

20:41 gfredericks: good luck explaining what "the jvm" is

20:42 wingy: why would that be a hard thing

20:43 its a platform for runing clj

20:43 gfredericks: that's what computers are

20:43 or maybe operating systems

20:43 wingy: but then jvm is an abstraction on top of OSes

20:43 so we don't have to care about the OSes

20:43 i think he'll get the pic

20:44 gfredericks: but we do have to care about the jvms

20:44 wingy: perhaps he won't even bother with understanding OSes

20:44 musicalchair: not if you're a little kid learning clojure

20:44 wingy: thats because i dont get it

20:44 gfredericks: in the future people will not be familiar with the existence of "operating systems"

20:44 wingy: :D

20:45 gfredericks: &:D

20:45 lazybot: ⇒ :D

20:45 wingy: lol

20:45 LesZedCB: lol

20:45 gfredericks: &'<o.o>

20:45 lazybot: ⇒ <o.o>

20:45 duck1123: I gave my son a Ruby shell to play with. I'll let him get a bit older before I try lisp

20:45 gfredericks: look son. if you give it a funny face it will give you one back.

20:45 LesZedCB: thanks for the response. cheers!

20:46 wingy: duck1123: why not clj immediately?

20:46 gfredericks: he has to learn about assignment and mutable data structures before he can learn to avoid them

20:46 duck1123: he was 5

20:46 wingy: does he? can't we just start correct

20:47 and then show him the OOP where everything is a mess

20:47 gfredericks: no. start with GOTO and malloc.

20:47 duck1123: He's 7 now, he may be able to grok it.

20:47 wingy: duck1123: i think people can get things when they are 4-5 really quickly .. if they have a good teacher

20:47 duck1123: Kids these days don't appreciate not needing to number their lines by 10

20:47 wingy: a 10 years old can be way smarter than a 30 years old if he started early

20:48 i won't put my boy through hell like the one i had to go through

20:48 duck1123: I was thinking that if I was going to teach him Clojure, I would use light table for that instant response

20:49 wingy: i teach him lisp immediately .. syntax comes and goes .. logic stays forever!

20:49 i want him to tell his teacher that

20:50 mefisto`: I agree... I want to do the same thing with my daughter (due in 1 month!)

20:51 gfredericks: man I should get my son to type his first paren before he gets out his first word

20:51 wingy: i wont dare to teach my girl computer

20:51 she can't be as geeky as me

20:51 i'll teach her design!

20:52 duck1123: I want to give my daughter as much opportunity as possible to learn science and technology

20:52 gfredericks: duck1123: teach your son design!

20:53 wingy: yeah who knows .. maybe it will be more trendy for girls to know programming

20:53 gfredericks: your mother and I will love you no matter what you do, as long as it's trendy.

20:53 wingy: i teach my girl design .. my boy programming .. they both do an app together by 15 years old and bring me money

20:54 mattmoss: Awesome sauce, duck1123: "Kids these days don't appreciate not needing to number their lines by 10."

20:55 gfredericks: if I had designed the language they would have been numbered by 7

20:55 mattmoss: Line numbers written in base 7 as well? Or is that too easy?

20:55 gfredericks: no too easy

20:55 base 10

20:56 mattmoss: 20 GOTO 10 becomes 26 GOTO 13

20:56 duck1123: I still have my old Atari XE. I would ride the bus to school while reading my BASIC manual then go home and try out new programs

20:59 mattmoss: POKE 1024,42

21:00 wingy: what happens when i have (def a 1) (def a 2) .. is it creating 2 separate vars or 1 var but the value is changed?

21:01 gfredericks: wingy: same var

21:01 hyPiRion: You could try it out.

21:01 wingy: hyPiRion: didn't know how to compare them to see if they were the same

21:01 (identical? (def a 1) (def a 2)) ;=> true

21:04 duck1123: wingy: you're creating the var a and altering its root binding

21:06 wingy: is that idiomatic way of changing a value of a var?

21:06 or should i use binding or atom?

21:07 or let

21:07 gfredericks: you don't normally want to change the root binding

21:07 what are you trying to do?

21:08 wingy: nothing .. watching videos are questions arise :)

21:08 nvm

21:08 ill get to it later more in depth

21:08 quizme: i have an array of 10 things wrapped in an atom. How can i access those 10 things from another clojure process ?

21:09 gfredericks: deref the atom?

21:09 and access the 10 things?

21:09 duck1123: quizme: do you have the atom stored in a var that both threads can read?

21:10 quizme: i want to access it from a different process

21:10 duck1123: avout?

21:10 quizme: i mean i want to fire up two different leiningen projects

21:10 duck1123: https://github.com/liebke/avout

21:10 quizme: and have them share the same atom

21:11 duck1123: you'll need to store it somewhere outside of the jvms memory or send it to the other process somehow

21:11 gfredericks: ah ha

21:12 quizme: how can i send it to the other process ?

21:12 i guess i have to create a socket

21:13 duck1123: open a socket between the two, store it in a queue, a myriad of ways

21:13 check out that link i just sen

21:13 quizme: duck1123 ok thank you

21:16 duc1123 looks awesome.

21:18 duck1123: I've only played with it a little bit. I want to make use of it, but just haven't had the time

21:18 also, slacker is kind of cool for inter-process communication

21:21 I really wish there was a decent websocket client with the features of readline. There's a chrome one, but it doesn't support command history

21:35 emezeske: duck1123: Is a websocket client something that runs in the browser?

21:35 duck1123: well it can, but it could be any connection really

21:36 emezeske: duck1123: I was just going to suggest "rlwrap" to get readline features, but it only works for command-line tools

21:36 duck1123: I found a swing one, but it was no good and the node.js stuff I found was more of a library

21:37 I've been building out a command interface to my server that works over the open websocket connection

21:37 emezeske: You might try staring it via rlwrap

21:37 It tends to have pretty decent results for normal REPL type things

21:38 duck1123: I could probably take my cljs code and make a node.js command

21:38 never done that before

22:43 sjl: is there something special I need to do to include images in my /resources/ directory when hosting a Noir site on Heroku?

22:43 The rest of the /resources/ work, and the image resources work locally...

22:44 technomancy: with compojure IIRC the "site" handler does that for you

22:44 or wrap-resource with raw ring

22:44 not sure how noir does it

22:44 sjl: nevermind, git is being an asshole

22:45 git commit --all-but-not-really-all-lol

22:45 sorry for the noise

22:46 musicalchair: could anyone explain under what circumstances I would use clojure.contrib.graph/stratification-list? Google hasn't been particularly illuminating for me

22:47 sjl: musicalchair: well clojure.contrib is abandoned, so effectively: "None"

22:47 duck1123: Slightly OT. Does anyone know why firebug complains about {"a": "b"} saying it has an invalid label. Should I be doing all my communication as clj forms?

22:48 musicalchair: sjl: I'm aware it's not officially supported, but the code still works and presumably the concept still lives

22:48 sjl: musicalchair: sure

22:49 emezeske: duck1123: I think more context is needed to explain firebug's behavior

22:49 duck1123: Regarding communications, I think using pr-str/read-string for (de)serialization is pretty common

22:50 duck1123: Although I know some people use JSON and other formats

22:50 duck1123: I'm just trying to eval that form in the js console. I'm trying to figure out why my json communication isn't working

22:51 what is the safe way to eval the string with cljs, looks like the jquery one didn't get ported to jayq, but I'm sure I could use that

22:51 I'm hesitant to use clj forms as I want the websocket connection usable from outside of the site

22:52 sjl: duck1123: heh, you're going to cry when I tell you the answer.

22:52 duck1123: try {a = "b"}

22:52 duck1123: see, my issue is that clojure.data.json gives me the form I said above

22:53 emezeske: duck1123: Or try x = {"a" : "b"}

22:53 duck1123: I think the {string : string} format only works for assignment

22:53 duck1123: wow

22:54 sjl: try { 1 + 3; }

22:54 lol

22:54 Firebug is parsing the braces as a block, not the start of an object literal

23:00 duck1123: Ok, I screwed it up, but if you go to renfer.name and send in your js console: jiksnu.websocket.send("whoami") you can see what's going on

23:01 It's because I was using eval. Need to find the fix for tha

23:03 got it

23:42 ned: i'm doing problem 16 on 4clojure but am having a bit of a challenge with it anyone know why (fn [x] (concat "Hello, " x "!")) won't work ?

23:45 jkkramer: ,((fn [x] (concat "Hello, " x "!")) "ned")

23:45 ned: ,(+ 9 9)

23:45 jkkramer: &((fn [x] (concat "Hello, " x "!")) "ned")

23:45 lazybot: ⇒ (\H \e \l \l \o \, \space \n \e \d \!)

23:46 ned: oh hm, what's the appropriate concat method then

23:46 duck1123: just use str (sorry for spoiler)

23:46 ned: duck1123: haha no need to apologize, i thought i was doing something dumb and i was!

23:48 duck1123: if you have a seq of charachters like that... (apply str coll)

23:48 michaelr`: good morning!

Logging service provided by n01se.net