#clojure logs

2008-02-05

08:59scramflotgeneral question about syntax: (defn make-adder [x]
08:59scramflot (let [y x]
08:59scramflot (fn [z] (+ y z))))
08:59scramflotin the above example, for instance.
09:00scramflotis what is in the [] following the definition of a symbol (or whatever) always a parameter?
09:00scramflotand, seeing as how it is an [], is that a vector?
09:06scramflotAnd, for instance, do the parameters to the definition of a vector always have to be passed in by a [] (vector?)? or can it rather be an {}?
09:09bgeroniiuc, x and z are parameters
09:18scramflotwell, I think I'm tracking that.. but in the let's [], an assignment seems to be happening, while in definitions it's more like parameters. Anyway, I've got to go, but I'll be back and I'll check back on the logs to see if there've been any comments.
11:49scramflotcorrection... perhaps assignment is the wrong word. let's [] is doing "bindings" ..
16:40jgracinwow, 10 users! most of them are blackdog, but this is a record on #clojure, nevertheless. ;-)
17:08scramflotand so jgracin
17:08scramflotleaves
17:09scramflotAnyone get the syntax file to work for vim on ubuntu?
17:10LunarCrisisI've got one working on gentoo
17:12scramflotmy vim/gvim doesn't seem to use ~/.vimrc or ~/.vim/syntax
17:13scramflotSo I tried modifying /usr/shr/vim/syntax and .vimrc there, and no worky
17:13scramflotI am pretty worthless though, so that could have something to do with it
17:15scramflotum, I mean /usr/share/ blah blah
17:29LunarCrisishmm
17:30LunarCrisisyour .vimrc doesn't work at all?
17:30LunarCrisisperhaps you should ask in #vim
17:33scramflotaye
17:43scramflotis "accessor" a built in symbol?
17:53scramflotThat's pretty cool: (defn string-from-byte-sequence [coll] (reduce strcat (map char coll)))
18:24scramflotWondering if rhickey would want the reference moved over from the website to the wikibook
19:39scramflothmm.. so what do you guys think? rich hickey said he wanted to docs moved over, right? After all, there is a section on the site named "Reference".. I'm just going to submit the page I've migrated and if he wants he can just take it off or ask me to
20:43scramflotrhickey: Hey, I added a page to the wikibook
20:44rhickeywas that the material copied from the Clojure site?
20:44scramflotyea
20:45scramflotI see it's gone.. guess you removed it?
20:45rhickeyThat's not ok - the Clojure site is copyrighted - please don't copy it. The wiki is for new original material.
20:45scramflotok.. ma'bad
20:48scramflotIt's just that there was a section called "reference," just like on your website, so i figured you'd want it moved over. It's not like I was trying to steal or anything though, obviously.
20:49rhickeyI didn't put the reference placeholder there, someone else added it
20:50scramflotoh. well, I didn't put it there. I was just trying to help you out. I don't want you to think there was any impropriety on my part.
20:51rhickeyI put some advice at the top now so people will know not to do that.
20:59scramflotrhickey: now that you're here... when [] is used for binding, like in (def a [b] b), is that actually a vector or just syntactic notation?
21:00scramflotermm. not binding
21:00scramflotI mean parameters
21:00rhickeythe names in the vector get bound to the corresponding parts of the argument
21:01scramflotbut one wouldn't see (def a (b) b) ever?
21:03scramflotor even (def a {b} b)
21:09travisbradyi'm a complete newb (i'm a python programmer with some haskell experience) and i'm working through the Getting STarted page
21:09travisbradyand in trying to run: java -cp jline-0.9.91.jar:clojure.jar jline.ConsoleRunner clojure.lang.Repl src/boot.clj
21:10travisbradyi get: Exception in thread "main" java.lang.NoClassDefFoundError: jline/ConsoleRunner
21:10travisbradyi assume this is a CLASSPATH issue, but i can't really make heads or tails of it
21:10scramflottravisbrady: rplace jline with it's absolute path
21:10travisbradyanyone know what that is off hand?
21:10scramflotreplace
21:11scramflotIn fact, put all absolute paths in there, then make a shell script to just run it.. much easier
21:11rhickeyscramflot: there's no structural binding in def
21:11scramflotrhickey: yea, I think I messed up my example
21:12travisbradyis JLine included with the clojure zip? or will i need to install that?
21:12scramflot(def a [b] b) (a 1) doesn't return 1, right?
21:13travisbradyanyway, great job Rich and team with the clojure site and docs
21:13scramflotno, there should be a link to it on the page where you saw the line
21:13travisbradyscramflot: ok, thank you
21:13rhickeythere's no team :)
21:14scramflot(def a [a b c]) actually binds the vector to a
21:14rhickeybinds a to the vector, yes
21:14travisbradyrhickey: just wanted to be inclusive
21:15travisbradyrhickey: excellent job to you then
21:15scramflot(defn nice [a] a) (nice 1) returns 1 then
21:15rhickeyright
21:16rhickeytravisbrady: if you can deal with emacs, clojure mode there is much more powerful than jline
21:17travisbradyrhickey: yeah, i'm setting that up now
21:18scramflotso, I guess what I'm asking is.. would this work? (def b [1]) (defn nice b (b)) -> 1 .. because b is a vector?
21:19scramflotor.. no
21:19scramflotcause defn doesn't evaluate until you pass it values
21:19rhickeyright
21:20rhickeyit is a macro that processes forms
21:20rhickeythe form b is not a macro, it's a symbol
21:20rhickeyer, is not a vector
21:20scramflotright right
21:21scramflotcould one expand a symbol into a vector at the time of macro processing?
21:21rhickeyno
21:22scramflotI guess what sparked the question in my mind was the bit about eval and programmatic evaluation
22:08scramflottrying to list the files in a directory:
22:08scramflot(import '(java.io File))
22:08scramflot(defn ls-f []
22:09scramflot (let [file (new File "home/john/tmp")])
22:09scramflot (. file listFiles))
22:10scramflotCompilerExecptoin: Unable to resolve symbol: file in this context
22:11scramflotAnd here's the code I'm trying to move over: http://www.rosettacode.org/rosettacode/w/index.php?title=Walk_Directory_Tree#Java
22:11scramflot(eventually it'll walk the directory
22:11scramflot)
22:11rhickeylet only binds file until its closing paren
22:14scramflotoh
22:14scramflotmisread the swing app example.. thanks
22:18scramflotIf listFiles returns an array, do I have to parse that a certain way? Or can I just leave (. file listFiles) as the last expression and have the function return an array?
22:21scramflotuser=> (defn ls-f [] (let [file (new File "/home/john/tmp")] (. file listFiles))) has Clojure talking about parse errors
22:22scramflotCompilerException: REPL:27: listFiles
22:23rhickeyI appreciate your enthusiasm, but I think you need to spend some more time with the Clojure docs, and double-check your work before asking here
22:23rhickeye.g. (. file (listFiles))
22:28scramflotbut there's no args. "(. instance-expr instanceFieldName-symbol)" I do see now that the swing app does use the parens for everything. I'll try to keep the chatter down.