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


Groups > comp.lang.forth > #35023

Re: Program or be Programmed !

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Paul E Bennett <Paul_E.Bennett@topmail.co.uk>
Newsgroups comp.lang.forth
Subject Re: Program or be Programmed !
Date Fri, 19 Dec 2014 09:29:24 +0000
Organization Hidecs Consultancy
Lines 50
Message-ID <cfi9flFbihrU1@mid.individual.net> (permalink)
References <98f287f7-fc54-4cd6-95c5-3c62100c89fd@googlegroups.com> <ce5mhdFctpU1@mid.individual.net> <m70n3m$vmk$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace individual.net V6bP4X1u1Jn2QLAyNNQD+gcB15934ohk6yAxHnrXUJWqnLZtou
Cancel-Lock sha1:+gWZ6/XnQGdM1O6XWJLZTPJij0M=
User-Agent KNode/4.11.4
Xref csiph.com comp.lang.forth:35023

Show key headers only | View raw


WJ wrote:

> 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. I was showing the
>> source code in a separate window.
> 
> Gauche Scheme:
> 
> (define line-length 79)
> (define mid-point (div line-length 2))
> (define one-line (string-append
>   (make-string mid-point #\space) "|" (make-string mid-point #\space)))
> (define (pause) (sys-nanosleep 5e7))
> (let loop ((x 0.0))
>   (when (< x 22)
>     (let ((this-line (string-copy one-line))
>           (p (round->exact (+ mid-point (* mid-point (sin x))))))
>       (string-set! this-line p #\*)
>       (print this-line)
>       (pause))
>     (loop (+ 0.1 x))))
> 
> Partial output:

[%X]

Ok, now do that without using the sin x function (which I did not in my 
example). I shall post the full source of my example shortly. I have just 
had a quick look and there is a total of 65 lines defining 7 words including 
the comments and a more vertical style than most use. You will see 
(eventually) that had I used a more horizontal style it would probably have 
been just seven lines.

The reason I started playing with the central sine-wave generation was for a 
small robotic project that required me to generate such a waveform. The 
three line sine-wave generation code is all that I am using from this 
example for the robotics project.

-- 
********************************************************************
Paul E. Bennett IEng MIET.....<email://Paul_E.Bennett@topmail.co.uk>
Forth based HIDECS Consultancy.............<http://www.hidecs.co.uk>
Mob: +44 (0)7811-639972
Tel: +44 (0)1235-510979
Going Forth Safely ..... EBA. www.electric-boat-association.org.uk..
********************************************************************

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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