Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #35250
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Program or be Programmed ! |
| Date | 2014-12-25 21:08 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <m7hubk$7ll$1@dont-email.me> (permalink) |
| References | <98f287f7-fc54-4cd6-95c5-3c62100c89fd@googlegroups.com> <ce5mhdFctpU1@mid.individual.net> |
Paul E Bennett wrote:
> I was displaying a sine-wave of
> asterix characters scrolling continuously down the screen. 3 lines of code
> generated the sine-wave (and cosine) numbers and the other 30 or so lines
> did scaling and arrangements for its display.
Factor:
USING: sequences literals locals math.ranges math.functions ;
<< CONSTANT: line-length 79 >>
CONSTANT: mid-point $[ line-length 2 /i ]
: one-line ( -- string )
mid-point " " first <string>
dup "|" prepend append ;
:: starred-line ( i -- string )
one-line :> str
CHAR: * i str set-nth
str ;
0.0 22.0 0.1 <range>
[ sin mid-point * mid-point +
round >fixnum starred-line print
] each
Partial output:
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
* |
|*
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| *
|*
* |
* |
* |
* |
* |
* |
Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread
Program or be Programmed ! visualforth@rocketmail.com - 2014-12-01 18:55 -0800
Re: Program or be Programmed ! Paul E Bennett <Paul_E.Bennett@topmail.co.uk> - 2014-12-02 11:36 +0000
Re: Program or be Programmed ! the_gavino_himself <visphatesjava@gmail.com> - 2014-12-13 12:47 -0800
Re: Program or be Programmed ! Paul E Bennett <Paul_E.Bennett@topmail.co.uk> - 2014-12-13 20:54 +0000
Re: Program or be Programmed ! visualforth@rocketmail.com - 2014-12-17 16:51 -0800
Re: Program or be Programmed ! "WJ" <w_a_x_man@yahoo.com> - 2014-12-19 08:20 +0000
Re: Program or be Programmed ! Paul E Bennett <Paul_E.Bennett@topmail.co.uk> - 2014-12-19 09:29 +0000
Re: Program or be Programmed ! "WJ" <w_a_x_man@yahoo.com> - 2015-03-27 07:57 +0000
Re: Program or be Programmed ! "WJ" <w_a_x_man@yahoo.com> - 2014-12-25 21:08 +0000
csiph-web