why not (mapcat next)?

On Tue, Feb 17, 2015 at 3:45 PM, Fluid Dynamics <a2093...@trbvm.com> wrote:

> On Tuesday, February 17, 2015 at 2:21:20 PM UTC-5, Cecil Westerhof wrote:
>>
>> What is the best way to remove all elements which position (counting from
>> 1) is a multiply of five out of a list?
>>
>> So the list:
>>     (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
>> becomes:
>>     (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)
>>
>
> The correct answer, obviously, is
>
> (->> s
>   (cons ::sentinel)
>   (partition n n nil)
>   (map next)
>   (mapcat identity))
>
> with, in this case, s = (range 1 22) and n = 5
>
>  --
> 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.
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
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.

Reply via email to