On 17 May 2016, at 10:47, 'Simon Brooke' via Clojure <clojure@googlegroups.com> wrote:
> I'm having trouble with writing a function > in idiomatic clojure > which doesn't blow the stack > The problem is I have a time series of events e.g. > > ({:idhistory 78758272, :timestamp #inst > "2016-03-31T19:34:27.313000000-00:00", :nameid 5637, :stringvalue nil, :value > 8000.0} > {:idhistory 78756591, :timestamp #inst > "2016-03-31T19:33:31.697000000-00:00", :nameid 5637, :stringvalue nil, :value > 7368.0} > {:idhistory 78754249, :timestamp #inst > "2016-03-31T19:32:17.100000000-00:00", :nameid 5637, :stringvalue nil, :value > 6316.0} > {:idhistory 78753165, :timestamp #inst > "2016-03-31T19:31:41.843000000-00:00", :nameid 5637, :stringvalue nil, :value > 5263.0} > {:idhistory 78751187, :timestamp #inst > "2016-03-31T19:30:36.213000000-00:00", :nameid 5637, :stringvalue nil, :value > 4211.0} > {:idhistory 78749476, :timestamp #inst > "2016-03-31T19:29:41.363000000-00:00", :nameid 5637, :stringvalue nil, :value > 3158.0} ...) > > which is to say, each event is a map, and each event has two critical keys, > :timestamp and :value. The series is sorted in descending order by timestamp, > i.e. most recent event first. These series are of up to millions of events; > the average length of the series is about half a million events. However, > many contain successive events at which the value does not change, and where > the value doesn't change I want to retain only the first event. One way of solving this sort of problem without blowing the stack is to use recur: https://clojuredocs.org/clojure.core/recur. I would guess this is the best fit for what you want to do. Alan -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.