Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #20422
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Rotate sequence |
| Date | 2013-03-08 01:37 +0000 |
| Organization | NewsGuy - Unlimited Usenet $19.95 |
| Message-ID | <khbfcu0gki@enews4.newsguy.com> (permalink) |
P19 (**) Rotate a list N places to the left.
Examples:
* (rotate '(a b c d e f g h) 3)
(D E F G H A B C)
* (rotate '(a b c d e f g h) -2)
(G H A B C D E F)
Factor:
: rotate ( seq n -- seq )
dup 0 < [ abs cut* ] [ cut ] if
swap append
;
{ "a" "b" "c" "d" "e" } 2 rotate .
{ "c" "d" "e" "a" "b" }
{ "a" "b" "c" "d" "e" } -2 rotate .
{ "d" "e" "a" "b" "c" }
Back to comp.lang.forth | Previous | Next — Next in thread | Find similar | Unroll thread
Rotate sequence "WJ" <w_a_x_man@yahoo.com> - 2013-03-08 01:37 +0000 Re: Rotate sequence "WJ" <w_a_x_man@yahoo.com> - 2013-07-07 03:20 +0000
csiph-web