#clojure logs

2008-02-14

12:03ChouserWhen I try to use assert, I get: clojure.lang.Compiler$CompilerException: REPL:1265: No such var: clojure/prstr
12:03rhickeyshould be pr-str, fixed in svn already
12:14Chouserok, thanks
15:42ChouserI think I wish more functions that currently return true or false instead returned an arg's value or false.
15:42rhickeywhich ones?
15:42Chouserlike "zero?", "or", etc.
15:42ChouserI'm not sure I've thought through the implications.
15:43ChouserWas it a concious decision to not do that?
15:43rhickeyuser=> (or nil 2 3)
15:43rhickey2
15:43ChouserEven things like < and > could do it
15:43Chouseroh. :-)
15:44rhickeyThe others are boolean though
15:44Chouserzero? wouldn't work
15:44Chouserbut pos? might
15:45Chouserif < returned the larger when true, you could chain them: (< (< 5 i) 10)
15:46rhickey(< 5 i 10)
15:47Chouserhmph.
15:47rhickeydoesn't negate your idea
15:47Chouseryou keep shooting down all my good ideas with .. better ones that ... already exist.
15:47Chouser:-)
15:48Chouserok, so the only one I've stumbled on in my actual code is pos?
15:49rhickeythere are many, just not or
15:49Chouser(some (fn [i] (and (pos? i) i)) seq)
15:49bgeronChouser: what would (< a b) return?
15:49rhickeypos? emulates CL plusp
15:50Chouserbgeron: either false or b
15:50bgeronwhy b?
15:50Chouserbecause it's the larger
15:50bgeronthat way (< a (< b c)) doesn't work as expected
15:51bgeronand < is commonly called "lesser-than" or the like
15:52Chouserbgeron: that's a pretty good point.
15:53ChouserI suppose that since < already supports multiple args, the (< (< a b) c) and (< a (< b c)) use cases aren't good ones to look at.
15:53bgeronit would be cool if we could use math notation to write a < b <= c
15:53rhickeyChouser: your problem might be with some returning the predicate return rather than the found value
15:53bgeronthat is a good point also
15:53rhickeyanother CL-ism
15:54Chouserrhickey: maybe, but I think it makes sense to use the predicate return, since that at least gives you the power to return the found valoue or something else.
15:54ChouserI'll go with power and simplicity over brevity.
15:55ChouserI guess if it gave you the found value you could wrap it in another (map ...). Hm.
15:55rhickeyCL has separate find-if
15:56Chouseryeah, I'm also in favor of fewer builtins
15:57Chouseroh, zero? would work. So is there a reason for zero?, pos?, and neg? not to return their arg when true?
15:58rhickeypossibly not - running now, will think about it
16:00Chouserbgeron: any objections? you had some good ones against <
16:03bgeronmaybe that it's not consistent with other predicates in returning values other than false/true, but it's really not a problem
16:05bgeronI think returning only false/true is more pure, but it's more practical to return the value itself in zero?,pos?,neg?
17:42scramflothi
17:43scramflotin the definition of the filter function, on page: http://clojure.sourceforge.net/reference/sequences.html , what does "pred" mean?
17:43scramflot(filter pred coll)
17:43scramflotReturns a lazy seq of the items in coll for which (pred item) returns true.
17:45scramflotso, like, (filter (= x 1) [4 1 3 1]) -> [1 1] ??
17:46scramflotor it's a function that takes a parameter and tests it, returning true or false
17:57Chouserpred is short for predicate, which means a function.
17:57ChouserIn this case at aleast, a function that returns true or false
17:58Chouser(= x 1) is a function call, not a function.
17:58Chouser(filter (fn [x] (= x 1)) [4 1 3 1])
23:38jh06Hi guys. I had a question which stems mainly from my misunderstanding of how Lisp works. How come I can redefine if, but the redefined version acts exactly the same as the old one?