Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #20413 > unrolled thread
| Started by | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| First post | 2013-03-07 20:25 +0000 |
| Last post | 2013-03-07 20:25 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.forth
Drop every nth "WJ" <w_a_x_man@yahoo.com> - 2013-03-07 20:25 +0000
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2013-03-07 20:25 +0000 |
| Subject | Drop 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" }
Back to top | Article view | comp.lang.forth
csiph-web