diff --git a/.gitattributes b/.gitattributes index 2c760207f90b50784060e487081f7707bc7f257a..f8091467758bbd068c4ce1ab3620968a5b513411 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,7 @@ * text ident *.gif binary *.gz binary +*.ppm binary *.rs binary testfont binary diff --git a/about_pike/README b/about_pike/README new file mode 100644 index 0000000000000000000000000000000000000000..e8fee7ee00c2c25e5f1b97806be8e4854d1ea880 --- /dev/null +++ b/about_pike/README @@ -0,0 +1,17 @@ +This directory contains some information about Pike and stuff to show +how great Pike is. + +why_pike_short is a short list of Pike-arguments +why_pike_long is a long list of Pike-arguments + +The foo.pike (where foo is something else) programs are examples of +Pike-code. Some of them can be used as programs (Maybe you have to +change the first line to the correct path) but some of them are just +code. + +foo.ppm is a picture used by the program draw_stuff.pike. + +perl_tcl_python_pike contains some code in Perl, Tcl, Python and Pike +to show the general syntax differences. + +matrix2.foo is some more examples of matrixes in Pike. diff --git a/about_pike/about_versions b/about_pike/about_versions new file mode 100644 index 0000000000000000000000000000000000000000..894e1b4215d5cd0cd7acf2280b97cd2ebb012b5f --- /dev/null +++ b/about_pike/about_versions @@ -0,0 +1,24 @@ +Versions + +Pike X.Y[{a|b}Z][plW] + +X=Major number +Y=Minor number +Z=alpha/beta number +W=patch level + +Examples: +The first 0.5 beta: + Pike 0.5b1 + +A bug is found and corrected: + Pike 0.5b1pl1 + +Pike 0.5 is here! It's a very stable version without bugs... + Pike 0.5 + +An other bug is corrected (shit happens): + Pike 0.5pl1 + +The next version of Pike is released as an alpha: + Pike 0.6a1 diff --git a/about_pike/client-server.pike b/about_pike/client-server.pike new file mode 100644 index 0000000000000000000000000000000000000000..59ceb7cc339e2852c28cd874a40ee6b3e0baac62 --- /dev/null +++ b/about_pike/client-server.pike @@ -0,0 +1,33 @@ +RoxenRPC �r mycket imponerande och anv�nder n�tverket. H�r �r ett +exempel med en klient och en server: + +(RoxenRPC.pmod finns i roxen/server/etc/modules/) + +Server: + + #!/usr/local/bin/pike + + class bonka { + string bonk() + { + return "bank!\n"; + } + } + + int main() + { + object rpc = RoxenRPC.Server("localhost", 31414); + rpc->provide("dunk", bonka()); + return -17; + } + +Klient: + + #!/usr/local/bin/pike + + int main() + { + object rpc = RoxenRPC.Client("localhost", 31414, "dunk"); + write(rpc->bonk()); + return 0; + } diff --git a/about_pike/crypto_stuff.pike b/about_pike/crypto_stuff.pike new file mode 100644 index 0000000000000000000000000000000000000000..9e47c04399e05029c694fb79bea1e23dff491863 --- /dev/null +++ b/about_pike/crypto_stuff.pike @@ -0,0 +1,66 @@ +/* encrypt.pike + * + */ + +// The name of the receiver: +#define NAME "nisse" + +int main(int argc, array(string) argv) +{ + object rsa = keys.pub_to_rsa(Stdio.read_file(NAME + ".pub")); + //Reads a rsa-key from nisse.pub and converts it to a rsa-object. + + + function r = Crypto.randomness.reasonably_random()->read; + //Gets a function that kan be used for generation of random bits. + + + string iv = r(8); + //Creates a random 8-octet initvector (Just as big as a IDEA-block) + + string session_key = r(16); + //Creates a 16 octet (128-bit, key size for IDEA) seasion key. + + object cipher = Crypto.crypto(Crypto.idea_cbc() + ->set_encrypt_key(session_key) + ->set_iv(iv)); + //creates an object that crypts with IDEA in CBC-mode + + + string data = Stdio.stdin->read(0x7fffffff); + //Reads a file from Standard Input. + + if (!data) + { + werror("Read from stdin failed.\n"); + return 1; + } + + string gibberish = cipher->crypt(data) + cipher->pad(); + //Crypt the file with IDEA-CBC-crypto-object + + string encrypted_key = rsa->encrypt(session_key); + //Crypt season key with RSA. + + string data = sprintf("%s%s%s%s", iv, + iv ^ sprintf("%4c%4c", + strlen(encrypted_key), + strlen(gibberish)), + encrypted_key, + gibberish); + //Writes the crypted file with the format: + // IV (8 octets) + // IV XOR (Length of crypted saeason key and crypted data. 8 octets) + // season key, crypted with RSA + // data, crypted with season key. + + + + if (strlen(data) != Stdio.stdout->write(data)) + { + werror("Write to stdout failed.\n"); + return 1; + } + + return 0; +} diff --git a/about_pike/draw_stuff.pike b/about_pike/draw_stuff.pike new file mode 100755 index 0000000000000000000000000000000000000000..58c5321948f9d6a14888fa0337bf1ffb23ca3085 --- /dev/null +++ b/about_pike/draw_stuff.pike @@ -0,0 +1,79 @@ +#!/usr/local/bin/pike-mirar + +//Information about Pike is found at +// http://pike.indonex.se + +//This program is made by hedda@idenex.se to demonstrate the Image-package +//in Pike. + +//Some understanding of Pike or C is assumed to understand this program. + +import Image; + +int main() +{ + object(Stdio.File) filefoo; + filefoo=Stdio.File(); //Init the file-object + int k=filefoo->open("foo.ppm", "r"); //Open file foo.ppm for reading + + + //Check if foo.ppm exists + if (k==0) + { + write("\nThe picture foo.ppm isn't here! Why?\n"); + return 0; + } + + object(image) imagefoo; + imagefoo=Image.PNM.decode(filefoo->read()); //Read foo.ppm and place in + //the imagefoo-object + + filefoo->close(); // Close the file foo.ppm + + + object(image) imagebar=image(52, 65); //Make another image: imagebar. + //This image has width=80 & high=40 + //The image will be black + + imagebar->setcolor(160, 240, 192); //The Pike-color! + //The color is coded (red, green, blue) + // 0 means nothing of that color and 255 is maximum + + //This draws a polygone. It's of cource anti-aliased! + imagebar->polygone( + ({ + 4.1, 50, //First x,y corner + 7,33, //second x,y corner + 51, 2, //.. + 45, 28, //The corners can be floats + 53, 50, + 9,64 + })); + + //Now we paste the imagebar image onto the imagefoo image + // "imagebar->threshold(1,1,1)*128" creates the alpha-mask image and + // is created to be grey where the image imagebar isn't black. + imagefoo->paste_mask(imagebar, imagebar->threshold(1,1,1)*128, 35, 16); + + object(Stdio.File) filebar; + filebar=Stdio.File(); + k=filebar->open("bar.gif", "wcx"); //Open bar.gif for writing. Fail if + //it exists. + + if (k==0) + { + write("\nSome error while trying to write to the file bar.gif!\n" + "Maybe the file already exists.\n"); + return 0; + } + + filebar->write(imagefoo->togif()); // Save the image as a gif to the file + // bar.gif + + filebar->close(); //Close the file bar.gif + + write("\nI have greated the image foo.gif with help of bar.ppm.\n" + "This achieved by drawing a polygon and pasting" + " it over the image.\n"); + return 1; +} diff --git a/about_pike/foo.ppm b/about_pike/foo.ppm new file mode 100644 index 0000000000000000000000000000000000000000..c85e0932fb409d2ab08888ad09f0aa44518d3de5 --- /dev/null +++ b/about_pike/foo.ppm @@ -0,0 +1,5 @@ +P5 +# CREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2 ZinO-2) +110 88 +255 +�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Ӳ�����������������������������������������������������������������������������������������������������������ֲiK7?7i^s^/'/'7sK??7/i�^^}s?///7}is}_???s�������������������������������������������������������������iK??Ks_s^7/7/?}}}^KKK?s�s}}sK77?77}s?i}ssK?O}�������������������������������������������������������������}}s???Oiis^?'7'?}}KO^K?i�}si}?7??7OK_}}iK?O������������������������������������������������������������ֲ}siK?/^i_sO?'7K}}}OKK??i�}si}?77^_?is}_??K}�������������������������������������������������i����������i}iK/7^_isK7/7Ks}}^KKOKi�siss?7?'?_s}_???}�������������������������������������������������s_}Ki������}}iK77^^ssO???O}}^KOK?^�i}iO?s^'K_?K^s}_???s�������������������������������������������������s?^7/����֪s}i???^^is_77?^s}}OKKOKO�i}K/?iOKO/O}s_??K}�����������������������������������������������֪s77/�����}}_??7O_ss^7/7'K}}sO?K??O�is_'Kss?O}Os}_???}������������������������������������������������s}77'����֪ss_??7Oi}s^?77'K}i}}OKKKKO�__//^ss/OiOsi^7??i�����������������������������������������������֣s}?7/'����֪ssi??K^_ssO???/Kiss}K????^�_^'OOis'_O?ii_?7?s�����������������������������������������������֟s}7/'/}�����ss_???^_ssO77?7?iis}KKK??^�sO'}Ois'?_'?_i_?7?s�����������������������������������������������֟iK//s����֪ss_??7O_isO7//7?ssi}O????^�ss'O_iiK?^OK_i_77?}�����������������������������������������������֟s}??/�����ss_???OissK/7//Ksi_i^???7_�s7_^??__iKK__^7??}�����������������������������������������������ӟs}?'77_s�KOKis_??7Kiss?7//?Kiiii????_KK^/i_K^^K^??_sO?7?}�����������������������������������������������ӟs}////sOO__isi?7?Kiii??77??si_s???^K?//^ii^OK_KK__^7?7s����������������������������������������������ӟs}7'??}//?7^is_?7/Ksis777/7?s^OsKK}��/7_sOK^?iO?iiO7/7}��������������������������������������ӏ^iiO}��֟si?/7O}'?//iis_?7/Ois_?7//?s__i_����7^_'KOK_O^_iO777���������������������������������������}_??7K��֟}^??/O//7'O_si?7?Kii_K/'/?sii}�����'^_?K^?^7^__^?77���������������������������������������i_?7/?��֟ss?7'^//''_O}i?77Kii_K?///?sis������'/O_^?^?i/?7^__O7?/����������������������������������������_^?7/7��֟ss77/_?77^^__??7?iiiK/''_^s�������?O_?Oii_?'^__O777����������������������������������������__?7'7��ӟs}?/7_}}77?7^Oi_7?7K_si?/?����������}?isis?_?'/KKiO77/���������������������������������������_i77/��ӟ}_7//_}}/?/'^Os^???KiOiK'������������O'is__?iK?/K'_O/7/����������������������������������������i_7/'/��֣si/?'_}s7/'OOK^??/?^K_O_������������'O^__?_O//?7iK777�������������������������������Ͻ�������_i?/7s����si7/7_ss7/''??O_??7K_Oi�����s�������K____????K_?777��������������������������������iss?K���__7/O^???i}s7/'^}s7'/'KK_i777?^_}}�����^�����}^?OO^^iK??^i?//7�������������������������������^^K?'���^_7/ii?7'Oi}'7/^i_?'77KK__///K_������'?�����KiK?^?O_K?O__K'/7�����Ͻ�����������������������Ͻ_O7'���^_?/si7/'Ois'/'^i_/'?KK^/7K}������/O�^�����/^_?O?Oi?7O__K'//���ֽ���������������������������_K'���^^7'i_7'/^_s''7Kii''??K^7i�������_?s�}�����/7i^OO^i_7'^__?/7/��������������������������������^K'/���^O?/ii?'^_i'//^ii'''7^?_s�����_��?}�}����77i_i^7^?7^_i?/7/������������������������������ϽOO7/���^^?/ii?/'^ii///Ksi?s^i�����7�/}�}����_''7i_?Oss_?^^_K//7�������������������������ӽ�����^^'���O_?'^_?/'^ss/'/Ki_''?_}����7?�O�O�'�}����?'//__}O7O7^__?/7/��������������������������}}s}��^^//���__?/_i?''O^i7/?Ks_'_�������?'_�s�O�'��s����/'?_/7^_sO?___K///��������������������������s?7?s�_O'^i_^O^?'_i?'O^s/'/K_^�������O/O�^�}�_��������'/KKs}}s??__^K77/��������������������������_?77i�^^'/__?KOO?'_i?'?iO///Oii�����'_�^�}�^�������_''?'}}}K/'___O/77��������������������������i?7/i�^O'?_^/'Oi?ii7?is'K_^7���_'�?i�^��^�������/7777s??i_iK/7/��������������������������s?7?i�^O'?_^//^i?/iiK/?is7K/?K��O�O��Os�^�}��'�����??7?K___K'//�������������������ӽ�����s?//}�^K'?^O/ii?'_i?'Kis'/^?s^����K���^s�O�����'�����''7/___iO//7����Ͻ������������Ӳ^}}���s?7/}�_O'?_^/s^?is?'O^sO�}���i���O���_s��K����������^?7^7'___iK///������������������ӏ_7/_��}7'^��_O?_^/s_?'_s?'KOiK���i^���O���^s�O����������/7???77__i_K777�������������������^/'_��s?Kisi^?_O7ii7/_s??'_7���������^���i��K���������7??O??i___K77/������������������ӏ^7/^��}?OiOKiKK^K''_K7'_iOi?/_�����'����_������K�����}���}7'?^O7____K///���Ͻ�������������֏^/?_��s?Oi7?iO'?^?/i?7_i��?Oi�����'����^�������?�����}����7'?/^^_?i^__K'//���ӽ���������ӟ^_��K77_ӽi7^i??sK'?^O/_^/i?�7��/���'����^������K�����'s����_?K?7O?^'/_i^_iO//'���������������}?7?�?77^ӽ_?Os/KiKK^O''^^7O?_��?��/���/����O�������?�����/s�����KK'??K^OKis_iiO/7/���Ͻ����������}'/7�?7?��i?^i7?i^?OO'/_^/K��������'��'����O�����?�����'}�����^K_???O^Kii^_iO/77���ӽ����������}77?�O?Os}ss?^i??_?'??^/'__/��s�?s���s��7����^�_����}7�����/i�����O?OO/7?^^?ii^_iK777����������Ϗ���s?/?�^?^i7Ks?^i7K_O??O'/K^/�i^�/s7���_��/����K�_����i/�����/i������ii^777__'?ii^__O///���Ͻ������^i?�i77?�^7_i7?s?^s??iKK?O7KO�'i�'���KO��/����^�?����7�����7^������7�s7??^_/?ii^__O///��」������^7'�i77K�^7^i?Ks7^s/?iOKOO'/_K�?�}K��O���_?��/����OK�����/�����?^������O^K?^K7^^'?ii___O77/�����������O?'�_?O�s_?^i7Oi?^s7?i^?_O''ii�^��K�����/��/����^�����'�����KO�������Oi?K7^O'?ii_i_O77/����O����}�O7/�_7^KOO?^_?Oi/^s7KiO'?K^i}�}}��_���i�����'����_?/����������KO�������sO?7?O'?i_i__O?7/���?��_OOi_?7�^/^K^^?__?^O7_s??i??O^'/_����}���^����/����^�����������OK�������}s_7/7O7ii___O777����/K_?7^^77�i/_KO^7__7O_/_s7?iO?^K?^��������K�}�7��'����_�����������iK��������}i?'?/^/ii___O777���i_^O??^^?i?_?^O7_i?^_/_i??i??^??O���}������?�i�O������_����������iK��������}s^?//^/isi_O^//'����i^K_??^_K_^K?iK^O7i^?^^7^_??_?7_O'?}���}�����?�_�_��/����_���_��������s7���������^K?K7is___^/7/����/7_?7_^K_K^?i?^_7iO7^^/^_/?OK?_K/����}�}����?�^�i}�����s���?��������}'���������K}s/?/ii___^/7/���/?/^?K_^K_K_7_?^O/sO7_^/^i/?_K?KK7����}�s����?�^�^�����s��O}�������'���������i_^7O/ii___O??/����7?'^?�OO_KO?_?O_7ii7_^7_i7?sOKiKK����}�i����K�^��K�'���_����}������������������i}_K/iii__^?77���7?'_O^iO^_K_?_K^_?i_7^_/_i7KiKKKKi����}�s����?�_��?�'���_}���������O���������_iOK/s_i_i^7?/����?K'__O_^^_?s7_K^_7i_7O^7_s/?_KK_?������s����O�_��'�/���i�}���}�������'���������isO'7i^_i_^777����?i�__O_O^^Ki/_?__?i_7iO/i_/?s?7_K����������^�^s'�'���^�}�}��'�����?����������/s_i_i_7?/���?^}_^OiO^^O_/_K^_7i_/i^/_^'K}??_??�����������_�^�/���O���_}��s���_����������?'/ssi_i_??7����K^_^_OsK_OO_7i?_i/i_7iOii?KKO_?�����������}sO��/�/���?�i�}i�'7}�����s����������/O'/ssi__i??7����K^^^_OiKOOO_7_?_i's_/s^ii?i??s?��������i������K�7���'�i���������}��������?'/sii^__??/����?_O__OsK^^^i?_7i^/s_/iKii/Oi??s?��������O��_�����_�/���i?����������}^������?'''sis^_^?7/����?OO^_^s?_^^__?i_7s^'}Oi_?i?Ks7?������?��?�����s�?O/s^�������������i���i^/7'ssiO__7?7���?i^O_OsO_^?s/^?i_/s^'}K_^'?i??i??������K��'�s���s?K7������������������7_//iii^i_??/���?i^O_OsK^Kis/_?i_'}^sOsOKsKOi?Ks�����is^^�i���'��_���������������O}7K7'ssi_ii??7����?i^OsOi?^Kii7i7i^'O}Kii^i7?}??O����}����?s������/����������}_?//KK/7ssiiiiK?7���?i^KsOsKsKsi7^7_^O'}Ksi?}7O^?KK����}��'/��K�������s�������/??^O//sis_ii??/���Ks_OsOsKs?i_7i7_^^_K}i/?s?K_KK_s���i��������������}����_7/'/'�7K__77ssiii_77'���?siKiO}?}?_i7i/_^O'}?siOs?Oi?KiK��s'���������������s�i7????/�KOi_K7isiii_77/���Oi_?sOs??i_?i/i^'}K/}?_Os?Ks?OiO��?s��������������sO^O^?�O^i^O/iisii_^K/���O__KsKs7?_^/i'i^O'?iKs?^i7O_O?�����}�������_O____7^_sO?/ss___i7?7���}_^iKs?i/�/i^/s'_O'O/?_'^s?Oi?OiO�����s����s'///_ii_?s_isO?'ssi^^^7?'���}O_iOiKs'�/i^7i's^�??}?i^_?O_7^^O}������i7?77iii_??iiiK?/sis_^_?7'���sO__?s?s�'sO?s}O'O7?i'^i??i?_K?���i/''???7_ss_K?ii_O?''ssii_i??'���i_^^?_?}/�}O?s}O/O?}7�_'^s7^s?OsOi??/'''?OO?ssi_?Ki_sK?/sssiis^K7���i_Ki?_?s�'sK?s}O'�O?}7�_'_i/__?OsO_????K/7'OO_?sss_??i_ii?/sssiss_O7���i_O_?s?s/��K?iO�K?}7_/_i7_i7Os?iO77OOK???//OO_Kss}_KOsi_i?/sssiss^O?���iiKi?s7s/�}K?i^�OK}/'_'^_7__7^OK'_K?/K'_O^O7??/OKiO}s}KOKssii7/s}sissOK/���ii?s?s?}7�}??iO'�OK}7i'_i?i_7^^^_i?/K'i?OO??7/^?i^sss??Kssii7''ss}iisO?/���i}K_?iK}/�??s^�KK/'�_/_^?^_''^_?'_iK??/i?i??K?_^_^}ss^K?�isi//}_}is}O?���_s?^?i?^/7?^}???}'}^'__'?^/K^?^_?7^/_O^O?77__i^sssO?K�ssi/'}_}i_}O?7��������������������������������������������������������������������������������������������������������������� \ No newline at end of file diff --git a/about_pike/mail_stuff.pike b/about_pike/mail_stuff.pike new file mode 100644 index 0000000000000000000000000000000000000000..db57ff82fda00c7feefd069a5a23057468080a5c --- /dev/null +++ b/about_pike/mail_stuff.pike @@ -0,0 +1,35 @@ +//And here is some stuff about mailing... +//Maybe take a look in the manual :-) + + +void mailit(string file, string subject, array (string) list) +{ + foreach(list, string email) + Process.popen("mail -n -s '"+subject+"' "+email+" < "+file); +} + +//or... + +void mailit(string file, string subject, array (string) list) +{ + foreach(list, string victim) + { + string command = "mail -n -s '"+subject+"' "+email+" < "+file; + write(command+"\n"); + Process.popen(command); + } +} + + +//or... + +import Process; +void mailit(string file, string subject, array (string) list) +{ + string command; + foreach(list, string victim) + { + write((command = "mail -n -s '"+subject+"' "+email+" < "+file)+"\n"); + write(popen(command)); // show the output of the command + } +} diff --git a/about_pike/matrix2.foo b/about_pike/matrix2.foo new file mode 100644 index 0000000000000000000000000000000000000000..7586868152cf0f3fee1eacc97c19e4bfae5f14d2 --- /dev/null +++ b/about_pike/matrix2.foo @@ -0,0 +1,43 @@ +import Array; +#define matrix array(array(int|float|object)) + +matrix mmult(matrix m1, matrix m2) +{ + int m2rows=sizeof(m2), m2cols=sizeof(m2[0]); + int m1rows=sizeof(m1), m1cols=sizeof(m1[0]); + + if((m1cols!=m2rows)||(m2cols!=m1rows)) return 0; + + matrix res=map(allocate(m1rows), + lambda(int c, int r) { return allocate(r); }, m2cols); + + for(int i; i<m1rows; i++) + for(int j; j<m2cols; j++) + res[i][j]=`+(@ Array.sum_arrays(`*, m1[i], column(m2, j))); + return res; +} + +// Using map cols indices etc. more extensively + +matrix mmult(matrix m1, matrix m2) +{ + int m2rows=sizeof(m2), m2cols=sizeof(m2[0]); + int m1rows=sizeof(m1), m1cols=sizeof(m1[0]); + + if((m1cols!=m2rows)||(m2cols!=m1rows)) return 0; + + return map(indices(allocate(m1rows)), + lambda(int r, int c, array m1, array m2) { + return map(indices(allocate(c)), + lambda(int i, int j, array m1, array m2) { + return `+(@Array.sum_arrays(`*,m1[i],column(m2,j))); + }, r, m1, m2); + },m2cols,m1,m2); +} + + +// With matrix objects + +#define matrix object(Matrix)|array(array(int|float|object)) + +matrix mmult(matrix m1, matrix m2) { return m1 * m2; } diff --git a/about_pike/perl_tcl_python_pike b/about_pike/perl_tcl_python_pike new file mode 100644 index 0000000000000000000000000000000000000000..9e19f00be8d9a19bd28b4dbb359129b6e1bcf6b6 --- /dev/null +++ b/about_pike/perl_tcl_python_pike @@ -0,0 +1,108 @@ +Perl + +Perl 5 is a remarkably efficient, compact, and terse interpreted +scripting language optimized for processing text files. Perl was +written by the amazing Larry Wall (who, it sometimes seems, also wrote +everything else). Aficionados of Sed and Awk and other UNIX tools +often find Perl elegant, easy to read, and easy to modify, but many +others don't. Below is a ``matrix multiplication'' function in Perl +posted to a number of Internet newsgroups by Tom Christiansen: + + sub mmult { my ($m1,$m2) = @_; + my ($m1rows,$m1cols) = (scalar @$m1, scalar @{$m1->[0]}); + my ($m2rows,$m2cols) = (scalar @$m2, scalar @{$m2->[0]}); + unless ($m1cols == $m2rows) { # raise exception, actually + die "IndexError: matrices don't match: $m1cols != $m2rows"; + } + my $result = []; + my ($i, $j, $k); + for $i (0 .. ($m1rows - 1 )) { + for $j (0 .. ($m2cols - 1 )) { + for $k ( 0 .. ($m1cols - 1)) { + $result->[$i]->[$j] += $m1->[$i]->[$k] * $m2->[$k]->[$j]; + } + } + } + return $result; + } + +(By the way, I believe this is an excellent example of good Perl style.) + +For comparison Roland Giersig translates the matrix multiplication +function into Tcl as follows: + + proc mmult {m1 m2} { + set m2rows [llength $m2]; + set m2cols [llength [lindex $m2 0]]; + set m1rows [llength $m1]; + set m1cols [llength [lindex $m1 0]]; + if { $m1cols != $m2rows || $m1rows != $m2cols } { + error "Matrix dimensions do not match!"; + } + foreach row1 $m1 { + set row {}; + for { set i 0 } { $i < $m2cols } { incr i } { + set j 0; + set element 0; + foreach row2 $m2 { + incr element [expr [lindex $row1 $j] * [lindex $row2 $i]]; + incr j; + } + lappend row $element; + } + lappend result $row; + } + return $result; + } + + +And here is a roughly analogous function in Python: + +(I didn't write this and think there's a missing "matrices don't +match"-check) + + + def mmult(m1,m2): + m2rows,m2cols = len(m2),len(m2[0]) + m1rows,m1cols = len(m1),len(m1[0]) + if m1cols != m2rows: raise IndexError, "matrices don't match" + result = [ None ] * m1rows + for i in range( m1rows ): + result[i] = [0] * m2cols + for j in range( m2cols ): + for k in range( m1cols ): + result[i][j] = result[i][j] + m1[i][k] * m2[k][j] + return result + + +And here is the Pike-function: + +(Note: This is best done in Pike using matrix objects with a +`*-method. This is just for comparison.) + + +#define matrix array(array(int|float|object)) +matrix mmult(matrix m1, matrix m2) +{ + int m2rows=sizeof(m2), m2cols=sizeof(m2[0]); + int m1rows=sizeof(m1), m1cols=sizeof(m1[0]); + if ((m1cols!=m2rows)||(m2cols!=m1rows)) + return 0; + matrix res=allocate(m1rows); + for(int i; i<m1rows; i++) + res[i]=allocate(m2cols); + + for(int i; i<m1rows; i++) + for(int j; j<m2cols; j++) + res[i][j]=`+(@ Array.sum_arrays(`*, m1[i], column(m2, j))); + return res; +} + + + + +// +The first part of this text is taken from: +http://www.unixworld.com/unixworld/archives/95/tutorial/005.html#Others +och the Pike-part is written by Henrik "Hedda" Wallin, Idonex. + \ No newline at end of file diff --git a/about_pike/why_pike_long b/about_pike/why_pike_long new file mode 100644 index 0000000000000000000000000000000000000000..44d07a5b2834de9bc3e20e0812b7d50d79bb6264 --- /dev/null +++ b/about_pike/why_pike_long @@ -0,0 +1,139 @@ +PIKE 0.5 - a longer lists of arguments + +/* +Learn about Pike, the language that lies among the reeds, just waiting +to use its big jaws to swallow both problems and problem solvers, and +thus staying at the top of the food chain. +*/ + +o Pike is an easy programming language to learn. Just as easily Pike lets you + develop powerful applications. Pike is designed to be used. + +o Although Pike is a scripting language it is designed to generate + very fast code. + +o Pike is readable *and* looks like C. + +o If you write large applications, you can write your own Pike-modules + in C, and this makes the code both more transparent and faster. + +Arguments for the Pike language: + + General Purpose Programming Language + + Free! It's not just free to use it. You may also modify the + code and use it. See more details at http://pike.idonex.se/GPL.html + + A nice up-to-date manual on the web + + Makes it possible to write multithreaded programs. + + Easy to write programs that listen to ports and other networking + Functions. + + Source Code Available - To promote use and sharing of useful code + + Portable- Platform independent available on most flavors of Unix + + C-like Syntax - Easy to learn + + Powerful - High-level language, short code + + Object Oriented - easy to use and allows multiple + developer cooperation + + Modular - Extendible with modules e.g. written in C + + Interpreted, which mean no long compiling and linking time. + Just program and run! And there will be no core dumbs... + + Iterative language + + Incremental - allows on-the-fly modifications and recompilations + + Powerful Data Types that are well-scaling + + Automatic Memory Management + + Scalable - as useful for small scripts as for powerful + and complex applications. + + Text Processing - e.g. for filters + + Exception Handling + + The lovely green color of its home page. + + Optimized, Faster than Perl, Python (and Java) + + Faster development than C, C++ + + - No Pike compiler or debugger + - Limited image format import options + - Not optimal for heavy numeric processing jobs + - Not for GUI based applications + - Few special effect image filters + - Not tried for embedded product applications. Why don't you be + the first one! + +Applications that have been made with Pike + + Network Applications - Client/Server applications, + e.g. the Roxen Challenger Web-server and the Jukebox + + System Administration Tools & Utilities - even as quick one-shots + + Possible to use for CGI programming + + Real-time client-server status monitor + + Custom mail gateways + + adduser or adddomain scripts that setup users/domains + + implementations of client-server protocols + + (complex) string / parsing operations. + + MUDs + + +Arguments for some of the Pike modules: + +IMAGE - Image Processing Tool + +Image processing, for filters, cut & paste and text rendering. +Input formats: ppm +Output formats: ppm, gif + +This package is fast, easy to use and have anti-aliasing on many +functions. It also makes it possible to write text with various fonts +in your images. + + +DB API - Database Application Programming Interface + +Makes it possible to use SQL-databases in your Pike-application. + + +MIME - Multimedia Internet Mail Extension + +To pack and unpack mails bundled and easy to use. + + +CRYPTO - Cryptographic toolkit + +Enables easy development of secure applications. + + +Regexp - A module for Regular Expression + +A regular expression is a standardized way to make pattern that match +certain strings. In Pike you can often use the sscanf, range and index +operators to match strings, but sometimes a regexp is both faster and +easier. + + +Gz - compressing files + +Note: This module is not compatible with gzip, but it will be in the +future. + + +Getopt - find command line options + +Makes it easier to parse command line options. + + +Gmp - very large numbers + +This makes it possible to use as big integers as you have memory. + + +Yp - an interface to the Yellow Pages functions. + +YP is most commonly used to distribute passwords and similar +information within a network + + +Foo - The module that you are about to write + +It will be able to show a 45 inch window on a 14 inch screen, It will +work as a combined communications satellite and Wunderbaum. It has to +be able to cure deadly diseases and make your teeth whiter while you +sleep. And it shall travel through time! And it will have a telepathic +user interface! +*Tock* *Spoff* +Or it might just as well be made to show some fishes on your screen. + + + diff --git a/about_pike/why_pike_short b/about_pike/why_pike_short new file mode 100644 index 0000000000000000000000000000000000000000..34db43dc0aa82ccd1701c0c1ef7b034ce79334b6 --- /dev/null +++ b/about_pike/why_pike_short @@ -0,0 +1,59 @@ +Pike - why it's here and why it's gonna save the world + +The philosophy behind Pike is to create an environment for programming +that makes it easy and fast to create powerful applications. To +accomplish this the language is made to be easy extendible with +modules. This has resulted in many powerful modules included in this +package and many more that are made but not yet have reached the +stability that is necessary. + +This is the main arguments for Pike: + +1) It's free! (GPL-license) + +You and the ones that use your software never have to bother with +paying for using Pike. The greatest think about this is that many +hackers around the world will have access to Pike and therefore the +language will never stop to evolve. + +2) C-like syntax. + +If you already know C, it will not take long to learn Pike. The only +thing that you have to learn is that everything is easier in Pike :-) + +3) Powerful data-types and object oriented + +When creating database or parsing applications powerful data-types like +mappings, objects and even run-able Pike-programs will make you +addicted to Pike. These data types are embedded in an environment with +functions often found in various C-libs, but in Pike there are no +pointers to obscure structs or 10 Mbyte core-dumps on your disc. + +4) Extendible + +It's fairly easy to extend Pike and write your own module. These +modules are can be written i C to make them as fast as possible. This +often has the effect that when a Pike-programmer has a wonderful +module she/he shares it with the rest of the Pike-programmers and +therefore the next-coming Pike applications will be smaller and more +powerful. + +5) Gives you short and readable code + +Thanks to the magic functions, the data-types and all the modules a +Pike program becomes shorter and therefore quicker to write, easier to +debug and maintain. + + +The drawbacks of Pike + +-1) No official GUI-module so far. + +-2) Not very fast for programs that can't take advantage of powerful +Pike functions. However, most Pike-programs spend most of their time +in these very optimized functions and are therefore often faster or +just as fast as pure C-programs. + +-3) No Pike debugger. + +In this directory there are also some example Pike-programs. \ No newline at end of file