Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #14155
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: I am still kinda depressed about learning forth |
| Date | 2012-07-19 00:34 +0000 |
| Organization | NewsGuy - Unlimited Usenet $19.95 |
| Message-ID | <ju7kmc02d36@enews4.newsguy.com> (permalink) |
| References | <7dc3c47f-0880-46a7-a902-2e3338a06ef4@nl1g2000pbc.googlegroups.com> <8e42b297-741e-4aab-a1ed-03006629e5e6@wt8g2000pbb.googlegroups.com> <ju3qna02krt@enews6.newsguy.com> <ju7hio02bm2@enews2.newsguy.com> |
WJ wrote: > WJ wrote: > > > > 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. > > Another Racket solution. > > (define (average numbers) (/ (apply + numbers) (length numbers))) > > ;; numbers must be already sorted. > (define (median numbers) > (define i (floor (/ (sub1 (length numbers)) 2))) > (if (odd? (length numbers)) > (list-ref numbers i) > (average (take (drop numbers i) 2)))) > > ;; 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))) <)))) > > (printf "range: ~a .. ~a\n" (first numbers) (last numbers)) > (printf "average: ~a\n" (average numbers)) > (printf "median: ~a\n" (median numbers)) > (printf "below average: ~a\n" > (length (filter (curry > (average numbers)) numbers))) > (printf "above average: ~a\n" > (length (filter (curry < (average numbers)) numbers))) (printf "below average: ~a\n" (count (curry > (average numbers)) numbers)) (printf "above average: ~a\n" (count (curry < (average numbers)) numbers))
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