Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #14135
| From | quiet_lad <gavcomedy@gmail.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: I am still kinda depressed about learning forth |
| Date | 2012-07-17 16:18 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <f2baefb4-8272-4e65-b0a9-049cedcb4199@k5g2000vbf.googlegroups.com> (permalink) |
| References | <7dc3c47f-0880-46a7-a902-2e3338a06ef4@nl1g2000pbc.googlegroups.com> <8e42b297-741e-4aab-a1ed-03006629e5e6@wt8g2000pbb.googlegroups.com> <ju3qna02krt@enews6.newsguy.com> |
On Jul 17, 6:52 am, "WJ" <w_a_x_...@yahoo.com> wrote: > Hugh Aguilar wrote: > > Your method of learning is completely wrong. You are expecting to read > > books and manuals to learn, and then with all of this wonderful > > knowledge begin to write "lean mean programs and utilize abstraction." > > That is not how it works at all. You must write a program, and then > > read up on the language to figure out how to improve the program. I > > already gave you a practice problem: > > >https://groups.google.com/group/comp.lang.forth/browse_thread/thread/... > > > I said this: > > > On Jul 7, 2:35 pm, Hugh Aguilar <hughaguila...@yahoo.com> wrote: > > > Here is a programming challenge easy enough that even Gavino should > > > succeed at it (although I doubt that John Passaniti or Elizabeth > > > Rather can do it). Write a program in ANS-Forth to read a seq file > > > containing one integer per line. Calculate the following: range of > > > data, average of data, median of data, and how many data are above and > > > below the average. > > > > For extra credit, generate a PostScript file that displays a bar-graph > > > of the distribution of data with the mean and median marked. > > > > Everybody please wait a week or two with your answer, in order to give > > > Gavino time to write his program --- this challenge is mostly for his > > > benefit --- it is okay to give him hints (my own hint is to use the > > > novice package's lists), but let him write his own code before you > > > show him your code. > > Since Gavino is interested in learning Lisp and Scheme, > here's a solution in Racket. > > ;; Lines containing numbers must not have whitespace. > ;; Blank lines are ignored. > (define numbers > (with-input-from-file "data.txt" (lambda() > (sort (filter-map string->number (sequence->list (in-lines))) <)))) > > ;; numbers must be already sorted. > (define (median numbers) > (define i (floor (/ (sub1 (length numbers)) 2))) > (if (odd? (length numbers)) > (list-ref numbers i) > (/ (apply + (take (drop numbers i) 2)) 2))) > > (printf "range: ~a .. ~a\n" (first numbers) (last numbers)) > (define average (/ (apply + numbers) (length numbers))) > (printf "average: ~a\n" average) > (printf "median: ~a\n" (median numbers)) > (printf "below average: ~a\n" (length (filter (curry > average) numbers))) > (printf "above average: ~a\n" (length (filter (curry < average) numbers))) > > ==> > > range: 3 .. 22 > average: 8 > median: 13/2 > below average: 5 > above average: 2 nice scheme seems kinda nice
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
I am still kinda depressed about learning forth quiet_lad <gavcomedy@gmail.com> - 2012-07-10 21:17 -0700
Re: I am still kinda depressed about learning forth quiet_lad <gavcomedy@gmail.com> - 2012-07-10 21:43 -0700
Re: I am still kinda depressed about learning forth marko <marko@marko.marko> - 2012-07-11 14:55 +1000
Re: I am still kinda depressed about learning forth quiet_lad <gavcomedy@gmail.com> - 2012-07-10 21:57 -0700
Re: I am still kinda depressed about learning forth marko <marko@marko.marko> - 2012-07-11 15:12 +1000
Re: I am still kinda depressed about learning forth quiet_lad <gavcomedy@gmail.com> - 2012-07-10 22:04 -0700
Re: I am re energized to learn forth and see how simple computers can be! quiet_lad <gavcomedy@gmail.com> - 2012-07-10 22:05 -0700
Re: I am re energized to learn forth and see how simple computers can be! Mark Wills <markrobertwills@yahoo.co.uk> - 2012-07-11 02:08 -0700
Re: I am re energized to learn forth and see how simple computers can be! Doug Hoffman <glidedog@gmail.com> - 2012-07-11 07:14 -0400
Re: I am re energized to learn forth and see how simple computers can be! Mark Wills <markrobertwills@yahoo.co.uk> - 2012-07-11 04:54 -0700
Re: I am re energized to learn forth and see how simple computers can be! marko <marko@marko.marko> - 2012-07-11 22:30 +1000
Re: I am re energized to learn forth and see how simple computers can be! Doug Hoffman <glidedog@gmail.com> - 2012-07-11 08:35 -0400
Re: I am re energized to learn forth and see how simple computers can be! Hannu Vuolasaho <hannu.vuolasaho@nospam.tut.fi.invalid> - 2012-07-11 14:13 +0000
Re: I am re energized to learn forth and see how simple computers can be! Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-12 22:01 +0200
Re: I am re energized to learn forth and see how simple computers can be! Fanzo <cristianof6@gmail.com> - 2012-07-11 21:27 +0200
Re: I am re energized to learn forth and see how simple computers can be! Doug Hoffman <glidedog@gmail.com> - 2012-07-11 16:41 -0400
Re: I am re energized to learn forth and see how simple computers can be! quiet_lad <gavcomedy@gmail.com> - 2012-07-11 14:49 -0700
Re: I am re energized to learn forth and see how simple computers can be! Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-12 01:06 +0000
Re: I am re energized to learn forth and see how simple computers can be! Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-07-13 23:01 -0700
Re: I am re energized to learn forth and see how simple computers can be! "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-07-14 03:28 -0400
Re: I am re energized to learn forth and see how simple computers can be! Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-07-14 03:39 -0700
Re: I am re energized to learn forth and see how simple computers can be! quiet_lad <gavcomedy@gmail.com> - 2012-07-17 15:54 -0700
Re: I am re energized to learn forth and see how simple computers can be! quiet_lad <gavcomedy@gmail.com> - 2012-07-17 14:23 -0700
Re: I am re energized to learn forth and see how simple computers can be! Doug Hoffman <glidedog@gmail.com> - 2012-07-11 16:37 -0400
Re: I am re energized to learn forth and see how simple computers can be! quiet_lad <gavcomedy@gmail.com> - 2012-07-11 13:19 -0700
Re: I am still kinda depressed about learning forth Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-07-15 16:57 -0700
Re: I am still kinda depressed about learning forth Clyde Phillips <cwpjr02@gmail.com> - 2012-07-15 22:07 -0700
Re: I am still kinda depressed about learning forth Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-07-15 22:36 -0700
Re: I am still kinda depressed about learning forth "WJ" <w_a_x_man@yahoo.com> - 2012-07-17 13:52 +0000
Re: I am still kinda depressed about learning forth quiet_lad <gavcomedy@gmail.com> - 2012-07-17 16:18 -0700
Re: I am still kinda depressed about learning forth "WJ" <w_a_x_man@yahoo.com> - 2012-07-18 23:41 +0000
Re: I am still kinda depressed about learning forth "WJ" <w_a_x_man@yahoo.com> - 2012-07-19 00:34 +0000
Re: I am still kinda depressed about learning forth Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-07-18 21:11 -0700
Re: I am still kinda depressed about learning forth "WJ" <w_a_x_man@yahoo.com> - 2012-07-19 06:23 +0000
Re: I am still kinda depressed about learning forth Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-07-18 23:54 -0700
Re: I am still kinda depressed about learning forth "WJ" <w_a_x_man@yahoo.com> - 2012-07-19 00:13 +0000
Re: I am still kinda depressed about learning forth quiet_lad <gavcomedy@gmail.com> - 2012-07-17 16:06 -0700
csiph-web