#clojure logs

2011-12-14

00:01dnolenambrosebs: technomancy_: down side of using type hints - doesn't it complicate analysis?
00:02ambrosebsisn't it just metadata?
00:02ambrosebswhat do you mean?
00:02dnolenambrosebs: but you need arg type and return type right?
00:04ambrosebsdnolen: I'm going to explore it a bit :)
00:04ambrosebshaven't tried yet
00:05dnolenambrosebs: other consideration is something consistent for typed data structures.
00:09ambrosebsdnolen: it would be awesome if we didn't have to add custom syntax. Just top level +T annotations and type hints
00:09ambrosebsthe +T annotations are important because they contain type refinement information
00:10ambrosebsi think ;)
00:10ambrosebsas in, i think they're important
00:20Turtl3boijoy of clojure is a hard book for me to read, therefore i did not buy it
00:20Turtl3boiafter all this reading i still didn't understand a lot of the terminology
00:20Turtl3boii spent 5 hours at the store reading it
00:22ScriptorTurtl3boi: alright, quick test
00:22Scriptordo you understand what the map function does?
00:22Turtl3boihold up
00:25Turtl3boimap function? is that different from a map
00:25ScriptorTurtl3boi: yes, very different, unless you look at it mathematically of course
00:25Scriptoranyway
00:25Turtl3boiwell i didn't come across the "map function" yet in my reading
00:26Scriptorit's one of those core functions of functional programming
00:26Scriptoranyway, what do you know of clojure so far?
00:27Turtl3boinothing really
00:27Turtl3boii just read a few bits here and there about what closures are
00:27Turtl3boiand immutability
00:27Turtl3boii decided not to buy the book since it seems confusing and not worth $30, however i do have the e-book
00:29ScriptorTurtl3boi: have a look at http://www.4clojure.com/
00:29Scriptorspecifically start here
00:30Turtl3boiyo, is the problem list like a quiz
00:30Scriptorsorta, you just write in valid clojure code
00:31Turtl3boiwow thanks
00:31ScriptorTurtl3boi: any valid clojure code that could replace the underscore that is
00:31Turtl3boii'm already lost with first one about "true"
00:31Scriptorfor that one
00:31Scriptorjust enter any expression that evaluates to true
00:31Turtl3boi"1" should eval to true
00:32ScriptorTurtl3boi: nope
00:32amalloyproblems #1 and #2 probably stump more users than any other problems on the site :P
00:32Scriptorbecause 1 is a number, which cannot be compared with a boolean
00:32Scriptorthat works in some languages, like python
00:32Scriptorbut not all
00:32Turtl3boihuh
00:32amalloyScriptor: well. it can be compared: it's just never equal
00:32Turtl3boi[1 2 3] = [1 2 3] should eval to true
00:33Scriptor(= [1 2 3] [1 2 3]) will return true, yes
00:33Scriptorbecause vectors, and other sequences, are designed in such a way that equality checks for the sequences' contents
00:33Turtl3boiso (= true true) should eval as well
00:33Turtl3boilet me try it
00:33Scriptoramalloy: damn semantics
00:34Turtl3boiyay it works
00:35Scriptoron to problem #2!
00:35Turtl3boii don't get the second one
00:35Turtl3boibut surprisingly i got it right on my first try
00:35Turtl3boithe answer is 4
00:36Scriptoryep
00:36Turtl3boibut unfortunately i don't get it
00:36Scriptorit's just understanding how lisps do math
00:36Scriptoreverything in lisp
00:36Scriptoris (operator arg1 arg2 ...)
00:36Turtl3boioh now i get it =)
00:37Turtl3boidamn pollish notation
00:37Turtl3boipolski
00:37Scriptorcool, if you're ever unsure, you can open up a private converation with clojurebot and use it as a repl
00:38Scriptoror use http://tryclj.com/
00:39amalloyTurtl3boi: just like instead of: [1 2 3] = [1 2 3] you had to write (= [1 2 3] [1 2 3])
00:39ambrosebsany suggestions for representing primitive array types in typed-clojure? is there a method somewhere like Array(Integer/TYPE)
00:39amalloyScriptor: i like to say it as (operator arg arg arg) because it sounds funny if you say it aloud
00:40Turtl3boifor #3 problem, how come "hello WORLD".toUpperCase() doesn't work
00:41amalloyquoting Scriptor here, Turtl3boi: everything in lisp is (operator arg1 arg2 ...)
00:41dnolenambrosebs: ? you have make-array
00:41Turtl3boilemme try another idea
00:41Turtl3boii solved it
00:41Turtl3boithis is better than sex
00:42Turtl3boinot that i've had sex, but i'd imagine it would be better
00:42amalloyoh man. i wish i could put that on the 4clojure front page
00:42amcnamaraits not.
00:42ambrosebsdnolen: I'm after the actual type of a prim array. ie. [Ljava.lang.Integer
00:42Turtl3boilol
00:42amcnamarabut both are awesome
00:42ambrosebsdnolen: maybe just a string "[Ljava.lang.Integer"
00:43Scriptoramalloy: I always feel like I'll run into someone confused about all the variables having the same name
00:43Scriptoris I say (op arg arg arg)
00:43amalloyScriptor: agreed it's not good pedagogical technique. but i'm this to have fun!
00:44Turtl3boii'm lost on #4
00:44dnolenambrosebs: oh … yeah. like I said syntax for such things might be a plus.
00:45ScriptorTurtl3boi: ah, so now we enter lists
00:45ambrosebsdnolen: right, yes
00:45Scriptorthat problem is just about showing you how to create lists in different ways
00:45Turtl3boiJoC doesn't explain lists very well hahaha
00:45dnolenambrosebs: it's one of less nice things about Clojure. prim arrays being identified by their cryptic JVM string name.
00:45Scriptorkeep in mind that lists aren't the only sequence-y data structure
00:45Scriptorbut anyway
00:46Scriptor'(1 2 3) is a list of 3 elements
00:46Turtl3boiwhat's the apostrophe do?
00:46Scriptorthe reason you need the quote is because otherwise clojure tries to do the (operator arg arg) thing
00:46Turtl3boiahh
00:46Scriptorwhich means that it tries to treat the '1' as a function
00:46Turtl3boiso you're asking to treat it like a list instead of some operations
00:46Scriptorexactly
00:47Turtl3boiis list a keyword?
00:47Turtl3boi'list'
00:47Scriptorit's a function name
00:47Scriptorso (list ... ... ...) is the same as '(... ... ...)
00:47Turtl3boiwhat does the colon do?
00:48Scriptorthe colon signfies something called a keyword
00:48Scriptoryou don't have to worry about that just yet
00:48Scriptorjust rewrite the call to the list function to use the '() notation
00:48amalloyScriptor: augh don't say list is the same as quote
00:48Turtl3boithen the answer is just :a :b :c
00:49Scriptoramalloy: it is for now, dammit!
00:49ScriptorTurtl3boi: but yea, like amalloy says, the quote can almost mean other things
00:49Turtl3boik
00:50Turtl3boiso saying (list :a :b :c) is the same as saying '(:a :b :c)
00:50ScriptorTurtl3boi: in the context of the problem, eys
00:52Turtl3boiso it's conj and pop isntead of push and pop for clojure stacks
00:52Turtl3boiis conj short for 'conjure'?
00:52ScriptorTurtl3boi: conjoin
00:53Turtl3boiahhh ok
00:53Scriptorbut also cons (for construct) was an important lisp function
00:53Scriptorand because of "clo(j|s)ure" a lot of things have the 's' replaced with 'j'
00:54Turtl3boithis is tough hehe
00:56Turtl3boi(conj '(2 3 4) 1) just adds 1 to the list
00:56Turtl3boiso it's now '(2 3 4 1)
00:56Turtl3boiright?
00:56clojurebotflatten |is| rarely the right answer. What if your "base type" is a list
00:57Turtl3boinani clojurebot?
00:57ScriptorTurtl3boi: not quite, with lists conj doesn't append to the end
00:57Turtl3boiThe conj function adds elements to and pop removes elements from the right side of the stack.
00:57Turtl3boithat's what JoC says
00:58Scriptoreach different type of sequence implements conj in a different way
00:58Turtl3boiso it adds to the other side of the list
00:59ScriptorTurtl3boi: do you know how linked lists work?
00:59Turtl3boiyeah i wrote one in C
00:59Turtl3boia singly linked list
00:59Scriptorsweet, so for now you can think of clojure lists as singly linked lists
01:00Scriptorconj is designed to work as optimally as possible depending on what kind of sequence you're using it for
01:00Turtl3boihow come (conj '(3 4) 2 1) doesn't evaluate to (list 2 1 3 4)
01:01ScriptorTurtl3boi: that's because it conjoins 2 to '(3 4), then conjoins 1 to the result of that
01:01Scriptorso since with linked lists adding an element to the beginning is most efficient and that's what conj does
01:02Turtl3boii think it stands for 'conjure' because this shit is magic
01:02ScriptorTurtl3boi: think about it this way, when you do (conj '(3 4) 2) you're adding 2 to the beginning of the list
01:02Scriptorwhich creates a new list of '(2 3 4)
01:03Turtl3boiso it evaluates from left to right
01:03Turtl3boii mean L to R is the order of operations
01:03Turtl3boiso it sees the '2' first
01:03Turtl3boiadds that to the front of the list
01:03Turtl3boiand then it sees the '1' after that and adds it to the front
01:03Turtl3boiso you're left with (list 1 2 3 4)
01:04Scriptorbasically
01:04Turtl3boithis isn't that hard
01:04amalloyyes, although that's not some fundamental property of arguments or of lists; it's just how conj (specifically) is defined to behave
01:05Turtl3boibecause a list is a linked list
01:05Scriptoryes
01:05Turtl3boiin other types of collections it may add to the rearend
01:05Scriptorright
01:05Turtl3boiwhatever i'll figure it out
01:05Scriptorsuch as vectors
01:07Turtl3boii'm lost on #6 already lol
01:07Turtl3boi&(+ 5 6 11 0)
01:07lazybot⇒ 22
01:07amalloyTurtl3boi: hey, that's one problem out of six that you haven't been stuck on!
01:07Turtl3boihmm
01:08Turtl3boilol
01:11Turtl3boi&(vec (range 10))
01:11lazybot⇒ [0 1 2 3 4 5 6 7 8 9]
01:13Turtl3boiwhat's the difference between "vec" and "vector"
01:13Turtl3boi&(vec '(:a :b :c))
01:13lazybot⇒ [:a :b :c]
01:13Turtl3boi&(vector '(:a :b :c))
01:13lazybot⇒ [(:a :b :c)]
01:13Turtl3boiwtf
01:13Turtl3boithis is whack
01:14amalloyau contraire, this is epic
01:17ScriptorTurtl3boi: behold
01:17Scriptor&(vec 1 2 3)
01:17lazybotclojure.lang.ArityException: Wrong number of args (3) passed to: core$vec
01:17Scriptorfuck you lazybot
01:17Turtl3boivec must be an operator which takes a list
01:17Scriptor&(vec '(1 2 3))
01:17lazybot⇒ [1 2 3]
01:17Scriptor&(vector 1 2 3)
01:17lazybot⇒ [1 2 3]
01:18ScriptorTurtl3boi: yep
01:18Turtl3boivec takes a list and converts it to a vector?
01:18Turtl3boiand only takes lists as arguments
01:18amcnamaraTurtl3boi: vec is used to turn a collection into a vector, vector is used to turn a bunch of arguments into a new vector
01:18Turtl3boi&(vec '(1 2 3) 1)
01:18lazybotclojure.lang.ArityException: Wrong number of args (2) passed to: core$vec
01:18ScriptorTurtl3boi: a list, or anything that supports a similar collection interface
01:18Turtl3boiinteresting
01:18Scriptorhttp://clojuredocs.org/clojure_core/clojure.core/vec
01:18Scriptorclojuredocs.org is a good way to look up functions
01:20Turtl3boiso nil evaluates to [] but not the other way around
01:20Vinzent,(seq [])
01:20clojurebotnil
01:25amalloyTurtl3boi: 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
01:26Turtl3boik
01:26Turtl3boianyways this is pedantry
01:29ScriptorTurtl3boi: it just depends on what function you're using, so always good to read the docs
01:29Scriptorthey do follow general rules though, so eventually you'll get used to it
01:32Turtl3boithis is kind of like matlab
01:32Turtl3boiwell maybe not
01:32Scriptorwhich problem are you on now?
01:50Turtl3boii'm on # 8 now
02:01VinzentHi, 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?
02:02ambrosebs,(-> #'apply meta)
02:02clojurebot{: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, ...}
02:02ambrosebsVinzent: no idea
02:03ambrosebs,(-> #'apply meta :arglists)
02:03clojurebot([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...])
02:04Vinzent,(-> #'apply meta :arglists last)
02:04clojurebot[f a b c d ...]
02:04ambrosebs:D
02:04ambrosebs,(-> #'apply meta :arglists last last)
02:04clojurebotargs
02:04ambrosebsfruitless
02:05amalloy&(-> #'apply meta :arglists)
02:05lazybot⇒ ([f args] [f x args] [f x y args] [f x y z args] [f a b c d & args])
02:05ambrosebsthx lazybot
02:05amalloybut presumably it's for performance, like all the other terrible code in core.clj
02:09Vinzentperfomance? but arglists used only for documentation purposes, aren't they?
02:10Vinzentand 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?
02:13Turtl3boii'm stuck on # 8 help!
02:15VinzentTurtl3boi, can you provide a link plz?
02:18amalloyVinzent: 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
02:18Turtl3boihttp://www.4clojure.com/problem/8
02:18Turtl3boithere you go Vinzent kun
02:23Vinzentamalloy, 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
02:25VinzentI mean, that has to be reported and fixed, but I'm not sure where exactly I should report such minor defects in docs, etc
02:25VinzentTurtl3boi, #{:a :b :c :d}?
02:26Turtl3boiwhy is there a # out in front
02:27ScriptorTurtl3boi: that's the notation for a set
02:27VinzentTurtl3boi, well, alongside with literal syntax for lists (), vectors [] and maps {}, clojure has notation for sets #{}
02:28Scriptorcollections of unique values, as 4clojure describes them
02:28Vinzentand, btw, for regexps also - #""
02:28Turtl3boieeeeeeeeek
02:29Scriptoryou won't always need it, but at this point 4clojure is just teaching all the different data structures
02:30Turtl3boii still don't get reg expressions after all this time
02:30Turtl3boithey just don't click for me
02:31Scriptorthat's a whole 'nother can of worms
02:31Turtl3boik let's not go there
02:32Turtl3boican i say "(set :a :b :c :d)
02:32Scriptor&(set :a :b :c :d)
02:32Turtl3boiguess not
02:32lazybotclojure.lang.ArityException: Wrong number of args (4) passed to: core$set
02:33amalloyTurtl3boi: set is like vec
02:33amalloyhash-set is like vector
02:33Turtl3boieeeeeeeeeek
02:33Scriptoryep, it takes one collection as an argument and converts it
02:33Turtl3boigotcha
02:34Scriptoragain, clojuredocs.org for when you need to look something up
02:34Scriptoralthough for some reason searching it from the chrome url bar and it's own search box yield different results
02:34ScriptorI want my moneies back
02:47sritchiehey, do you guys know why (import 'clojure.lang.BigInt) works with an [org.clojure/clojure "1.2.1"] dependency?
02:47sritchiewas that class included retroactively in builds of 1.2.1 and 1.2.0?
02:48sritchieit's odd, I can't see its class file if I look inside the jar
02:49amalloyVinzent: well, jira is pretty much the place to complain about anything, including docs
02:49amalloy&(doc juxt)
02:49lazybot⇒ "([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)]"
02:49amalloy&(doc comp)
02:49lazybot⇒ "([] [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."
02:49amalloyanyway, these cause me to doubt your assertion that "most" things in clojure.core have doctored-to-be-friendly arglist meta
02:50amalloyonly the stuff defined before defn is introduced does that, is my recollection; and that's because there's no other choice
02:50sritchieoh, never mind, I think leiningen was including some of its own stuff in there
02:56Vinzentwell, 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
02:58amalloy&(doc apply)
02:58lazybot⇒ "([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."
02:58amalloysounds accurate to me
02:58amalloy&(apply + 1 2 [3 4])
02:58lazybot⇒ 10
02:59amalloyhere 1 and 2 are the intervening arguments; prepend them to [3 4] to get [1 2 3 4], and then apply + to that
03:01Vinzentthat 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?
03:02amalloyah
03:03amalloyi agree with your reading of the docstring as it applies to the last arglist. that could use a fix
03:03Vinzentoops, 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
03:03amalloywell. i disagree with your fix :P
03:04Vinzentwhy? :) (apply f 1 2 3 4 42) will throw exception, last arg must be a seq
03:05amalloyindeed, 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"
03:06amalloyback when the arglist was something like (f args* argseq), then the current docstring was correct: "prepend intervening args onto the argseq" or whatever
03:08Vinzentyeah, that's what I mean!
03:11Vinzentso 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?
03:12amalloyanyone with a CA can file a ticket
03:21Turtl3boithanks Scriptor kun
03:21Turtl3boii can sleep better now
03:30ScriptorTurtl3boi: np
03:33Turtl3boiwhere do you live scriptor
03:34ScriptorTurtl3boi: NYC
03:36Scriptoryou're in cali, right?
03:37Raynesi liek tuutles.
03:39Scriptorplenty in chinatown
03:42Turtl3boiman yeah how did you know
03:42Turtl3boii wish i lived in NY or boston
03:42Turtl3boiwould get a great job
03:44Scriptoryou mentioned it earlier, I think
03:44Scriptoryep, a good number of startups springing up
03:45Turtl3boican i come to NY and we hang out in coffee shop and you tutor me
03:45Turtl3boireally?
03:45Turtl3boiso not just finance related jobs
03:45Scriptoroh definitely, there's a good balance of both
03:46Scriptorsure, coffee shop, bookstore, wherever
03:46Turtl3boireally?
03:46Turtl3boido u work full time now
03:46Scriptornah, I'm a student
03:47Turtl3boiwow nice
03:47Turtl3boicomp sci student at stonybrook?
03:48Scriptornyu
03:49Turtl3boiniiice man
03:49Turtl3boigreat school
03:50Scriptorthanks, what do you do?
03:50RaynesReaches for the 'u' key too often.
03:50Turtl3boiwhat do i do?
03:51Turtl3boiman i'm a loser.....i quit my electronics job because it was too hardware oriented
03:51Turtl3boinow i can't find a job
03:51Turtl3boii've been rejected so many times
04:23Blktgood morning everyone
04:39zakwilsonI 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.
05:11Vinzentwhat'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"
05:13Raynesamalloy: How not-ready-for-use is it?
05:14Raynesamalloy: It looks like he added that message because he didn't feel like writing actual documentation at the time.
05:14amalloyugh
05:14RaynesSo it's hard to tell.
05:14amalloyit 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
05:15RaynesVinzent: Anyways, there is a built in library for parsing XML. http://clojure.github.com/clojure/clojure.xml-api.html
05:18VinzentRaynes, yeah, probably parse + xml-seq will be enough for me this time
05:20teromzipfilter.xml in 1.2 contrib is useful (not sure if there's something like it for 1.3)
05:23zakwilsonThose work well as long as the xml is not large.
05:28teromis there anything that parses xml to the format used by prxml/hiccup?
05:36Vinzentterom, https://github.com/nathell/clj-tagsoup
05:39teromVinzent: thanks, will look that up
05:40Vinzentbut it doesn't seem to be maintained
05:51raekterom: it is very easy to write a function that translates a tree from one form into the other
05:52raekterom: https://gist.github.com/633049
07:36devinuscan anybody tell me what when-let does?
07:41raek,(macroexpand-1 '(when-let [[x y] (f)] a b c)) ;; :-)
07:41clojurebot(clojure.core/let [temp__3698__auto__ (f)] (clojure.core/when temp__3698__auto__ (clojure.core/let [[x y] temp__3698__auto__] a b c)))
07:43raekas 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]
07:44raekvery useful in conjunction with functions like re-matches
07:46raek(if-let [[_ x y] (re-matches #"([0-9]+) ([0-9]+)" "123 456")] {:x x, :y y} (throw (Exception. "invalid pair format")))
07:51devinusraek: sorry, i'm...confused. i'll have to learn more about before i can even understand the explanation :P
07:52devinusraek: i understand creating functions, lists/maps/vectors and let right now :P
07:52devinusthen they throw out when-let
07:52devinusand of course i'm assuming it's combining a when and a let expr
07:52devinusbut it's still confusing
07:53ambrosebs(when [a 1] ...) is (let [a 1] (when a ...))
07:53ambrosebssorry (when-let [a 1] ...)(
07:54raek(when-let [x y] ...) is (let [z x] (when z (let [x z] ...)))
07:55devinusok that makes sense now
07:55devinusthank you
08:02devinuswhat exactly is (seq [1 2 3]) doing?
08:03clgvdevinus: building a seq from that vector
08:03clgv&(seq [1 2 3])
08:03lazybot⇒ (1 2 3)
08:03raekit gives you a sequence of the values in the vector (many functions do this implicitly)
08:04clgvmore interesting: ##(seq {:a 1 :b 2})
08:04lazybot⇒ ([:a 1] [:b 2])
08:04raekdevinus: also, seq on an empty collection returns nil
08:05raekso you can use it to check if the collection is empty by passing the return value of seq to if or when
08:18devinusok, that makes sense, but what *is* a seq?
08:19devinusand why can i do:
08:19devinus&(seq [1 2 3])
08:19lazybot⇒ (1 2 3)
08:19devinus&(1 2 3)
08:19lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
08:19devinuswhy isn't that allowed? because of funcall syntax?
08:21raekdevinus: yes. sequences does not have a literal syntax.
08:21raekbut it is ideomatic to use a vector as a sequence literal
08:21raeksince vectors are seqable
08:22devinusi see
08:22devinusso a seq is just an instance of ISeq?
08:22raekyes
08:22devinusbasically just a linked list?
08:22devinusi use that term lightly
08:22devinus"linked list"
08:22raekyes. most oftenly a lazilly realized linked list
08:23devinusok, coming together now
08:23raekyou can think of sequences as functional programming's version of iterators
08:49devinusi'm trying to get syntax highlighting in slime
08:49devinustried: (add-hook 'slime-repl-mode-hook 'clojure-mode-font-lock-setup)
08:50devinusadded to my .emacs
08:50devinusbut it's not highlighting, anybody know what the problem could be?
09:00TimMcdevinus: 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`.)
09:04AWizzArdWhen 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?
09:06kotarakAWizzArd: 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...
09:11TimMcAWizzArd: Open-ended ranges do weird stuff soemtimes.
09:11TimMcI did [1.2.0,1.4.0) and was startled to get 1.4.0-SNAPSHOT.
09:18jeremyheilerAWizzArd: 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.
09:19jeremyheiler*greator than or equal to 1.0.7
09:33AWizzArdokay, thanks for your various inputs
12:10juhu_chapaHi comrades, by the clojure nature is there an area where the problems solved with clojure are faster than a %100 java solution?
12:12clgvjuhu_chapa: I guess thats only possible if the java program is written poorly
12:12clgvboth java and clojure "cant be faster than the jvm"
12:13clgvso you could ask for almost equal performance
12:13jolyIf you include coding time, solving problems with clojure can be faster than solving them in Java.
12:13clgvjoly: lol yeah. I thought he meant runtime ;)
12:13juhu_chapaclgv: so the real neat writing in clojure is beautiful code that is easier to read?
12:14_briggs_juhu_chapa: and safer.
12:14_briggs_STM.
12:15dnolenjuhu_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:15clgvjuhu_chapa:it's entirely different code from java. I think it's often more expressive due to macros.
12:15juhu_chapai see.
12:16dnolenjuhu_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:16hiredman~rationale
12:16clojurebotrationale is http://clojure.org/rationale
12:18juhu_chapathx
12:26juhu_chapafeatures like inmutability promote faster code than java code?
12:29mdeboardsimplicity uber alles
12:29jolyDon'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:30jolyEasier to reason about.
12:30jolyetc
12:31juhu_chapainteresting!
12:31Turtl3boican i do i everything i can do in java, in clojure
12:31Turtl3boilike what if i write little stupid GUIs with Swing
12:32jolycan't think of the names, but there are Swing wrappers for Clojure
12:32Turtl3boii take it nobody really does that though?
12:32cemerickhttp://spin.atomicobject.com/2011/12/14/clojure-desktop-applications-with-swing/
12:32mdeboardreal men write GUIs in Fortran
12:33jolycemerick: thanks, I knew I'd just seen an article on that topic go by my reader
12:33cemerick"clarity" is the name of the newer swing framework IIRC.
12:34Turtl3boican someone write a little GUI real quick for me to prove it can be done, and send me the compiled code
12:34cemerickTurtl3boi: There's about 86 different Clojure Swing tutorials and demo apps floating around the web…
12:34mdeboardTurtl3boi: lol
12:34Turtl3boioh c'mon
12:34Turtl3boii figured you guys already had something
12:34jolyquick google check: http://clojure.org/jvm_hosted
12:35cemerickTurtl3boi: such things are what google is for
12:35mdeboardYeah 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:35Turtl3boiso none ofyou have written a GUI in Clojure
12:35jamiltronhttps://github.com/daveray/seesaw
12:35mdeboardOh he was serious
12:35jamiltronTurtl3boi: I have, but to be honest your request is a little ridiculous
12:35cemerickTurtl3boi: written many, deployed many, but I doubt people are going to whip up examples on demand.
12:36Turtl3boiwhy is it ridiculous? it would help me learn honestly
12:36Turtl3boidarnit! !
12:36jolycheck the link I posted. It has a small Swing app
12:36Turtl3boii didn't say you had to whip up an example
12:36Turtl3boithx joly
12:36Turtl3boii'll try it now now ;)
12:36jolywould likely be cleaner using one of the mentioned libraries
12:36Turtl3boigrrrrrrrrrrrrrrrrrrrrrrrrrrrr
12:37mdeboard12: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:37jamiltronTurtl3boi: Go to https://github.com/daveray/seesaw and follow the TL;DR example
12:39blakesmithTurtl3boi: People like to help, but usually they like to see that you've tried to help yourself first.
12:39Turtl3boisorry i don't even have Clojure installed yet
12:39Turtl3boihelp me with that
12:40Turtl3boimainly i just want to see certain things can be done in a language before i go too far with it
12:40Turtl3boiClojure seems like the first language that can truly do it all
12:40blakesmithAgain, help yourself... Google is your friend.
12:40mdeboardTurtl3boi: Here you go https://github.com/technomancy/leiningen
12:40jamiltronTurtl3boi: Download leiningen - https://raw.github.com/technomancy/leiningen/stable/bin/lein
12:40mdeboardTurtl3boi: Follow the instructions there and you'll be set for the most part. Good luck :)
12:41Turtl3boithank you to all you non haters
12:41jamiltronmdeboard: Even though I think I'd suggest googling most Clojure topics, installation isn't one of them I'd trust.
12:41cemerickClojure can't do it all, but it's pretty nifty.
12:41mdeboardjamiltron: That's why I didn't suggest googling it :P
12:41jamiltronmdeboard: Oh right you linked to lein, like I did :P
12:42jamiltronmdeboard: Sorry, my mistake. I must have gotten the conversation mixed up.
12:42mdeboards'ok
12:42Turtl3boidoes leiningen assume i already have JAVA SE 6 installed
12:44jamiltronUmm, honestly I don't know.
12:44jamiltronI mean - you need a version of Java installed just to run Clojure
12:45Turtl3boiright
12:51mdeboardYeah it doesn't assume anything
12:52mdeboardbut java is a requirement :P
13:21Apage43:w
13:21Apage43gah!
13:22sirn,(apply hash-map (flatten (map #(vector (:name %) (:price %)) [{:name :apple :price 10} {:name :orange :price 15} {:name :apple :price 30}])))
13:22clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: :apple>
13:23sirnanyway to make hash-map ignore duplicate key in a case like this?
13:23sirn(or is there a better way to do this?)
13:27technomancysirn: (zipmap (map :name fruit-vec) (map :price fruit-vec))
13:28technomancyassuming I've deciphered your snippet correctly
13:29sirntechnomancy: thanks, that solved the duplicate problem!
13:32technomancyand also the "making it more complicated than it needed to be" problem. =)
13:33sirnthat one too :)
13:47TimMcCgrand 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:48TimMcI don't know the etiquette here.
13:48amalloysend a pull request. 0-line diff, with a comment: "FFFFFUUUUUUUUUUU, I'm forking this project and everyone will use miiiiine!"
13:50amalloysrsly 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:50TimMcI didn't have a patch when I sent the email.
14:08TimMcOh hey, and my patch was broken! I was relying on binding when using lazy seqs. >_<
14:09TimMcwith-redefs is the appropriate thing, then?
14:09amalloy*shudder*
14:09raekTimMc: for tests, yes
14:09TimMcIt is in a test, yeah.
14:10raekat runtime in production code = madness
14:10TimMc...but the test is supposed to mimic actual usage, so I shouldn't use that.
14:10amalloyTimMc: 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:11TimMcUrgh, right -- the problem is that thread-local is the wrong approach entirely.
14:27klutometis,(cons "foo" "bar")
14:27clojurebot("foo" \b \a \r)
14:28klutometisI vaguely understand why that's the case (strings as seqs, &c.); it's still surprising behavior, though.
14:28klutometisIn Scheme, (cons "foo" "bar") => ("foo" . "bar")
14:29amalloyclojure ain't got dotted pairs
14:29klutometisAh.
14:29amalloy&(cons 1 2)
14:29lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long
14:48Turtl3boiwhat does 'cons' do
14:50dnolenTurtl3boi: in Scheme it creates a fundamental data structure - a linked list. In Clojure it adds something to a valid sequence.
14:50Raynes&(cons 0 '(1 2))
14:50lazybot⇒ (0 1 2)
14:50duck1123it's similar to conj
14:51Raynesdnolen: Man.
14:51Raynesdnolen: Just say "It shoves something onto the front."
14:51Turtl3boi,(cons #{1 2} 3)
14:51clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
14:51dnolenRaynes: heh.
14:51Turtl3boiwtf why didn't that work
14:51dnolenTurtl3boi: is 3 a valid sequence?
14:52dnolen,(type 3)
14:52clojurebotjava.lang.Long
14:52Turtl3boiis zer a valid sequence?
14:52dnolen,(seq? 3)
14:52clojurebotfalse
14:52Turtl3boizero
14:52dnolen,(seq? ())
14:52clojurebottrue
14:52dnolen,(seq? nil)
14:52clojurebotfalse
14:52TimMcTurtl3boi: Pay attention to the order of the arguments!
14:52Turtl3boi,(seq? 0)
14:52clojurebotfalse
14:52dnolenTurtl3boi: basically a you can cons onto a sequence or nil.
14:53TimMc&(doc cons)
14:53lazybot⇒ "([x seq]); Returns a new seq where x is the first element and seq is the rest."
14:53Turtl3boi,(cons 0 #{1 2})
14:53clojurebot(0 1 2)
14:53Turtl3boiwhy does the order of operations matter
14:53TimMc....
14:53RaynesBecause...
14:53Turtl3boiso the 'cons' operation takes a number as the first argument
14:53TimMcTurtl3boi: How could it ever be otherwise?
14:53Turtl3boiand a collection as the second
14:54Turtl3boithis is getting hard Timothy
14:54TimMcHow would cons know which you wanted to cons *onto*?
14:55Turtl3boii'm just wondering why zero works
14:55Turtl3boi,(cons 1 '(2 3))
14:55clojurebot(1 2 3)
14:55RaynesIt doesn't.
14:56Turtl3boiugh this is confusing
14:56Turtl3boi&(cons '(1 2) '(3 4))
14:56lazybot⇒ ((1 2) 3 4)
14:56Turtl3boiwhat in gods name
14:56Turtl3boi&(cons 1 2 '(3 4))
14:56lazybotclojure.lang.ArityException: Wrong number of args (3) passed to: core$cons
14:56Turtl3boilord
14:56duck1123cons is a little odd in it's order of arguments (for historical reasons)
14:57Turtl3boisee Tim
14:57Turtl3boii was onto something
14:57duck1123cons just takes the first argument, and shoves it into the second
14:57RaynesIt really isn't any more complex than that.
14:57RaynesTakes x and shoves it onto (y).
14:58hiredmancons does exactly what its docstring says it does
15:05Turtl3boihow come it can't take several arguments and shove them into the last
15:05Turtl3boilike (cons 1 2 3 '(4 5 6))
15:05TimMcI think conj can do that.
15:06TimMcand list*, which actually makes a seq (bad name)
15:06RaynesIt is a little more complicated for cons, given the order of argument.s
15:06TimMc&(cons 1 (list* 2 3 4 '(5 6 7)))
15:06lazybot⇒ (1 2 3 4 5 6 7)
15:07Turtl3boi&(conj '(3 4) 1 2)
15:07lazybot⇒ (2 1 3 4)
15:08Turtl3boii can do do multiple arguments with conj
15:08Turtl3boiit seems odd i can't do the same with cons
15:08TimMcYep, and conj is what you'll use most of the time.
15:08Turtl3boik thanks
15:08amalloyTurtl3boi: list* is a "version" of cons that allows extra args
15:08TimMcconj is for collections in general, cons is specifically for seqs
15:09amalloywell! i see that's been recommended three or four times already
15:09TimMcwe're on it
15:09Turtl3boiso just use CONJ
15:09amalloyTimMc: specifically conses :P
15:09Turtl3boii'm gonna try and forget cons even exists
15:10TimMcYeah, until you need to *build* seqs, that's fine.
15:11jcrossley3i just now realized how leiningen got its name
15:11Turtl3boihow did leiningen get it's name
15:11Turtl3boiwhat's a sequence again
15:11amalloytechnomancy named it, dude
15:11Turtl3boiwith the curly braces
15:13Turtl3boiA 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:13Turtl3boi&(seq? #{1 2})
15:13lazybot⇒ false
15:14Turtl3boi&(seq? '(1 2 3))
15:14lazybot⇒ true
15:14Turtl3boihmm so a set is not a sequence
15:14Scriptornope
15:14Scriptorbecause mathematically, sets have no order
15:14Scriptorseqs do
15:14TimMcTurtl3boi: You can *acquire* a seq over a set.
15:15TimMc`seq` says "get me a sequence backed by this thing"
15:15TimMcThe seq will be ordered, but the order will be arbitrary for seqs over maps and sets.
15:16Turtl3boiim lost again
15:16Turtl3boiwhat doth it mean to acquire
15:17Turtl3boiTim can i call you
15:17Scriptoryou can make a seq out of things that aren't sequences, such as maps and sets
15:17Turtl3boihmm
15:17Scriptorbut like TimMc said, the order of the resulting seq wlll be arbitrary
15:17Turtl3boiis a sequence ordered?
15:18TimMcas ordered as an onion
15:18Turtl3boilol is an onion ordered ?
15:19TimMcfrom the outside in
15:24lobotomyis it normal that there are things like (reduce #(merge-with concat %1 {(second %2) [(first %2)]}) {} fbfs) in my code?
15:24lobotomythere's probably a more elegant way to do that but um
15:25TimMclobotomy: That anonymous function could maybe stand to be a defn.
15:26TimMcI think that's best advice I can give for that out-of-context snippet.
15:28lobotomybasically 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:33TimMcMaybe a for.
15:48Bronsa,(for [[k v] (group-by second '([a :a] [b :a] [c :b]))] [k (map first v)])
15:48clojurebot([:a (a b)] [:b (c)])
15:49Bronsa,(into {} (for [[k v] (group-by second '([a :a] [b :a] [c :b]))] [k (vec (map first v))]))
15:49clojurebot{:a [a b], :b [c]}
15:49Bronsalobotomy: ^
15:53TimMclobotomy: So, [[{:a1 :a2} :ak] [{:b1 :b2} :bk]] goes to {:ak [:a1 :a2], :bk [:b1 :b2]} ?
15:57lobotomyooh, group-by is exactly what i needed here, cheers
15:58TimMclobotomy: I think I misunderstood your question.
16:11SomelauwFor merging lists, use concat and for maps use merge. I don't really see a use for into.
16:12Raynes&(into {} [[1 2] [3 4]])
16:12lazybot⇒ {1 2, 3 4}
16:12SomelauwAlso if I want to add to the right of a random sequence, I just use (concat seq [x]).
16:13RaynesThat is just not a good idea.
16:13raekSomelauw: you can use into to add multiple elements to a vector, queue, or stack
16:14raek(lists and vectors can be used as stacks)
16:14RaynesSomelauw: 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:15Raynes##(into [1 2] [3 4]) vs ##(concat [1 2] [3 4])
16:15lazybot(into [1 2] [3 4]) ⇒ [1 2 3 4]
16:15lazybot(concat [1 2] [3 4]) ⇒ (1 2 3 4)
16:16Raynescmeier: Howdy.
16:16cmeierHey man
16:18aaelonyI 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:18SomelauwRaynes: then what should I use when merging 2 vectors?
16:19RaynesSomelauw: Define 'merge'.
16:19SomelauwSo concat if you need more than 2 items and into when the types are different?
16:19raekaaelony: (doall rs)
16:19aaelonyraek: thanks, I'll try that. I must have tried 10 things already.
16:19SomelauwSomelauw: the thing concat and into both seem to do.
16:20Raynesinto is necessary when you want to retain types.
16:20Raynesconcat will always return a seq.
16:20RaynesSometimes you don't want a seq.
16:20aaelonyraek: many thanks!
16:22Somelauwok
16:28raekSomelauw: one way to think of it is that a sequence is a sequential walk through a set of data.
16:28raek(seq x) means walk though x. (concat (seq x) (seq y)) means walk through x and then y.
16:28raek(but most function, including concat, will call seq for you as a convenience)
16:28raek(into x y) mean augment the x data structure with some additional elements.
16:28raeka vector can do more things than a seq, for example random access and updates.
16:31raekthere 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:31raekso if you nest them to deep you can blow the stack
16:32raekthis is why (concat coll [element]) is not exactly just like adding something to the end of a collection
16:32SomelauwSo concat doesn't actually create a single vector in memory.
16:33raeknope
16:33Somelauwokay, that is cool
16:33raekit creates something that has a sequence of references to sequences
16:34TimMc&(into [1 2] [3] [4] [5])
16:34lazybotclojure.lang.ArityException: Wrong number of args (4) passed to: core$into
16:34raek,(recude into [1 2] [3] [4] [5])
16:34clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: recude in this context, compiling:(NO_SOURCE_PATH:0)>
16:34raekeh
16:34raek,(reduce into [1 2] [3] [4] [5])
16:34clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (5) passed to: core$reduce>
16:35raek,(reduce into [1 2] [[3] [4] [5]])
16:35clojurebot[1 2 3 4 5]
16:35TimMcinteresting
16:35Somelauwthanks, now I understand
16:35TimMcGotta work on my HOF skills.
16:35raekalso, (into coll elements) can be defined as (reduce conj coll elements)
16:36Bronsaraek: that is exactly how it is defined in clojure.core indeed
16:36dnolenBronsa: raek: into uses transients
16:36brehautits not exactly how its defined
16:36TimMcalong with some speedups for IEditableCollection
16:37Bronsadnolen: yes but that's a speedup detail
16:37brehautBronsa: but 'exactly' has quite precise meaning
16:37Bronsai shouldn't have used 'exactly' then
16:37Bronsaright
16:38raekhence my "can be"... :-)
16:38TimMcI think a middle ground of "basically" is correct.
16:40gtrak`,(seq #{1 2 3})
16:40clojurebot(1 2 3)
16:40gtrak`Turtl3boi, ^^
16:47Squee-Dantares_ my friend. Alll your help payed off and we have a really solid EM / AMQP app now.
17:07sritchieRaynes, I have an interesting little puzzle for you
17:16Raynessritchie: OKay.
17:17sritchiestuart sierra's clojure.tools.namespace seems to break on the moustache format of the templates in lein-newnew
17:17sritchie(ns {{name}}.core), for example
17:17sritchie(I'm realizing this probably needs to be address in clojure.tools.logging)
17:17sritchieerr, namespace
17:18RaynesIt definitely needs to be fixed in c.t.namespace.
17:18RaynesNot much I can do about it.
17:18RaynesCertainly not going to switch to a new template engine.
17:18sritchieby the time you'd answered, it was less of an interesting puzzle and more of a boring routine ticket :-/
17:19sritchiehaha, yeah, I know
17:19RaynesHeh.
17:19Raynessritchie: If you submit the ticket, I'll see about patching it later tonight.
17:21RaynesUnless you do it.
17:21sritchieawesome, thanks
17:21sritchieI have my CA now
17:21sritchiebut I'm still a jira virgin
17:21RaynesI've had a CA for forever but I haven't actually done anything with it.
17:22sritchieRaynes: I'll submit a patch, anyway
17:22RaynesI'm not sure its valid though. I signed my name as Simpson...
17:22RaynesI need to talk to Stu about that.
17:22TimMcI want to help improve Clojure documentation, but I don't know how to go about it.
17:22sritchieI just put lipstick on and spent about an hour with it
17:23Raynes"New in Confluence 4.0! We still suck!"
17:23TimMcAnd 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:24RaynesHaha
17:24RaynesThe 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:24TimMc...which seems really kind of terrible and backwards.
17:25sritchieRaynes: it's actually a bug in clojure.core
17:25sritchie(read (PushbackReader. (BufferedReader. (FileReader. example-file)))) fails if example-file contains (ns {{name}}.core)
17:26TimMcI guess a decent system would split the docstrings off of clojure.core during compilation and put them into a separate package, clojure.doc.
17:26Raynessritchie: Well that is kind of understandable.
17:27TimMc&(read-string "(ns {{name}}.core)")
17:27lazybotjava.lang.RuntimeException: Map literal must contain an even number of forms
17:27sritchieRaynes, 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:27RaynesHow do you read a map with a key and no value?
17:28RaynesI 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:28Raynesvalid*
17:28technomancysritchie: 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:28Raynestechnomancy: Yeah, I noticed that a while back.
17:28technomancyit's been fixed, but that was a fun one to track down
17:28RaynesMustache is also a really good template system, so I'd have to be pretty convinced to change it.
17:29technomancyone of the few things that actually got me befuddled enough to pull out the debugger
17:29RaynesBut you're right, it should catch exceptions like that.
17:29sritchieclojure.tools.namespace can just skip on an exception, I suppose
17:29sritchietechnomancy: nice
17:30TimMctechnomancy: What sort of debugger?
17:30technomancyTimMc: swank-cdt
17:33sritchietechnomancy: 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:34technomancysritchie: https://github.com/technomancy/leiningen/commit/7dc1b034ee
17:34technomancy^^ my workaround
17:37sritchienice, thanks
17:50technomancyso I wrote a little tool to allow deploying from leiningen to private repositories on s3: https://github.com/technomancy/s3-wagon-private
17:50technomancyhad 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:51technomancyanyone want to try it out before I make a wider announcement?
17:51sritchietechnomancy, Raynes: patched -- http://dev.clojure.org/jira/browse/TNS-1
17:52technomancyhm... I wonder if they'll bite considering the underlying bug is fixed in Clojure
17:53sritchietechnomancy: not with 1.2, though, right?
17:53technomancyright
17:53sritchiethey may enjoy another reason to force folks onward
17:53sritchiewhich I'm okay with
17:54technomancywell leiningen _is_ switched over on master. it's just that it won't be released for a long time yet.
17:55sritchiethis popped up for me on pallet
17:55sritchiewhich I think still needs 1.2
18:12technomancycould 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:13technomancyI'm wondering if they've disabled downloads entirely, or just limited them to facebook logins.
18:41chessguycan someone help me understand this output? it looks like a 4-element list? https://gist.github.com/1479137
18:42amalloycompare for/doseq
18:43amalloyit'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:45chessguyaha
18:45chessguythat makes sense, thanks amalloy
18:46amalloybtw, gist has a Clojure mode; you don't have to use Common Lisp
18:47chessguyso it does. i looked for it last time and missed it, my bad
18:48chessguyyou are a wealth of information :)
19:22chessguyi'm using this pattern a lot. is there something i should prefer? https://gist.github.com/1479246
19:25amalloymostly 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:26chessguyinteresting
19:52RaynesTimMc: TIM!
19:57TimMcRaynes: ANTHONY!
19:58RaynesTimMc: Are you doing a trycljs?
19:58TimMcim in ur github stealin' ur repl
19:58RaynesHow do you plan to sandbox cljs code?
19:58TimMcRaynes: Yeah, there's a group here that's gonna hack it apart and build it back up.
19:58TimMcRaynes: Browser.
19:58RaynesThe README says it will evaluate code on the server side.
19:59RaynesI thought you planned on doing something fancy.
19:59TimMchaha, we just haven't modified the README yet
19:59RaynesAnyways, 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:59Turtl3boican i do a newbie project with you TimMc
20:00Turtl3boilike you give me a project to do and we do it together and i ask questions
20:16devn,(macroexpand-1 '(my-fn ~(list var-a) ~var-b)))
20:16clojurebot(my-fn (clojure.core/unquote (list var-a)) (clojure.core/unquote var-b))
20:17amalloydevn: the macroexpand is a no-op there
20:17devnamalloy: Yeah, I could use your help if you have a second.
20:18amalloyokay...?
20:18devn(defmacro foo-parse [p s] `(run ~(list p) ~s)))
20:18amalloythat's the same as `(run (~p) ~s)
20:19devnbeautiful, i was feeling like list was superfluous
20:19devnthanks
20:19devn(inc amalloy
20:19devn(inc amalloy)
20:20devn,(inc amalloy)
20:20clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: amalloy in this context, compiling:(NO_SOURCE_PATH:0)>
20:24arohnerif I use clojure.java.shell, is there any safe way to stop a long-running process?
20:25chessguyugh, i am so confused by these namespaces
20:26amalloyarohner: yank the power-cord out. safe to say that would stop it
20:26amalloychessguy: cuz they're confusing
20:27chessguycan someone help me understand why "lein test" is giving me a stack trace on my project? https://github.com/arwagner/bps-clojure
20:27Scriptor>(ns confusing.core)
20:27Scriptors/>/&
20:27chessguyit complains "Could not locate building_problem_solvers/test/examples__init.class or building_problem_solvers/test/examples.clj on classpath:"
20:28amalloyyour source files need namespace declarations
20:29amalloyas i understand it that's a lot like needing to (provide 'foo) somewhere in, say, elisp
20:29chessguyamalloy: ok, by why this particular error?
20:29chessguylike, what line is causing the error?
20:30sritchie(:use [building_problem_solvers.unify]); that ns doesn't exist
20:30sritchieoh, that one does :)
20:31amalloyline one of test/unify
20:31amalloyprobably? i dunno
20:31devnthe more I use it the more I love it: midje
20:31chessguyamalloy: but that's declaring a namespace
20:31amalloyit's also declaring a dependency on another namespace
20:31amalloysaid namespace cannot be found, so boom
20:33chessguyamalloy: but that one is found
20:34chessguyamalloy: the namespace it's complaining about is declared on line 1 of treex1.clj
20:35chessguybut that one doesn't depend on any other namespace
20:38Turtl3boiwhat's a 'predicate'?
20:39chessguyTurtl3boi: typically, a function which returns true or false
20:40Turtl3boihaha JoC assumes I already knew this
20:41amalloy$dict predicate
20:41lazybotamalloy: verb-transitive: To base or establish (a statement or action, for example): I predicated my argument on the facts.
20:41chessguyhmm, strange. setting my namespace to be the equivalent of the path of the file seems to have fixed it
20:41amalloyokay, not actually the right definition. but seriously, "google, what is the definition of predicate" is not a high bar for JoC
20:42Turtl3boiwell i did and didn't get a clear answer geez
20:57devnTurtl3boi: there are a lot of assumptions, nearly all of them are wrong
20:57Turtl3boiyeah i bet
20:57devnfor instance, you are discovering your assumption that JoC would explain what a predicate is, was flawed
20:58devnlikewise, JoC didn't explain predicates because they assumed the reader would already know
20:58Turtl3boiyou gotta assume some prior knowledge
20:58Turtl3boii had just never known that a predicate was a function which returns a boolean
20:58devnTurtl3boi: it's okay to not know stuff, but i think amalloy is right to suggest the "google ceremony"
20:58Turtl3boiwell i did that too
20:59Turtl3boithen after 4 minutes of search i came here and asked
20:59Scriptorgoogling "predicate function" yields good results
20:59Turtl3boii didn't know it was a function
20:59Turtl3boiso i googled 'predicate comps ci'
20:59devnTurtl3boi: did you get an answer that has helped you understand?
20:59Turtl3boiyeah
21:00devngood :) just checking.
21:00amalloyi 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:00Scriptordoes JoC assume any clojure knowledge?
21:00devnamalloy: nah, I read it the same, but idk, I remember asking in here a couple years ago: "what does foo-bar-p means?"
21:01devns/means/mean
21:01devnit wasn't always so obvious
21:02devnand 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:02devnso we take it for granted
21:03devnamalloy: have you used the-parsatron at all?
21:03Turtl3boiwhat do you mean it's a necessity to understand what a predicate is?
21:03amalloynope
21:03ScriptorTurtl3boi: both predicates themselves and the term is used throughout the whole clojure world
21:04hiredmanwell, all of programming
21:04Turtl3boiis this a predicate: &(seq? 1)
21:04Turtl3boi?
21:04Scriptoryes
21:07amalloywelllll, seq? is a predicate. the expression (seq? 1) is a boolean value
21:07licenserTurtl3boi: I think the simplest way to say it is, a predicate is a function that test for something and returns true or false
21:09Turtl3boithanks that clarifies further
21:43actualHas anyone here used Clojure for game development? If so what did you think of the experience?
22:10aperiodicmy 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:14aperiodicah, found it (immigrate)
22:29TimMcRaynes: What I'm trying to figure out right now is how to print the results of a CLJS evaluation back out as CLJS.
22:32wiseenis there a way to use enviroment variables in Lein extra-classpaths (eg. ["$CLOJURESCRIPT_HOME/src/clj"...])
22:36licenserTimMc: how do you mean that?
22:36licenserso from browser -> server?
22:40TimMclicenser: 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:40TimMcThat's the first half of "REPL"...
22:41TimMclicenser: The question is, how can we then take the resulting JS value and represent it as CLJS?
22:43licenseryou mean like decompile it?
22:44amalloyhe means call (pr-str) on it so you can show it in the repl
22:45amalloybut 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:45TimMcamalloy: Sounds good.
22:45TimMcI guess pr-str would already be there...
22:46TimMc(pr-str (do ...))
22:46TimMcThey *should* only put one form, but I'll be nice.
22:46amalloysure
22:47amalloywell actually, you have to be able to parse/read the forms locally anyway
22:47amalloyso you can just wrap each individual form
23:00TimMcI do?
23:04amalloyTimMc: o/w you can't allow multiline input
23:04amalloy(defn foo [x] ;; don't send to server
23:04amalloy (inc (dec x))) ;; do send to server
23:16licenseramalloy TimMc make sure you pass along some kind of ID to guarantee ordered execution
23:17licenserotherwise: (def x 1)
23:17licenser(+ x x)
23:17licensermight lead to errors
23:23fbru02hey guys, what's the best strategy to debug java code called by clojure code ?
23:23amalloyTimMc: the good news is, calling the clojure reader locally will be easy, because you app will be written in cljs...right...?
23:23TimMcheh
23:24TimMcamalloy: Ah, right -- multiline stuff. So I'll need to use the reader on the client side.
23:24TimMcMore of the original tryclojure might come in handy than I thought.
23:29TimMcI really know basically nothing about cljs. -.-
23:33amalloythat's probably a good reason to use cljs to write a program about cljs
23:34alexbaranoskyamalloy, exactly :)