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 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: References: <98f287f7-fc54-4cd6-95c5-3c62100c89fd@googlegroups.com> 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 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..... Forth based HIDECS Consultancy............. Mob: +44 (0)7811-639972 Tel: +44 (0)1235-510979 Going Forth Safely ..... EBA. www.electric-boat-association.org.uk.. ********************************************************************