Bug in read-line?

2008-12-13 Thread Michel Salim
Using up-to-date clojure and swank-clojure, I've not been able to use read-line: - In Emacs (with Slime / swank-clojure), (read-line) never stops consuming inputs - Running clojure directly from a terminal console, (read-line) always returns "" This exception is also thrown when starting Swank:

Re: Bug in read-line?

2008-12-13 Thread Michel Salim
On Dec 13, 4:26 am, Michel Salim wrote: > Using up-to-date clojure and swank-clojure, I've not been able to use > read-line: > > - In Emacs (with Slime / swank-clojure), (read-line) never stops > consuming inputs > > - Running clojure directly from a terminal c

Re: performance question

2008-12-13 Thread Michel Salim
On Dec 13, 10:41 am, Dmitri wrote: > I wrote a simple word counter described herehttp://ptrace.fefe.de/wp/ > it reads stdin and counts the occurrences of words, however I notice > that it runs significantly slower than the java version in the link. > > I was wondering why there is such a dramatic

Re: Is 'mapcat' name that logic ?

2008-12-13 Thread Michel Salim
On Dec 13, 8:28 am, lpetit wrote: > Hello, > > I wanted to know if I was alone thinking that 'mapcat' should better > have been named 'catmap' ? > When reading code, this looks more natural because it resembles the > functional composition of the 2 functions : (cat (map ...)) > mapcat, I take to

Re: newbie question on true?

2008-12-13 Thread Michel Salim
On Dec 13, 9:27 am, wubbie wrote: > > My question is what's the usage for ture?. I don't see a meaningful > example on usage of true? > At the very least, when you have to interface with Java? Also, your code might use true as a special value -- say as values inside a key to indicate you don't ca

Re: Fibonacci: Clojure vs the World

2008-12-14 Thread Michel Salim
On Dec 14, 9:01 am, Mike Perham wrote: > Hi, I'm just learning Clojure but I thought I would do a little > experiment to see where Clojure sits performance-wise compared to a > number of other languages on the old Fibonacci sequence.  I think it > handles itself quite well. > > The full writeup

Re: Bug in read-line?

2008-12-14 Thread Michel Salim
n (which runs a repl by default). The   > reading done by the latter is intended to be identical to the reading   > done by the former but isn't in the case of read-line. If anyone sees   > the fix before I find it, please let me know. > > --Steve > > On Dec 13, 2008, at 10:

Bug in unchecked operations?

2008-12-14 Thread Michel Salim
This follows from the recent micro-benchmarking discussion, though as it concerns a potential bug, I'm starting a new thread. With this (very inefficient) implementation of fib, (defn fib [n] (if (<= n 1) 1 (+ (fib (dec n)) (fib (- n 2) computing (fib 40) takes, give or take, 12 s

Re: Fibonacci: Clojure vs the World

2008-12-14 Thread Michel Salim
On Dec 14, 12:08 pm, James Reeves wrote: > On Dec 14, 2:01 pm, Mike Perham wrote: > > > Hi, I'm just learning Clojure but I thought I would do a little > > experiment to see where Clojure sits performance-wise compared to a > > number of other languages on the old Fibonacci sequence.  I think

Re: Bug in unchecked operations?

2008-12-14 Thread Michel Salim
My mistake; unchecked operations work just fine if their arguments (including constants) are given type hints. What happens if unchecked- add/sub/... is given an argument of unknown type, though? It still seems to work, though slowly. On Dec 14, 12:35 pm, Michel Salim wrote: > This follows f

Re: Emtpy (filter ...) Result Yields nil; Could / Should It Be An Empty List?

2008-12-14 Thread Michel Salim
On Dec 14, 3:16 pm, Randall R Schulz wrote: > Does this makes sense (specifically the last one)? > > user=> (flatten []) > nil > > user=> (flatten ()) > nil > Yes; the empty sequence is just nil. > user=> (flatten nil) > (nil) > That does look like a bug. -- Michel --~--~-~--~~--

Re: Example of use of Atom: Fibonacci generator

2009-02-15 Thread Michel Salim
On Feb 15, 2:44 pm, timc wrote: > I'm new to Clojure, just thought I would share this. > I was playing around, trying to understand Atoms and I devised a > function that generates the next value in the Fibonacci sequence each > time it is called. > > (def fib-gen-val (atom [1 1])) > > (defn fib

Re: Clojure Off-topic IRC channel

2009-02-17 Thread Michel Salim
Since -social might imply the normal channel is .. err .. not (which would be most inaccurate!), how about #clojure-cafe? - Haskell has a "Cafe" forum / mailing list - Additional cute point: the first 16-bit of a Java class file is 0xCAFE Best regards, -- Michel S. On Feb 17, 11:27 am, Rayne

Re: Clojure on CLR/DLR

2009-02-17 Thread Michel Salim
On Tue, Feb 17, 2009 at 10:03 AM, Craig Andera wrote: > >> I'm up for suggestions on the name. The obvious ones: >> >> - Clojure.net >> - ClojureCLR >> - IronClojure (paralleling IronPython/IronRuby, unless MS has Iron >> trademarked.) >> - CLjR (too cute) >> >> Perhaps Rich will have a pre

Re: Performance of (fn [] ...)?

2009-02-18 Thread Michel Salim
On Feb 18, 3:17 am, Laurent PETIT wrote: > Hello, > > 2009/2/18 CuppoJava > > > > > Hi, > > I've noticed that I'm creating a lot of maps of functions, and I'm > > wondering if there's a performance penalty for this. > > > ie. > > (defn create_fn [] > >  (fn [] (println "hi"))) > > If you use A

Re: How to get rid of reflection warning from countdown latch?

2009-02-23 Thread Michel Salim
On Mon, Feb 23, 2009 at 12:20 PM, Anand Patil wrote: > > Hi all, > > I'm getting > > Reflection warning, line: 150 - reference to field countDown can't be > resolved. > > from > >(if cell-updated? >(if (not (:updating @cell)) >(.countDown latch > > Is there any way to

Re: alternate syntax

2009-02-23 Thread Michel Salim
On Mon, Feb 23, 2009 at 10:42 AM, Mark Volkmann wrote: > > I have an idea I'd like to float to see if there are reasons why it's > a bad idea. > > What if Clojure had an alternate "surface" syntax that was translated > into standard Clojure syntax by a kind of preprocessor? > > Many people that d

Would people be interested in extending test-is with random tests?

2009-02-23 Thread Michel Salim
I recently wrote a test framework for Scheme, initially similar to what test-is provides; recently, it has been extended to add random checks akin to Haskell's QuickCheck. The syntax is very similar (I have not bothered defining a 'deftest' form, but that is trivial): (define a-test (test a-test

Re: challenge: best fibo implementation under the new laziness?

2009-02-23 Thread Michel Salim
On Mon, Feb 23, 2009 at 10:26 PM, Raffael Cavallaro wrote: > > > > On Feb 23, 9:31 pm, Jeffrey Straszheim > wrote: >> The speed of the JVM's big ints, and therefore Clojure's, doesn't seem to be >> competitive. > > Clearly the JVM's big ints doesn't compare favorably with GMP. On the > other han

Re: Where to put fixed-point?

2009-02-23 Thread Michel Salim
On Mon, Feb 23, 2009 at 11:06 PM, Jeffrey Straszheim wrote: > For my graph code in contrib, I've created a function fixed-point.  It is, I > believe, generally useful.  However, it is not properly a "graph" function > per se, and might belong elsewhere in the library. > > Does anyone have a bette

Re: test-is integration via SLIME

2009-02-23 Thread Michel Salim
On Wed, Feb 18, 2009 at 7:07 PM, Phil Hagelberg wrote: > I've been cooking up a little tool to help with running tests using > test-is. It's a little cumbersome to need to switch back and forth > between the test buffer and the repl to see the test results, so I've > created an Emacs mode that ac

Re: How to get rid of reflection warning from countdown latch?

2009-02-24 Thread Michel Salim
On Tue, Feb 24, 2009 at 4:44 AM, Anand Patil wrote: > > Thanks Miʃel, > > On Feb 23, 10:15 pm, Michel Salim wrote: >> >> What's the object on which .countDown is called? You need to find >> where it's first declared and give it a type annot

Re: Would people be interested in extending test-is with random tests?

2009-02-24 Thread Michel Salim
On Tue, Feb 24, 2009 at 5:00 AM, James Reeves wrote: > > On Feb 24, 3:11 am, "Michel S." wrote: >> I started Quiche after taking a look at Fact, actually; the difference >> between what I'm proposing and Fact is that the latter is a standalone >> test framework, whereas the random-testing part o

Re: If/cond thoughts..

2009-02-25 Thread Michel Salim
On Wed, Feb 25, 2009 at 6:19 AM, glow wrote: > > Hi everyone! > I am currently learning Lisp and Clojure. A few days ago i read how > "if" in Arc works and I wonder why it is not the same in Clojure: > (if a b       ; if a then b >    c d       ; elseif c then d >      e)      ; else e. > I thoug

Rebinding functions?

2009-06-16 Thread Michel Salim
It's currently not possible to dynamically rebind functions: (binding [+ -] (+ 5 3)) ==> 8 ;; not 2 Would this be supported in the future? It would make it easier, for example, to extend the current tracing functionality, e.g. (trace-in-expr [f1 f2] (f1 (f2 10))) ==> (let [oldf1 f1 oldf2 f2]

clojure.contrib.trace enhancement proposal: dotrace

2009-06-16 Thread Michel Salim
I've often felt the need to enable tracing on some particular functions, but do not really want to modify their definitions and then add a requirement on clojure.contrib.trace. Here's a macro I came up with, inspired by the tracing syntax in Chez Scheme: (defmacro dotrace "Given a sequence of f

Re: Rebinding functions?

2009-06-16 Thread Michel Salim
On Jun 16, 2:22 pm, Kevin Downey wrote: > you can use apply to avoid in-lining: > > user=> (binding [+ -] (apply + '(5 3))) > 2 > Indeed; this is what my macro ended up doing anyway, since it has to work regardless of the arity of the functions to trace. -- Michel --~--~-~--~~-

Re: clojure.contrib.trace enhancement proposal: dotrace

2009-06-17 Thread Michel Salim
wrote: > Hi Michel, > Thanks for working on this!  I'm going away this week, but I'll be > sure to look at this more closely when I get back.  (I wrote the first > c.c.trace, it may have been modified by others since.) > -Stuart Sierra > > On Jun 16, 7:13 pm, Michel Sal

Re: Clojure in "Computing in Science and Engineering"

2009-06-18 Thread Michel Salim
On Jun 18, 2:00 am, Konrad Hinsen wrote: > The July/August issue of the IEEE magazine "Computing in Science and   > Engineering" has an introduction to functional programming for   > scientists that uses Clojure for the examples. It is already   > available (a bit in advance of the paper issue)

contrib proposal: apropos

2009-06-18 Thread Michel Salim
in contrib to put these in -- and whether substring? will be generally useful, and thus should be exported, or not. Thanks, -- Michel Salim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: contrib proposal: apropos

2009-06-18 Thread Michel Salim
On Jun 18, 3:45 pm, Richard Newman wrote: > > (defn substring? [str1 str2] > >  (let [c1 (count str1) > >    c2 (count str2)] > >  (and (<= c1 c2) > >       (or (= str1 (subs str2 0 c1)) > >       (substring? str1 > >                   (subs str2 1 c2)) > > This should be a little faster: >

Re: Help with example from "A Field Guide to Genetic Programming"

2009-07-07 Thread Michel Salim
On Jul 7, 8:18 am, Robert Campbell wrote: > First, how can I print out the definition of a function in clojure? > For example, if I do (defn add [x y] (+ x y)) how can inspect this > definition, like (show-def add) -> (defn add [x y] (+ x y)). This > would help a lot in debugging the random pro

Re: New string utilities library ready

2009-08-20 Thread Michel Salim
On Wed, 2009-08-19 at 23:29 -0700, Meikel Brandmeyer wrote: > Hi, > > Disclaimer: personal opinion following... > > I'm sorry. I don't get the elegance of point-free style. > > In mathematics f denotes the function, while f(x) denotes the value f > takes over x. This is actually a nice and easy

Re: Eval not working on unexpanded macro quote

2009-08-21 Thread Michel Salim
On Thu, 2009-08-20 at 21:52 -0700, gutzofter wrote: > thanks for the version number: > > Clojure 1.1.0-alpha-SNAPSHOT > > is this from the github? It's from github, yes. The version number is actually a bit meaningless: the 'master' branch on github has been on 1.1.0-alpha-SNAPSHOT ever since 1.

Re: clojure success story ... hopefully :-)

2009-08-21 Thread Michel Salim
On Fri, 2009-08-21 at 11:02 -0700, Sigrid wrote: > Hi, > > I read the related story on InfoQ and found it an extremely > interesting and motivating read, Clojure being applied in such an > interesting field as machine learning! > > There is something in the article I'd like to understand better,

Re: clojure success story ... hopefully :-)

2009-08-21 Thread Michel Salim
On Fri, 2009-08-21 at 12:50 -0700, Kevin Downey wrote: > user=> (defmulti length empty?) > #'user/length > > user=> (defmethod length true [x] 0) > # > > user=> (defmethod length false [x] (+ 1 (length (rest x > # > > user=> (length [1 2 3 4]) > 4 > Très cool! This could be applied to Meike

Re: explode a string to a list

2009-08-22 Thread Michel Salim
the closest thing I found was SUBS: > > =>(subs "test" 1 2) > "t" The key rule is that in Clojure, if a data structure can reasonably be viewed as a sequence, it can be turned into one. Thus => (seq "abcde") (\a \b \c \d \e) HTH, -- Michel Salim --~--~--

Re: clojure success story ... hopefully :-)

2009-08-22 Thread Michel Salim
On Fri, 2009-08-21 at 22:26 -0700, James Sofra wrote: > This seems like a pretty nice pattern matching implementation for > Clojure. > http://www.brool.com/index.php/pattern-matching-in-clojure > Beautiful! Cheers, -- Michel --~--~-~--~~~---~--~~ You received

Re: clojure success story ... hopefully :-)

2009-08-22 Thread Michel Salim
On Sat, 2009-08-22 at 23:00 -0700, bradford cross wrote: > > Destructuring is useful all over the place, not just for pattern > matching. For example, it is really useful in function parameter > vectors. I consider that to be an example of pattern matching, though. -- Michel --~--~---

Re: clojure success story ... hopefully :-)

2009-08-23 Thread Michel Salim
On Sat, 2009-08-22 at 23:58 -0700, bradford cross wrote: > > > On Sat, Aug 22, 2009 at 11:24 PM, Michel Salim > wrote: > > On Sat, 2009-08-22 at 23:00 -0700, bradford cross wrote: > > > > > Destructuring is useful

News on Mini Kanren / Javascript generator; when is an implementation sufficiently original?

2009-10-24 Thread Michel Salim
Jim was working on logic programming in Clojure up to a few months ago, and it seems as if the concern was that the code was too derivative. I have recently made available a Scala-based Kanren implementation; the differences between Scala and Scheme means that the code is sufficiently original. M

Re: help a journalist: why Clojure?

2008-10-10 Thread Michel Salim
Coming from Scheme, at first my impression was "whoa, they removed a *lot* of parentheses!". So I guess it depends on where one's coming from. -- Michel On Oct 10, 1:22 pm, ".Bill Smith" <[EMAIL PROTECTED]> wrote: > I think the biggest initial complaint about Clojure will be "too many > parenth

Re: Formatted printing?

2008-10-10 Thread Michel Salim
#x27;t be hard. Is this for printing, or just for better readability? Regards, -- Michel Salim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegro

Re: Formatted printing?

2008-10-13 Thread Michel Salim
On Sat, Oct 11, 2008 at 9:58 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: >> Starting from some Scheme or CL code is a good idea. I'll just adapt >> it to support literal maps, vectors, and such. >> > > A pretty-print for Clojure would be a welcome contribution. In order > to be an acceptable contr

Re: help a journalist: why Clojure?

2008-10-14 Thread Michel Salim
On Mon, Oct 13, 2008 at 6:13 PM, estherschindler <[EMAIL PROTECTED]> wrote: > 7 Cool, Weird and Useful Computer Keyboards > Not every computer keyboard or input device is a boring hunk of > plastic. We look at several ergonomic, wireless, high-tech and just > plain fun keyboards to brighten your da

Re: is clojure known to work on any phones with javame?

2008-10-15 Thread Michel Salim
A related question would be: does it work on Android? Thanks, -- Michel Salim On Oct 15, 12:46 am, "Kevin Downey" <[EMAIL PROTECTED]> wrote: > I am in the market for a phone and it would be so cool to have clojure > on it. Has anyone tried this yet? > > -- >

Documentation bug: assoc

2008-10-15 Thread Michel Salim
The documentation for assoc (both using find-doc and on the website) stipulates that the index must be <= (count col). This is incorrect, though, since index ranges from [0, (count col)) ? Thanks, -- Michel Salim --~--~-~--~~~---~--~~ You received this mess

Re: Documentation bug: assoc

2008-10-15 Thread Michel Salim
On Oct 15, 8:38 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Oct 15, 8:14 pm, Michel Salim <[EMAIL PROTECTED]> wrote: > > > The documentation for assoc (both using find-doc and on the website) > > stipulates that the index must be <= (count col). This is i

Re: splat operator

2008-10-15 Thread Michel Salim
I'm probably missing something regarding string handling, though. But from what I've seen, it appears that the recommended way is to use Java's built-in string methods here. Regards, -- Michel Salim --~--~-~--~~~---~--~~ You received this message because

Re: splat operator

2008-10-15 Thread Michel Salim
On Oct 15, 9:08 pm, Martin DeMello <[EMAIL PROTECTED]> wrote: > On Oct 15, 5:49 pm, Martin DeMello <[EMAIL PROTECTED]> wrote: > > > Is there any sort of "splat" operator that expands a list into an > > inline sequence of arguments? Failing that, is there any way to use > > apply within a doto bl

Re: splat operator

2008-10-17 Thread Michel Salim
On Thu, Oct 16, 2008 at 8:13 PM, Timothy Pratley <[EMAIL PROTECTED]> wrote: > > Maybe something along these lines? > > (defn myreplace [str [a b]] > (.replace str a b)) > (myreplace target search-replace) > -> "heo world" > Clojure's ML/Haskell-style deconstructing of sequences takes a while to si

Re: Multiple return values

2008-10-20 Thread Michel Salim
_forms > We could further combine this by making a scalar equivalent to a vector of length 1; that way, users who expect a function to return one value would not be confused when a vector is returned instead. There's a problem, of course -- how to distinguish between vector-as- holder-of-r

Re: Lazy Seq and refs

2008-11-14 Thread Michel Salim
On Nov 14, 5:48 pm, Chouser <[EMAIL PROTECTED]> wrote: > On Fri, Nov 14, 2008 at 3:51 PM, Bradbev <[EMAIL PROTECTED]> wrote: > > > (which will convert it from lazy to ...?  Hmm, what's the > > word - motivated?) > > I think the word you want is "eager" > > http://www.zazzle.com/i_get_more_done_w

Re: Getting a flat sequence from a map (and vice versa)

2008-11-14 Thread Michel Salim
On Nov 14, 10:56 pm, samppi <[EMAIL PROTECTED]> wrote: > I'm trying to figure out how to do this: > >   (flat-map-seq {:a 3, :b 1, :c 2}) ; returns (:a 3 :b 1 :c 2) > (defn flat-map-seq [m] (if (empty? m) '() (let [kv (first m)] (lazy-cons (kv 0) (lazy-cons (kv 1) (flat-map-seq (rest

Re: Newbie question: Sequences from a function

2008-11-15 Thread Michel Salim
On Nov 15, 11:15 am, samppi <[EMAIL PROTECTED]> wrote: > Is there a way to make a lazy sequence whose sequential values are > derived from some function? I'm thinking about two ways: > >     (recursive-fn-seq f initial [n]) ; returns (initial (f initial) (f > (f initial)) ...) n or infinity times