Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #20413 > unrolled thread

Drop every nth

Started by"WJ" <w_a_x_man@yahoo.com>
First post2013-03-07 20:25 +0000
Last post2013-03-07 20:25 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.forth


Contents

  Drop every nth "WJ" <w_a_x_man@yahoo.com> - 2013-03-07 20:25 +0000

#20413 — Drop every nth

From"WJ" <w_a_x_man@yahoo.com>
Date2013-03-07 20:25 +0000
SubjectDrop every nth
Message-ID<khat2u$50t$1@dont-email.me>
P16 (**) Drop every N'th element from a list.
    Example:
    * (drop '(a b c d e f g h i j) 3)
    (A B D E G H J)


Factor:

USING: locals grouping sequences.deep ;

:: drop-nths ( seq n -- seq )
  seq n group
  [ dup length n 1 - min head ] map
  flatten
;
  

{ "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" }
3 drop-nths .
{ "a" "b" "d" "e" "g" "h" "j" }

[toc] | [standalone]


Back to top | Article view | comp.lang.forth


csiph-web