Author Topic: Pike  (Read 10392 times)

ZXDunny

  • Guest
Re: Pike
« Reply #30 on: February 15, 2016, 11:39:30 PM »
Tomaaz: I wouldn't describe what I posted as a high-school fight; I don't think that a BASIC programming forum is the place to promoting religious texts of any kind - this is a forum that, by it's very nature may well be read by children and we should be keeping it family friendly.

That said, the word count challenge is a worthy exercise - but it shouldn't be used in this manner.

D.

Tomaaz

  • Guest
Re: Pike
« Reply #31 on: February 15, 2016, 11:59:08 PM »
Tomaaz: I wouldn't describe what I posted as a high-school fight...

I wasn't referring to you. I was called "a liar" and a "copy/paste programmer" on the other forum (you know which one). Without any proof or examples. Also, some members here change their opinion about me to often. One minute I'm a cool guy (because I happen to agree with them), the other one I'm a troll, liar and lamer (because I dared to disagree with them). This all reminds me about teenagers fighting and playing games between each other. I totally understand your opinion about the Bible. I never thought about it before, because Bible is not that much important to me.

ScriptBasic

  • Guest
Re: Pike
« Reply #32 on: February 16, 2016, 12:10:23 AM »
Quote
Bible is not that much important to me

The bible is a book of words hacked over the years to suit the current audience. Hell didn't make it's debut until after the depression with the onslaught of evangelist. I would think anyone that could code and look in the sky has figured out god, after life are just couping tools to get through life.

Ed Davis

  • Guest
Re: Pike
« Reply #33 on: February 16, 2016, 12:04:41 PM »

I haven' changed anything. The goal is to count all and unique words, count how many times each word appears in the file and sort the result by occurrence (not alphabetically!).

But I don't care anymore. The whole topic has been wiped out without any information. On the other forum I found posts saying that the whole word count challenge is just boring. Well, it may be not the most exciting programming task ever, but is definitely more interesting that another combination of color dots, circles and rectangles in 20 lines of code. On the same forum I just read that I'm a a copy/paste programmer and a liar. I really can't see a point of being part of this community. Having high-school like fights? Risking all my posts being wiped out only because someone else got angry at someone? No, thanx.

That is a real shame.  I was really enjoying seeing (especially) the way it could be done in various other languages - Pike, Perl, Python, Ruby and Lua.   

I guess beauty truly is in the eye of the beholder.  But just ignore those that want to complain and argue about almost anything.  Keep the posts coming!

jj2007

  • Guest
Re: Pike
« Reply #34 on: February 16, 2016, 01:42:45 PM »
isking all my posts being wiped out only because someone else got angry at someone? No, thanx.

Tomaaz,

As Ed already wrote, I enjoyed your posts very much. It looked promising, and I am genuinely interested in the topic, which you certainly understand when looking at my second version, where the occurrence is weighted by the length of the words.

However, when I start a thread, and Mr "I'll send my lawyers to shut this site down if you don't obey to my orders" dumps several long and completely irrelevant posts, with the absolutely clear intention to troll me, then I will be kind enough to react to his provocation. Apparently he needs the occasional beating, for reasons that my professional background doesn't allow me to analyse. Maybe his mother knows what went wrong.

Tomaaz

  • Guest
Re: Pike
« Reply #35 on: February 16, 2016, 01:58:39 PM »
But just ignore those that want to complain and argue about almost anything.

I can do it easily, but what about moderators/administrators who delete my posts/topics only because someone else started trolling?

As Ed already wrote, I enjoyed your posts very much. It looked promising, and I am genuinely interested in the topic, which you certainly understand when looking at my second version, where the occurrence is weighted by the length of the words.

I know you're interested in the topic, but well... the topic has been wiped out. As I said above - this is what I can't understand. It was the same problem with BP.org. One member started trolling, so let's close/remove the whole topic.

BTW Thanx guys! It's good to know that some people are interested in the same things I am. :)

EDIT jj, all the sources I posted are gone, so do you want me to send them to you? They are very similar (it's the same code translated to other languages), so if you still have the Python version, you've got everything you need.

Tomaaz, would you check this rosetta code? http://rosettacode.org/wiki/Associative_array/Iteration#Pike
it don't work for me.

I was finally able to check this example. It works but you need to add main() function and remove badly inserted comments:

Code: [Select]
void main() {
mapping(string:string) m = ([ "A":"a", "B":"b", "C":"c" ]);
foreach(m; string key; string value)
{
    write(key+value);
}

foreach(m; string key;)
{
    write(key);
}

foreach(m;; string value)
{
    write(value);
}
}

Here you can find information about foreach loop.

Was that the problem or did you mean something else?
« Last Edit: February 16, 2016, 02:24:19 PM by Tomaaz »

jj2007

  • Guest
Re: Pike
« Reply #36 on: February 16, 2016, 03:40:40 PM »
all the sources I posted are gone, so do you want me to send them to you? They are very similar (it's the same code translated to other languages), so if you still have the Python version, you've got everything you need.

I've got the Python version, of course, but it would do no harm if you zipped them all and attached it here. Before the whole thread goes bang again ;-)

Tomaaz

  • Guest
Re: Pike
« Reply #37 on: February 16, 2016, 03:58:08 PM »
The file is attached.

Tomaaz

  • Guest
Re: Pike
« Reply #38 on: August 03, 2016, 09:55:15 PM »
The old, good, boring word count again. ;) The last Pike version I've posted is very slow. This is the proper one:
Code: [Select]
void main() {
mapping(string:int) m;
m = ([]);
array|mixed a, b, c;
b = ({});
c = ({});
int x;
string y;
write("Reading the file...\n");
string content = Stdio.File("warandpeace.txt")->read();
content = lower_case(content);
a = content / " ";
write("Counting all words...\n");
for(x = 0; x < (sizeof(a) - 1); x++) {
a[x] = Regexp.PCRE("[^a-z]")->replace(a[x]," ");
b = b + (a[x] / " ");
}
for(x = 0; x < (sizeof(b) - 1); x++) {
if (strlen(b[x]) > 1 || b[x] == "a" || b[x] == "i") {
c = c + ({b[x]});
}
}
object plik = Stdio.File();
plik -> open("Words.txt", "w");
write("All words: ");
plik -> write("All words: ");
write("%d\n", sizeof(c));
plik -> write("%d\n", sizeof(c));
write("Counting unique words...\n");
write("Unique words: ");
plik -> write("Unique words: ");
write("%d\n", sizeof(Array.uniq(c)));
plik -> write("%d\n\n", sizeof(Array.uniq(c)));
write("Counting numbers of occurences of each word and sorting the result...\n");
x = 0;
foreach (c, y) {
if (m[y]) {
m[y] = m[y] + 1;
}
else {
m[y] = 1;
}
}
foreach (reverse(sort(values(m))), x) {
foreach (indices(m), y) {
if (m[y] == x) {
plik -> write(y);
plik -> write(" - ");
plik -> write("%d\n", m[y]);
m = m - ([y:x]);
}
}
}
plik -> close();
write("Done!\n");
}