2015-02-19 23:25 GMT+01:00 Steve Miner :
> I found a better data structure for calculating lucky numbers. The
> contrib library data.avl (from Michał Marczyk) has a persistent sorted-set
> that supports nth. This runs much faster than my previous attempts.
>
> (require '[clojure.data.avl :as avl
I found a better data structure for calculating lucky numbers. The contrib
library data.avl (from Michał Marczyk) has a persistent sorted-set that
supports nth. This runs much faster than my previous attempts.
(require '[clojure.data.avl :as avl])
(defn lucky-avl
([max] (lucky-avl 1 (apply a
2015-02-18 20:47 GMT+01:00 Steve Miner :
> One more try. This time using the int-map contrib library. (Thanks to
> Zack Tellman.)
>
> Warning: I'm assuming that the int-set seq is automagically sorted so I
> can reliably turn it back into a vector without sorting. It seems to be
> stable at leas
2015-02-18 18:25 GMT+01:00 Cecil Westerhof :
> 2015-02-18 16:31 GMT+01:00 Tassilo Horn :
>
>> Here's my version:
>>
>> --8<---cut here---start->8---
>> (defn drop-every-nth [c n]
>> (keep-indexed (fn [i el]
>> (if (zero? (mod (inc i) n)) nil
2015-02-18 20:47 GMT+01:00 Steve Miner :
> One more try. This time using the int-map contrib library. (Thanks to
> Zack Tellman.)
>
Not installed on my system. So for the moment I let it rest.
--
Cecil Westerhof
--
You received this message because you are subscribed to the Google
Groups "C
One more try. This time using the int-map contrib library. (Thanks to Zack
Tellman.)
Warning: I'm assuming that the int-set seq is automagically sorted so I can
reliably turn it back into a vector without sorting. It seems to be stable at
least. I wanted a vector for fast nth access. (Nth
2015-02-18 16:31 GMT+01:00 Tassilo Horn :
> Here's my version:
>
> --8<---cut here---start->8---
> (defn drop-every-nth [c n]
> (keep-indexed (fn [i el]
> (if (zero? (mod (inc i) n)) nil el))
> c))
>
> (defn lucky-numbers [n]
2015-02-18 16:31 GMT+01:00 Tassilo Horn :
> Cecil Westerhof writes:
>
> > One problem is that max-value is used in the doc-string also, so if it
> > changes, it has to be done at two places. Is there a way around this?
>
> I wouldn't specify a max-value at all. Some users might have enough
> tim
Cecil Westerhof writes:
> One problem is that max-value is used in the doc-string also, so if it
> changes, it has to be done at two places. Is there a way around this?
I wouldn't specify a max-value at all. Some users might have enough
time to wait for the result, have faster machines, might u
I have updated my Lucky Numbers code:
(defn indexed-sieve
"Removes all elements that have a position that is a multiply of
index.
With first position counting as 1."
[index this-list]
(keep-indexed
(fn [i v]
(if (= 0 (mod (inc i) index))
n
10 matches
Mail list logo