ClojureCLR Windows Service

2010-11-19 Thread David Jagoe
Hi All,

Is this the right place for ClojureCLR-specific questions?

I have managed to install and use ClojureCLR on Windows but before I
head too far down that track I'd like to canvas some expert opinion:

Is it going to be painful trying to implement a Windows Service in ClojureCLR?

Basically, I will need to subclass a Windows ServiceClass (possibly
providing some typing information) and build to a standalone
executable. Are both of these things easy?

Once compiled to an executable, will the code be distinguishable from
a C# application? That might sound strange, but I've run into problems
with IronPython because (I understand) that subclassing a .net class
in IronPython actually does something weird under the hood to support
the dynamic features of Python classes (i.e. the compiled binary *is*
different to a C# implementation).


Thanks,
David

-- 
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: Weird result for (get max key)

2010-11-19 Thread Ken Wesson
On Fri, Nov 19, 2010 at 8:52 PM, Bob Shock  wrote:
> I had a bug in my code where I meant to type:
>
> (get map key)
>
> and instead typed:
>
> (get max key)
>
> It seems that any function name I put in for "max" always returns nil.
>
> user=> (get max 3)
> nil
> user=> (get min 3)
> nil
> user=> (get maxx 3)
> java.lang.Exception: Unable to resolve symbol: maxx in this context
> (NO_SOURCE_FILE:10)
> user=>
>
> Any ideas?

Get seems to never throw. If the first argument's not an associative
it returns nil:

uni.io=> (get 1 :foo)
nil
uni.io=> (get nil :foo)
nil
uni.io=> (get :q :foo)
nil
uni.io=> (get "bar" :foo)
nil
uni.io=> (get (Object.) :foo)
nil

-- 
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: Weird result for (get max key)

2010-11-19 Thread Mike Meyer
On Fri, 19 Nov 2010 17:52:03 -0800 (PST)
Bob Shock  wrote:

> I had a bug in my code where I meant to type:
> 
> (get map key)
> 
> and instead typed:
> 
> (get max key)
> 
> It seems that any function name I put in for "max" always returns nil.
> 
> user=> (get max 3)
> nil
> user=> (get min 3)
> nil
> user=> (get maxx 3)
> java.lang.Exception: Unable to resolve symbol: maxx in this context
> (NO_SOURCE_FILE:10)
> user=>
> 
> Any ideas?

Yup. get returns nil if the key isn't in the map. Since functions
aren't maps (or anything else that fits that abstraction), they can't
contain the key, so you get nil. If you try it with pretty much any
arbitrary map value (integers, etc.) you get nil. If you provide the
third argument to get, you'll get that value back in all these cases.

   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


Weird result for (get max key)

2010-11-19 Thread Bob Shock
I had a bug in my code where I meant to type:

(get map key)

and instead typed:

(get max key)

It seems that any function name I put in for "max" always returns nil.

user=> (get max 3)
nil
user=> (get min 3)
nil
user=> (get maxx 3)
java.lang.Exception: Unable to resolve symbol: maxx in this context
(NO_SOURCE_FILE:10)
user=>

Any ideas?

Thanks.

-- 
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: Function Design: sequence or "&" argument?

2010-11-19 Thread Eric Schulte
I generally prefer to pass in a sequence rather than use a variable
number of arguments.  The only time variable arguments are really useful
is in functions like map (or maybe +) in which you rarely use more than
one (or two) arguments and it would be a pain to wrap the last argument
in a list.

e.g.
#+begin_src clojure
  (map (partial + 1) (list (range 10)))
#+end_src
would be very awkward but required without &rest

finally, explicitly wrapped sequences are more composable

just my opinions... -- Eric

Alan  writes:

> I always write a function to take a single seq argument because it can
> also take varargs if I wrap them in a seq.
>
> (defn add [nums]
>   (reduce + nums))
>
> (add some-seq)
> (add [1 2 3 4 5])
>
> On Nov 19, 4:19 pm, Jarl Haggerty  wrote:
>> I always write a function to take varargs because it can also take a
>> list using apply.
>>
>> (+ 1 2 3 4 5)
>> (apply + [1 2 3 4 5])
>>
>> On Nov 15, 9:52 am, Chris  wrote:
>>
>> > If you have a function that needs to treat multiple arguments as a
>> > group, what forces drive you to represent this as a single sequence
>> > argument vs. an "&" argument?  To give a concrete example, why does
>> > "+" work like
>>
>> > (+ 1 2 3 4)
>>
>> > instead of
>>
>> > (+ [1 2 3 4])
>>
>> > Is it performance?  Aesthetics?  Composability concerns?  Not having
>> > to call "apply" all the time?
>>
>> > Thanks,
>> > Chris
>>
>>

-- 
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: Function Design: sequence or "&" argument?

2010-11-19 Thread Alan
I always write a function to take a single seq argument because it can
also take varargs if I wrap them in a seq.

(defn add [nums]
  (reduce + nums))

(add some-seq)
(add [1 2 3 4 5])

On Nov 19, 4:19 pm, Jarl Haggerty  wrote:
> I always write a function to take varargs because it can also take a
> list using apply.
>
> (+ 1 2 3 4 5)
> (apply + [1 2 3 4 5])
>
> On Nov 15, 9:52 am, Chris  wrote:
>
> > If you have a function that needs to treat multiple arguments as a
> > group, what forces drive you to represent this as a single sequence
> > argument vs. an "&" argument?  To give a concrete example, why does
> > "+" work like
>
> > (+ 1 2 3 4)
>
> > instead of
>
> > (+ [1 2 3 4])
>
> > Is it performance?  Aesthetics?  Composability concerns?  Not having
> > to call "apply" all the time?
>
> > Thanks,
> > Chris
>
>

-- 
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: Function Design: sequence or "&" argument?

2010-11-19 Thread Jarl Haggerty
I always write a function to take varargs because it can also take a
list using apply.

(+ 1 2 3 4 5)
(apply + [1 2 3 4 5])

On Nov 15, 9:52 am, Chris  wrote:
> If you have a function that needs to treat multiple arguments as a
> group, what forces drive you to represent this as a single sequence
> argument vs. an "&" argument?  To give a concrete example, why does
> "+" work like
>
> (+ 1 2 3 4)
>
> instead of
>
> (+ [1 2 3 4])
>
> Is it performance?  Aesthetics?  Composability concerns?  Not having
> to call "apply" all the time?
>
> Thanks,
> Chris

-- 
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: Error message specifies wrong line # in source file if function lacks argvec.

2010-11-19 Thread Ken Wesson
On Fri, Nov 19, 2010 at 1:59 PM, Chris Perkins  wrote:
> On Nov 18, 11:09 pm, Ken Wesson  wrote:
>> I got this oddity while debugging a Clojure sourcefile today:
>>
>> user=> 
>> #> declaration loop should be a vector (io.clj:55)>
>> user=>
>
> You're misinterpreting the error message.

I'm misinterpreting nothing. It may be misstating, however.

> It's not trying to tell you that the parameters to loop should be a
> vector - it's trying to tell you that the symbol "loop" was used
> where you should have used a vector.

It looks like it is indeed misstating then (albeit accidentally, in
the way of computers).

How about

(throw (IllegalArgumentException. (str "Parameter declaration:
expected a vector, saw \"" (first bad-args) "\" instead.")))

=>

Parameter declaration: expected a vector, saw "loop" instead.

That one's crystal clear no matter what symbol happens to come next
after the missing argvec.

-- 
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: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-19 Thread Sam Aaron
Looks really good. Great work,

Sam

---
http://sam.aaron.name

On 18 Nov 2010, at 19:10, LauJensen wrote:

> Hi gents,
> 
> For those of you who have followed the development
> of ClojureQL over the past 2.5 years you'll be excited
> to know that ClojureQL is as of today being released
> as 1.0.0 beta1.
> 
> That means that the significant primitives from Relational
> Algebra are all in place and functional. The documentation
> is there and I've even made a screencast in order to get
> you guys started.
> 
> Personally Im excited about this version because it really
> does change the way you work with a database. Queries
> are incredibly composable!
> 
> For more information, please checkout this blogpost +
> screencast:
> http://bestinclass.dk/index.clj/2010/11/clojureql--1.0.0-now-in-beta.html
> 
> Best regards,
> Lau
> 
> -- 
> 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: Error message specifies wrong line # in source file if function lacks argvec.

2010-11-19 Thread Chris Perkins
On Nov 18, 11:09 pm, Ken Wesson  wrote:
> I got this oddity while debugging a Clojure sourcefile today:
>
> user=> 
> # declaration loop should be a vector (io.clj:55)>
> user=>
>

You're misinterpreting the error message. It's not trying to tell you
that the parameters to loop should be a vector - it's trying to tell
you that the symbol "loop" was used where you should have used a
vector. Try this:

user=> (defn foo (loop [] 1))
java.lang.IllegalArgumentException: Parameter declaration loop should
be a vector (NO_SOURCE_FILE:0)

user=> (defn foo (xyz [] 1))
java.lang.IllegalArgumentException: Parameter declaration xyz should
be a vector (NO_SOURCE_FILE:0)

You're hitting this line from core.clj (the very last line,
coincidentally):

(throw (IllegalArgumentException. (str "Parameter declaration " (first
bad-args) " should be a vector")))

I have no idea about the line-numbering thing, though.


- Chris

-- 
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: Converting from 1.2 to 1.3-alpha3

2010-11-19 Thread Juha Arpiainen
On Nov 19, 6:34 pm, "nicolas.o...@gmail.com" 
wrote:
> I found a minimal case:
>
> (defprotocol A (f [x]))
>
> (deftype T [ ^{:unsynchronized-mutable true} ^int a] A
>                (f [x] (loop [c 0]
>                            (set! a c
>
> (class: user/T, method: f signature: ()Ljava/lang/Object;) Expecting
> to find integer on stack
>
> The problem disappear with let instead of loop.
>
> It seems that Clojure creates c as a long a long and do not put a
> conversion before setting to the int variable.

Yes, 1.3 supports only long and double primitives as local variables.
But the bug doesn't seem to be new. I get the same error if I try to
assign an int into a long deftype field in 1.2.

--
Juha Arpiainen

-- 
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: Error message specifies wrong line # in source file if function lacks argvec.

2010-11-19 Thread Jason Wolfe
http://dev.clojure.org/jira/browse/CLJ-420
Perhaps it's the same bug?

-Jason

On Nov 18, 8:09 pm, Ken Wesson  wrote:
> I got this oddity while debugging a Clojure sourcefile today:
>
> user=> 
> # declaration loop should be a vector (io.clj:55)>
> user=>
>
> Huh? Line 55 is a blank line!
>
> user=> 
> # declaration loop should be a vector (io.clj:65)>
> user=>  
> # declaration loop should be a vector (io.clj:76)>
> user=>
>
> The line number is changing every time and every line is innocuous
> (though only the first time was it actually blank). No unmatched
> delimiters that could be derailing the parser.
>
> So I manually check every occurrence of "loop" (ok, helped a bit by
> isearch) but every one of them has a vector of bindings. Every one of
> those is empty (they're all loops that sleep and wait on an external
> condition, used where a C or Java programmer would have used while
> (true)) but that's supposed to be legal.
>
> user=> (loop [] 1)
> 1
> user=>
>
> And apparently it still is.
>
> So I decide to check everything ELSE that requires vectors, starting
> with defn and defn- arglists and planning to move on to let bindings,
> fn arglists, and such.
>
> I promptly find three defn- forms for no-argument functions with no
> arglists and fix them by adding empty arglists. The file then compiles
> successfully.
>
> None of them were anywhere near any of the line numbers I got in the
> error messages.
>
> The error messages appear to contain two errors, then:
>
> 1. They specify a loop lacks a vector when it's a defn lacking a
> vector that caused them.
>
> 2. The line numbers specified are not only not in general the actual
> location of the error in the source file, they aren't even a
> deterministic function of the input file and its dependencies.
>
> If the Clojure compiler were implemented in C I'd suspect an
> uninitialized automatic variable in the routine used to generate that
> particular error message. In Java (or Clojure itself!) this simply
> shouldn't happen. I'm mystified as to what could be causing this.

-- 
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: bimaps in clojure

2010-11-19 Thread Wilson MacGyver
In guava, there is an immutable version of bimap.

http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableBiMap.html

On Fri, Nov 19, 2010 at 3:24 AM, Christophe Grand  wrote:
> One call away but rarely persistent or even immutable.
>
> On Fri, Nov 19, 2010 at 4:55 AM, Sunil S Nandihalli
>  wrote:
>>
>> awesome.. :) i keep forgetting that all of java is just a call away .. hmm
>> thanks Lachlan..:)
>> Sunil.
>>
>> On Fri, Nov 19, 2010 at 7:46 AM, jlk  wrote:
>>>
>>> I haven't tried it, but I just stumbled across
>>> http://commons.apache.org/collections/
>>> -> BidiMap, might be what you're after?
>>>
>>>
>>> On Nov 16, 6:14 pm, Sunil S Nandihalli 
>>> wrote:
>>> > Hello everybody,
>>> >
>>> > Is there something like a bimap in clojure? I know I can have two
>>> > regular
>>> > hash-maps .. but I was wondering if there is a better implementation..?
>>> >
>>> >  a similar implementation in c++ is
>>> >
>>> > http://beta.boost.org/doc/libs/1_41_0/libs/bimap/doc/html/index.html
>>> >
>>> > Thanks,
>>> > Sunil.
>>>
>>> --
>>> 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
>
>
> --
> Professional: http://cgrand.net/ (fr)
> On Clojure: http://clj-me.cgrand.net/ (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



-- 
Omnem crede diem tibi diluxisse supremum.

-- 
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: Converting from 1.2 to 1.3-alpha3

2010-11-19 Thread nicolas.o...@gmail.com
I found a minimal case:



(defprotocol A (f [x]))

(deftype T [ ^{:unsynchronized-mutable true} ^int a] A
   (f [x] (loop [c 0]
   (set! a c

(class: user/T, method: f signature: ()Ljava/lang/Object;) Expecting
to find integer on stack

The problem disappear with let instead of loop.

It seems that Clojure creates c as a long a long and do not put a
conversion before setting to the int variable.
(deftype T [ ^{:unsynchronized-mutable true} ^int a] A
   (f [x] (loop [c 0]
   (set! a (int c)

works without trouble.

Notably, doing (loop [c (int 0)]  does not help.

Is it known or should I report the bug?
(I don't mind casting by hand for this case, but at least the error
message should be clearer)

Best,

Nicolas.

-- 
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: Enclojure for Clojure 1.2

2010-11-19 Thread Sergey Didenko
Hi David,

May be you will be interested, I use Enclojure with a pom file generated by
leiningen. Clojure 1.2 on Netbeans 6.9.1.

On Fri, Nov 19, 2010 at 4:15 AM, David  wrote:

> Have you been able to "Build with Dependencies"?  I haven't been able
> to figure this out yet - though I suspect it's my inexperience with
> Maven.
>

-- 
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: using swig in clojure

2010-11-19 Thread Seth
unfortunately doesnt work. The library loads succesfully but i still
get the error when calling add. Note that compiling on the top is a
workaround to get it working on the repl.

i added the loadlibrary to an init function which is good and i
decided to ahead of time compile it - and it worked! I could call
(init) and then add, without getting a link error!

The question is why do i need to ahead of time compile this code to
get it to work? Any ideas?

-- 
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: Lazy sequences with circular definition

2010-11-19 Thread babui
Thanks for your explanation which has allowed me to make this
definition

(def fibs
 (list* 0 1 (lazy-seq (map + fibs (rest fibs)

that uses rest and IMHO is clearer that the first one using drop.

Juan Manuel

On 19 nov, 12:04, Christophe Grand  wrote:
> Hi,
>
>
>
>
>
> On Fri, Nov 19, 2010 at 11:44 AM, babui  wrote:
> > I've been playing with lazy sequences defined by autoreferential
> > definition. For instance:
>
> > (def ones (lazy-seq (cons 1 ones)))
>
> > which is equivalent to (def ones (repeat 1)).
>
> > My problem arises when defining the sequence of fibonacci numbers.
> > With this definition:
>
> > (def fibs
> >  (lazy-seq (list* 0 1 (map + fibs (drop 1 fibs)
>
> > all works, for instance:
>
> > user=> (take 10 fibs)
> > (0 1 1 2 3 5 8 13 21 34)
>
> > But if I change (drop 1 fibs) with (rest fibs), that is:
>
> > (def fibs
> >  (lazy-seq (list* 0 1 (map + fibs (rest fibs)
>
> > and try to get the first 10, I get:
>
> > user=> (take 10 fibs)
> > java.lang.StackOverflowError
>
> > My problem is that I don't understand why.
>
> (drop 1 fibs) is fully lazy, it doesn't look at fibs to return a new seq
> (rest fibs) needs to evaluate the 1st item to return
> (next fibs) needs to evaluate the 1sy item and the rest (so most of the time
> it means evaluating the 2nd item too)
>
> (def fibs
>  (lazy-seq (list* 0 1 (map + fibs (rest fibs)
>
> when you try to get the first item of the seq, it forces eval of (list* 0 1
> (map + fibs (rest fibs)))
> list* being a fn, 0, 1 and (map + fibs (rest fibs)) are evaluated
> map being a fn, +, fibs and (rest fibs) are evaluated
> and as as I mentioned above rest forces evaluation of the lazy-seq body (the
> list* call) which is exactly what we are actually doing, so we call
> ourselves until the stack blow.
>
> (rest 1 fibs) on the other hand delay the evaluation and saves us from the
> stack overflow.
>
> hth,
>
> Christophe

-- 
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: Lazy sequences with circular definition

2010-11-19 Thread Christophe Grand
Hi,

On Fri, Nov 19, 2010 at 11:44 AM, babui  wrote:

> I've been playing with lazy sequences defined by autoreferential
> definition. For instance:
>
> (def ones (lazy-seq (cons 1 ones)))
>
> which is equivalent to (def ones (repeat 1)).
>
> My problem arises when defining the sequence of fibonacci numbers.
> With this definition:
>
> (def fibs
>  (lazy-seq (list* 0 1 (map + fibs (drop 1 fibs)
>
> all works, for instance:
>
> user=> (take 10 fibs)
> (0 1 1 2 3 5 8 13 21 34)
>
> But if I change (drop 1 fibs) with (rest fibs), that is:
>
> (def fibs
>  (lazy-seq (list* 0 1 (map + fibs (rest fibs)
>
> and try to get the first 10, I get:
>
> user=> (take 10 fibs)
> java.lang.StackOverflowError
>
> My problem is that I don't understand why.
>

(drop 1 fibs) is fully lazy, it doesn't look at fibs to return a new seq
(rest fibs) needs to evaluate the 1st item to return
(next fibs) needs to evaluate the 1sy item and the rest (so most of the time
it means evaluating the 2nd item too)



(def fibs
 (lazy-seq (list* 0 1 (map + fibs (rest fibs)

when you try to get the first item of the seq, it forces eval of (list* 0 1
(map + fibs (rest fibs)))
list* being a fn, 0, 1 and (map + fibs (rest fibs)) are evaluated
map being a fn, +, fibs and (rest fibs) are evaluated
and as as I mentioned above rest forces evaluation of the lazy-seq body (the
list* call) which is exactly what we are actually doing, so we call
ourselves until the stack blow.

(rest 1 fibs) on the other hand delay the evaluation and saves us from the
stack overflow.

hth,

Christophe

-- 
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

Lazy sequences with circular definition

2010-11-19 Thread babui
I've been playing with lazy sequences defined by autoreferential
definition. For instance:

(def ones (lazy-seq (cons 1 ones)))

which is equivalent to (def ones (repeat 1)).

My problem arises when defining the sequence of fibonacci numbers.
With this definition:

(def fibs
  (lazy-seq (list* 0 1 (map + fibs (drop 1 fibs)

all works, for instance:

user=> (take 10 fibs)
(0 1 1 2 3 5 8 13 21 34)

But if I change (drop 1 fibs) with (rest fibs), that is:

(def fibs
  (lazy-seq (list* 0 1 (map + fibs (rest fibs)

and try to get the first 10, I get:

user=> (take 10 fibs)
java.lang.StackOverflowError

My problem is that I don't understand why.

Thanks in advance,

Juan Manuel

-- 
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: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-19 Thread Jeff Rose
Looks great, I'm giving it a try now.  FYI, the github link in your
post is the private URL so it won't work for anyone but you.

-Jeff

On Nov 18, 8:10 pm, LauJensen  wrote:
> Hi gents,
>
> For those of you who have followed the development
> of ClojureQL over the past 2.5 years you'll be excited
> to know that ClojureQL is as of today being released
> as 1.0.0 beta1.
>
> That means that the significant primitives from Relational
> Algebra are all in place and functional. The documentation
> is there and I've even made a screencast in order to get
> you guys started.
>
> Personally Im excited about this version because it really
> does change the way you work with a database. Queries
> are incredibly composable!
>
> For more information, please checkout this blogpost +
> screencast:http://bestinclass.dk/index.clj/2010/11/clojureql--1.0.0-now-in-beta
>
> Best regards,
> Lau

-- 
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: Clojure on the AppEngine Talk

2010-11-19 Thread Saul Hazledine
On Nov 19, 7:08 am, Miki  wrote:
> Greetings,
>
> I gave a short presentation on getting started with Clojure on the
> AppEngine tonight at the clj-la meetup.
> Slides can be found 
> athttps://docs.google.com/present/view?id=ah82mvnssv5d_1784s26pwsh
>
> Comments welcomed.
>
> Enjoy,
> --
> Miki

I'm going to restart app-engine development soon and this will be
really useful. Many thanks.
Saul

-- 
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: bimaps in clojure

2010-11-19 Thread Christophe Grand
One call away but rarely persistent or even immutable.

On Fri, Nov 19, 2010 at 4:55 AM, Sunil S Nandihalli <
sunil.nandiha...@gmail.com> wrote:

> awesome.. :) i keep forgetting that all of java is just a call away .. hmm
> thanks Lachlan..:)
> Sunil.
>
>
> On Fri, Nov 19, 2010 at 7:46 AM, jlk  wrote:
>
>> I haven't tried it, but I just stumbled across
>> http://commons.apache.org/collections/
>> -> BidiMap, might be what you're after?
>>
>>
>> On Nov 16, 6:14 pm, Sunil S Nandihalli 
>> wrote:
>> > Hello everybody,
>> >
>> > Is there something like a bimap in clojure? I know I can have two
>> regular
>> > hash-maps .. but I was wondering if there is a better implementation..?
>> >
>> >  a similar implementation in c++ is
>> >
>> > http://beta.boost.org/doc/libs/1_41_0/libs/bimap/doc/html/index.html
>> >
>> > Thanks,
>> > Sunil.
>>
>> --
>> 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
>



-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (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