#clojure log - Dec 14 2011

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

0:01 dnolen: ambrosebs: technomancy_: down side of using type hints - doesn't it complicate analysis?

0:02 ambrosebs: isn't it just metadata?

0:02 what do you mean?

0:02 dnolen: ambrosebs: but you need arg type and return type right?

0:04 ambrosebs: dnolen: I'm going to explore it a bit :)

0:04 haven't tried yet

0:05 dnolen: ambrosebs: other consideration is something consistent for typed data structures.

0:09 ambrosebs: dnolen: it would be awesome if we didn't have to add custom syntax. Just top level +T annotations and type hints

0:09 the +T annotations are important because they contain type refinement information

0:10 i think ;)

0:10 as in, i think they're important

0:20 Turtl3boi: joy of clojure is a hard book for me to read, therefore i did not buy it

0:20 after all this reading i still didn't understand a lot of the terminology

0:20 i spent 5 hours at the store reading it

0:22 Scriptor: Turtl3boi: alright, quick test

0:22 do you understand what the map function does?

0:22 Turtl3boi: hold up

0:25 map function? is that different from a map

0:25 Scriptor: Turtl3boi: yes, very different, unless you look at it mathematically of course

0:25 anyway

0:25 Turtl3boi: well i didn't come across the "map function" yet in my reading

0:26 Scriptor: it's one of those core functions of functional programming

0:26 anyway, what do you know of clojure so far?

0:27 Turtl3boi: nothing really

0:27 i just read a few bits here and there about what closures are

0:27 and immutability

0:27 i decided not to buy the book since it seems confusing and not worth $30, however i do have the e-book

0:29 Scriptor: Turtl3boi: have a look at http://www.4clojure.com/

0:29 specifically start here

0:30 Turtl3boi: yo, is the problem list like a quiz

0:30 Scriptor: sorta, you just write in valid clojure code

0:31 Turtl3boi: wow thanks

0:31 Scriptor: Turtl3boi: any valid clojure code that could replace the underscore that is

0:31 Turtl3boi: i'm already lost with first one about "true"

0:31 Scriptor: for that one

0:31 just enter any expression that evaluates to true

0:31 Turtl3boi: "1" should eval to true

0:32 Scriptor: Turtl3boi: nope

0:32 amalloy: problems #1 and #2 probably stump more users than any other problems on the site :P

0:32 Scriptor: because 1 is a number, which cannot be compared with a boolean

0:32 that works in some languages, like python

0:32 but not all

0:32 Turtl3boi: huh

0:32 amalloy: Scriptor: well. it can be compared: it's just never equal

0:32 Turtl3boi: [1 2 3] = [1 2 3] should eval to true

0:33 Scriptor: (= [1 2 3] [1 2 3]) will return true, yes

0:33 because vectors, and other sequences, are designed in such a way that equality checks for the sequences' contents

0:33 Turtl3boi: so (= true true) should eval as well

0:33 let me try it

0:33 Scriptor: amalloy: damn semantics

0:34 Turtl3boi: yay it works

0:35 Scriptor: on to problem #2!

0:35 Turtl3boi: i don't get the second one

0:35 but surprisingly i got it right on my first try

0:35 the answer is 4

0:36 Scriptor: yep

0:36 Turtl3boi: but unfortunately i don't get it

0:36 Scriptor: it's just understanding how lisps do math

0:36 everything in lisp

0:36 is (operator arg1 arg2 ...)

0:36 Turtl3boi: oh now i get it =)

0:37 damn pollish notation

0:37 polski

0:37 Scriptor: cool, if you're ever unsure, you can open up a private converation with clojurebot and use it as a repl

0:38 or use http://tryclj.com/

0:39 amalloy: Turtl3boi: just like instead of: [1 2 3] = [1 2 3] you had to write (= [1 2 3] [1 2 3])

0:39 ambrosebs: any suggestions for representing primitive array types in typed-clojure? is there a method somewhere like Array(Integer/TYPE)

0:39 amalloy: Scriptor: i like to say it as (operator arg arg arg) because it sounds funny if you say it aloud

0:40 Turtl3boi: for #3 problem, how come "hello WORLD".toUpperCase() doesn't work

0:41 amalloy: quoting Scriptor here, Turtl3boi: everything in lisp is (operator arg1 arg2 ...)

0:41 dnolen: ambrosebs: ? you have make-array

0:41 Turtl3boi: lemme try another idea

0:41 i solved it

0:41 this is better than sex

0:42 not that i've had sex, but i'd imagine it would be better

0:42 amalloy: oh man. i wish i could put that on the 4clojure front page

0:42 amcnamara: its not.

0:42 ambrosebs: dnolen: I'm after the actual type of a prim array. ie. [Ljava.lang.Integer

0:42 Turtl3boi: lol

0:42 amcnamara: but both are awesome

0:42 ambrosebs: dnolen: maybe just a string "[Ljava.lang.Integer"

0:43 Scriptor: amalloy: I always feel like I'll run into someone confused about all the variables having the same name

0:43 is I say (op arg arg arg)

0:43 amalloy: Scriptor: agreed it's not good pedagogical technique. but i'm this to have fun!

0:44 Turtl3boi: i'm lost on #4

0:44 dnolen: ambrosebs: oh … yeah. like I said syntax for such things might be a plus.

0:45 Scriptor: Turtl3boi: ah, so now we enter lists

0:45 ambrosebs: dnolen: right, yes

0:45 Scriptor: that problem is just about showing you how to create lists in different ways

0:45 Turtl3boi: JoC doesn't explain lists very well hahaha

0:45 dnolen: ambrosebs: it's one of less nice things about Clojure. prim arrays being identified by their cryptic JVM string name.

0:45 Scriptor: keep in mind that lists aren't the only sequence-y data structure

0:45 but anyway

0:46 '(1 2 3) is a list of 3 elements

0:46 Turtl3boi: what's the apostrophe do?

0:46 Scriptor: the reason you need the quote is because otherwise clojure tries to do the (operator arg arg) thing

0:46 Turtl3boi: ahh

0:46 Scriptor: which means that it tries to treat the '1' as a function

0:46 Turtl3boi: so you're asking to treat it like a list instead of some operations

0:46 Scriptor: exactly

0:47 Turtl3boi: is list a keyword?

0:47 'list'

0:47 Scriptor: it's a function name

0:47 so (list ... ... ...) is the same as '(... ... ...)

0:47 Turtl3boi: what does the colon do?

0:48 Scriptor: the colon signfies something called a keyword

0:48 you don't have to worry about that just yet

0:48 just rewrite the call to the list function to use the '() notation

0:48 amalloy: Scriptor: augh don't say list is the same as quote

0:48 Turtl3boi: then the answer is just :a :b :c

0:49 Scriptor: amalloy: it is for now, dammit!

0:49 Turtl3boi: but yea, like amalloy says, the quote can almost mean other things

0:49 Turtl3boi: k

0:50 so saying (list :a :b :c) is the same as saying '(:a :b :c)

0:50 Scriptor: Turtl3boi: in the context of the problem, eys

0:52 Turtl3boi: so it's conj and pop isntead of push and pop for clojure stacks

0:52 is conj short for 'conjure'?

0:52 Scriptor: Turtl3boi: conjoin

0:53 Turtl3boi: ahhh ok

0:53 Scriptor: but also cons (for construct) was an important lisp function

0:53 and because of "clo(j|s)ure" a lot of things have the 's' replaced with 'j'

0:54 Turtl3boi: this is tough hehe

0:56 (conj '(2 3 4) 1) just adds 1 to the list

0:56 so it's now '(2 3 4 1)

0:56 right?

0:56 clojurebot: flatten |is| rarely the right answer. What if your "base type" is a list

0:57 Turtl3boi: nani clojurebot?

0:57 Scriptor: Turtl3boi: not quite, with lists conj doesn't append to the end

0:57 Turtl3boi: The conj function adds elements to and pop removes elements from the right side of the stack.

0:57 that's what JoC says

0:58 Scriptor: each different type of sequence implements conj in a different way

0:58 Turtl3boi: so it adds to the other side of the list

0:59 Scriptor: Turtl3boi: do you know how linked lists work?

0:59 Turtl3boi: yeah i wrote one in C

0:59 a singly linked list

0:59 Scriptor: sweet, so for now you can think of clojure lists as singly linked lists

1:00 conj is designed to work as optimally as possible depending on what kind of sequence you're using it for

1:00 Turtl3boi: how come (conj '(3 4) 2 1) doesn't evaluate to (list 2 1 3 4)

1:01 Scriptor: Turtl3boi: that's because it conjoins 2 to '(3 4), then conjoins 1 to the result of that

1:01 so since with linked lists adding an element to the beginning is most efficient and that's what conj does

1:02 Turtl3boi: i think it stands for 'conjure' because this shit is magic

1:02 Scriptor: Turtl3boi: think about it this way, when you do (conj '(3 4) 2) you're adding 2 to the beginning of the list

1:02 which creates a new list of '(2 3 4)

1:03 Turtl3boi: so it evaluates from left to right

1:03 i mean L to R is the order of operations

1:03 so it sees the '2' first

1:03 adds that to the front of the list

1:03 and then it sees the '1' after that and adds it to the front

1:03 so you're left with (list 1 2 3 4)

1:04 Scriptor: basically

1:04 Turtl3boi: this isn't that hard

1:04 amalloy: yes, although that's not some fundamental property of arguments or of lists; it's just how conj (specifically) is defined to behave

1:05 Turtl3boi: because a list is a linked list

1:05 Scriptor: yes

1:05 Turtl3boi: in other types of collections it may add to the rearend

1:05 Scriptor: right

1:05 Turtl3boi: whatever i'll figure it out

1:05 Scriptor: such as vectors

1:07 Turtl3boi: i'm lost on #6 already lol

1:07 &(+ 5 6 11 0)

1:07 lazybot: ⇒ 22

1:07 amalloy: Turtl3boi: hey, that's one problem out of six that you haven't been stuck on!

1:07 Turtl3boi: hmm

1:08 lol

1:11 &(vec (range 10))

1:11 lazybot: ⇒ [0 1 2 3 4 5 6 7 8 9]

1:13 Turtl3boi: what's the difference between "vec" and "vector"

1:13 &(vec '(:a :b :c))

1:13 lazybot: ⇒ [:a :b :c]

1:13 Turtl3boi: &(vector '(:a :b :c))

1:13 lazybot: ⇒ [(:a :b :c)]

1:13 Turtl3boi: wtf

1:13 this is whack

1:14 amalloy: au contraire, this is epic

1:17 Scriptor: Turtl3boi: behold

1:17 &(vec 1 2 3)

1:17 lazybot: clojure.lang.ArityException: Wrong number of args (3) passed to: core$vec

1:17 Scriptor: fuck you lazybot

1:17 Turtl3boi: vec must be an operator which takes a list

1:17 Scriptor: &(vec '(1 2 3))

1:17 lazybot: ⇒ [1 2 3]

1:17 Scriptor: &(vector 1 2 3)

1:17 lazybot: ⇒ [1 2 3]

1:18 Scriptor: Turtl3boi: yep

1:18 Turtl3boi: vec takes a list and converts it to a vector?

1:18 and only takes lists as arguments

1:18 amcnamara: Turtl3boi: vec is used to turn a collection into a vector, vector is used to turn a bunch of arguments into a new vector

1:18 Turtl3boi: &(vec '(1 2 3) 1)

1:18 lazybot: clojure.lang.ArityException: Wrong number of args (2) passed to: core$vec

1:18 Scriptor: Turtl3boi: a list, or anything that supports a similar collection interface

1:18 Turtl3boi: interesting

1:18 Scriptor: http://clojuredocs.org/clojure_core/clojure.core/vec

1:18 clojuredocs.org is a good way to look up functions

1:20 Turtl3boi: so nil evaluates to [] but not the other way around

1:20 Vinzent: ,(seq [])

1:20 clojurebot: nil

1:25 amalloy: Turtl3boi: nil always evaluates to nil, and [] always evaluates to []. in some contexts the two may be treated the same, but it's separate from the evaluation process

1:26 Turtl3boi: k

1:26 anyways this is pedantry

1:29 Scriptor: Turtl3boi: it just depends on what function you're using, so always good to read the docs

1:29 they do follow general rules though, so eventually you'll get used to it

1:32 Turtl3boi: this is kind of like matlab

1:32 well maybe not

1:32 Scriptor: which problem are you on now?

1:50 Turtl3boi: i'm on # 8 now

2:01 Vinzent: Hi, I have some questions about very minor aspects of core functions: arglist for apply is [f a b c d & args] now, and I find it a little confusing, because the docstring says "... prepending intervening arguments to args", but it actually prepends them to the last element of args (that is, to the last argument). In 1.2 arglist was [f args* argseq], and it's perfectly clear (imo). Why was this changed?

2:02 ambrosebs: ,(-> #'apply meta)

2:02 clojurebot: {:ns #<Namespace clojure.core>, :name apply, :arglists ([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]), :added "1.0", :static true, ...}

2:02 ambrosebs: Vinzent: no idea

2:03 ,(-> #'apply meta :arglists)

2:03 clojurebot: ([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...])

2:04 Vinzent: ,(-> #'apply meta :arglists last)

2:04 clojurebot: [f a b c d ...]

2:04 ambrosebs: :D

2:04 ,(-> #'apply meta :arglists last last)

2:04 clojurebot: args

2:04 ambrosebs: fruitless

2:05 amalloy: &(-> #'apply meta :arglists)

2:05 lazybot: ⇒ ([f args] [f x args] [f x y args] [f x y z args] [f a b c d & args])

2:05 ambrosebs: thx lazybot

2:05 amalloy: but presumably it's for performance, like all the other terrible code in core.clj

2:09 Vinzent: perfomance? but arglists used only for documentation purposes, aren't they?

2:10 and second question: let, doseq and other control structures accepts & body as last arg, but for some reason 'for' accepts the single body expression. Shoudn't that be changed?

2:13 Turtl3boi: i'm stuck on # 8 help!

2:15 Vinzent: Turtl3boi, can you provide a link plz?

2:18 amalloy: Vinzent: arglists are, yes, but they're autogenerated by the defn macro (by default). so if you define (apply f args), (apply f a args), etc, for performance, then the arglist will be polluted

2:18 Turtl3boi: http://www.4clojure.com/problem/8

2:18 there you go Vinzent kun

2:23 Vinzent: amalloy, yes, but they can be changed with metadata, and they are changed for most functions and macros in core. So maybe someone just forgot to add it when was changing code, or something like that

2:25 I mean, that has to be reported and fixed, but I'm not sure where exactly I should report such minor defects in docs, etc

2:25 Turtl3boi, #{:a :b :c :d}?

2:26 Turtl3boi: why is there a # out in front

2:27 Scriptor: Turtl3boi: that's the notation for a set

2:27 Vinzent: Turtl3boi, well, alongside with literal syntax for lists (), vectors [] and maps {}, clojure has notation for sets #{}

2:28 Scriptor: collections of unique values, as 4clojure describes them

2:28 Vinzent: and, btw, for regexps also - #""

2:28 Turtl3boi: eeeeeeeeek

2:29 Scriptor: you won't always need it, but at this point 4clojure is just teaching all the different data structures

2:30 Turtl3boi: i still don't get reg expressions after all this time

2:30 they just don't click for me

2:31 Scriptor: that's a whole 'nother can of worms

2:31 Turtl3boi: k let's not go there

2:32 can i say "(set :a :b :c :d)

2:32 Scriptor: &(set :a :b :c :d)

2:32 Turtl3boi: guess not

2:32 lazybot: clojure.lang.ArityException: Wrong number of args (4) passed to: core$set

2:33 amalloy: Turtl3boi: set is like vec

2:33 hash-set is like vector

2:33 Turtl3boi: eeeeeeeeeek

2:33 Scriptor: yep, it takes one collection as an argument and converts it

2:33 Turtl3boi: gotcha

2:34 Scriptor: again, clojuredocs.org for when you need to look something up

2:34 although for some reason searching it from the chrome url bar and it's own search box yield different results

2:34 I want my moneies back

2:47 sritchie: hey, do you guys know why (import 'clojure.lang.BigInt) works with an [org.clojure/clojure "1.2.1"] dependency?

2:47 was that class included retroactively in builds of 1.2.1 and 1.2.0?

2:48 it's odd, I can't see its class file if I look inside the jar

2:49 amalloy: Vinzent: well, jira is pretty much the place to complain about anything, including docs

2:49 &(doc juxt)

2:49 lazybot: ⇒ "([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"

2:49 amalloy: &(doc comp)

2:49 lazybot: ⇒ "([] [f] [f g] [f g h] [f1 f2 f3 & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."

2:49 amalloy: anyway, these cause me to doubt your assertion that "most" things in clojure.core have doctored-to-be-friendly arglist meta

2:50 only the stuff defined before defn is introduced does that, is my recollection; and that's because there's no other choice

2:50 sritchie: oh, never mind, I think leiningen was including some of its own stuff in there

2:56 Vinzent: well, but these arglists are not confusing: you can call juxt with 1, 2 or 3 args, or with whatever number of args you want, but with a small perfomance penalty. On the other hand, arglist and doc for apply don't match the truth

2:58 amalloy: &(doc apply)

2:58 lazybot: ⇒ "([f args] [f x args] [f x y args] [f x y z args] [f a b c d & args]); Applies fn f to the argument list formed by prepending intervening arguments to args."

2:58 amalloy: sounds accurate to me

2:58 &(apply + 1 2 [3 4])

2:58 lazybot: ⇒ 10

2:59 amalloy: here 1 and 2 are the intervening arguments; prepend them to [3 4] to get [1 2 3 4], and then apply + to that

3:01 Vinzent: that means (apply f 1 2 3 4 42) => (f [1 2 3 4 42]) (according to doc!), because & turns 42 into a coll, do I understand it right?

3:02 amalloy: ah

3:03 i agree with your reading of the docstring as it applies to the last arglist. that could use a fix

3:03 Vinzent: oops, I mean (apply f 1 2 3 4 [42]), and then it should be (f [[1 2 3 4 42]])... i think... or something like that

3:03 amalloy: well. i disagree with your fix :P

3:04 Vinzent: why? :) (apply f 1 2 3 4 42) will throw exception, last arg must be a seq

3:05 amalloy: indeed, that's the actual behavior. but as you say, the "args" here seems to mean "the sequence containing the rest of the arguments", rather than "the last argument, which should be a sequence containing more arguments"

3:06 back when the arglist was something like (f args* argseq), then the current docstring was correct: "prepend intervening args onto the argseq" or whatever

3:08 Vinzent: yeah, that's what I mean!

3:11 so anyway, since we came to agreement, can you please report it on jira or something? One should be in a clojure/core to do that, right?

3:12 amalloy: anyone with a CA can file a ticket

3:21 Turtl3boi: thanks Scriptor kun

3:21 i can sleep better now

3:30 Scriptor: Turtl3boi: np

3:33 Turtl3boi: where do you live scriptor

3:34 Scriptor: Turtl3boi: NYC

3:36 you're in cali, right?

3:37 Raynes: i liek tuutles.

3:39 Scriptor: plenty in chinatown

3:42 Turtl3boi: man yeah how did you know

3:42 i wish i lived in NY or boston

3:42 would get a great job

3:44 Scriptor: you mentioned it earlier, I think

3:44 yep, a good number of startups springing up

3:45 Turtl3boi: can i come to NY and we hang out in coffee shop and you tutor me

3:45 really?

3:45 so not just finance related jobs

3:45 Scriptor: oh definitely, there's a good balance of both

3:46 sure, coffee shop, bookstore, wherever

3:46 Turtl3boi: really?

3:46 do u work full time now

3:46 Scriptor: nah, I'm a student

3:47 Turtl3boi: wow nice

3:47 comp sci student at stonybrook?

3:48 Scriptor: nyu

3:49 Turtl3boi: niiice man

3:49 great school

3:50 Scriptor: thanks, what do you do?

3:50 Raynes: Reaches for the 'u' key too often.

3:50 Turtl3boi: what do i do?

3:51 man i'm a loser.....i quit my electronics job because it was too hardware oriented

3:51 now i can't find a job

3:51 i've been rejected so many times

4:23 Blkt: good morning everyone

4:39 zakwilson: I don't suppose anybody's awake and familiar with Korma. I'm trying to construct a query that expands to "not in" but {:foo [not [in bar]]} results in "Wrong number of args (2) passed to: sql$pred-not" when the query is run.

5:11 Vinzent: what's the preferred way to parse and process xml (rss feed) now? clojure.data.xml's readme says that it "it not yet ready for use"

5:13 Raynes: amalloy: How not-ready-for-use is it?

5:14 amalloy: It looks like he added that message because he didn't feel like writing actual documentation at the time.

5:14 amalloy: ugh

5:14 Raynes: So it's hard to tell.

5:14 amalloy: it works fine for basic tasks. nobody wants to make a real release because it can't do Everything You Could Ever Want Even If You Were Insane

5:15 Raynes: Vinzent: Anyways, there is a built in library for parsing XML. http://clojure.github.com/clojure/clojure.xml-api.html

5:18 Vinzent: Raynes, yeah, probably parse + xml-seq will be enough for me this time

5:20 terom: zipfilter.xml in 1.2 contrib is useful (not sure if there's something like it for 1.3)

5:23 zakwilson: Those work well as long as the xml is not large.

5:28 terom: is there anything that parses xml to the format used by prxml/hiccup?

5:36 Vinzent: terom, https://github.com/nathell/clj-tagsoup

5:39 terom: Vinzent: thanks, will look that up

5:40 Vinzent: but it doesn't seem to be maintained

5:51 raek: terom: it is very easy to write a function that translates a tree from one form into the other

5:52 terom: https://gist.github.com/633049

7:36 devinus: can anybody tell me what when-let does?

7:41 raek: ,(macroexpand-1 '(when-let [[x y] (f)] a b c)) ;; :-)

7:41 clojurebot: (clojure.core/let [temp__3698__auto__ (f)] (clojure.core/when temp__3698__auto__ (clojure.core/let [[x y] temp__3698__auto__] a b c)))

7:43 raek: as you can see, it's usable when you want to have a let, but with a condition between the call to (f) and the destructuring to [x y]

7:44 very useful in conjunction with functions like re-matches

7:46 (if-let [[_ x y] (re-matches #"([0-9]+) ([0-9]+)" "123 456")] {:x x, :y y} (throw (Exception. "invalid pair format")))

7:51 devinus: raek: sorry, i'm...confused. i'll have to learn more about before i can even understand the explanation :P

7:52 raek: i understand creating functions, lists/maps/vectors and let right now :P

7:52 then they throw out when-let

7:52 and of course i'm assuming it's combining a when and a let expr

7:52 but it's still confusing

7:53 ambrosebs: (when [a 1] ...) is (let [a 1] (when a ...))

7:53 sorry (when-let [a 1] ...)(

7:54 raek: (when-let [x y] ...) is (let [z x] (when z (let [x z] ...)))

7:55 devinus: ok that makes sense now

7:55 thank you

8:02 what exactly is (seq [1 2 3]) doing?

8:03 clgv: devinus: building a seq from that vector

8:03 &(seq [1 2 3])

8:03 lazybot: ⇒ (1 2 3)

8:03 raek: it gives you a sequence of the values in the vector (many functions do this implicitly)

8:04 clgv: more interesting: ##(seq {:a 1 :b 2})

8:04 lazybot: ⇒ ([:a 1] [:b 2])

8:04 raek: devinus: also, seq on an empty collection returns nil

8:05 so you can use it to check if the collection is empty by passing the return value of seq to if or when

8:18 devinus: ok, that makes sense, but what *is* a seq?

8:19 and why can i do:

8:19 &(seq [1 2 3])

8:19 lazybot: ⇒ (1 2 3)

8:19 devinus: &(1 2 3)

8:19 lazybot: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

8:19 devinus: why isn't that allowed? because of funcall syntax?

8:21 raek: devinus: yes. sequences does not have a literal syntax.

8:21 but it is ideomatic to use a vector as a sequence literal

8:21 since vectors are seqable

8:22 devinus: i see

8:22 so a seq is just an instance of ISeq?

8:22 raek: yes

8:22 devinus: basically just a linked list?

8:22 i use that term lightly

8:22 "linked list"

8:22 raek: yes. most oftenly a lazilly realized linked list

8:23 devinus: ok, coming together now

8:23 raek: you can think of sequences as functional programming's version of iterators

8:49 devinus: i'm trying to get syntax highlighting in slime

8:49 tried: (add-hook 'slime-repl-mode-hook 'clojure-mode-font-lock-setup)

8:50 added to my .emacs

8:50 but it's not highlighting, anybody know what the problem could be?

9:00 TimMc: devinus: seq is an abstraction -- you can't inspect an object and reliably tell if it is behaving as part of that abstraction, but you *can* coerce into that abstraction (in this case, by calling `seq`.)

9:04 AWizzArd: When I specify [some.lib/foo "[1.0.7,)"] then I guess it would prefer 1.0.13 over 1.0.9, if both are available. But would it also prefer 1.4.0 over 1.0.7?

9:06 kotarak: AWizzArd: wild guess: it should. Unless something else says something like [some.lib/foo "[1.0,1.2)"]. But I was surprised about this behaviour more than once...

9:11 TimMc: AWizzArd: Open-ended ranges do weird stuff soemtimes.

9:11 I did [1.2.0,1.4.0) and was startled to get 1.4.0-SNAPSHOT.

9:18 jeremyheiler: AWizzArd: Yes, it does prefer all versions greater than 1.0.7. If you want to to limit your range to an upper version, you need to specify that version, and whether or not to include it.

9:19 *greator than or equal to 1.0.7

9:33 AWizzArd: okay, thanks for your various inputs

12:10 juhu_chapa: Hi comrades, by the clojure nature is there an area where the problems solved with clojure are faster than a %100 java solution?

12:12 clgv: juhu_chapa: I guess thats only possible if the java program is written poorly

12:12 both java and clojure "cant be faster than the jvm"

12:13 so you could ask for almost equal performance

12:13 joly: If you include coding time, solving problems with clojure can be faster than solving them in Java.

12:13 clgv: joly: lol yeah. I thought he meant runtime ;)

12:13 juhu_chapa: clgv: so the real neat writing in clojure is beautiful code that is easier to read?

12:14 _briggs_: juhu_chapa: and safer.

12:14 STM.

12:15 dnolen: juhu_chapa: you're not going to get faster than what the JVM is capable of. But it's also possible to write high performance code that is as fast as Java if you need that.

12:15 clgv: juhu_chapa:it's entirely different code from java. I think it's often more expressive due to macros.

12:15 juhu_chapa: i see.

12:16 dnolen: juhu_chapa: no the *real* neat writing in clojure is the ability to write code that you drive you bonkers in Java and 10X more work on your part.

12:16 hiredman: ~rationale

12:16 clojurebot: rationale is http://clojure.org/rationale

12:18 juhu_chapa: thx

12:26 features like inmutability promote faster code than java code?

12:29 mdeboard: simplicity uber alles

12:29 joly: Don't need to make defensive copies in case data changes. Can share copies safely, reducing memory costs. Don't need to synchronize over them.

12:30 Easier to reason about.

12:30 etc

12:31 juhu_chapa: interesting!

12:31 Turtl3boi: can i do i everything i can do in java, in clojure

12:31 like what if i write little stupid GUIs with Swing

12:32 joly: can't think of the names, but there are Swing wrappers for Clojure

12:32 Turtl3boi: i take it nobody really does that though?

12:32 cemerick: http://spin.atomicobject.com/2011/12/14/clojure-desktop-applications-with-swing/

12:32 mdeboard: real men write GUIs in Fortran

12:33 joly: cemerick: thanks, I knew I'd just seen an article on that topic go by my reader

12:33 cemerick: "clarity" is the name of the newer swing framework IIRC.

12:34 Turtl3boi: can someone write a little GUI real quick for me to prove it can be done, and send me the compiled code

12:34 cemerick: Turtl3boi: There's about 86 different Clojure Swing tutorials and demo apps floating around the web…

12:34 mdeboard: Turtl3boi: lol

12:34 Turtl3boi: oh c'mon

12:34 i figured you guys already had something

12:34 joly: quick google check: http://clojure.org/jvm_hosted

12:35 cemerick: Turtl3boi: such things are what google is for

12:35 mdeboard: Yeah hey while we're putting out requests, can someone give me an example of a fix to this problem we're having on our site

12:35 Turtl3boi: so none ofyou have written a GUI in Clojure

12:35 jamiltron: https://github.com/daveray/seesaw

12:35 mdeboard: Oh he was serious

12:35 jamiltron: Turtl3boi: I have, but to be honest your request is a little ridiculous

12:35 cemerick: Turtl3boi: written many, deployed many, but I doubt people are going to whip up examples on demand.

12:36 Turtl3boi: why is it ridiculous? it would help me learn honestly

12:36 darnit! !

12:36 joly: check the link I posted. It has a small Swing app

12:36 Turtl3boi: i didn't say you had to whip up an example

12:36 thx joly

12:36 i'll try it now now ;)

12:36 joly: would likely be cleaner using one of the mentioned libraries

12:36 Turtl3boi: grrrrrrrrrrrrrrrrrrrrrrrrrrrr

12:37 mdeboard: 12:34 <Turtl3boi> can someone write a little GUI real quick for me to prove it can be done, and send me the compiled code <-- saving that

12:37 jamiltron: Turtl3boi: Go to https://github.com/daveray/seesaw and follow the TL;DR example

12:39 blakesmith: Turtl3boi: People like to help, but usually they like to see that you've tried to help yourself first.

12:39 Turtl3boi: sorry i don't even have Clojure installed yet

12:39 help me with that

12:40 mainly i just want to see certain things can be done in a language before i go too far with it

12:40 Clojure seems like the first language that can truly do it all

12:40 blakesmith: Again, help yourself... Google is your friend.

12:40 mdeboard: Turtl3boi: Here you go https://github.com/technomancy/leiningen

12:40 jamiltron: Turtl3boi: Download leiningen - https://raw.github.com/technomancy/leiningen/stable/bin/lein

12:40 mdeboard: Turtl3boi: Follow the instructions there and you'll be set for the most part. Good luck :)

12:41 Turtl3boi: thank you to all you non haters

12:41 jamiltron: mdeboard: Even though I think I'd suggest googling most Clojure topics, installation isn't one of them I'd trust.

12:41 cemerick: Clojure can't do it all, but it's pretty nifty.

12:41 mdeboard: jamiltron: That's why I didn't suggest googling it :P

12:41 jamiltron: mdeboard: Oh right you linked to lein, like I did :P

12:42 mdeboard: Sorry, my mistake. I must have gotten the conversation mixed up.

12:42 mdeboard: s'ok

12:42 Turtl3boi: does leiningen assume i already have JAVA SE 6 installed

12:44 jamiltron: Umm, honestly I don't know.

12:44 I mean - you need a version of Java installed just to run Clojure

12:45 Turtl3boi: right

12:51 mdeboard: Yeah it doesn't assume anything

12:52 but java is a requirement :P

13:21 Apage43: :w

13:21 gah!

13:22 sirn: ,(apply hash-map (flatten (map #(vector (:name %) (:price %)) [{:name :apple :price 10} {:name :orange :price 15} {:name :apple :price 30}])))

13:22 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: :apple>

13:23 sirn: anyway to make hash-map ignore duplicate key in a case like this?

13:23 (or is there a better way to do this?)

13:27 technomancy: sirn: (zipmap (map :name fruit-vec) (map :price fruit-vec))

13:28 assuming I've deciphered your snippet correctly

13:29 sirn: technomancy: thanks, that solved the duplicate problem!

13:32 technomancy: and also the "making it more complicated than it needed to be" problem. =)

13:33 sirn: that one too :)

13:47 TimMc: Cgrand hasn't responded to my email about whether he'd like to see a certain feature added to enlive. Should I just send a pull request, or what?

13:48 I don't know the etiquette here.

13:48 amalloy: send a pull request. 0-line diff, with a comment: "FFFFFUUUUUUUUUUU, I'm forking this project and everyone will use miiiiine!"

13:50 srsly though a pull request is reasonable if you already have the patch. i wouldn't even bother to have emailed him first, just send a pull request

13:50 TimMc: I didn't have a patch when I sent the email.

14:08 Oh hey, and my patch was broken! I was relying on binding when using lazy seqs. >_<

14:09 with-redefs is the appropriate thing, then?

14:09 amalloy: *shudder*

14:09 raek: TimMc: for tests, yes

14:09 TimMc: It is in a test, yeah.

14:10 raek: at runtime in production code = madness

14:10 TimMc: ...but the test is supposed to mimic actual usage, so I shouldn't use that.

14:10 amalloy: TimMc: i don't see how with-redefs would fix a case in which binding is broken, unless the var isn't declared dynamic. it shouldn't fix laziness issues at all

14:11 TimMc: Urgh, right -- the problem is that thread-local is the wrong approach entirely.

14:27 klutometis: ,(cons "foo" "bar")

14:27 clojurebot: ("foo" \b \a \r)

14:28 klutometis: I vaguely understand why that's the case (strings as seqs, &c.); it's still surprising behavior, though.

14:28 In Scheme, (cons "foo" "bar") => ("foo" . "bar")

14:29 amalloy: clojure ain't got dotted pairs

14:29 klutometis: Ah.

14:29 amalloy: &(cons 1 2)

14:29 lazybot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long

14:48 Turtl3boi: what does 'cons' do

14:50 dnolen: Turtl3boi: in Scheme it creates a fundamental data structure - a linked list. In Clojure it adds something to a valid sequence.

14:50 Raynes: &(cons 0 '(1 2))

14:50 lazybot: ⇒ (0 1 2)

14:50 duck1123: it's similar to conj

14:51 Raynes: dnolen: Man.

14:51 dnolen: Just say "It shoves something onto the front."

14:51 Turtl3boi: ,(cons #{1 2} 3)

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

14:51 dnolen: Raynes: heh.

14:51 Turtl3boi: wtf why didn't that work

14:51 dnolen: Turtl3boi: is 3 a valid sequence?

14:52 ,(type 3)

14:52 clojurebot: java.lang.Long

14:52 Turtl3boi: is zer a valid sequence?

14:52 dnolen: ,(seq? 3)

14:52 clojurebot: false

14:52 Turtl3boi: zero

14:52 dnolen: ,(seq? ())

14:52 clojurebot: true

14:52 dnolen: ,(seq? nil)

14:52 clojurebot: false

14:52 TimMc: Turtl3boi: Pay attention to the order of the arguments!

14:52 Turtl3boi: ,(seq? 0)

14:52 clojurebot: false

14:52 dnolen: Turtl3boi: basically a you can cons onto a sequence or nil.

14:53 TimMc: &(doc cons)

14:53 lazybot: ⇒ "([x seq]); Returns a new seq where x is the first element and seq is the rest."

14:53 Turtl3boi: ,(cons 0 #{1 2})

14:53 clojurebot: (0 1 2)

14:53 Turtl3boi: why does the order of operations matter

14:53 TimMc: ....

14:53 Raynes: Because...

14:53 Turtl3boi: so the 'cons' operation takes a number as the first argument

14:53 TimMc: Turtl3boi: How could it ever be otherwise?

14:53 Turtl3boi: and a collection as the second

14:54 this is getting hard Timothy

14:54 TimMc: How would cons know which you wanted to cons *onto*?

14:55 Turtl3boi: i'm just wondering why zero works

14:55 ,(cons 1 '(2 3))

14:55 clojurebot: (1 2 3)

14:55 Raynes: It doesn't.

14:56 Turtl3boi: ugh this is confusing

14:56 &(cons '(1 2) '(3 4))

14:56 lazybot: ⇒ ((1 2) 3 4)

14:56 Turtl3boi: what in gods name

14:56 &(cons 1 2 '(3 4))

14:56 lazybot: clojure.lang.ArityException: Wrong number of args (3) passed to: core$cons

14:56 Turtl3boi: lord

14:56 duck1123: cons is a little odd in it's order of arguments (for historical reasons)

14:57 Turtl3boi: see Tim

14:57 i was onto something

14:57 duck1123: cons just takes the first argument, and shoves it into the second

14:57 Raynes: It really isn't any more complex than that.

14:57 Takes x and shoves it onto (y).

14:58 hiredman: cons does exactly what its docstring says it does

15:05 Turtl3boi: how come it can't take several arguments and shove them into the last

15:05 like (cons 1 2 3 '(4 5 6))

15:05 TimMc: I think conj can do that.

15:06 and list*, which actually makes a seq (bad name)

15:06 Raynes: It is a little more complicated for cons, given the order of argument.s

15:06 TimMc: &(cons 1 (list* 2 3 4 '(5 6 7)))

15:06 lazybot: ⇒ (1 2 3 4 5 6 7)

15:07 Turtl3boi: &(conj '(3 4) 1 2)

15:07 lazybot: ⇒ (2 1 3 4)

15:08 Turtl3boi: i can do do multiple arguments with conj

15:08 it seems odd i can't do the same with cons

15:08 TimMc: Yep, and conj is what you'll use most of the time.

15:08 Turtl3boi: k thanks

15:08 amalloy: Turtl3boi: list* is a "version" of cons that allows extra args

15:08 TimMc: conj is for collections in general, cons is specifically for seqs

15:09 amalloy: well! i see that's been recommended three or four times already

15:09 TimMc: we're on it

15:09 Turtl3boi: so just use CONJ

15:09 amalloy: TimMc: specifically conses :P

15:09 Turtl3boi: i'm gonna try and forget cons even exists

15:10 TimMc: Yeah, until you need to *build* seqs, that's fine.

15:11 jcrossley3: i just now realized how leiningen got its name

15:11 * jcrossley3 is slow

15:11 Turtl3boi: how did leiningen get it's name

15:11 what's a sequence again

15:11 amalloy: technomancy named it, dude

15:11 Turtl3boi: with the curly braces

15:13 A seq is any object that implements the seq API, thereby supporting the functions first and rest. You might consider it an immutable variant of an enumerator or iterator.

15:13 &(seq? #{1 2})

15:13 lazybot: ⇒ false

15:14 Turtl3boi: &(seq? '(1 2 3))

15:14 lazybot: ⇒ true

15:14 Turtl3boi: hmm so a set is not a sequence

15:14 Scriptor: nope

15:14 because mathematically, sets have no order

15:14 seqs do

15:14 TimMc: Turtl3boi: You can *acquire* a seq over a set.

15:15 `seq` says "get me a sequence backed by this thing"

15:15 The seq will be ordered, but the order will be arbitrary for seqs over maps and sets.

15:16 Turtl3boi: im lost again

15:16 what doth it mean to acquire

15:17 Tim can i call you

15:17 Scriptor: you can make a seq out of things that aren't sequences, such as maps and sets

15:17 Turtl3boi: hmm

15:17 Scriptor: but like TimMc said, the order of the resulting seq wlll be arbitrary

15:17 Turtl3boi: is a sequence ordered?

15:18 TimMc: as ordered as an onion

15:18 Turtl3boi: lol is an onion ordered ?

15:19 TimMc: from the outside in

15:24 lobotomy: is it normal that there are things like (reduce #(merge-with concat %1 {(second %2) [(first %2)]}) {} fbfs) in my code?

15:24 there's probably a more elegant way to do that but um

15:25 TimMc: lobotomy: That anonymous function could maybe stand to be a defn.

15:26 I think that's best advice I can give for that out-of-context snippet.

15:28 lobotomy: basically i have a list of [thing key], and i want to get a map of {key [thing1 thing2]}, where each thing is a map

15:33 TimMc: Maybe a for.

15:48 Bronsa: ,(for [[k v] (group-by second '([a :a] [b :a] [c :b]))] [k (map first v)])

15:48 clojurebot: ([:a (a b)] [:b (c)])

15:49 Bronsa: ,(into {} (for [[k v] (group-by second '([a :a] [b :a] [c :b]))] [k (vec (map first v))]))

15:49 clojurebot: {:a [a b], :b [c]}

15:49 Bronsa: lobotomy: ^

15:53 TimMc: lobotomy: So, [[{:a1 :a2} :ak] [{:b1 :b2} :bk]] goes to {:ak [:a1 :a2], :bk [:b1 :b2]} ?

15:57 lobotomy: ooh, group-by is exactly what i needed here, cheers

15:58 TimMc: lobotomy: I think I misunderstood your question.

16:11 Somelauw: For merging lists, use concat and for maps use merge. I don't really see a use for into.

16:12 Raynes: &(into {} [[1 2] [3 4]])

16:12 lazybot: ⇒ {1 2, 3 4}

16:12 Somelauw: Also if I want to add to the right of a random sequence, I just use (concat seq [x]).

16:13 Raynes: That is just not a good idea.

16:13 raek: Somelauw: you can use into to add multiple elements to a vector, queue, or stack

16:14 (lists and vectors can be used as stacks)

16:14 Raynes: Somelauw: into is useful in a couple of cases. In particular, if you have some specific collection like a vector and want to add the elements of some other collection, you need into.

16:15 ##(into [1 2] [3 4]) vs ##(concat [1 2] [3 4])

16:15 lazybot: (into [1 2] [3 4]) ⇒ [1 2 3 4]

16:15 (concat [1 2] [3 4]) ⇒ (1 2 3 4)

16:16 Raynes: cmeier: Howdy.

16:16 cmeier: Hey man

16:18 aaelony: I have a function that will print database results, how can I change it to return the results instead of printing them? http://pastie.org/3017678

16:18 Somelauw: Raynes: then what should I use when merging 2 vectors?

16:19 Raynes: Somelauw: Define 'merge'.

16:19 Somelauw: So concat if you need more than 2 items and into when the types are different?

16:19 raek: aaelony: (doall rs)

16:19 aaelony: raek: thanks, I'll try that. I must have tried 10 things already.

16:19 Somelauw: Somelauw: the thing concat and into both seem to do.

16:20 Raynes: into is necessary when you want to retain types.

16:20 concat will always return a seq.

16:20 Sometimes you don't want a seq.

16:20 aaelony: raek: many thanks!

16:22 Somelauw: ok

16:28 raek: Somelauw: one way to think of it is that a sequence is a sequential walk through a set of data.

16:28 (seq x) means walk though x. (concat (seq x) (seq y)) means walk through x and then y.

16:28 (but most function, including concat, will call seq for you as a convenience)

16:28 (into x y) mean augment the x data structure with some additional elements.

16:28 a vector can do more things than a seq, for example random access and updates.

16:31 there is also a cost associated with nesting sequence returning expression. for each level in a (concat (concat (concat (concat [0] [1]) [2]) [3]) [4])-like expression, one stack frame is needed when the seq is finally walked through

16:31 so if you nest them to deep you can blow the stack

16:32 this is why (concat coll [element]) is not exactly just like adding something to the end of a collection

16:32 Somelauw: So concat doesn't actually create a single vector in memory.

16:33 raek: nope

16:33 Somelauw: okay, that is cool

16:33 raek: it creates something that has a sequence of references to sequences

16:34 TimMc: &(into [1 2] [3] [4] [5])

16:34 lazybot: clojure.lang.ArityException: Wrong number of args (4) passed to: core$into

16:34 raek: ,(recude into [1 2] [3] [4] [5])

16:34 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: recude in this context, compiling:(NO_SOURCE_PATH:0)>

16:34 raek: eh

16:34 ,(reduce into [1 2] [3] [4] [5])

16:34 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (5) passed to: core$reduce>

16:35 raek: ,(reduce into [1 2] [[3] [4] [5]])

16:35 clojurebot: [1 2 3 4 5]

16:35 TimMc: interesting

16:35 Somelauw: thanks, now I understand

16:35 TimMc: Gotta work on my HOF skills.

16:35 raek: also, (into coll elements) can be defined as (reduce conj coll elements)

16:36 Bronsa: raek: that is exactly how it is defined in clojure.core indeed

16:36 dnolen: Bronsa: raek: into uses transients

16:36 brehaut: its not exactly how its defined

16:36 TimMc: along with some speedups for IEditableCollection

16:37 Bronsa: dnolen: yes but that's a speedup detail

16:37 brehaut: Bronsa: but 'exactly' has quite precise meaning

16:37 Bronsa: i shouldn't have used 'exactly' then

16:37 right

16:38 raek: hence my "can be"... :-)

16:38 TimMc: I think a middle ground of "basically" is correct.

16:40 gtrak`: ,(seq #{1 2 3})

16:40 clojurebot: (1 2 3)

16:40 gtrak`: Turtl3boi, ^^

16:47 Squee-D: antares_ my friend. Alll your help payed off and we have a really solid EM / AMQP app now.

17:07 sritchie: Raynes, I have an interesting little puzzle for you

17:16 Raynes: sritchie: OKay.

17:17 sritchie: stuart sierra's clojure.tools.namespace seems to break on the moustache format of the templates in lein-newnew

17:17 (ns {{name}}.core), for example

17:17 (I'm realizing this probably needs to be address in clojure.tools.logging)

17:17 err, namespace

17:18 Raynes: It definitely needs to be fixed in c.t.namespace.

17:18 Not much I can do about it.

17:18 Certainly not going to switch to a new template engine.

17:18 sritchie: by the time you'd answered, it was less of an interesting puzzle and more of a boring routine ticket :-/

17:19 haha, yeah, I know

17:19 Raynes: Heh.

17:19 sritchie: If you submit the ticket, I'll see about patching it later tonight.

17:21 Unless you do it.

17:21 sritchie: awesome, thanks

17:21 I have my CA now

17:21 but I'm still a jira virgin

17:21 Raynes: I've had a CA for forever but I haven't actually done anything with it.

17:22 sritchie: Raynes: I'll submit a patch, anyway

17:22 Raynes: I'm not sure its valid though. I signed my name as Simpson...

17:22 I need to talk to Stu about that.

17:22 TimMc: I want to help improve Clojure documentation, but I don't know how to go about it.

17:22 sritchie: I just put lipstick on and spent about an hour with it

17:23 Raynes: "New in Confluence 4.0! We still suck!"

17:23 TimMc: And I just read on the mailing list that Clojure/Core is maybe resistant to expanding the docstrings in core.clj because of artifact size? :-/

17:24 Raynes: Haha

17:24 The should totally separate the code from the docstrings and have an add-on artifact that adds them to the metadata of everything in clojure.core.

17:24 TimMc: ...which seems really kind of terrible and backwards.

17:25 sritchie: Raynes: it's actually a bug in clojure.core

17:25 (read (PushbackReader. (BufferedReader. (FileReader. example-file)))) fails if example-file contains (ns {{name}}.core)

17:26 TimMc: I guess a decent system would split the docstrings off of clojure.core during compilation and put them into a separate package, clojure.doc.

17:26 Raynes: sritchie: Well that is kind of understandable.

17:27 TimMc: &(read-string "(ns {{name}}.core)")

17:27 lazybot: java.lang.RuntimeException: Map literal must contain an even number of forms

17:27 sritchie: Raynes, yeah, it's true, it IS invalid lisp… I suppose the proper behavior would be to skip a namespace that throws an error like this

17:27 Raynes: How do you read a map with a key and no value?

17:28 I mean, that'd be a valid reason to use a different template system, but I don't know if any that is also value lisp.

17:28 valid*

17:28 technomancy: sritchie: the fun part is that in clojure 1.2, that doesn't actually throw an exception until you try to get a value out of the map.

17:28 Raynes: technomancy: Yeah, I noticed that a while back.

17:28 technomancy: it's been fixed, but that was a fun one to track down

17:28 Raynes: Mustache is also a really good template system, so I'd have to be pretty convinced to change it.

17:29 technomancy: one of the few things that actually got me befuddled enough to pull out the debugger

17:29 Raynes: But you're right, it should catch exceptions like that.

17:29 sritchie: clojure.tools.namespace can just skip on an exception, I suppose

17:29 technomancy: nice

17:30 TimMc: technomancy: What sort of debugger?

17:30 technomancy: TimMc: swank-cdt

17:30 * TimMc files that away

17:33 sritchie: technomancy: this is probably the issue you're talking about -- I can't catch an exception on read, since it only shows up when I try to actually print out that bad namespace

17:34 technomancy: sritchie: https://github.com/technomancy/leiningen/commit/7dc1b034ee

17:34 ^^ my workaround

17:37 sritchie: nice, thanks

17:50 technomancy: so I wrote a little tool to allow deploying from leiningen to private repositories on s3: https://github.com/technomancy/s3-wagon-private

17:50 had a lot of questions about what to do with private jars; this should make it a lot easier to handle them without having to set up an archiva instance

17:51 anyone want to try it out before I make a wider announcement?

17:51 sritchie: technomancy, Raynes: patched -- http://dev.clojure.org/jira/browse/TNS-1

17:52 technomancy: hm... I wonder if they'll bite considering the underlying bug is fixed in Clojure

17:53 sritchie: technomancy: not with 1.2, though, right?

17:53 technomancy: right

17:53 sritchie: they may enjoy another reason to force folks onward

17:53 which I'm okay with

17:54 technomancy: well leiningen _is_ switched over on master. it's just that it won't be released for a long time yet.

17:55 sritchie: this popped up for me on pallet

17:55 which I think still needs 1.2

18:12 technomancy: could someone with a facebook account tell me if it's possible to download blip.tv videos if you log in with your facebook account?

18:13 I'm wondering if they've disabled downloads entirely, or just limited them to facebook logins.

18:41 chessguy: can someone help me understand this output? it looks like a 4-element list? https://gist.github.com/1479137

18:42 amalloy: compare for/doseq

18:43 it's a two-element list: (nil nil); but you printed some other stuff while the repl was in the middle of showing it to you

18:45 chessguy: aha

18:45 that makes sense, thanks amalloy

18:46 amalloy: btw, gist has a Clojure mode; you don't have to use Common Lisp

18:47 chessguy: so it does. i looked for it last time and missed it, my bad

18:48 you are a wealth of information :)

19:22 i'm using this pattern a lot. is there something i should prefer? https://gist.github.com/1479246

19:25 amalloy: mostly i think that depends whether you actually plan to use the 2-arg version of f externally, or if it's only used by the 1-arg version

19:26 chessguy: interesting

19:52 Raynes: TimMc: TIM!

19:57 TimMc: Raynes: ANTHONY!

19:58 Raynes: TimMc: Are you doing a trycljs?

19:58 TimMc: im in ur github stealin' ur repl

19:58 Raynes: How do you plan to sandbox cljs code?

19:58 TimMc: Raynes: Yeah, there's a group here that's gonna hack it apart and build it back up.

19:58 Raynes: Browser.

19:58 Raynes: The README says it will evaluate code on the server side.

19:59 I thought you planned on doing something fancy.

19:59 TimMc: haha, we just haven't modified the README yet

19:59 Raynes: Anyways, I hope we can collaborate on things. If you guys do anything that'd be useful in tryclj as well, be sure to attack me with it.

19:59 Turtl3boi: can i do a newbie project with you TimMc

20:00 like you give me a project to do and we do it together and i ask questions

20:16 devn: ,(macroexpand-1 '(my-fn ~(list var-a) ~var-b)))

20:16 clojurebot: (my-fn (clojure.core/unquote (list var-a)) (clojure.core/unquote var-b))

20:17 amalloy: devn: the macroexpand is a no-op there

20:17 devn: amalloy: Yeah, I could use your help if you have a second.

20:18 amalloy: okay...?

20:18 devn: (defmacro foo-parse [p s] `(run ~(list p) ~s)))

20:18 amalloy: that's the same as `(run (~p) ~s)

20:19 devn: beautiful, i was feeling like list was superfluous

20:19 thanks

20:19 (inc amalloy

20:19 (inc amalloy)

20:20 ,(inc amalloy)

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

20:24 arohner: if I use clojure.java.shell, is there any safe way to stop a long-running process?

20:25 chessguy: ugh, i am so confused by these namespaces

20:26 amalloy: arohner: yank the power-cord out. safe to say that would stop it

20:26 chessguy: cuz they're confusing

20:27 chessguy: can someone help me understand why "lein test" is giving me a stack trace on my project? https://github.com/arwagner/bps-clojure

20:27 Scriptor: >(ns confusing.core)

20:27 s/>/&

20:27 chessguy: it complains "Could not locate building_problem_solvers/test/examples__init.class or building_problem_solvers/test/examples.clj on classpath:"

20:28 amalloy: your source files need namespace declarations

20:29 as i understand it that's a lot like needing to (provide 'foo) somewhere in, say, elisp

20:29 chessguy: amalloy: ok, by why this particular error?

20:29 like, what line is causing the error?

20:30 sritchie: (:use [building_problem_solvers.unify]); that ns doesn't exist

20:30 oh, that one does :)

20:31 amalloy: line one of test/unify

20:31 probably? i dunno

20:31 devn: the more I use it the more I love it: midje

20:31 chessguy: amalloy: but that's declaring a namespace

20:31 amalloy: it's also declaring a dependency on another namespace

20:31 said namespace cannot be found, so boom

20:33 chessguy: amalloy: but that one is found

20:34 amalloy: the namespace it's complaining about is declared on line 1 of treex1.clj

20:35 but that one doesn't depend on any other namespace

20:38 Turtl3boi: what's a 'predicate'?

20:39 chessguy: Turtl3boi: typically, a function which returns true or false

20:40 Turtl3boi: haha JoC assumes I already knew this

20:41 amalloy: $dict predicate

20:41 lazybot: amalloy: verb-transitive: To base or establish (a statement or action, for example): I predicated my argument on the facts.

20:41 chessguy: hmm, strange. setting my namespace to be the equivalent of the path of the file seems to have fixed it

20:41 amalloy: okay, not actually the right definition. but seriously, "google, what is the definition of predicate" is not a high bar for JoC

20:42 Turtl3boi: well i did and didn't get a clear answer geez

20:57 devn: Turtl3boi: there are a lot of assumptions, nearly all of them are wrong

20:57 Turtl3boi: yeah i bet

20:57 devn: for instance, you are discovering your assumption that JoC would explain what a predicate is, was flawed

20:58 likewise, JoC didn't explain predicates because they assumed the reader would already know

20:58 Turtl3boi: you gotta assume some prior knowledge

20:58 i had just never known that a predicate was a function which returns a boolean

20:58 devn: Turtl3boi: it's okay to not know stuff, but i think amalloy is right to suggest the "google ceremony"

20:58 Turtl3boi: well i did that too

20:59 then after 4 minutes of search i came here and asked

20:59 Scriptor: googling "predicate function" yields good results

20:59 Turtl3boi: i didn't know it was a function

20:59 so i googled 'predicate comps ci'

20:59 devn: Turtl3boi: did you get an answer that has helped you understand?

20:59 Turtl3boi: yeah

21:00 devn: good :) just checking.

21:00 amalloy: i don't object to your asking, but to "haha JoC assumes I already knew this". i can see now that i may have misread your statement, but i previously read it as "they are foolish for assuming readers know this"

21:00 Scriptor: does JoC assume any clojure knowledge?

21:00 devn: amalloy: nah, I read it the same, but idk, I remember asking in here a couple years ago: "what does foo-bar-p means?"

21:01 s/means/mean

21:01 it wasn't always so obvious

21:02 and especially for programmers of clojure, it is a necessity to understand what a predicate is, even just for reading source, using filter correctly, etc.

21:02 so we take it for granted

21:03 amalloy: have you used the-parsatron at all?

21:03 Turtl3boi: what do you mean it's a necessity to understand what a predicate is?

21:03 amalloy: nope

21:03 Scriptor: Turtl3boi: both predicates themselves and the term is used throughout the whole clojure world

21:04 hiredman: well, all of programming

21:04 Turtl3boi: is this a predicate: &(seq? 1)

21:04 ?

21:04 Scriptor: yes

21:07 amalloy: welllll, seq? is a predicate. the expression (seq? 1) is a boolean value

21:07 licenser: Turtl3boi: I think the simplest way to say it is, a predicate is a function that test for something and returns true or false

21:09 Turtl3boi: thanks that clarifies further

21:43 actual: Has anyone here used Clojure for game development? If so what did you think of the experience?

22:10 aperiodic: my google-fu is failing me; what's the name of the function that re-exports all the symbols from another namespace in the current namespace?

22:14 ah, found it (immigrate)

22:29 TimMc: Raynes: What I'm trying to figure out right now is how to print the results of a CLJS evaluation back out as CLJS.

22:32 wiseen: is there a way to use enviroment variables in Lein extra-classpaths (eg. ["$CLOJURESCRIPT_HOME/src/clj"...])

22:36 licenser: TimMc: how do you mean that?

22:36 so from browser -> server?

22:40 TimMc: licenser: Well, we'll take CLJS input from the browser and compile them on the server into JS, which is then sent back to the browser for evaluation.

22:40 That's the first half of "REPL"...

22:41 licenser: The question is, how can we then take the resulting JS value and represent it as CLJS?

22:43 licenser: you mean like decompile it?

22:44 amalloy: he means call (pr-str) on it so you can show it in the repl

22:45 but seriously TimMc, can't you just take the user's (x y z) code, wrap it like (pr-str (x y z)), and send that to the server as the code to compile

22:45 TimMc: amalloy: Sounds good.

22:45 I guess pr-str would already be there...

22:46 (pr-str (do ...))

22:46 They *should* only put one form, but I'll be nice.

22:46 amalloy: sure

22:47 well actually, you have to be able to parse/read the forms locally anyway

22:47 so you can just wrap each individual form

23:00 TimMc: I do?

23:04 amalloy: TimMc: o/w you can't allow multiline input

23:04 (defn foo [x] ;; don't send to server

23:04 (inc (dec x))) ;; do send to server

23:16 licenser: amalloy TimMc make sure you pass along some kind of ID to guarantee ordered execution

23:17 otherwise: (def x 1)

23:17 (+ x x)

23:17 might lead to errors

23:23 fbru02: hey guys, what's the best strategy to debug java code called by clojure code ?

23:23 amalloy: TimMc: the good news is, calling the clojure reader locally will be easy, because you app will be written in cljs...right...?

23:23 TimMc: heh

23:24 amalloy: Ah, right -- multiline stuff. So I'll need to use the reader on the client side.

23:24 More of the original tryclojure might come in handy than I thought.

23:29 I really know basically nothing about cljs. -.-

23:33 amalloy: that's probably a good reason to use cljs to write a program about cljs

23:34 alexbaranosky: amalloy, exactly :)

Logging service provided by n01se.net