Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #24227
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Rotate sequence |
| Date | 2013-07-07 03:20 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <krampi$ocr$1@dont-email.me> (permalink) |
| References | <khbfcu0gki@enews4.newsguy.com> |
WJ wrote:
> 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" }
Julia:
julia> circshift( [2,3,4], 1)
3-element Int32 Array:
4
2
3
julia> circshift( [2,3,4], -1)
3-element Int32 Array:
3
4
2
Back to comp.lang.forth | Previous | Next — Previous 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