Hi, On 3 Feb., 09:11, Petr Gladkikh <petrg...@gmail.com> 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) > > But list conj's at the beginning not at end of sequence as I would > like to. Of course I could use () from the beginning (with account for > reverse order). > But with [] I should do little more. There is a misunderstanding here: the sequence functions return - well - sequences. If you want a vector back, you have to tell Clojure so. [] -> (take-last n []) -> nil -> (vec nil) -> [] [1 2 3] -> (take-last n [1 2 3]) -> (3) -> (vec (3)) -> [3]. Or use into: (into (empty input) (take-last n input)) Sincerely Meikel -- 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