Ack I somehow missed the code sample
On Sunday, April 24, 2016, James Reeves wrote:
> On 25 April 2016 at 03:27, Timothy Baldridge > wrote:
>
>> Transients are not thread safe. http://clojure.org/reference/transients
>
>
> It doesn't appear that they're being used across multiple threads. The
>
On 25 April 2016 at 03:27, Timothy Baldridge wrote:
> Transients are not thread safe. http://clojure.org/reference/transients
It doesn't appear that they're being used across multiple threads. The code
creates a transient, reduces over it, then makes it persistent.
- James
--
You received th
It's hard to tell for sure from your code sample, because you don't include
"place" or "get-free-squares", but it's possible your error is in the
reducing function here:
(reduce #(when (not (keyword? %2))
(conj! %1
(if nxt
{:board %2 :pawns (update
Your reduction function uses when, which returns nil for the false case. You
need to use if instead and return %1 unchanged in the else case so the
reduction can continue.
There may still be other problems, but that is the cause of your NPE
--
You received this message because you are subscrib
Transients are not thread safe. http://clojure.org/reference/transients
On Sunday, April 24, 2016, Vandr0iy wrote:
> Hi, Clojurists!
>
> I'm writing some clojure in these days, and I stumbled upon an error that
> I'm unable to easily understand.
> My goal is to asynchronously process a 2D vector
Hi, Clojurists!
I'm writing some clojure in these days, and I stumbled upon an error that
I'm unable to easily understand.
My goal is to asynchronously process a 2D vector in order to solve a
parametric version of the 8 chess queens problem (where the parameters are:
the board's dimensions and
Here's how I would do it:
```
(defn to-timed-events [events]
(->> events
(reduce (fn [[acc-events acc-time] {:keys [duration], :as event}]
[(conj acc-events (assoc event :time acc-time))
(+ acc-time duration)])
[[] 0])
first))
```
Hello Olivier,
perhaps 'reductions' would be a good fit here:
(let [times (reductions + 0 (map :duration events))]
(into [] (map #(assoc %1 :time %2) events times)))
Best,
--
David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To pos
Hi all,
I am a Clojure beginner
And I have an advice to ask !
I have an array of events:
(def events [
{:id "1" :duration 100}
{:id "2" :duration 200}
{:id "3" :duration 300}
])
I wanted to transform this array into:
[
{:id 1, :duration 100, :time 0} ; event 1 starts at 0
{:id 2,