2008-02-05
| 08:59 | scramflot | general question about syntax: (defn make-adder [x] |
| 08:59 | scramflot | (let [y x] |
| 08:59 | scramflot | (fn [z] (+ y z)))) |
| 08:59 | scramflot | in the above example, for instance. |
| 09:00 | scramflot | is what is in the [] following the definition of a symbol (or whatever) always a parameter? |
| 09:00 | scramflot | and, seeing as how it is an [], is that a vector? |
| 09:06 | scramflot | And, 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:09 | bgeron | iiuc, x and z are parameters |
| 09:18 | scramflot | well, 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:49 | scramflot | correction... perhaps assignment is the wrong word. let's [] is doing "bindings" .. |
| 16:40 | jgracin | wow, 10 users! most of them are blackdog, but this is a record on #clojure, nevertheless. ;-) |
| 17:08 | scramflot | and so jgracin |
| 17:08 | scramflot | leaves |
| 17:09 | scramflot | Anyone get the syntax file to work for vim on ubuntu? |
| 17:10 | LunarCrisis | I've got one working on gentoo |
| 17:12 | scramflot | my vim/gvim doesn't seem to use ~/.vimrc or ~/.vim/syntax |
| 17:13 | scramflot | So I tried modifying /usr/shr/vim/syntax and .vimrc there, and no worky |
| 17:13 | scramflot | I am pretty worthless though, so that could have something to do with it |
| 17:15 | scramflot | um, I mean /usr/share/ blah blah |
| 17:29 | LunarCrisis | hmm |
| 17:30 | LunarCrisis | your .vimrc doesn't work at all? |
| 17:30 | LunarCrisis | perhaps you should ask in #vim |
| 17:33 | scramflot | aye |
| 17:43 | scramflot | is "accessor" a built in symbol? |
| 17:53 | scramflot | That's pretty cool: (defn string-from-byte-sequence [coll] (reduce strcat (map char coll))) |
| 18:24 | scramflot | Wondering if rhickey would want the reference moved over from the website to the wikibook |
| 19:39 | scramflot | hmm.. 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:43 | scramflot | rhickey: Hey, I added a page to the wikibook |
| 20:44 | rhickey | was that the material copied from the Clojure site? |
| 20:44 | scramflot | yea |
| 20:45 | scramflot | I see it's gone.. guess you removed it? |
| 20:45 | rhickey | That's not ok - the Clojure site is copyrighted - please don't copy it. The wiki is for new original material. |
| 20:45 | scramflot | ok.. ma'bad |
| 20:48 | scramflot | It'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:49 | rhickey | I didn't put the reference placeholder there, someone else added it |
| 20:50 | scramflot | oh. 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:51 | rhickey | I put some advice at the top now so people will know not to do that. |
| 20:59 | scramflot | rhickey: 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:00 | scramflot | ermm. not binding |
| 21:00 | scramflot | I mean parameters |
| 21:00 | rhickey | the names in the vector get bound to the corresponding parts of the argument |
| 21:01 | scramflot | but one wouldn't see (def a (b) b) ever? |
| 21:03 | scramflot | or even (def a {b} b) |
| 21:09 | travisbrady | i'm a complete newb (i'm a python programmer with some haskell experience) and i'm working through the Getting STarted page |
| 21:09 | travisbrady | and in trying to run: java -cp jline-0.9.91.jar:clojure.jar jline.ConsoleRunner clojure.lang.Repl src/boot.clj |
| 21:10 | travisbrady | i get: Exception in thread "main" java.lang.NoClassDefFoundError: jline/ConsoleRunner |
| 21:10 | travisbrady | i assume this is a CLASSPATH issue, but i can't really make heads or tails of it |
| 21:10 | scramflot | travisbrady: rplace jline with it's absolute path |
| 21:10 | travisbrady | anyone know what that is off hand? |
| 21:10 | scramflot | replace |
| 21:11 | scramflot | In fact, put all absolute paths in there, then make a shell script to just run it.. much easier |
| 21:11 | rhickey | scramflot: there's no structural binding in def |
| 21:11 | scramflot | rhickey: yea, I think I messed up my example |
| 21:12 | travisbrady | is JLine included with the clojure zip? or will i need to install that? |
| 21:12 | scramflot | (def a [b] b) (a 1) doesn't return 1, right? |
| 21:13 | travisbrady | anyway, great job Rich and team with the clojure site and docs |
| 21:13 | scramflot | no, there should be a link to it on the page where you saw the line |
| 21:13 | travisbrady | scramflot: ok, thank you |
| 21:13 | rhickey | there's no team :) |
| 21:14 | scramflot | (def a [a b c]) actually binds the vector to a |
| 21:14 | rhickey | binds a to the vector, yes |
| 21:14 | travisbrady | rhickey: just wanted to be inclusive |
| 21:15 | travisbrady | rhickey: excellent job to you then |
| 21:15 | scramflot | (defn nice [a] a) (nice 1) returns 1 then |
| 21:15 | rhickey | right |
| 21:16 | rhickey | travisbrady: if you can deal with emacs, clojure mode there is much more powerful than jline |
| 21:17 | travisbrady | rhickey: yeah, i'm setting that up now |
| 21:18 | scramflot | so, I guess what I'm asking is.. would this work? (def b [1]) (defn nice b (b)) -> 1 .. because b is a vector? |
| 21:19 | scramflot | or.. no |
| 21:19 | scramflot | cause defn doesn't evaluate until you pass it values |
| 21:19 | rhickey | right |
| 21:20 | rhickey | it is a macro that processes forms |
| 21:20 | rhickey | the form b is not a macro, it's a symbol |
| 21:20 | rhickey | er, is not a vector |
| 21:20 | scramflot | right right |
| 21:21 | scramflot | could one expand a symbol into a vector at the time of macro processing? |
| 21:21 | rhickey | no |
| 21:22 | scramflot | I guess what sparked the question in my mind was the bit about eval and programmatic evaluation |
| 22:08 | scramflot | trying to list the files in a directory: |
| 22:08 | scramflot | (import '(java.io File)) |
| 22:08 | scramflot | (defn ls-f [] |
| 22:09 | scramflot | (let [file (new File "home/john/tmp")]) |
| 22:09 | scramflot | (. file listFiles)) |
| 22:10 | scramflot | CompilerExecptoin: Unable to resolve symbol: file in this context |
| 22:11 | scramflot | And here's the code I'm trying to move over: http://www.rosettacode.org/rosettacode/w/index.php?title=Walk_Directory_Tree#Java |
| 22:11 | scramflot | (eventually it'll walk the directory |
| 22:11 | scramflot | ) |
| 22:11 | rhickey | let only binds file until its closing paren |
| 22:14 | scramflot | oh |
| 22:14 | scramflot | misread the swing app example.. thanks |
| 22:18 | scramflot | If 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:21 | scramflot | user=> (defn ls-f [] (let [file (new File "/home/john/tmp")] (. file listFiles))) has Clojure talking about parse errors |
| 22:22 | scramflot | CompilerException: REPL:27: listFiles |
| 22:23 | rhickey | I 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:23 | rhickey | e.g. (. file (listFiles)) |
| 22:28 | scramflot | but 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. |