On Thu, Feb 3, 2011 at 5:22 PM, Alan wrote:
> You don't need an extra element in the vector to distinguish between
> empty and full. You can store (start, size) instead of (start, end).
I considered that, but it made the arithmetic much messier in various
places. Count gets simpler, obviously, bu
You don't need an extra element in the vector to distinguish between
empty and full. You can store (start, size) instead of (start, end).
On Feb 3, 12:57 pm, Ken Wesson wrote:
> On Thu, Feb 3, 2011 at 2:03 PM, Alan wrote:
> > Or use a fixed-size vector as a ring, with start and end "pointers",
>
On Thu, Feb 3, 2011 at 2:03 PM, Alan wrote:
> Or use a fixed-size vector as a ring, with start and end "pointers",
> and a couple functions to abstract over the handling thereof. But
> unless you really really care about performance, this is likely to be
> overkill, and Ken's suggestion to just us
Or use a fixed-size vector as a ring, with start and end "pointers",
and a couple functions to abstract over the handling thereof. But
unless you really really care about performance, this is likely to be
overkill, and Ken's suggestion to just use a vector or a seq and
accept the O(n) behavior.
On
On Thu, Feb 3, 2011 at 3:11 AM, Petr Gladkikh wrote:
> On Thu, Feb 3, 2011 at 1:31 PM, Meikel Brandmeyer wrote:
>> Hi,
>>
>> On 3 Feb., 08:04, Petr Gladkikh wrote:
>>
>>> Should not it be empty colection instead?
>>> It seems odd to me since it is inconsistent and forces to consider one
>>> more
On Feb 3, 1:04 am, Petr Gladkikh wrote:
>
> And another question. I have written this function
> (defn index-by
> "Make map (f x) -> x"
> [f coll]
> (reduce #(assoc %1 (f %2) %2) {} coll))
>
> I wonder, is there already such function somewhere in Clojure libraries?
Somewhat shorter:
(defn
Hi,
On 3 Feb., 09:11, Petr Gladkikh wrote:
> I have a vector that holds some history. I conj new items to it and to
> save space I'd like to retain not more than n last items.
> To do that I used (take-last n history). So: [] -> (take-last n []) ->
> nil -> (conj nil newItem) -> '(newItem)
>
> B
On Thu, Feb 3, 2011 at 1:31 PM, Meikel Brandmeyer wrote:
> Hi,
>
> On 3 Feb., 08:04, Petr Gladkikh wrote:
>
>> Should not it be empty colection instead?
>> It seems odd to me since it is inconsistent and forces to consider one
>> more case (nil or collection).
>
> It is consistent. There is a dif
On Thu, Feb 3, 2011 at 2:31 AM, Meikel Brandmeyer wrote:
> Hi,
>
> On 3 Feb., 08:04, Petr Gladkikh wrote:
>
>> Should not it be empty colection instead?
>> It seems odd to me since it is inconsistent and forces to consider one
>> more case (nil or collection).
>
> It is consistent. There is a dif
Hi,
On 3 Feb., 08:04, Petr Gladkikh wrote:
> Should not it be empty colection instead?
> It seems odd to me since it is inconsistent and forces to consider one
> more case (nil or collection).
It is consistent. There is a difference between () and nil. () is the
empty list. However there is no
Should not it be empty colection instead?
It seems odd to me since it is inconsistent and forces to consider one
more case (nil or collection).
And another question. I have written this function
(defn index-by
"Make map (f x) -> x"
[f coll]
(reduce #(assoc %1 (f %2) %2) {} coll))
I wonder,
11 matches
Mail list logo