#clojure logs

2009-07-19

00:33hamzaI have an array of integers i would like to find the biggest integer in the array using max but it does not work. is there a way to do it or do i have to roll my own function to iterate and find it?
00:35durka42hamza: what have you tried?
00:36hamzai was using (max array) but just found the answer (reduce max array) worked thx.
00:36hamzashould have RTFM
00:40hiredman(apply max array)
00:40hiredmanI wonder if that works
00:41hiredman,(apply max (into-array [1 2 3 4]))
00:41clojurebot4
00:49hamzais it possible to do this to a 2d array?
00:51hiredmana. there is no such thing, java arrays are 1d b. yes
00:53hiredman,(apply max (reduce #(apply max 5) (into-array (map into-array [[1 2] [3 4] [5 6]])))))
00:53clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--2791$fn
00:53hiredman,(apply max (reduce #(apply max %) (into-array (map into-array [[1 2] [3 4] [5 6]])))))
00:53clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--2798$fn
00:53hamzai created an array in repl like (def atest (make-array Integer 5 5)) now if do (reduce max atest) i get class cast exception
00:53hiredmanbah
00:54hiredman,(apply max (into-array (map into-array [[1 2] [3 4] [5 6]])))
00:54clojurebotjava.lang.ClassCastException: [Ljava.lang.Integer; cannot be cast to java.lang.Number
00:54hiredman,(map #(apply max %) (into-array (map into-array [[1 2] [3 4] [5 6]])))
00:54clojurebot(2 4 6)
00:54hiredman,(apply max (map #(apply max %) (into-array (map into-array [[1 2] [3 4] [5 6]]))))
00:54clojurebot6
00:56hamzathx alot ill try using this
01:37fsmHi, I have a question about efficiency - I am writing 3d code, which makes heavy use of vectors e.g. [x y z]
01:37fsmright now I am using arrays to represent them and 'nth' to access the values
01:38fsmis there a more efficient way of reading doubles from a small, fixed-size array like this?
01:42JomyootThere should be emacs built on Clojure
01:44JomyootIS there IDE with syntax completion yet?
02:02durka42does slime do tab completion?
02:02durka42vimclojure does some
02:03replacadurka42: I've heard that you can get slime to do tab completion, but I haven't succeeded at it myself
02:03replacaI think technomancy knows how
03:19Jomyoothow to just grab unique entry from a seq?
03:20duncanm(first my-seq) ?
03:20Jomyoothmm?
03:20Jomyootthat would just get the first one?
03:20duncanmthe first one is not unique?
03:20Jomyootunique entries
03:21duncanmturn it into a set?
03:21duncanm,(set '(1 1 1 2 3 4 5 5))
03:21clojurebot#{1 2 3 4 5}
03:21Jomyootthen it becomes a hash
03:21JomyootThen how would I make it back into a seq again?
03:21duncanmerr
03:21Jomyootseq() ?
03:22duncanm,(seq (set '(1 1 1 2 3 4 5 5)))
03:22clojurebot(1 2 3 4 5)
03:22Jomyootcool
03:22kotarakJomyoot: all the seq functions take also maps, vectors, sets....
03:23kotarak,(map inc (set [1 1 1 2 3 4 5 5]))
03:23clojurebot(2 3 4 5 6)
03:24duncanmla la la
03:24erohtarjomyoot: distinct
03:25erohtar,(distinct [1 1 2 2 3 3 4 5])
03:25clojurebot(1 2 3 4 5)
03:25duncanmoh cool
03:25duncanmerohtar: good job!
03:25duncanmthat's neat
03:48mariorzhow can i tell how much of the heap a collection is taking?
05:21Jomyootwhat is elegant way to do infinite loop?
05:26kotarak(while true ...)
05:26kotarakThere is no break, though.
05:27kotarakIf you want to leave the loop at some time do: (def *running* (atom true)) (while @*running* .... (when condition (reset! *running* false)))
05:46berkHi, I am reading Okasaki's book, implementing examples as I go along. I want to create a seq interface (at least conj, first, rest) for the datastructures, in clojure (ie. not ISeq and java). What is the correct way of doing that?
05:51kotarakberk: use proxy: (defn seq-from-your-coll [coll] (proxy [clojure.lang.ASeq] (first [] ...) (more [] ...)))
05:55berkthanks kotorak, I didn't know about proxy.
05:55kotarakberk: it's useful to implement eg interfaces.
05:55kotaraksome kind of anonymous class.
05:55kotarakIf it's more involved you can also use gen-class.
05:56JomyootLisp is cool
05:56JomyootI wish I could use Lisp for everything
06:00cp2use lisp for your toaster
09:58rhickeychunks now in master
09:58rhickeybut not the mutable vector stuff
11:49JomyootI want a Classifier in Clojure
11:49JomyootNaive Bayes or SVM
12:11Chouserthe commit history in git confuses me
12:13Chouserthe only thing that appears to be new today is an empty commit
12:16JomyootIs there Naive Bayes in Clojure already?
12:23ChousukeChouser: it's a merge commit :)
12:23ChousukeChouser: the actual commits are ordered by creation date, so whatever was added is further down in the log.
12:24ChousukeChouser: it helps to use gitk or something to look at it, I guess.
12:25ChousukeThe merge commit message could have been a bit more informative though :P
12:26ChousukeBut git autocommits merges by default
12:33rhickeyChouser: yeah, I don't get the the forks view either, but the commit was a merge of chunks prior to mutable vector work, so now chunks work is in master
12:46JomyootPhilosophically, is Clojure tied to JVM?
12:46JomyootWill Clojure eventually support other platform?
12:46Jomyooteven native platform?
12:47Chousukehmmh
12:47Chousuketo port clojure to "native" code you would have to implement an entire runtime providing GC etc. for it. :/
12:47JomyootDoes RIch Hickey view JVM as "THE" platform?
12:48Jomyootor just one of the platforms
12:49ChousukeThat I don't know. There are already attempts for "ports" to other platforms, but because clojure tries to tightly integrate with the host system, I don't think the ports can ever be 100% compatible with implementations on other hosts.
12:50Chousukeof course, if your clojure code never uses host interop and only core.clj, then it could be compatible with any clojure implementation, providing they supply a working version of core.clj
12:59pronikhi, is clojure-contrib supposed to be compilible with clojure 1.0 release (as opposed to current HEAD)?
13:01Chousukethe master branch is not.
13:01Chousukethere's a clojure-1.0-compatible branch
13:07pronikok, thanks
13:12ChousukeNo, no, no. Nothing of the sort. Idea is different and it's somewhat simpler:
13:12Chousuke1. Behavior is undefined so program can do anything it wants. It can destroy the world for god's sake!
13:12Chousuke2. Program which can destroy the world is pretty useless so obviously people will not write such program.
13:12Chousukeoops.
13:12Chousukedrag&drop fail :P
13:43Drakesonhow would you recursively search (e.g., with a pred) on zips? (e.g. zip/xml-zip)
17:26maaclIs anybody else having problems with clojure-update from clojure-mode?
17:31maaclah - the repo has been changed
17:54maaclUsing emacs/slime what would cause (ns test (:use [clojure-contrib server-socket])) not to work while (use 'clojure.contrib.server-socket) works?
18:07Chousukemaacl: because you need a list, like (clojure-contrib server-socket), not a vector
18:08maaclChousuke: oh, has this been changed at some point?
18:08ChousukeIt has always been like that as far as I know.
18:08Chousukeit's a prefix list. a vector is used for libspecs
18:09Chousukeeg. (:use (prefix lib [lib2 :as somealias] lib3))
18:13maaclthat is odd - the code for the clojure peepcode screencast - the mire mud uses a vector
18:23maaclChousuke: changing it to a lost doesn't fix it - this is really weird
18:26Chousukewait, hm
18:26Chousukeit's clojure.contrib, not clojure-contrib .P
18:27Chousuke:use etc. need to be redone anyway. :/
18:27Chousukethere was some discussion here earlier but I don't think anyone did anything. hmm
18:28Chousukeoh well, I'll get some sleep for now.