Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #44782 > unrolled thread
| Started by | Chris Curl <ccurl609@gmail.com> |
|---|---|
| First post | 2016-01-12 07:47 -0800 |
| Last post | 2016-02-11 07:39 -0800 |
| Articles | 20 on this page of 127 — 28 participants |
Back to article view | Back to comp.lang.forth
Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 07:47 -0800
Re: Ruby/Forth challenge for WJ Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-12 16:25 +0000
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-12 10:45 -0600
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 08:46 -0800
Re: Ruby/Forth challenge for WJ rickman <gnuarm@gmail.com> - 2016-01-12 11:57 -0500
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 09:22 -0800
Re: Ruby/Forth challenge for WJ hughaguilar96@gmail.com - 2016-01-12 21:04 -0800
Re: Ruby/Forth challenge for WJ Ron Aaron <rambamist@gmail.com> - 2016-01-13 07:59 +0200
Re: Ruby/Forth challenge for WJ Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-12 19:42 +0000
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-12 12:53 -0800
Re: Ruby/Forth challenge for WJ anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-13 15:45 +0000
Re: Ruby/Forth challenge for WJ rickman <gnuarm@gmail.com> - 2016-01-13 13:44 -0500
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-13 11:39 -0800
Re: Ruby/Forth challenge for WJ Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-14 05:01 +0100
Re: Ruby/Forth challenge for WJ anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-14 12:28 +0000
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 09:50 -0800
Re: Ruby/Forth challenge for WJ Pablo Hugo Reda <pabloreda@gmail.com> - 2016-01-12 11:50 -0800
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 12:30 -0800
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 12:43 -0800
Re: Ruby/Forth challenge for WJ stephen@mpeforth.com (Stephen Pelc) - 2016-01-12 21:01 +0000
Re: Ruby/Forth challenge for WJ peter.m.falth@gmail.com - 2016-01-12 15:00 -0800
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-12 16:13 -0800
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-12 16:22 -0800
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-12 16:24 -0800
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-12 17:46 -0800
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-12 18:39 -0800
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-13 13:05 -0800
Re: Ruby/Forth challenge for WJ Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-14 04:33 +0100
Re: Ruby/Forth challenge for WJ m.a.m.hendrix@tue.nl - 2016-01-14 03:27 -0800
Re: Ruby/Forth challenge for WJ peter.m.falth@gmail.com - 2016-01-14 04:42 -0800
Re: Ruby/Forth challenge for WJ anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-14 13:03 +0000
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-13 21:17 -0800
Re: Ruby/Forth challenge for WJ hughaguilar96@gmail.com - 2016-01-13 21:44 -0800
Re: Ruby/Forth challenge for WJ anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-14 10:57 +0000
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-14 12:20 -0800
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-14 13:57 -0800
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-14 14:22 -0800
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-14 16:14 -0800
Re: Ruby/Forth challenge for WJ Melzzzzz <mel@zzzzz.com> - 2016-01-15 03:05 +0100
Re: Ruby/Forth challenge for WJ Waldek Hebisch <hebisch@antispam.uni.wroc.pl> - 2016-01-15 00:41 +0000
Re: Ruby/Forth challenge for WJ anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-15 16:22 +0000
Re: Ruby/Forth challenge for WJ mhx@iae.nl (Marcel Hendrix) - 2016-01-16 11:44 +0200
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-16 04:49 -0800
Re: Ruby/Forth challenge for WJ Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-16 15:05 +0000
Re: Ruby/Forth challenge for WJ m.a.m.hendrix@tue.nl - 2016-01-18 03:26 -0800
Re: Ruby/Forth challenge for WJ anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-18 12:48 +0000
Re: Ruby/Forth challenge for WJ Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-19 22:26 +0100
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-20 03:05 -0800
Re: Ruby/Forth challenge for WJ Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-20 21:00 +0100
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-20 15:57 -0800
Re: Ruby/Forth challenge for WJ Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-21 23:02 +0100
Re: Ruby/Forth challenge for WJ Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-22 01:25 +0000
Re: Ruby/Forth challenge for WJ hughaguilar96@gmail.com - 2016-01-21 18:05 -0800
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-21 22:03 -0800
Re: Ruby/Forth challenge for WJ anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-20 13:40 +0000
Re: Ruby/Forth challenge for WJ m.a.m.hendrix@tue.nl - 2016-01-18 03:55 -0800
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-23 15:13 -0600
Re: Ruby/Forth challenge for WJ mhx@iae.nl - 2016-01-24 00:55 -0800
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-25 04:48 -0600
Re: Ruby/Forth challenge for WJ Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-25 12:39 +0000
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-25 08:05 -0600
Re: Ruby/Forth challenge for WJ Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-25 16:40 +0000
Re: Ruby/Forth challenge for WJ Mark Wills <markwills1970@gmail.com> - 2016-01-25 04:44 -0800
Re: Ruby/Forth challenge for WJ stephen@mpeforth.com (Stephen Pelc) - 2016-01-25 14:01 +0000
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-25 08:08 -0600
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-25 11:56 -0600
Re: Ruby/Forth challenge for WJ "Elizabeth D. Rather" <erather@forth.com> - 2016-01-25 11:12 -1000
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-26 03:33 -0600
Re: Ruby/Forth challenge for WJ stephen@mpeforth.com (Stephen Pelc) - 2016-01-26 11:09 +0000
Re: Ruby/Forth challenge for WJ stephen@mpeforth.com (Stephen Pelc) - 2016-01-26 11:06 +0000
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-26 07:45 -0600
Re: Ruby/Forth challenge for WJ anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-26 16:46 +0000
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-26 11:16 -0600
Object-oriented Forth (was: Ruby/Forth challenge for WJ) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-27 14:13 +0000
Re: Object-oriented Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-27 10:33 -0600
Re: Object-oriented Forth hughaguilar96@gmail.com - 2016-01-27 08:45 -0800
Re: Object-oriented Forth Chris Curl <ccurl609@gmail.com> - 2016-01-27 09:14 -0800
Re: Object-oriented Forth hughaguilar96@gmail.com - 2016-01-29 21:57 -0800
Re: Object-oriented Forth Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-30 10:58 +0000
Re: Object-oriented Forth Chris Curl <ccurl609@gmail.com> - 2016-01-30 09:38 -0800
Re: Object-oriented Forth Coos Haak <chforth@hccnet.nl> - 2016-01-30 20:39 +0100
Re: Ruby/Forth challenge for WJ Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-26 15:56 +0100
Re: Ruby/Forth challenge for WJ stephen@mpeforth.com (Stephen Pelc) - 2016-01-26 20:46 +0000
Re: Ruby/Forth challenge for WJ Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-25 22:27 +0100
Re: Ruby/Forth challenge for WJ Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2016-01-28 14:20 +0100
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-28 08:06 -0600
Re: Ruby/Forth challenge for WJ Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-28 16:14 +0100
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-28 10:32 -0600
Re: Ruby/Forth challenge for WJ anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-28 17:26 +0000
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-28 12:13 -0600
Re: Ruby/Forth challenge for WJ Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-29 11:07 +0000
Re: Ruby/Forth challenge for WJ Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-29 21:18 +0100
Re: Ruby/Forth challenge for WJ Tessa Bonting <tessa.bonting@gmail.com> - 2016-01-16 06:24 -0800
Re: Ruby/Forth challenge for WJ Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-01-13 05:21 -0500
Re: Ruby/Forth challenge for WJ Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-01-13 05:36 -0500
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-13 10:33 -0800
Re: Ruby/Forth challenge for WJ Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-01-14 01:37 -0500
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 13:45 -0800
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 13:55 -0800
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-12 14:34 -0800
Re: Ruby/Forth challenge for WJ rickman <gnuarm@gmail.com> - 2016-01-12 19:00 -0500
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 16:49 -0800
Re: Ruby/Forth challenge for WJ rickman <gnuarm@gmail.com> - 2016-01-12 22:18 -0500
Re: Ruby/Forth challenge for WJ hughaguilar96@gmail.com - 2016-01-12 14:31 -0800
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-12 16:05 -0800
Re: Ruby/Forth challenge for WJ "WJ" <w_a_x_man@yahoo.com> - 2016-01-13 07:58 +0000
Re: Ruby/Forth challenge for WJ Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> - 2016-01-13 05:17 -0500
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-13 12:36 -0800
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-13 12:53 -0800
Re: Ruby/Forth challenge for WJ Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-14 06:50 -0600
Re: Ruby/Forth challenge for WJ Julian Fondren <julian.fondren@gmail.com> - 2016-01-13 05:36 -0800
Re: Ruby/Forth challenge for WJ lehs <skydda.barnen@gmail.com> - 2016-01-13 11:59 -0800
Re: Ruby/Forth challenge for WJ Chris Curl <ccurl609@gmail.com> - 2016-01-21 21:08 -0800
Re: Ruby/Forth challenge for WJ "WJ" <w_a_x_man@yahoo.com> - 2016-02-09 13:36 +0000
Re: Ruby/Forth challenge for WJ "WJ" <w_a_x_man@yahoo.com> - 2016-02-09 13:48 +0000
Re: Ruby/Forth challenge for WJ hughaguilar96@gmail.com - 2016-02-09 12:02 -0800
Re: Ruby/Forth challenge for WJ "WJ" <w_a_x_man@yahoo.com> - 2016-02-09 13:58 +0000
Re: Ruby/Forth challenge for WJ "WJ" <w_a_x_man@yahoo.com> - 2016-02-09 14:30 +0000
Re: Ruby/Forth challenge for WJ "WJ" <w_a_x_man@yahoo.com> - 2016-02-14 15:35 +0000
Re: Ruby/Forth challenge for WJ franck.bensusan@gmail.com - 2016-02-14 08:50 -0800
Re: Ruby/Forth challenge for WJ Julian Fondren <julian.fondren@gmail.com> - 2016-02-14 20:09 -0800
Re: Ruby/Forth challenge for WJ hughaguilar96@gmail.com - 2016-02-15 08:52 -0800
Re: Ruby/Forth challenge for WJ "WJ" <w_a_x_man@yahoo.com> - 2016-02-14 21:31 +0000
Re: Ruby/Forth challenge for WJ "WJ" <w_a_x_man@yahoo.com> - 2016-01-14 22:49 +0000
Re: Ruby/Forth challenge for WJ Paul Rubin <no.email@nospam.invalid> - 2016-01-14 15:31 -0800
Re: Ruby/Forth challenge for WJ Melzzzzz <mel@zzzzz.com> - 2016-01-15 06:55 +0100
Re: Ruby/Forth challenge for WJ djc <ciesinger@gmx.net> - 2016-02-11 07:39 -0800
Page 6 of 7 — ← Prev page 1 2 3 4 5 [6] 7 Next page →
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2016-01-12 19:00 -0500 |
| Message-ID | <n743ti$io4$1@dont-email.me> |
| In reply to | #44797 |
On 1/12/2016 4:55 PM, Chris Curl wrote: > OK ... let's see how fast WJ's Ruby implementation runs. > > Since Ruby is so much better than the "toy" language Forth, Ruby can do the same thing be much faster than 600ms, right? > > WJ, the ball is in your court. You don't really expect WJ to respond do you? I'll be very surprised if he produces a program for this. -- Rick
[toc] | [prev] | [next] | [standalone]
| From | Chris Curl <ccurl609@gmail.com> |
|---|---|
| Date | 2016-01-12 16:49 -0800 |
| Message-ID | <82f04fbf-0d6c-4eed-9c51-7e8e665ad149@googlegroups.com> |
| In reply to | #44804 |
On Tuesday, January 12, 2016 at 7:00:22 PM UTC-5, rickman wrote: > On 1/12/2016 4:55 PM, Chris Curl wrote: > > OK ... let's see how fast WJ's Ruby implementation runs. > > > > Since Ruby is so much better than the "toy" language Forth, Ruby can do the same thing be much faster than 600ms, right? > > > > WJ, the ball is in your court. > > You don't really expect WJ to respond do you? I'll be very surprised if > he produces a program for this. > > -- > > Rick No, I do not expect him to respond. He is too much of a coward.
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2016-01-12 22:18 -0500 |
| Message-ID | <n74fhv$f7g$1@dont-email.me> |
| In reply to | #44809 |
On 1/12/2016 7:49 PM, Chris Curl wrote: > On Tuesday, January 12, 2016 at 7:00:22 PM UTC-5, rickman wrote: >> On 1/12/2016 4:55 PM, Chris Curl wrote: >>> OK ... let's see how fast WJ's Ruby implementation runs. >>> >>> Since Ruby is so much better than the "toy" language Forth, Ruby can do the same thing be much faster than 600ms, right? >>> >>> WJ, the ball is in your court. >> >> You don't really expect WJ to respond do you? I'll be very surprised if >> he produces a program for this. >> >> -- >> >> Rick > > No, I do not expect him to respond. He is too much of a coward. I don't know about coward. That's just not his game. He likes to invent silly little problems that match the capabilities of his favorite languages and then tease folks here with them. He has never done anything really useful in this regard. Oddly, I have seen him post in some other groups where he seems to not be so single minded. He can actually write and appear to be a person rather than a bot. -- Rick
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2016-01-12 14:31 -0800 |
| Message-ID | <0e0562c5-1150-4dd5-8eda-7cdf15ff7c3b@googlegroups.com> |
| In reply to | #44782 |
On Tuesday, January 12, 2016 at 8:47:09 AM UTC-7, Chris Curl wrote: > So, Ruby is so powerful, and Forth is a toy language. Let's see how fast Ruby can do this: > > 1. Allocate 256MB ram and fill it with random binary data. > 2. Collect and print out the distribution of byte values in all 256MB bytes from #1. > > Forthers, how fast can your Forth do it? > > Any bets on which will be faster? Chris, you challenge doesn't make any sense. What is the point of filling up the array with this data? Why not just collect the data on the distribution on the fly as the random numbers are generated, and discard the random numbers afterward as they have no further use? You just need an array of 256 elements to hold the count of each generated random byte. Also, this test is going to depend heavily upon which prng you use, as they vary in speed quite a lot --- my LC53 is pretty fast given a processor with hardware multiplication and division --- it is not good enough for use in encryption, but it should provide a pretty rectangular distribution for your test (your test is pretty basic because it doesn't test for patterns over time, but only for the final distribution). As a better challenge, how about porting my LowDraw program to Ruby? It takes a while to run, so it makes a good bench-mark. It involves a lot of ANDing and ORing of probabilities. There is no LowDraw function in Ruby or any other scripting language, so the script kiddies who expect to write a wrapper around a built-in function will be defeated. I am learning R right now, and my first project will be porting the LowDraw program to R --- I mean to do that every weekend, but then I end up spending the whole weekend playing Go on the internet as usual --- hopefully I will actually do it this weekend (getting anything done is all about staying away from the internet, which is just a gigantic time-sink).
[toc] | [prev] | [next] | [standalone]
| From | Chris Curl <ccurl609@gmail.com> |
|---|---|
| Date | 2016-01-12 16:05 -0800 |
| Message-ID | <66176529-fc82-4f7b-962d-ea6b23214796@googlegroups.com> |
| In reply to | #44799 |
On Tuesday, January 12, 2016 at 5:31:45 PM UTC-5, hughag...@gmail.com wrote: > Chris, you challenge doesn't make any sense. What is the point of filling up the array with this data? Why not just collect the data on the distribution on the fly as the random numbers are generated, and discard the random numbers afterward as they have no further use? You just need an array of 256 elements to hold the count of each generated random byte. Also, this test is going to depend heavily upon which prng you use, as they vary in speed quite a lot --- my LC53 is pretty fast given a processor with hardware multiplication and division --- it is not good enough for use in encryption, but it should provide a pretty rectangular distribution for your test (your test is pretty basic because it doesn't test for patterns over time, but only for the final distribution). > > As a better challenge, how about porting my LowDraw program to Ruby? It takes a while to run, so it makes a good bench-mark. It involves a lot of ANDing and ORing of probabilities. There is no LowDraw function in Ruby or any other scripting language, so the script kiddies who expect to write a wrapper around a built-in function will be defeated. > > I am learning R right now, and my first project will be porting the LowDraw program to R --- I mean to do that every weekend, but then I end up spending the whole weekend playing Go on the internet as usual --- hopefully I will actually do it this weekend (getting anything done is all about staying away from the internet, which is just a gigantic time-sink). Hugh, you may have missed my later updated version of the challenge: Given a 256MB buffer of binary data in memory, generate a table of counts of the byte values for all the bytes in the 256MB buffer as fast as possible. How the 256MB buffer is created is left to the discretion of the programmer, and the time to create it is not included in the timing of the test.
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2016-01-13 07:58 +0000 |
| Message-ID | <n7503j$noj$1@dont-email.me> |
| In reply to | #44782 |
Chris Curl wrote:
> So, Ruby is so powerful, and Forth is a toy language. Let's see how fast Ruby can do this:
>
> 1. Allocate 256MB ram and fill it with random binary data.
> 2. Collect and print out the distribution of byte values in all 256MB bytes from #1.
>
> Forthers, how fast can your Forth do it?
>
> Any bets on which will be faster?
Speed isn't everything. As a general rule, high-level languages are
slower than low-level languages. If speed of execution were the only
thing that mattered, then all programming would be done in assembly
language, Fortran, or C.
Ease of writing and maintaining programs matters a lot.
This is a very simplistic, low-level task which a simplistic,
low-level language can perform swiftly. Would it be unfair
to say that this is a toy task tailored for a toy language?
I suspect that the random number generators used in the ANS Forth
solutions will have somewhat smaller periods than the Ruby one.
From the documentation at http://ruby-doc.org/core-2.0.0/Random.html :
PRNGs are currently implemented as a modified Mersenne Twister
with a period of 2**19937-1.
How big is that? Let's ask Ruby.
puts (2**19937-1).to_s.scan /.{1,64}/
4315424797388162648055235516337919839053935043226711505165250541
4033306801376580911304513629318584665545269938257648835317902217
3345844139095282691546091680190078753437413962968019201144864809
0266141431844327698030006672810498409545158817607713296984376213
4621790396391341285205627619600513106646376648615994236675486537
4802419643502959351686623639090479483476923139783013778207857124
1905447433284452918317297324231088826508132162646945107770781228
2829444775022680488057820028764659399164766265200900561495800344
0543536903898628940617928720111208336148084474829135473283672778
7956564830784690911694586623016970240126024018702874665003344577
4570315431292996025187780790119375902863171084149642473378986267
5033089613749057663409052895722900160380005716308751913739795550
4746815433325347499104624813250451634179655147057548145920085947
2614836213875557116864445789750886277996487304308450484223420629
2665185560243393391908443689210184248446770427276646018529149252
7728092269753842677025733392895440120546589561034765885538663390
2546289962132643282425748035786233580608154696546932563833327670
7698994397748885266872785274510029630591469638757154257355344759
7973446310067836739332740214993096877829674139151459960237421362
9898720611431410402147238998090962818915890645693934483330994169
6322958779958489933667470148717634948055499961630515412254034652
9700772114623135570408149309866306573367719117285398709574816781
6256084212823380168625334586431254034670806135273543270714478876
8618619833207772806448066911257131972625817631513135964295477635
7636783701934983517846214429496075719091805462511414366638418943
3852576452289347652454631535740468786228945885654608562058042468
9873724369214450923153776984071681983765382377486141962070415481
0637936512319281799900662176646716711347163271548179587700538269
4393400403061700457691135349187874888923429349340145170571716181
1257958888892774954269771499145496239163940148229850253316515114
3127880200905680845650681887726660983163688388490562182226293398
6548645669080672191704740408891349835685662428063231198520436826
3294152907529727983434294465099922063687813671540917026557727273
9132942427752934908260058588476652315095741707783191001616847568
5658673192860882070179760307269849987354836042371734660257694347
2355063017441188741412924389581415491006097522168822308876114319
9647233084238013711092744948355781503758684964458574991777286992
6744218369621137675101083278543794081749094091043084096774144708
4363242794768920562004272279616386691498054898311212446763999319
5537148401288636074870647956866904857478285521705474011394592962
2177502575565811067452201448981991968635965361551681273982740760
1388996388203187763036687627301575846400427988806918626402686126
8618088387493957381812502227968993026744625577395954246983163786
3000171279227151406034129902181570659650532600775823677398182129
0873944498591827499990072235924233345678506711865688391867477049
6001627754062533144061901912998378991471251536520033605799350860
1678807687568562377857095255541304902927192220184172502357124449
9118702106426945650613849193734743245039662677990384023867816868
0996201587909058654942350469919074351955104372254451574096782908
4336025938225780730880273855261551972044075620326780624448803490
9982321612316877947156134057932495455095280525180101230872587789
7411581704824558897143859675440808131343837550298872673952337529
6641615501406091607983229239827240614783252892479716519936989519
1878086812211916417477109024806334910917048274412282811866324459
0714578713835123484226138007462191400481815238666604313334487506
7903582838283562688083236575482068479639546383819532174522502682
3724413632757658756091197836532983120667082171493167735643403792
8972439398674413989185541661229573935666861265827123469643837712
2838998040199739078061443675415671078463404673702403777653478173
3670848447347020568666361581380036922533822099094664695919301616
2609792050874217567030650513954286075080615983535754103214709508
4278461056701367739794932024202998707731017692582046210702212514
1204293225304317896162670477761151235979354041470848709854654265
0277205730090033384790533425060411950303000170400288789294140460
3345869926367501355094942750552591581639980523190679610784993580
8966832992976812624423140086570334218680945517405064488290392073
1671130769513189229659350901862309481055751956030524078716380921
9164433754514863301000915916985856242176563624771328981678548246
2973762495302513603634127683664561750770319774575349128064331765
3999599434330811847014715871281614939442127661422826290995005574
6981053206610001560295784656616193252269412026831159508949671513
8451958832171479827488792618514178199790344172855986077272208666
7768042609030875482380334544656630561924130837445275466814301548
7710877728011086004325892262259413968285283497045571062757701421
7615652627251534074076254051499319894944591064146605343053785767
0986252004986488096114486925860347371436365919401396270636685138
9299692869491805172556818508298824954954815796063169517658741420
1597987542734280267234524812635691573072131537397810416276537150
7859850415479728766312294671134815852941881643282504446669278113
7474494898385064375787507376496345148625306383391555145690087891
9553159944629444932352488175999071191357559333821217061914771850
5493663221115722292033114850248756330311801880568507356984158051
8118710778653953571296014372940865270407021924383167290323231567
9122894194862405940390744523216780193818712190921554607684445735
7855951361330424220615135645751393727093900970723782710124585383
7678338161023397586854894230696091540249987907453461311923963852
9507547580582056259566008177430071917468126559550217476709224608
6674774452087560785906233475062709832859348006778945616960249439
2813763495657599847485773553990957557313200809040830036446492219
4099340969487305474943012161656867507357495558823403039898746729
7545506095773692155919548081551403591570712993005702711728625284
3197413312307617886797506784260195436760305990340708481464607278
9554954877421407535706212171982521929788697869167346256184301754
54903864111585429504569920905636741539030968041471
If ANS Forth is asked, will it be so helpful?
I doubt it.
Create a string containing 99,000,000 random bytes.
t = Time.now; s = Random.new.bytes(99_000_000) ; p Time.now - t; s = ""
Here are some problems that call for a high-level language.
When did England adopt the Gregorian calendar?
require 'date'
Date.new(1700,1).upto(Date.new 1799,12,31).find{|d| d.england.gregorian?}.to_s
===>
"1752-09-14"
Find an element in an array, and replace it with an (unwrapped) array.
a = [:a,:b,:c]
a[a.index(:b),1] = [1,2]
a
===>
[:a, 1, 2, :c]
As above, but without unwrapping.
a = [:a,:b,:c]
a[a.index(:b)] = [1,2]
a
===>
[:a, [1, 2], :c]
An array or list contains strings and non-strings.
Segregate the strings from the non-strings.
["one",2,"three",:four,5].partition{|x| x.is_a? String}
===>
[["one", "three"], [2, :four, 5]]
From a string extract the substrings contained in [].
"toy [pd] language [dp] ? [a][1,2;3--4][c]".scan(/\[(.*?)\]/).map &:first
===>
["pd", "dp", "a", "1,2;3--4", "c"]
The first 5 characters of each line of a file are a vendor code.
Determine how many times each code occurs.
table = Hash.new(0)
IO.foreach("data.txt"){|line| table[line[0,5]] += 1}
table.sort_by{|k,v| k}.each{|k,v| puts "#{k} #{v}"}
Split a string into 3 fields. The delimiter string is ";",
but the last field may contain ";" as part of its data.
"U8942;2.72;Not that; but this".split(";", 3)
===>
["U8942", "2.72", "Not that; but this"]
Count the number of times the elements in a list occur, and
sort so that the counts are decreasing.
def occurrences array
array.group_by{|x| x}.map{|k,v| [k,v.size]}.sort_by{|x| -x[1]}
end
occurrences %w(b a d c d c b d c d)
==>[["d", 4], ["c", 3], ["b", 2], ["a", 1]]
Decode an http-encoded string.
"foo%20bar%20%41ct".gsub(/%(..)/){$1.to_i(16).chr}
==>"foo bar Act"
Given an item and a sequence, produce multiple copies of
the sequence with the item inserted at every possible position.
def variations item, array
0.upto(array.size).map{|i| array.dup.insert(i, item)}
end
variations :-, [:a,:b,:c]
===>
[[:-, :a, :b, :c],
[:a, :-, :b, :c],
[:a, :b, :-, :c],
[:a, :b, :c, :-]]
Flatten a sequence that contains sequences.
[[0],2,[[3,4]],[6],[[8]]].flatten
===>
[0, 2, 3, 4, 6, 8]
As above, but with only one level of flattening.
[[0],2,[[3,4]],[6],[[8]]].flatten 1
===>
[0, 2, [3, 4], 6, [8]]
Remove consecutive duplicates from a sequence.
%w(a a a a b c c a a d e e e e).chunk{|x| x}.map &:first
===>
["a", "b", "c", "a", "d", "e"]
Determine whether some item in a sequence occurs at least
4 times.
def four? hand
hand.group_by{|x| x}.map{|k,v| v.size}.max > 3
end
[[2,2,2,5,6,7,:a],
[8,8,8,8,8,8,8],
[2,3,2,4,2,2,:k],
[:k,:q,:j,9,9,9,9],
[:a,2,:a,:a,:a,5,8]].each{|hand| printf "%-5s %s\n", four?(hand), hand}
false [2, 2, 2, 5, 6, 7, :a]
true [8, 8, 8, 8, 8, 8, 8]
true [2, 3, 2, 4, 2, 2, :k]
true [:k, :q, :j, 9, 9, 9, 9]
true [:a, 2, :a, :a, :a, 5, 8]
Shuffle the cards, and deal them into four hands.
Sort the cards in each hand.
$suits = [:clubs,:diamonds,:hearts,:spades]
$ranks = [2,3,4,5,6,7,8,9,10,:jack,:queen,:king,:ace]
def create_hands
$suits.flat_map{|s| $ranks.map{|r| [s,r]}}.shuffle.
each_slice(13).map{|hand|
hand.sort_by{|s,r| [$suits.index(s), $ranks.index(r)]}}
end
create_hands
[[[:clubs, 7], [:diamonds, 9], [:diamonds, :king], [:diamonds, :ace],
[:hearts, 3], [:hearts, 5], [:hearts, 6], [:hearts, 10],
[:hearts, :jack], [:spades, 6], [:spades, 7], [:spades, 9], [:spades, 10]],
[[:clubs, 6], [:clubs, 10], [:clubs, :king], [:diamonds, 2], [:diamonds, 3],
[:diamonds, 4], [:diamonds, 8], [:diamonds, 10], [:hearts, 2],
[:hearts, 8], [:spades, 5], [:spades, :queen], [:spades, :king]],
[[:clubs, 3], [:clubs, 4], [:clubs, 9], [:clubs, :jack], [:clubs, :queen],
[:diamonds, 5], [:diamonds, :queen], [:hearts, 7], [:hearts, :queen],
[:spades, 2], [:spades, 8], [:spades, :jack], [:spades, :ace]],
[[:clubs, 2], [:clubs, 5], [:clubs, 8], [:clubs, :ace], [:diamonds, 6],
[:diamonds, 7], [:diamonds, :jack], [:hearts, 4], [:hearts, 9],
[:hearts, :king], [:hearts, :ace], [:spades, 3], [:spades, 4]]]
Vigenere cipher.
def str_to_nums str, negate=false
str.upcase.gsub(/[^A-Z]+/, "").each_char.map{|c|
(c.ord - "A".ord) * (negate ? -1 : 1)}
end
def nums_to_str nums
nums.map{|n| (n + "A".ord).chr}.join
end
def vig text, key, decipher=false
nums_to_str(str_to_nums(text).zip(str_to_nums(key, decipher).cycle).
map{|a,b| (a + b).modulo 26})
end
msg = "Beware the Jabberwock... The jaws that... the claws that catch!"
key = "vigenere cipher"
enc = vig msg, key
dec = vig enc, key, true
puts "msg: #{msg}\nenc: #{enc}\ndec: #{dec}"
===>
msg: Beware the Jabberwock... The jaws that... the claws that catch!
enc: WMCEEIKLGRPIFVMEUGXXYILILZXYVBZLRGCEYAIOEKXIZGU
dec: BEWARETHEJABBERWOCKTHEJAWSTHATTHECLAWSTHATCATCH
--
The gangs are almost always operated by Dutch-born Moroccan and Turkish men
[who] ... give their victims alcohol and drugs, use lies to separate them from
their families, gang rape them ..., and then place the girls in
prostitution.... Some of these girls are as young as 11 or 12 years old.
http://www.liveleak.com/view?i=807_1369627137
[toc] | [prev] | [next] | [standalone]
| From | Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> |
|---|---|
| Date | 2016-01-13 05:17 -0500 |
| Message-ID | <20160113051755.10f38de7@_> |
| In reply to | #44817 |
On Wed, 13 Jan 2016 07:58:49 -0000 (UTC) "WJ" <w_a_x_man@yahoo.com> wrote: > Chris Curl wrote: > > [Chris' challenge] > > > > Any bets on which will be faster? > > Speed isn't everything. As a general rule, high-level languages are > slower than low-level languages. If speed of execution were the only > thing that mattered, then all programming would be done in assembly > language, Fortran, or C. So, you've excluded C from being a high-level language? ... You've also included *all* interpreters in the high-level language group, i.e., simply because they're slower than assembly. (Clearly, I don't know what to say to that.) > [teaching examples] What purpose do those serve other than as programming examples to fill a textbook? I.e., none of them seem to be real-world problems that anyone would ever need to solve. Most seem to be the same types of problems that were taught for Pascal programming to teach programming, not to teach problem solving. I take it that you posted those examples in order to prove that the ability to solve a problem quickly is more important than speed. This is only true only for a non-computer programming situations, i.e., for solving homework or engineering problems. If you're coding applications or an operating system, which I'm assuming is still the job of most computer programmers, then speed is far more important. Rod Pemberton
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2016-01-13 12:36 -0800 |
| Message-ID | <87wprdtdwc.fsf@nightsong.com> |
| In reply to | #44818 |
Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> writes: > If you're coding applications or an operating system, which I'm > assuming is still the job of most computer programmers, then > speed is far more important. Nah, not really, OS development is a niche, and most application programming these days isn't very speed intensive, primarily because computation is at least 1e6 times cheaper than in the early Unix era (1 mips vax at $100k vs. 10000 mips x86 at $1000. The software development cycle has gotten a lot faster so people can't spend as long tweaking and debugging code. There are some big applications and OS's written in C or C++ but not that many people work on those. Facebook and Wikipedia are written in PHP, Youtube and Yelp are supposedly written in Python, Github is written in Ruby, etc. (Youtube of course depends heavily on ffmpeg or the like, which are written in C, but not considered part of the application proper). Most programmers I know these days, including me, do most of their stuff in scripting languages and quite a few have never used C at all.
[toc] | [prev] | [next] | [standalone]
| From | Chris Curl <ccurl609@gmail.com> |
|---|---|
| Date | 2016-01-13 12:53 -0800 |
| Message-ID | <71219ff9-36af-43db-95f7-eaac3f751cc3@googlegroups.com> |
| In reply to | #44836 |
On Wednesday, January 13, 2016 at 3:36:56 PM UTC-5, Paul Rubin wrote: > Nah, not really, OS development is a niche, and most application > programming these days isn't very speed intensive, primarily because > computation is at least 1e6 times cheaper than in the early Unix era (1 > mips vax at $100k vs. 10000 mips x86 at $1000. The software development > cycle has gotten a lot faster so people can't spend as long tweaking and > debugging code. There are some big applications and OS's written in C > or C++ but not that many people work on those. Facebook and Wikipedia > are written in PHP, Youtube and Yelp are supposedly written in Python, > Github is written in Ruby, etc. (Youtube of course depends heavily on > ffmpeg or the like, which are written in C, but not considered part of > the application proper). Most programmers I know these days, including > me, do most of their stuff in scripting languages and quite a few have > never used C at all. I'm a developer for 3M. Here, pretty much all of our stuff is C++ or C#. I do not see that changing any time in the near future.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2016-01-14 06:50 -0600 |
| Message-ID | <esSdnfmlj-w5BArLnZ2dnUU78U-dnZ2d@supernews.com> |
| In reply to | #44836 |
Paul Rubin <no.email@nospam.invalid> wrote: > Rod Pemberton <NoHaveNotOne@bcczxcfre.cmm> writes: >> If you're coding applications or an operating system, which I'm >> assuming is still the job of most computer programmers, then >> speed is far more important. > > Nah, not really, OS development is a niche, and most application > programming these days isn't very speed intensive, primarily because > computation is at least 1e6 times cheaper than in the early Unix era > (1 mips vax at $100k vs. 10000 mips x86 at $1000. The software > development cycle has gotten a lot faster so people can't spend as > long tweaking and debugging code. There are some big applications > and OS's written in C or C++ but not that many people work on those. > Facebook and Wikipedia are written in PHP, Youtube and Yelp are > supposedly written in Python, Github is written in Ruby, etc. We-ell, kinda sorta. People are very concerned about power consumption, and you pay for every megabyte on the cloud. If most of the CPU usage and I/O of an application is in the core database, then that's what matters. I think that performance is still really important, but what people call an "application" is just a thin skin over a database and a web server. Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2016-01-13 05:36 -0800 |
| Message-ID | <a22614d2-014d-4625-86a0-03aaed3bbf24@googlegroups.com> |
| In reply to | #44817 |
On Wednesday, January 13, 2016 at 2:01:34 AM UTC-6, WJ wrote:
>
> Speed isn't everything. As a general rule, high-level languages are
> slower than low-level languages.
>
No, this isn't a general rule. There's a particular category that
includes awk, Python, Perl, Ruby, PHP, which are historically slow
because they A) have all been horribly implemented, because even
completely naive programming was good enough to sort of compete in a
space with awk, and then B) don't have designs with information that
would lend themselves to optimization should a need for a competent
implementor ever come along -- and by accident, not out of some
special 'high levelness' that was optimized for.
Put Forth aside. These languages are blatantly not any 'higher level'
than Common Lisp, but Common Lisp trounces them in speed. It's better
designed and has more competent implementations. As a bonus, your
Common Lisp code doesn't rot away when your language dictator decides
one day that he likes O'Reilly bucks (perl6) or vectorable I/O
primitives (result: Python programmers write as if 'print' had never
existed) or lazy evaluation (Clojure, back before it was cool but
after at least two books were written about it).
>
> Ease of writing and maintaining programs matters a lot.
>
> This is a very simplistic, low-level task which a simplistic,
> low-level language can perform swiftly.
>
Any language on a modern operating system should be able to it. Just
read so many bytes of /dev/urandom and then loop over them. It's a
task designed by someone who sort of thought it might be hard or slow
for Ruby but hadn't tried doing it in Ruby -- much like all of your
tasks.
>
> If ANS Forth is asked, will it be so helpful?
> I doubt it.
>
Here you go:
: tedious-number ( -- ) 0 0 do i 60 mod 0= if cr then ." 1" loop ;
All the spam you want in a can. A little harder to hide hidden
messages in than your digits that nobody will ever read. But still
impressive in its own way.
Having a big number facility is a matter of *convenience*. Means you
don't have to go to the store for, or link in, a library that does the
same thing. You don't really show off the convenience of it with a
run of (fact 400), though.
> When did England adopt the Gregorian calendar?
"Do you have a date/time library? (y/n)"
> Find an element in an array, and replace it with an (unwrapped) array.
> As above, but without unwrapping.
> An array or list contains strings and non-strings.
> Segregate the strings from the non-strings.
Hey, Haskell's a meme language. Why don't you learn Haskell? Please,
learn something functional and stop pestering us with these challenges
that start with the stupidest arrangements of data.
> From a string extract the substrings contained in [].
>
> "toy [pd] language [dp] ? [a][1,2;3--4][c]".scan(/\[(.*?)\]/).map &:first
> ===>
> ["pd", "dp", "a", "1,2;3--4", "c"]
>
Perl: =~ //g
Ruby: .scan().map &first # build arays just to throw them away
What's sad is that this can be solved easily with SKIP and SCAN
Meanwhile, there's FFL's rgx and C interfaces to libpcre. There's
some 'whippitupitude' to having more natural regex interfaces on hand.
This is a reason, for once-off awk-level tasks, to just use awk. It's
undeniable that awk is convenient. Denying that would be like denying
that grep is convenient. It's a tool and very specific convenience is
about all that anyone expects from it.
>
> The first 5 characters of each line of a file are a vendor code.
> Determine how many times each code occurs.
>
> table = Hash.new(0)
> IO.foreach("data.txt"){|line| table[line[0,5]] += 1}
> table.sort_by{|k,v| k}.each{|k,v| puts "#{k} #{v}"}
>
cut -b 1-5 data.txt | sort | uniq -c | sort -n
Guess Ruby's a 'lower level' language than bash.
>
> Split a string into 3 fields. The delimiter string is ";",
> but the last field may contain ";" as part of its data.
>
> "U8942;2.72;Not that; but this".split(";", 3)
> ===>
> ["U8942", "2.72", "Not that; but this"]
>
: .split ( 'string' -- )
&; $/ type cr
&; $/ type cr
type cr ;
"a;b;c;d" .split
a
b
c;d
OK
lina. I guess defining $/ makes it higher level than most Forths
>
> Count the number of times the elements in a list occur, and
> sort so that the counts are decreasing.
>
> def occurrences array
> array.group_by{|x| x}.map{|k,v| [k,v.size]}.sort_by{|x| -x[1]}
> end
>
> occurrences %w(b a d c d c b d c d)
> ==>[["d", 4], ["c", 3], ["b", 2], ["a", 1]]
>
"I used lists and group_by to do this. Take that, Forth!"
Oh no, walking through an ordered arrangement of literally four
values, populating a table with boring information about it, and then
walking through that table in an ordered manner. How ever will I
accomplish this in Forth?
create tallies 0 , 0 , 0 , 0 ,
: tally ( c-addr u -- )
bounds ?do i c@ [char] a - cells tallies + ++ loop ;
: .tallies ( -- ) tallies
cr ." a: " @+ .
cr ." b: " @+ .
cr ." c: " @+ .
cr ." d: " @+ . drop ;
s" badcdcbdcd" tally .tallies
Do the sorting on the fly, in the browser :^)
>
> Decode an http-encoded string.
>
> "foo%20bar%20%41ct".gsub(/%(..)/){$1.to_i(16).chr}
> ==>"foo bar Act"
>
"Do I have HTTP encoding libraries?"
Yes.
~/public_html/fs# sf include uridecode.fs 's" foo%20bar%20%41ct" uridecode type' bye
foo bar Act
>
> Given an item and a sequence, produce multiple copies of
> the sequence with the item inserted at every possible position.
>
> Flatten a sequence that contains sequences.
>
> As above, but with only one level of flattening.
>
See above, re. learning any functional language and using reasonably
typed data instead of artificial nonsense.
http://mercurylang.org/
>
> Remove consecutive duplicates from a sequence.
>
> %w(a a a a b c c a a d e e e e).chunk{|x| x}.map &:first
> ===>
> ["a", "b", "c", "a", "d", "e"]
>
You have got to be kidding me.
spam.txt is a file containing a single "a", one billion of "b", and
then a single "c", 954MB in size.
$ time sf dedup.fs
real 0m2.416s
user 0m2.269s
sys 0m0.147s
I killed the ruby variant before it could run to completion, because
it was causing performance issues.
jfondren 4628 44.6 90.1 11859588 7299684 pts/1 Dl+ 07:12 2:30 |
\_ /usr/bin/ruby-mri dedup.rb
>
> Determine whether some item in a sequence occurs at least
> 4 times.
>
> def four? hand
> hand.group_by{|x| x}.map{|k,v| v.size}.max > 3
> end
>
>
> Shuffle the cards, and deal them into four hands.
> Sort the cards in each hand.
>
"I used .group_by .max .map and lists of lists and ...!"
Yeah, OK. I would use an array of 52 cells.
>
> Vigenere cipher.
>
Please explain, with charts and graphs, how you think this could
possibly be a challenging task in Forth.
-- Julian
[toc] | [prev] | [next] | [standalone]
| From | lehs <skydda.barnen@gmail.com> |
|---|---|
| Date | 2016-01-13 11:59 -0800 |
| Message-ID | <31b69251-fdca-4f59-8f4f-f557481152a7@googlegroups.com> |
| In reply to | #44817 |
Den onsdag 13 januari 2016 kl. 09:01:34 UTC+1 skrev WJ:
> Chris Curl wrote:
>
> > So, Ruby is so powerful, and Forth is a toy language. Let's see how fast Ruby can do this:
> >
> > 1. Allocate 256MB ram and fill it with random binary data.
> > 2. Collect and print out the distribution of byte values in all 256MB bytes from #1.
> >
> > Forthers, how fast can your Forth do it?
> >
> > Any bets on which will be faster?
>
> Speed isn't everything. As a general rule, high-level languages are
> slower than low-level languages. If speed of execution were the only
> thing that mattered, then all programming would be done in assembly
> language, Fortran, or C.
>
> Ease of writing and maintaining programs matters a lot.
>
> This is a very simplistic, low-level task which a simplistic,
> low-level language can perform swiftly. Would it be unfair
> to say that this is a toy task tailored for a toy language?
>
> I suspect that the random number generators used in the ANS Forth
> solutions will have somewhat smaller periods than the Ruby one.
> From the documentation at http://ruby-doc.org/core-2.0.0/Random.html :
>
> PRNGs are currently implemented as a modified Mersenne Twister
> with a period of 2**19937-1.
>
> How big is that? Let's ask Ruby.
>
> puts (2**19937-1).to_s.scan /.{1,64}/
> 4315424797388162648055235516337919839053935043226711505165250541
> 4033306801376580911304513629318584665545269938257648835317902217
> 3345844139095282691546091680190078753437413962968019201144864809
> 0266141431844327698030006672810498409545158817607713296984376213
> 4621790396391341285205627619600513106646376648615994236675486537
> 4802419643502959351686623639090479483476923139783013778207857124
> 1905447433284452918317297324231088826508132162646945107770781228
> 2829444775022680488057820028764659399164766265200900561495800344
> 0543536903898628940617928720111208336148084474829135473283672778
> 7956564830784690911694586623016970240126024018702874665003344577
> 4570315431292996025187780790119375902863171084149642473378986267
> 5033089613749057663409052895722900160380005716308751913739795550
> 4746815433325347499104624813250451634179655147057548145920085947
> 2614836213875557116864445789750886277996487304308450484223420629
> 2665185560243393391908443689210184248446770427276646018529149252
> 7728092269753842677025733392895440120546589561034765885538663390
> 2546289962132643282425748035786233580608154696546932563833327670
> 7698994397748885266872785274510029630591469638757154257355344759
> 7973446310067836739332740214993096877829674139151459960237421362
> 9898720611431410402147238998090962818915890645693934483330994169
> 6322958779958489933667470148717634948055499961630515412254034652
> 9700772114623135570408149309866306573367719117285398709574816781
> 6256084212823380168625334586431254034670806135273543270714478876
> 8618619833207772806448066911257131972625817631513135964295477635
> 7636783701934983517846214429496075719091805462511414366638418943
> 3852576452289347652454631535740468786228945885654608562058042468
> 9873724369214450923153776984071681983765382377486141962070415481
> 0637936512319281799900662176646716711347163271548179587700538269
> 4393400403061700457691135349187874888923429349340145170571716181
> 1257958888892774954269771499145496239163940148229850253316515114
> 3127880200905680845650681887726660983163688388490562182226293398
> 6548645669080672191704740408891349835685662428063231198520436826
> 3294152907529727983434294465099922063687813671540917026557727273
> 9132942427752934908260058588476652315095741707783191001616847568
> 5658673192860882070179760307269849987354836042371734660257694347
> 2355063017441188741412924389581415491006097522168822308876114319
> 9647233084238013711092744948355781503758684964458574991777286992
> 6744218369621137675101083278543794081749094091043084096774144708
> 4363242794768920562004272279616386691498054898311212446763999319
> 5537148401288636074870647956866904857478285521705474011394592962
> 2177502575565811067452201448981991968635965361551681273982740760
> 1388996388203187763036687627301575846400427988806918626402686126
> 8618088387493957381812502227968993026744625577395954246983163786
> 3000171279227151406034129902181570659650532600775823677398182129
> 0873944498591827499990072235924233345678506711865688391867477049
> 6001627754062533144061901912998378991471251536520033605799350860
> 1678807687568562377857095255541304902927192220184172502357124449
> 9118702106426945650613849193734743245039662677990384023867816868
> 0996201587909058654942350469919074351955104372254451574096782908
> 4336025938225780730880273855261551972044075620326780624448803490
> 9982321612316877947156134057932495455095280525180101230872587789
> 7411581704824558897143859675440808131343837550298872673952337529
> 6641615501406091607983229239827240614783252892479716519936989519
> 1878086812211916417477109024806334910917048274412282811866324459
> 0714578713835123484226138007462191400481815238666604313334487506
> 7903582838283562688083236575482068479639546383819532174522502682
> 3724413632757658756091197836532983120667082171493167735643403792
> 8972439398674413989185541661229573935666861265827123469643837712
> 2838998040199739078061443675415671078463404673702403777653478173
> 3670848447347020568666361581380036922533822099094664695919301616
> 2609792050874217567030650513954286075080615983535754103214709508
> 4278461056701367739794932024202998707731017692582046210702212514
> 1204293225304317896162670477761151235979354041470848709854654265
> 0277205730090033384790533425060411950303000170400288789294140460
> 3345869926367501355094942750552591581639980523190679610784993580
> 8966832992976812624423140086570334218680945517405064488290392073
> 1671130769513189229659350901862309481055751956030524078716380921
> 9164433754514863301000915916985856242176563624771328981678548246
> 2973762495302513603634127683664561750770319774575349128064331765
> 3999599434330811847014715871281614939442127661422826290995005574
> 6981053206610001560295784656616193252269412026831159508949671513
> 8451958832171479827488792618514178199790344172855986077272208666
> 7768042609030875482380334544656630561924130837445275466814301548
> 7710877728011086004325892262259413968285283497045571062757701421
> 7615652627251534074076254051499319894944591064146605343053785767
> 0986252004986488096114486925860347371436365919401396270636685138
> 9299692869491805172556818508298824954954815796063169517658741420
> 1597987542734280267234524812635691573072131537397810416276537150
> 7859850415479728766312294671134815852941881643282504446669278113
> 7474494898385064375787507376496345148625306383391555145690087891
> 9553159944629444932352488175999071191357559333821217061914771850
> 5493663221115722292033114850248756330311801880568507356984158051
> 8118710778653953571296014372940865270407021924383167290323231567
> 9122894194862405940390744523216780193818712190921554607684445735
> 7855951361330424220615135645751393727093900970723782710124585383
> 7678338161023397586854894230696091540249987907453461311923963852
> 9507547580582056259566008177430071917468126559550217476709224608
> 6674774452087560785906233475062709832859348006778945616960249439
> 2813763495657599847485773553990957557313200809040830036446492219
> 4099340969487305474943012161656867507357495558823403039898746729
> 7545506095773692155919548081551403591570712993005702711728625284
> 3197413312307617886797506784260195436760305990340708481464607278
> 9554954877421407535706212171982521929788697869167346256184301754
> 54903864111585429504569920905636741539030968041471
>
> If ANS Forth is asked, will it be so helpful?
> I doubt it.
>
>
> Create a string containing 99,000,000 random bytes.
>
> t = Time.now; s = Random.new.bytes(99_000_000) ; p Time.now - t; s = ""
>
>
>
> Here are some problems that call for a high-level language.
>
>
> When did England adopt the Gregorian calendar?
>
> require 'date'
> Date.new(1700,1).upto(Date.new 1799,12,31).find{|d| d.england.gregorian?}.to_s
> ===>
> "1752-09-14"
>
>
> Find an element in an array, and replace it with an (unwrapped) array.
>
> a = [:a,:b,:c]
> a[a.index(:b),1] = [1,2]
> a
> ===>
> [:a, 1, 2, :c]
>
>
> As above, but without unwrapping.
>
> a = [:a,:b,:c]
> a[a.index(:b)] = [1,2]
> a
> ===>
> [:a, [1, 2], :c]
>
>
>
> An array or list contains strings and non-strings.
> Segregate the strings from the non-strings.
>
> ["one",2,"three",:four,5].partition{|x| x.is_a? String}
> ===>
> [["one", "three"], [2, :four, 5]]
>
>
> From a string extract the substrings contained in [].
>
> "toy [pd] language [dp] ? [a][1,2;3--4][c]".scan(/\[(.*?)\]/).map &:first
> ===>
> ["pd", "dp", "a", "1,2;3--4", "c"]
>
>
> The first 5 characters of each line of a file are a vendor code.
> Determine how many times each code occurs.
>
> table = Hash.new(0)
> IO.foreach("data.txt"){|line| table[line[0,5]] += 1}
> table.sort_by{|k,v| k}.each{|k,v| puts "#{k} #{v}"}
>
>
> Split a string into 3 fields. The delimiter string is ";",
> but the last field may contain ";" as part of its data.
>
> "U8942;2.72;Not that; but this".split(";", 3)
> ===>
> ["U8942", "2.72", "Not that; but this"]
>
>
> Count the number of times the elements in a list occur, and
> sort so that the counts are decreasing.
>
> def occurrences array
> array.group_by{|x| x}.map{|k,v| [k,v.size]}.sort_by{|x| -x[1]}
> end
>
> occurrences %w(b a d c d c b d c d)
> ==>[["d", 4], ["c", 3], ["b", 2], ["a", 1]]
>
>
> Decode an http-encoded string.
>
> "foo%20bar%20%41ct".gsub(/%(..)/){$1.to_i(16).chr}
> ==>"foo bar Act"
>
>
> Given an item and a sequence, produce multiple copies of
> the sequence with the item inserted at every possible position.
>
> def variations item, array
> 0.upto(array.size).map{|i| array.dup.insert(i, item)}
> end
>
> variations :-, [:a,:b,:c]
> ===>
> [[:-, :a, :b, :c],
> [:a, :-, :b, :c],
> [:a, :b, :-, :c],
> [:a, :b, :c, :-]]
>
>
> Flatten a sequence that contains sequences.
>
> [[0],2,[[3,4]],[6],[[8]]].flatten
> ===>
> [0, 2, 3, 4, 6, 8]
>
>
> As above, but with only one level of flattening.
>
> [[0],2,[[3,4]],[6],[[8]]].flatten 1
> ===>
> [0, 2, [3, 4], 6, [8]]
>
>
> Remove consecutive duplicates from a sequence.
>
> %w(a a a a b c c a a d e e e e).chunk{|x| x}.map &:first
> ===>
> ["a", "b", "c", "a", "d", "e"]
>
>
> Determine whether some item in a sequence occurs at least
> 4 times.
>
> def four? hand
> hand.group_by{|x| x}.map{|k,v| v.size}.max > 3
> end
>
> [[2,2,2,5,6,7,:a],
> [8,8,8,8,8,8,8],
> [2,3,2,4,2,2,:k],
> [:k,:q,:j,9,9,9,9],
> [:a,2,:a,:a,:a,5,8]].each{|hand| printf "%-5s %s\n", four?(hand), hand}
>
> false [2, 2, 2, 5, 6, 7, :a]
> true [8, 8, 8, 8, 8, 8, 8]
> true [2, 3, 2, 4, 2, 2, :k]
> true [:k, :q, :j, 9, 9, 9, 9]
> true [:a, 2, :a, :a, :a, 5, 8]
>
>
> Shuffle the cards, and deal them into four hands.
> Sort the cards in each hand.
>
> $suits = [:clubs,:diamonds,:hearts,:spades]
> $ranks = [2,3,4,5,6,7,8,9,10,:jack,:queen,:king,:ace]
>
> def create_hands
> $suits.flat_map{|s| $ranks.map{|r| [s,r]}}.shuffle.
> each_slice(13).map{|hand|
> hand.sort_by{|s,r| [$suits.index(s), $ranks.index(r)]}}
> end
>
> create_hands
>
> [[[:clubs, 7], [:diamonds, 9], [:diamonds, :king], [:diamonds, :ace],
> [:hearts, 3], [:hearts, 5], [:hearts, 6], [:hearts, 10],
> [:hearts, :jack], [:spades, 6], [:spades, 7], [:spades, 9], [:spades, 10]],
> [[:clubs, 6], [:clubs, 10], [:clubs, :king], [:diamonds, 2], [:diamonds, 3],
> [:diamonds, 4], [:diamonds, 8], [:diamonds, 10], [:hearts, 2],
> [:hearts, 8], [:spades, 5], [:spades, :queen], [:spades, :king]],
> [[:clubs, 3], [:clubs, 4], [:clubs, 9], [:clubs, :jack], [:clubs, :queen],
> [:diamonds, 5], [:diamonds, :queen], [:hearts, 7], [:hearts, :queen],
> [:spades, 2], [:spades, 8], [:spades, :jack], [:spades, :ace]],
> [[:clubs, 2], [:clubs, 5], [:clubs, 8], [:clubs, :ace], [:diamonds, 6],
> [:diamonds, 7], [:diamonds, :jack], [:hearts, 4], [:hearts, 9],
> [:hearts, :king], [:hearts, :ace], [:spades, 3], [:spades, 4]]]
>
>
> Vigenere cipher.
>
> def str_to_nums str, negate=false
> str.upcase.gsub(/[^A-Z]+/, "").each_char.map{|c|
> (c.ord - "A".ord) * (negate ? -1 : 1)}
> end
>
> def nums_to_str nums
> nums.map{|n| (n + "A".ord).chr}.join
> end
>
> def vig text, key, decipher=false
> nums_to_str(str_to_nums(text).zip(str_to_nums(key, decipher).cycle).
> map{|a,b| (a + b).modulo 26})
> end
>
> msg = "Beware the Jabberwock... The jaws that... the claws that catch!"
> key = "vigenere cipher"
> enc = vig msg, key
> dec = vig enc, key, true
>
> puts "msg: #{msg}\nenc: #{enc}\ndec: #{dec}"
>
> ===>
> msg: Beware the Jabberwock... The jaws that... the claws that catch!
> enc: WMCEEIKLGRPIFVMEUGXXYILILZXYVBZLRGCEYAIOEKXIZGU
> dec: BEWARETHEJABBERWOCKTHEJAWSTHATTHECLAWSTHATCATCH
>
> --
> The gangs are almost always operated by Dutch-born Moroccan and Turkish men
> [who] ... give their victims alcohol and drugs, use lies to separate them from
> their families, gang rape them ..., and then place the girls in
> prostitution.... Some of these girls are as young as 11 or 12 years old.
> http://www.liveleak.com/view?i=807_1369627137
My bigint compute 2**19937-1 on GForth for Androids.
https://github.com/Lehs/BIG-INTEGER-ANS-FORTH
http://forthmath.blogspot.se/2016/01/dynamic-sets.html
[toc] | [prev] | [next] | [standalone]
| From | Chris Curl <ccurl609@gmail.com> |
|---|---|
| Date | 2016-01-21 21:08 -0800 |
| Message-ID | <fe1591d9-a736-4201-b673-8dc3dfe78c95@googlegroups.com> |
| In reply to | #44817 |
On Wednesday, January 13, 2016 at 3:01:34 AM UTC-5, WJ wrote: > Speed isn't everything. As a general rule, high-level languages are > slower than low-level languages. If speed of execution were the only > thing that mattered, then all programming would be done in assembly > language, Fortran, or C. > ... Maybe speed isn't everything. Either is using a language that is so bloated that it can do in one the kind of trivial little things like the stupid shit you post to this board. Here is the difference. Everything you can do in your "high-level" languages can be done in Forth, and Forth can also do anything and everything else that can be done on the computer, because it is both a very high-level language and a low-level language at the same time. On top of that, it can also run on much smaller systems that your high-level languages could never fit on.
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2016-02-09 13:36 +0000 |
| Message-ID | <n9cq1p$e64$1@dont-email.me> |
| In reply to | #44817 |
WJ wrote:
>
> Remove consecutive duplicates from a sequence.
>
> %w(a a a a b c c a a d e e e e).chunk{|x| x}.map &:first
> ===>
> ["a", "b", "c", "a", "d", "e"]
Oforth:
[$a,$a,$a,$a,$b,$c,$c,$a,$a,$d,$e,$e,$e,$e] group map(#first) .
===>
[a, b, c, a, d, e] ok
--
Amazon bans book. After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunkers-5.html
https://www.youtube.com/watch?v=EEl_1HWFRfo
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2016-02-09 13:48 +0000 |
| Message-ID | <n9cqo9$grk$1@dont-email.me> |
| In reply to | #44817 |
WJ wrote:
> Count the number of times the elements in a list occur, and
> sort so that the counts are decreasing.
>
> def occurrences array
> array.group_by{|x| x}.map{|k,v| [k,v.size]}.sort_by{|x| -x[1]}
> end
>
> occurrences %w(b a d c d c b d c d)
> ==>[["d", 4], ["c", 3], ["b", 2], ["a", 1]]
Oforth:
[$b,$a,$d,$c,$d,$c,$b,$d,$c,$d]
sort group map(#[dup first swap size [,]]) sortBy(#[last neg]) .
===>
[[d, 4], [c, 3], [b, 2], [a, 1]]
--
After being told there was no money, the attackers tore off the woman's clothes
and raped her until five others arrived, according to the documents. The new
arrivals took turns having sex with her and then sodomized her.... At gunpoint,
the assailants forced the mother and son to have sex.
www.sun-sentinel.com/local/palm-beach/sfl-flpdunbar0822nbaug22-story.html
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2016-02-09 12:02 -0800 |
| Message-ID | <24b0b192-d9e9-4b41-b4dc-5bba8a1ac4a3@googlegroups.com> |
| In reply to | #45390 |
On Tuesday, February 9, 2016 at 6:51:53 AM UTC-7, WJ wrote: > After being told there was no money, the attackers tore off the woman's clothes > and raped her until five others arrived, according to the documents. The new > arrivals took turns having sex with her and then sodomized her.... At gunpoint, > the assailants forced the mother and son to have sex. > www.sun-sentinel.com/local/palm-beach/sfl-flpdunbar0822nbaug22-story.html WJ --- you are a pervert --- fascinated by rape. Over on comp.lang.lisp all of your posts are automatically deleted without being read --- the same will be done on comp.lang.forth from now on. The reason why the flaming faggot Passaniti was supported on comp.lang.forth by Elizabeth Rather and Bernd Paysan was because he supported them, but you are not smart enough to support the Forth-200x committee and so they won't support you either --- to succeed as a troll on comp.lang.forth you have to support Forth-200x, and then you can get away with all this perversion, but you are too dumb for such basic political maneuvering so you even fail at being a troll. The reason why Forth has failed is because of a lack of leadership --- who cares about Forth other than me? Supporting ANS-Forth or Forth-200x doesn't count as caring about Forth, because ANS-Forth was a marketing gimmick of Forth Inc. and Forth-200x was mandated to be 100% compatible with ANS-Forth (and the Forth-200x committee members are all appointed by Elizabeth Rather) --- nobody cares about this blatant sales trumpeting except trolls like John Passaniti and Alex McDonald, and they just wander away when they get bored.
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2016-02-09 13:58 +0000 |
| Message-ID | <n9cr9d$im2$1@dont-email.me> |
| In reply to | #44817 |
WJ wrote:
> Determine whether some item in a sequence occurs at least
> 4 times.
>
> def four? hand
> hand.group_by{|x| x}.map{|k,v| v.size}.max > 3
> end
>
> [[2,2,2,5,6,7,:a],
> [8,8,8,8,8,8,8],
> [2,3,2,4,2,2,:k],
> [:k,:q,:j,9,9,9,9],
> [:a,2,:a,:a,:a,5,8]].each{|hand| printf "%-5s %s\n", four?(hand), hand}
>
> false [2, 2, 2, 5, 6, 7, :a]
> true [8, 8, 8, 8, 8, 8, 8]
> true [2, 3, 2, 4, 2, 2, :k]
> true [:k, :q, :j, 9, 9, 9, 9]
> true [:a, 2, :a, :a, :a, 5, 8]
Oforth:
: four? sort group map(#size) maxFor(#yourself) 3 > ;
[[2,2,2,5,6,7,$a],[8,8,8,8,8,8,8],[2,3,2,4,2,2,$k]]
[[$k,$q,$j,9,9,9,9],[$a,2,$a,$a,$a,5,8]] +
apply(#[dup four? . println])
0 [2, 2, 2, 5, 6, 7, a]
1 [8, 8, 8, 8, 8, 8, 8]
1 [2, 3, 2, 4, 2, 2, k]
1 [k, q, j, 9, 9, 9, 9]
1 [a, 2, a, a, a, 5, 8]
--
The report card by the American Society of Civil Engineers showed the national
infrastructure a single grade above failure, a step from declining to the point
where everyday things simply stop working the way people expect them to. ---
washingtonpost.com/local/trafficandcommuting/us-infrastructure-gets-d-in-annual-report/2013/03/19/c48cb010-900b-11e2-9cfd-36d6c9b5d7ad_story.html
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2016-02-09 14:30 +0000 |
| Message-ID | <n9ct6h$q84$1@dont-email.me> |
| In reply to | #44817 |
WJ wrote: > Flatten a sequence that contains sequences. > > [[0],2,[[3,4]],[6],[[8]]].flatten > ===> > [0, 2, 3, 4, 6, 8] Oforth: [[0],2,[[3,4]],[6],[[8]]] expand . ===> [0, 2, 3, 4, 6, 8] -- Amazon bans book. After nearly a month on the site, all traces of the book and its 80 reviews have been removed. http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunkers-5.html https://www.youtube.com/watch?v=EEl_1HWFRfo
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2016-02-14 15:35 +0000 |
| Message-ID | <n9q6ra$hh5$1@dont-email.me> |
| In reply to | #44817 |
WJ wrote:
> An array or list contains strings and non-strings.
> Segregate the strings from the non-strings.
>
> ["one",2,"three",:four,5].partition{|x| x.is_a? String}
> ===>
> [["one", "three"], [2, :four, 5]]
Oforth version V0.9.23.1:
["one",2,"three","four",5] sortBy(#isString) groupWith(#isString) .
===>
[[5, 2], [four, one, three]] ok
--
I do know that Jews are G-d's Chosen People (we say that in Kiddush every
Friday nite). Does that make us different from Gentiles? Clearly. If that's a
problem, deal with it.
https://web.archive.org/web/20101020044210/http://www.jpost.com/JewishWorld/JewishNews/Article.aspx?id=191782
[toc] | [prev] | [next] | [standalone]
| From | franck.bensusan@gmail.com |
|---|---|
| Date | 2016-02-14 08:50 -0800 |
| Message-ID | <c320a936-739e-44ad-a669-96c3759c33fe@googlegroups.com> |
| In reply to | #45521 |
Le dimanche 14 février 2016 16:38:04 UTC+1, WJ a écrit : > WJ wrote: > > Oforth version V0.9.23.1: > > ["one",2,"three","four",5] sortBy(#isString) groupWith(#isString) . > ===> > [[5, 2], [four, one, three]] ok > > -- > I do know that Jews are G-d's Chosen People (we say that in Kiddush every > Friday nite). Does that make us different from Gentiles? Clearly. If that's a > problem, deal with it. > https://web.archive.org/web/20101020044210/http://www.jpost.com/JewishWorld/JewishNews/Article.aspx?id=191782 Let's make it clear about Oforth. Oforth choices (GC, memory, ...) makes it not suitable for lots of usages (embedded targets, ...). So there are lots of areas where standard Forth is much more suitable and it is really stupid that you use Oforth to denigrate it. Also, I feel very sad and chocked each time I see your posts, especially when you mix Oforth code with your awful and brainless signatures. You seem to have big problems and whatever I can say, you will probably keep on with your horrible messages. At least, please stop using Oforth from now on. Franck
[toc] | [prev] | [next] | [standalone]
Page 6 of 7 — ← Prev page 1 2 3 4 5 [6] 7 Next page →
Back to top | Article view | comp.lang.forth
csiph-web