On Tue, Aug 10, 2010 at 11:23 AM, Will M. Farr wrot>
> Sorry for the digression; I hope people find it interesting.
I found it interesting.
--
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
Maybe this point about Racket is too off-topic for the list, but:
On Aug 10, 2010, at 4:55 AM, Mark Engelberg wrote:
> Generally speaking, I find I do not have to worry about "blowing the
> stack" in Scheme, and as a result, non-tail-call structural recursion
> (such as the algorithm that kicked
The table show 20!.
I am far from being sure of my point, but in a first approximation:
Loading a part of memory that is not cached (which will be the case
for big lists) is around 300 cycles.
An addition in a register is a few cycles, a jump is a few cycles too,
at most, (the prediction will be go
Hi,
On Aug 10, 11:34 am, Mark Engelberg wrote:
> The table shows that the performance of the accumulator-style version
> of factorial is always worse than that of the original factorial
> function."
I'm a little bit surprised, that people still prefer programs, which
are only sometimes not brok
On Tue, Aug 10, 2010 at 2:21 AM, Nicolas Oury wrote:
> It would probably be up to twice as slow, I would say.
> For a list that is continuous in memory and continuations that are
> allocated perfectly in memory,
> you would need to go through twice the same amount of memory.
> (I assume that the m
2010/8/10 Laurent PETIT
>
>
> 2010/8/10 Nicolas Oury
>
> On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT
>> wrote:
>> > Naive question from someone who has not really used Scheme in practice :
>> > beyond the memory footprint problem (which may or may not be a problem
>> > depending on the memo
2010/8/10 Nicolas Oury
> On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT
> wrote:
> > Naive question from someone who has not really used Scheme in practice :
> > beyond the memory footprint problem (which may or may not be a problem
> > depending on the memory size of an element in the initial
On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT wrote:
> Naive question from someone who has not really used Scheme in practice :
> beyond the memory footprint problem (which may or may not be a problem
> depending on the memory size of an element in the initial list, and also
> depending on wheth
On Tue, Aug 10, 2010 at 9:55 AM, Mark Engelberg
wrote:
> In Clojure, I find stack limitations are a real issue unless
> I transform the algorithms into a tail-recursive accumulator style.
> For lists, it's usually not hard. For trees, it can be a bit of a
> pain.
Try CPS+trampoline
It is mo
Hello Mark,
2010/8/10 Mark Engelberg
> On Tue, Aug 10, 2010 at 1:15 AM, Nicolas Oury
> wrote:
> > So, in this particular case, Scheme does not warranty no exhaustion
> > of resources.
>
> Yes, but your recursion depth is limited to the length of the list you
> are processing. So if you have e
On Tue, Aug 10, 2010 at 1:15 AM, Nicolas Oury wrote:
> So, in this particular case, Scheme does not warranty no exhaustion
> of resources.
Yes, but your recursion depth is limited to the length of the list you
are processing. So if you have enough resources to comfortably hold
and manipulate th
On Tue, Aug 10, 2010 at 2:40 AM, Mark Engelberg
wrote:
> arbitrary-sized lists is a primary goal. The posted code (minus the
> call to recur), is an elegant recursive formulation that is idiomatic
> in Scheme because Scheme is (typically) implemented in a way that
> makes stack limitations (mostl
2010/8/10 Laurent PETIT
> 2010/8/10 Meikel Brandmeyer
>
>> Hi,
>>
>>
>> On Aug 10, 9:36 am, Laurent PETIT wrote:
>>
>> > Interesting ! Though it seems like a repetition in this case ...
>>
>> Indeed. However, eg. with multimethods this a nice-to-know to supply
>> some meaningful argument info.
2010/8/10 Meikel Brandmeyer
> Hi,
>
> On Aug 10, 9:36 am, Laurent PETIT wrote:
>
> > Interesting ! Though it seems like a repetition in this case ...
>
> Indeed. However, eg. with multimethods this a nice-to-know to supply
> some meaningful argument info.
>
Indeed !
--
You received this messa
Hi,
On Aug 10, 9:36 am, Laurent PETIT wrote:
> Interesting ! Though it seems like a repetition in this case ...
Indeed. However, eg. with multimethods this a nice-to-know to supply
some meaningful argument info.
Sincerely
Meikel
--
You received this message because you are subscribed to the
2010/8/10 Meikel Brandmeyer
> Hi,
>
> On Aug 10, 8:22 am, Laurent PETIT wrote:
>
> > Though here, the version with different arities "exposes as API for the
> > user" the 2-arity version, but it may not make sense for the user of your
> > function to know about this 2-arity version. I personally
Hi,
On Aug 10, 8:22 am, Laurent PETIT wrote:
> Though here, the version with different arities "exposes as API for the
> user" the 2-arity version, but it may not make sense for the user of your
> function to know about this 2-arity version. I personally prefer the first
> approach (with a priva
2010/8/10 David Sletten
>
> On Aug 10, 2010, at 2:22 AM, Laurent PETIT wrote:
>
>
>
>> You could accomplish pretty much the same thing by defining two versions
>> with different arities:
>> (defn count-zeros
>> ([l] (count-zeros l 0))
>> ([l result]
>> (cond (empty? l) result
>>
On Aug 10, 2010, at 2:22 AM, Laurent PETIT wrote:
>
>
> You could accomplish pretty much the same thing by defining two versions with
> different arities:
> (defn count-zeros
> ([l] (count-zeros l 0))
> ([l result]
> (cond (empty? l) result
>(zero? (first l)) (recur (rest
Hi,
2010/8/10 David Sletten
> Carlos,
>
> I think this is pretty much what you had in mind:
> (defn count-zeros [l]
> (cond (empty? l) 0
> (zero? (first l)) (inc (count-zeros (rest l)))
> :else (count-zeros (rest l
>
> (count-zeros '(9 8 6 0 1 2 0 5)) => 2
> (count-zeros '(
Carlos,
I think this is pretty much what you had in mind:
(defn count-zeros [l]
(cond (empty? l) 0
(zero? (first l)) (inc (count-zeros (rest l)))
:else (count-zeros (rest l
(count-zeros '(9 8 6 0 1 2 0 5)) => 2
(count-zeros '(9 8 6)) => 0
(count-zeros '()) => 0
Of course th
On Mon, Aug 9, 2010 at 9:00 PM, Phil Hagelberg wrote:
> On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres
> wrote:
> > (defn count-zeros
> > "Returns the numbers of zero in a simple sequence of numbers"
> > [list1]
> > (cond
> > (empty? list1) 0
> > (not (zero? (first list1))) 0
> >
On Mon, Aug 9, 2010 at 6:00 PM, Phil Hagelberg wrote:
> Just remove the call to recur and it will work, albeit only for lists
> small enough to not blow the stack.
I'm assuming from the tone of the original post that the author is
trying to generally understand how to write recursive functions in
On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres wrote:
> (defn count-zeros
> "Returns the numbers of zero in a simple sequence of numbers"
> [list1]
> (cond
> (empty? list1) 0
> (not (zero? (first list1))) 0
> :else
> (recur (+ 1 (count-zeros (rest list1))
Michael's soluti
2010/8/10 Carlos Torres
> Hi to everyone,
>
> I'm trying to create a function that takes a simple list and returns the
> number of zeros in the list.
> So I'm assuming that they will enter a list containing only numbers.
> This is what I have so far, but it only works when the list empty. Can
> s
On Mon, Aug 9, 2010 at 5:24 PM, Carlos Torres wrote:
> Hi to everyone,
> I'm trying to create a function that takes a simple list and returns the
> number of zeros in the list.
> So I'm assuming that they will enter a list containing only numbers.
> This is what I have so far, but it only works wh
On Aug 9, 2010, at 7:24 PM, Carlos Torres wrote:
> I'm trying to create a function that takes a simple list and returns the
> number of zeros in the list.
user=> (count (filter zero? [0 1 2 3 0 4 5 6 0 7 8 9]))
3
--
You received this message because you are subscribed to the Google
Groups "Clo
Hi to everyone,
I'm trying to create a function that takes a simple list and returns the
number of zeros in the list.
So I'm assuming that they will enter a list containing only numbers.
This is what I have so far, but it only works when the list empty. Can
somebody tell me what I'm missing?
(def
28 matches
Mail list logo