Re: IDE agnostic question on user assistance (emacs/vimClojure users help appreciated too !)
On Jul 20, 10:15 am, Laurent PETIT laurent.pe...@gmail.com wrote: Oh, maybe I understand: by partial drafts, you mean pseudo-code, directly written in clojure, is it this ? It could be pseudo-code or partial implementations or code that is more or less complete but won't compile because the functions or libs it is using aren't written yet. Or a number of other things that might cause compilation to fail. The non-compiling code tends to be syntactically correct, at least enough to get the Enclojure paren-matching, bulk formatting and code navigator to work - these are all things I want to help me quickly navigate the drafts. If there was a shortcut key to quickly wrap/unwrap a top level defn with (comment), and if the keyboard shortcut for evaluate top level form in the REPL would be smart enough to detect top level comment and send to the REPL the unwrapped form, would it help you ? That way, your files would visually show the pseudo-code parts (those within comments), and your namespaces will remain in a loadable shape, eventually relieving you from manually load your project piece by piece every time you must restart a REPL ? Actually, it's an interesting idea. If I were to think aloud on a possible feature in a future IDE, it could go something like this: - Some special markup for pseudo-code. Not (comment) as it is already used for comments, but perhaps something like (pseudo) or (draft). It would act as a comment from the compiler's perspective but the IDE could treat it differently. Or perhaps a keyword argument to comment, ignored by the compiler but read by the IDE - like (comment :pseudo ). - The contents of (pseudo) would be parsed and displayed in the code navigator window (I assume CCW has one as well?) as a distinct group or marked in some other way, so you could at a glance see which functions/vars are implemented and which ones are still at the draft stage. It would be a code-level TODO-list of sorts. It would have the advantage over what I am doing in Enclojure today that I could load the non-draft functions without resorting to evaluate expression, and the navigator window would explicitly show me what remains to be implemented. Very handy for large files. I can't see the immediate need to send pseudo-code to the REPL - it's in the pseudo-tag because it doesn't work, isn't it? (Copy/paste works fine for those rare occasions where I might want to do so anyway.) I would probably edit it in the editor, move it out of the pseudo-tag when it is ready for testing and evaluate it then. I guess something like this would take a few iterations to get right, but I imagine I would find it very useful. Regards jf -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: IDE agnostic question on user assistance (emacs/vimClojure users help appreciated too !)
On Wed, Jul 21, 2010 at 9:33 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Jul 21, 1:35 pm, Jeff Rose ros...@gmail.com wrote: Really, there isn't a way to start processes from VIM? How about just opening a temporary buffer for the output of the nailgun server, and then start it with a bang!? I was a but unclear on what I mean with background: I can start processes from Vim. That's not the problem. But then Vim waits for them to complete. And no. Adding doesn't help, because it doesn't work in Windows. So you fire up your server and have a waiting Vim which cannot be used anymore. Ah, the attainments of single-threaded applications. There is certainly no race condition. Bleh. :( If this was not the case I could offer such a starter command. Although I doubt it has much value, because Vim's started from the graphical user interface don't know your project directory. So starting at plugin load would not work. So you need another command (maybe key bindings) to start the server after changing the vim cwd (or providing it as an argument). Complexity creeps in for a non- issue. Apologies if you know all this Meikel, but have you seen http://vim.wikia.com/wiki/Execute_external_programs_asynchronously_under_Windows ? --Aaron -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Access function argument from outer anonymous function
When I use the reader macro for anonymous functions I can use % to access the function argument: #(... % ...) This is great. When I nest these however: #(.. #(.. % ..) ) Is there a way to access the function argument for the outer anonymous function from inside the inner one? E.g, it would be handy if % was rebound to %% (or some other magic). At the moment I've had to convert my outer anonymous function to use (fn [x] ..) style to allow me to use % and x inside the inner anonymous function. -- Paul Richards @pauldoo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Access function argument from outer anonymous function
On Thu, Jul 22, 2010 at 10:36, Paul Richards paul.richa...@gmail.com wrote: When I use the reader macro for anonymous functions I can use % to access the function argument: #(... % ...) This is great. When I nest these however: #(.. #(.. % ..) ) Is there a way to access the function argument for the outer anonymous function from inside the inner one? E.g, it would be handy if % was rebound to %% (or some other magic). At the moment I've had to convert my outer anonymous function to use (fn [x] ..) style to allow me to use % and x inside the inner anonymous function. That's the way to go. Or are you intentionally trying to make your code cryptic? // Ben -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Access function argument from outer anonymous function
Hi, On Jul 22, 10:36 am, Paul Richards paul.richa...@gmail.com wrote: When I nest these however: #() cannot be nested. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Slime, debug-repl clojure debugging toolkit
On Jul 21, 4:43 pm, George Jahad cloj...@blackbirdsystems.net wrote: Karl, I use the debug-repl all the time and don't see errors like this. You can use the standard debug-repl from with slime's *inferior-lisp* buffer. Try it from there and see what you get. If that fails, try it from outside of emacs entirely in a regular command line repl and see if it behaves differently there. Let me know how it goes. Thanks, g Hi George, thanks for helping out. I can reproduce a number of different behaviours as follows. Note, I am using clojure-1.2.0-master-SNAPSHOT with :dev-dependencies [[swank-clojure 1.2.1] [org.clojars.gjahad/debug-repl 0.3.0-SNAPSHOT] [cdt 1.0.1-SNAPSHOT] ] 1) Start emacs, run M-x swank-clojure-project. From the *slime-repl clojure* buffer run: ; SLIME 20100404 user (use 'alex-and-georges.debug-repl) nil user (let [c 1 d 2] (defn a [b c] (debug-repl) d)) (a foo bar) dr-1-1001 = (+ 2 3) Now it hangs, not evaluating (+ 2 3). 2) Start emacs, run M-x swank-clojure-project. From the *inferior-lisp* buffer run: user= (use 'alex-and-georges.debug-repl) nil user= (let [c 1 d 2] (defn a [b c] (debug-repl) d)) (a foo bar) #'user/a user= dr-1-1001 = (+ 2 3) 5 dr-1-1001 = b foo dr-1-1001 = c bar dr-1-1001 = (quit-dr) alex_and_georges.debug_repl.proxy$java.lang.Exception$Enumeration $f482e887 dr-1-1001 = b foo dr-1-1001 = c bar dr-1-1001 = (exit-dr) java.lang.Throwable: Exiting back to main repl from debug-repl dr-1-1001 = b foo dr-1-1001 = c bar dr-1-1001 = so it seems I can't escape back to the main repl. 3) From a shell run: krukow:~/workspaces/trifork/intrafoo_clj$ lein swank Listening for transport dt_socket at address: 8030 WARNING: group-by already refers to: #'clojure.core/group-by in namespace: clojure.contrib.pprint, being replaced by: #'clojure.contrib.pprint/group-by user= Connection opened on local port 4005 #ServerSocket ServerSocket[addr=localhost/ 127.0.0.1,port=0,localport=4005] start emacs and M-x slime-connect From *slime-repl clojure* buffer, run: ; SLIME 20100404 user (use 'alex-and-georges.debug-repl) nil user (let [c 1 d 2] (defn a [b c] (debug-repl) d)) (a foo bar) dr-1-1001 = 2 user it seems to immediately quit the debug-repl (not sure why it writes 2). 4) From a shell start a regular repl. This works like case 2. In 2,4 I just realized I can exit the debug-repl with C-d. In case 4 this works, in case 2 it exits both the debug-repl and the regular repl :( Ideally I would like to run case 3 with lein swank as that lets me set JVM options so I can use the Clojure Debugging Tool. Any ideas? /Karl -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Slime, debug-repl clojure debugging toolkit
On Jul 21, 4:02 pm, Ramakrishnan Muthukrishnan vu3...@gmail.com wrote: On Wed, Jul 21, 2010 at 6:04 PM, Krukow karl.kru...@gmail.com wrote: 0: com.trifork.intrafoo.clj.extract_contacts $extract_all.invoke(NO_SOURCE_FILE:1) Locals: pref = /Users/krukow/workspaces/trifork/intrafoo_clj/ contactdata/ cli = org.apache.commons.httpclient.httpcli...@6078b973 cs = [411719 413255 413279 In the repl I can hit ENTER: I don't seem to get this problem. user (defn foobar [] (let [a 10 b 20] (swank.core/break) (* a b))) #'user/foobar user (foobar) (I switch back to slime-repl and hit enter, this drops me into the repl. nil user a 10 user b 20 -- Ramakrishnan Yes that works for me too. But the problem seems to happen because I have a Java object in scope. user (import 'org.apache.commons.httpclient.HttpClient) user (defn foobar [] (let [a (HttpClient.) b 20] (swank.core/break) (* a b))) #'user/foobar user (foobar) nil user a Gives: Can't embed object in code, maybe print-dup not defined: org.apache.commons.httpclient.httpcli...@5406f513 [Thrown class java.lang.RuntimeException] Restarts: 0: [QUIT] Quit to the SLIME top level 1: [ABORT] ABORT to SLIME level 0 /Karl -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Literate Clojure - a good lead ...
On Thursday 22 July 2010 03:41:15 martin_clausen wrote: Hi Martin, A good example of this for a non-trivial app is here: http://genprog.adaptive.cs.unm.edu/asm/instructions.html I guess that's the wrong link... Viele Grüße, Tassilo On Jul 21, 8:54 am, Tassilo Horn tass...@member.fsf.org wrote: On Wednesday 21 July 2010 06:32:02 Mark Engelberg wrote: Hi Mark, I would definitely welcome a literate Clojure tool. You might want to have a look at Emacs' org-mode [1]. It has a facility called Babel [2] that allows for literate programming in all the languages listed at [3], Clojure being one of them, and support for new languages is being added frequently. Currently it is moved from the contribution directory to the org core, and the documentation is being updated or written at all. Bye, Tassilo __ [1]http://orgmode.org/ [2]http://orgmode.org/manual/Working-With-Source-Code.html#Working-With-... [3]http://orgmode.org/manual/Languages.html#Languages -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Literate Clojure - a good lead ...
On Thursday 22 July 2010 12:08:15 Martin Clausen wrote: No it is right. The .org file can be found in the source code archive: http://genprog.adaptive.cs.unm.edu/asm/asm-gp.tar.bz2 Oh, I see. A very nice example. :-) Bye, Tassilo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Memoizing a recursive function?
Lets say I have the following function (defn fib[n] (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) and I want to memoize it, what is the right way to do it? Using the default memoize does not work correctly. the reason is even though the first call to fib is memoized, the recursive calls go to the original fib, and not the memoized function. Even using (def fib (memoize fib)) does not seem to work. if you run (fib 45) and (fib 46), in the ideal case, (fib 47) should just call the memoized (fib 45) and (fib 46) and return almost immediately, but that is not the case. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: gobble up a collection 2 at a time
(partition 2 coll) will give you the sequence two at a time. To map your function, you'd do (map #(apply myfcn %) (partition 2 '(1 2 3 4 5 6 7 8))) On Jul 21, 10:20 pm, Glen Rubin rubing...@gmail.com wrote: Hi! I want to process a collection 2 elements at a time using map. My function accepts 2 parameters (a,b) and returns a result (c): (myfcn [a b]) = c so I want to iterate myfcn over a collection and create a new sequence for example let's say myfcn sums a and b, then i would like to do something like this: (map myfcn '(1 2 3 4 5 6 7 8) = 3 7 11 15 accept i get the error that myfcn is being passed the wrong number of arguments, since map is passing them in 1 at a time. How do I get map to pass in 2 at a time? thx! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Literate Clojure - a good lead ...
Tim Daly d...@axiom-developer.org writes: Antony Blakey wrote: The essence of the PLT model is the language integration that allows symbol resolution by reusing the language mechanism for the documentation. Language integration is a false goal. It is technically possible to call functions in any language from latex but unnecessary in general. Language integration is a very concrete goal. If you look at the PLT (which I'll refer to as Racket blow) documentation, you'll see the result of this integration wherever code appears, bindings are rendered as links to the place where they're defined. This is not something that you can easily do, more so when you have an environment like Racket where certain names are bound by several modules. In Scribble, this integration means that the *same* facility that is used to resolve module names and link bindings is also used in the documentation system. In other words, when you use `foo' in a piece of text, you import its definition in the same way that you do so in code -- and the system makes sure that it is rendered accurately. It is technically possible to generate latex from any language. (That's trivially true for any language that can print text.) Symbol resolution is also rarely an issue in literate programs. That's very much understating the benefit of how Scribble deals with bindings. Take for example a page from a page that was rendered by the scribble literate programming tool: http://docs.racket-lang.org/games/Breadth-first_Search.html Reading such code where every identifier is linked to its documentation makes this a much more effective document. Note also that the Scribble literate programming library is not the main focus of the system (or the main focus of the paper). Unlike dealing with bindings, which is one of the key aspects of Scribble, in all forms. Your prose is intended to explain why a code chunks exists, not how a code chunk works. If you explain the problem you are trying to solve and the issues of various approaches you considered then I can usually understand the solution. (Coincidentally, I dislike literate programming as a paradigm exactly because it creates a strong focus on the how part. The fact that the code should all be in the document means that I'm forced to talk about all kinds of below-the-api technicalities that are irrelevant for most users of my code.) Choosing the right approach matters. It is technically possible to write clojure code in Microsoft word but utterly painful since MSWord does not have a programming focus. It is possible to write a book in PLT Scheme but painful for the same reason. I've read your followup, but this really makes me think that you didn't read the paper. Writing a book in Racket using Scribble is extremely close to writing one in latex... If your intention is to write a literate program, which as Knuth defined it, to be a piece of literature, use a tool designed for literature. ...and more to the point: the default mode of writing in Scribble (again, whether you're using the literate programming library or not) is writing marked-up text. It is very much a tool that is designed for literature. -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Memoizing a recursive function?
You should make a LazySeq to momoize intermediate result: (defn fib[n] (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) (def fib (memoize fib)) (def fib-seq (map fib (iterate inc 0))) then take the result by nth: user= (nth fib-seq 45) 1134903170 user= (nth fib-seq 46) 1836311903 user= (nth fib-seq 47) 2971215073 The only problem is that the fib-seq would cosume more memories to hold intermediate result. On Jul 22, 5:47 am, logan duskli...@gmail.com wrote: Lets say I have the following function (defn fib[n] (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) and I want to memoize it, what is the right way to do it? Using the default memoize does not work correctly. the reason is even though the first call to fib is memoized, the recursive calls go to the original fib, and not the memoized function. Even using (def fib (memoize fib)) does not seem to work. if you run (fib 45) and (fib 46), in the ideal case, (fib 47) should just call the memoized (fib 45) and (fib 46) and return almost immediately, but that is not the case. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: BUG: Clojure hierarchies (affects 1.2-beta1)
I closed #406: this is a subset of the issue already covered under #382, which Rob was planning to do a patch for. Rich, can you check and see if CAs have arrived from Rob Lachlan and Michał Marczyk? Stu Made a ticket for this here (including the simple diagnosis): https://www.assembla.com/spaces/clojure/support/tickets/406-typo-in-underive-causes-breaking-in-the-resulting-hierarchy No patch, since my CA wasn't ack'd yet... Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
CCW in Eclipse Market Place + needs a logo !
Hello, Just a word to inform you that I've provisioned the Eclipse Market Place for Counterclockwise. That way, installing counterclockwise from Eclipse Helios is even simpler than before: use the new Install from Market Place feature, search for Counterclockwise, install. But we need a logo ! If there's an area where I dooon't shine at all, it's graphics. If somebody feels like he could provide a logo for Counterclockwise in an open-source / loyaltie free way, help very welcome ! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Memoizing a recursive function?
On Wed, 21 Jul 2010 14:47:12 -0700 (PDT) logan duskli...@gmail.com wrote: Lets say I have the following function (defn fib[n] (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) and I want to memoize it, what is the right way to do it? Use defn-memo from clojure.contrib.def. mike -- Mike Meyer m...@mired.org http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. O ascii ribbon campaign - stop html mail - www.asciiribbon.org -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Memoizing a recursive function?
Another solution, use the var, and then use memoize on your function as usual: (defn fib[n] (if ( n 2) (+ (#'fib (- n 2)) (#'fib (- n 1 (of course this was to answer closely to the question. Nobody would write fib like that in practice : good general question, bad example) HTH, -- Laurent 2010/7/22 Mike Meyer mwm-keyword-googlegroups.620...@mired.org On Wed, 21 Jul 2010 14:47:12 -0700 (PDT) logan duskli...@gmail.com wrote: Lets say I have the following function (defn fib[n] (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) and I want to memoize it, what is the right way to do it? Use defn-memo from clojure.contrib.def. mike -- Mike Meyer m...@mired.org http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. O ascii ribbon campaign - stop html mail - www.asciiribbon.org -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Confusing compiler error in defrecord and deftype.
Stuart Halloway wrote: I have created a ticket for this at https://www.assembla.com/spaces/clojure/tickets/405-better-error-messages-for-bad-defrecord-calls. The ticket comment includes instructions for how and where to patch this. If anyone has been frustrated by Clojure's error messages and is looking for an easy way to contribute, have at it. :-) Do I need to have my CA on file before I can contribute? I have them signed and ready to ship anyway... Regards, BG -- Baishampayan Ghose b.gh...@ocricket.com oCricket.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Memoizing a recursive function?
(def fib (memoize (lambda ...))) On Jul 22, 1:25 pm, Laurent PETIT laurent.pe...@gmail.com wrote: Another solution, use the var, and then use memoize on your function as usual: (defn fib[n] (if ( n 2) (+ (#'fib (- n 2)) (#'fib (- n 1 (of course this was to answer closely to the question. Nobody would write fib like that in practice : good general question, bad example) HTH, -- Laurent 2010/7/22 Mike Meyer mwm-keyword-googlegroups.620...@mired.org On Wed, 21 Jul 2010 14:47:12 -0700 (PDT) logan duskli...@gmail.com wrote: Lets say I have the following function (defn fib[n] (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) and I want to memoize it, what is the right way to do it? Use defn-memo from clojure.contrib.def. mike -- Mike Meyer m...@mired.org http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. O ascii ribbon campaign - stop html mail -www.asciiribbon.org -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Typed Racket
Mark Engelberg mark.engelb...@gmail.com writes: It is my understanding that Typed Racket programs do not run any faster than their dynamically-typed counterparts, and in fact commonly run slower because there are a lot of additional runtime checks that must be inserted to handle various types of unsafe calls that can cross module boundaries or be executed at the REPL. Typed Racket is purely about safety, not about speed. [...] 1. The dynamic type checks are contracts, which happen only on interaction between typed and untyped code. The cost is therefore not larger than the cost of contracts, and if you're talking about code inside a single module, or involving several typed ones, then there is no runtime cost at all. 2. Typed Racket used to be only about safety, but there's no intention to avoid using it for speed. Recently there has been work invested in making statically-typed code use unsafe operations, which can make code run significantly faster. It's not publicly advertised, yet, but it's not too far from it. -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: IDE agnostic question on user assistance (emacs/vimClojure users help appreciated too !)
Hi, On Jul 22, 8:45 am, Aaron Cohen aa...@assonance.org wrote: Apologies if you know all this Meikel, but have you seenhttp://vim.wikia.com/wiki/Execute_external_programs_asynchronously_un... ? Thanks for the pointer. In fact I haven't seen this. I'm obviously googling the wrong keywords. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Memoizing a recursive function?
nevermind, the following code does not work. Jules' one is the right one 2010/7/22 Laurent PETIT laurent.pe...@gmail.com Another solution, use the var, and then use memoize on your function as usual: (defn fib[n] (if ( n 2) (+ (#'fib (- n 2)) (#'fib (- n 1 (of course this was to answer closely to the question. Nobody would write fib like that in practice : good general question, bad example) HTH, -- Laurent 2010/7/22 Mike Meyer mwm-keyword-googlegroups.620...@mired.org On Wed, 21 Jul 2010 14:47:12 -0700 (PDT) logan duskli...@gmail.com wrote: Lets say I have the following function (defn fib[n] (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) and I want to memoize it, what is the right way to do it? Use defn-memo from clojure.contrib.def. mike -- Mike Meyer m...@mired.org http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. O ascii ribbon campaign - stop html mail - www.asciiribbon.org -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: BUG: Clojure hierarchies (affects 1.2-beta1)
I sent in my CA some weeks ago. I have a patch ready, with tests, and now I'm just waiting to be let in to clojure-dev + assembla. As I mentioned in the other thread, there are other problems with underive -- essentially the hierarchy can become inconsistent in cases of multiple inheritance, over and beyond the incorrect key being used in the map. http://groups.google.com/group/clojure/browse_thread/thread/b70f8bf16de2216 On Jul 22, 3:36 am, Stuart Halloway stuart.hallo...@gmail.com wrote: I closed #406: this is a subset of the issue already covered under #382, which Rob was planning to do a patch for. Rich, can you check and see if CAs have arrived from Rob Lachlan and Michał Marczyk? Stu Made a ticket for this here (including the simple diagnosis): https://www.assembla.com/spaces/clojure/support/tickets/406-typo-in-u... No patch, since my CA wasn't ack'd yet... Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: [ccw-users] CCW in Eclipse Market Place + needs a logo !
On 22 Jul 2010, at 13:09, Laurent PETIT wrote: But we need a logo ! If there's an area where I dooon't shine at all, it's graphics. Me neither, but here is an idea: start from the nicely circular Clojure logo and add a circular arrow pointing counterclockwise. The arrow could cover 2/3 of the white ring in the logo. Of course I don't know if using the Clojure logi as a starting point implies any nasty copyright problems. Konrad. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Two convenience methods
*sigh* ... it was a typo. Good catch! On Jul 21, 10:16 pm, B Smith-Mannschott bsmith.o...@gmail.com wrote: On Wed, Jul 21, 2010 at 23:45, Travis Hoffmantravis.a.hoff...@gmail.com wrote: ... The second function is suggested as an addition to clojure.set. The disjoint? function decides if two sets have no elements in common. This can easily be done using: (not (nil? (intersection s1 s2))) but this implementation should be more efficient (I think) and is more readable, imho: (defn disjoint? Is set1 disjoint from set2? {:added 1.3 :tag Boolean} [set1 set2] (if (= (count set1) (count set2)) (recur set2 set1) (not-any? (fn [item] (contains? item set1)) set2))) so, when set1 and set2 are the same size, we recur, swapping the order of the two arguments, which means set2 and set1 are the same size, so we recur, swapping the two arguments, which means ... (if ( (count set1) (count set2)) (recur set2 set1) ...) would be better, no? // ben -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Two convenience methods
Frederick, I agree with all you said; perhaps this is as much my personal coding style. Also, I'm seeing Clojure through beginner's eyes. What I love about Clojure is the readability and the naturalness of the names of functions. While skimming the API, I was looking for the natural opposite of (not- any? pred coll) function. My initial though was, Aha! There must be a function (any? pred coll). That only seems natural to me, since there is both (every? pred coll) and (not-every? pred coll). It took me quite a bit of searching to realize that (some pred coll) does what I need. So, to me, (any? pred coll), just seems natural, even if it is little more than sugar. Also, comparing these two statements: (disjoint? s1 s2) (empty? (intersection s1 s2)) To me, the simpler the better, and therefore the more readable. So, again, personally, I find the former to be easier, simpler, more direct and to the point. Thanks for the link too! Cheers, -Travis On Jul 21, 6:14 pm, Frederick Polgardy f...@polgardy.com wrote: Oops, you already said that, my bad. :) -- Science answers questions; philosophy questions answers. On Jul 21, 2010, at 8:13 PM, Frederick Polgardy wrote: Or [using clojure.set] (empty? (intersection s1 s2)). -- Science answers questions; philosophy questions answers. On Jul 21, 2010, at 4:45 PM, Travis Hoffman wrote: The second function is suggested as an addition to clojure.set. The disjoint? function decides if two sets have no elements in common. This can easily be done using: (not (nil? (intersection s1 s2))) but this implementation should be more efficient (I think) and is more readable, imho: (defn disjoint? Is set1 disjoint from set2? {:added 1.3 :tag Boolean} [set1 set2] (if (= (count set1) (count set2)) (recur set2 set1) (not-any? (fn [item] (contains? item set1)) set2))) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojure tag wiki on Stack Overflow
Hi All, Stack Overflow has recently introduced a new concept of tag wikis. Here's the one for Clojure: http://stackoverflow.com/questions/tagged?sort=infotagnames=clojure I thought it would be useful to put a general notice about what Clojure is and which resources might be most helpful to beginners up there, so I've just edited a basic summary and some links. I'm sure this can be improved upon, so -- any suggestions? :-) There is a 100 upvotes on non-community wiki answers in the tag requirement for editing the tag wiki; I will happily edit in any good suggestions from interested parties who do not meet this criterion. Better yet, let's reach a consensus on the ideal shape of our SO tag wiki first, then someone with enough Clojure answer rep can edit it in. As an example, so far the only really fleshed out tag wiki that I've seen is Python's [1]. All the best, Michał [1] http://stackoverflow.com/questions/tagged?tagnames=pythonsort=infopagesize=15 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Memoizing a recursive function?
Why not simply do: (defn fib [n] (println called with n) (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) (def fib (memoize fib)) I inserted the println to verify when we were actually calling the function, and I believe this works - fib only seems to get invoked a single time for any given n. Is this solution incorrect in some way? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN: clj-dropbox, Dropbox client library in Clojure
Hi all, I've released my clojure library for accessing the Dropbox API. Its called clj-dropbox and it can be found at: http://github.com/aria42/clj-dropbox Hope some people get use out of it. Feel free to email or leave comments and/or suggestions Best, Aria -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: BUG: Clojure hierarchies (affects 1.2-beta1)
On 22 July 2010 12:36, Stuart Halloway stuart.hallo...@gmail.com wrote: I closed #406: this is a subset of the issue already covered under #382, which Rob was planning to do a patch for. Oh, sorry for the duplicate then. I thought I searched for underive, but I guess I didn't (or made a typo or something...). Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
RFC on my letrec macro
Hi All, I've written a letrec macro with the goal of hopefully tying the knot [1] in Clojure etc. Some examples of what it can do are included in the Gist (including -- as of now -- two not immediately rewritable in terms of letfn). So far I haven't caught any bugs, but hey, it's about an hour old and the knot is still untied... Any comments / suggestions / remarks on this being crazy? http://gist.github.com/486880 Sincerely, Michał [1] http://www.haskell.org/haskellwiki/Tying_the_Knot -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Slime, debug-repl clojure debugging toolkit
1) Start emacs, run M-x swank-clojure-project. From the *slime-repl clojure* buffer run: ; SLIME 20100404 user (use 'alex-and-georges.debug-repl) nil user (let [c 1 d 2] (defn a [b c] (debug-repl) d)) (a foo bar) dr-1-1001 = (+ 2 3) Now it hangs, not evaluating (+ 2 3). the slime repl is a split repl, stdin/stdout are connected to emacs which processes the io and then sends it on to a separate java vm. the standard clojure repl connects stdin/out directly to the java vm. the debug-repl also works this way. so the debug repl can't be used with the slime repl directly, but only through the *inferior lisp* buffer. that's why Hugo Duncan enhanced the slime repl to be similar to the debug repl, but you have to use swank/break for that. 2) Start emacs, run M-x swank-clojure-project. From the *inferior-lisp* buffer run: user= (use 'alex-and-georges.debug-repl) nil user= (let [c 1 d 2] (defn a [b c] (debug-repl) d)) (a foo bar) #'user/a user= dr-1-1001 = (+ 2 3) 5 dr-1-1001 = b foo dr-1-1001 = c bar dr-1-1001 = (quit-dr) alex_and_georges.debug_repl.proxy$java.lang.Exception$Enumeration $f482e887 dr-1-1001 = b foo dr-1-1001 = c bar dr-1-1001 = (exit-dr) java.lang.Throwable: Exiting back to main repl from debug-repl dr-1-1001 = b foo dr-1-1001 = c bar dr-1-1001 = so it seems I can't escape back to the main repl. this is a bug in the debug-repl's quit and exit routines, which i hadn't noticed before because i always use the empty list, () , to exit. Try that. ctrl-d also works, but is a little dangerous because you risk exiting all the way out of the original repl. 3) From a shell run: krukow:~/workspaces/trifork/intrafoo_clj$ lein swank Listening for transport dt_socket at address: 8030 WARNING: group-by already refers to: #'clojure.core/group-by in namespace: clojure.contrib.pprint, being replaced by: #'clojure.contrib.pprint/group-by user= Connection opened on local port 4005 #ServerSocket ServerSocket[addr=localhost/ 127.0.0.1,port=0,localport=4005] start emacs and M-x slime-connect From *slime-repl clojure* buffer, run: ; SLIME 20100404 user (use 'alex-and-georges.debug-repl) nil user (let [c 1 d 2] (defn a [b c] (debug-repl) d)) (a foo bar) dr-1-1001 = 2 user it seems to immediately quit the debug-repl (not sure why it writes 2). again, use the empty list. 4) From a shell start a regular repl. This works like case 2. In 2,4 I just realized I can exit the debug-repl with C-d. In case 4 this works, in case 2 it exits both the debug-repl and the regular repl :( Ideally I would like to run case 3 with lein swank as that lets me set JVM options so I can use the Clojure Debugging Tool. as i explained above you have to use swank/break with case 3. in addition to these 4 cases, it sounds like you are having a problem viewing the local java object, which is why i suggested using the vanilla debug-repl. I want to see if it has the same problem, because I use it all the time and have never seen that problem. I'm trying to determine if the bug is only in swank/break, or in the debug-repl too. (I'm also trying to make people aware of the various combinations/options available.) Keep me posted! thanks, g -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Memoizing a recursive function?
Here is what I get: (and BTW, my original version with #' seems to work, I'm a little bit puzzled ...) user= (defn fib [n] (println called with n) (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) (def fib (memoize fib)) #'user/fib user= user= #'user/fib user= (fib 6) called with 6 called with 4 called with 2 called with 3 called with 1 called with 2 called with 5 called with 3 called with 1 called with 2 called with 4 called with 2 called with 3 called with 1 called with 2 8 user= (defn fib [n] (println called with n) (if ( n 2) (+ (#'fib (- n 2)) (#'fib (- n 1))) 1)) (def fib (memoize fib)) #'user/fib user= user= #'user/fib user= (fib 6) called with 6 called with 4 called with 2 called with 3 called with 1 called with 5 8 user= 2010/7/23 Paul Mooser taron...@gmail.com Why not simply do: (defn fib [n] (println called with n) (if ( n 2) (+ (fib (- n 2)) (fib (- n 1))) 1)) (def fib (memoize fib)) I inserted the println to verify when we were actually calling the function, and I believe this works - fib only seems to get invoked a single time for any given n. Is this solution incorrect in some way? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: RFC on my letrec macro
On 23 July 2010 06:50, George Jahad cloj...@blackbirdsystems.net wrote: i like it a lot! what do you think of adding trampoline to it like so: http://gist.github.com/487019 Thanks! Trampoline in letrec automatically breaks all cases where the value being bound to the local is not a function, so it would interfere with what I'm trying to do. Having said that, it seems to me that it's a very cool idea for a custom letfn variant permitting mutual recursion of unbounded depth. I'll investigate this further. All the best, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en