Constant Limit = 1000; %Sufficient digits. Constant Base = 10; %The base of the simulated arithmetic. Constant FactorialLimit = 365; %Target number to solve, 365! Array digit[1:Limit] of integer; %The big number. Integer carry,d; %Assistants during multiplication. Integer last,i; %Indices to the big number's digits. Array text[1:Limit] of character;%Scratchpad for the output. Constant tdigit[0:9] of character = ["0","1","2","3","4","5","6","7","8","9"]; BEGIN digit:=0; %Clear the whole array. digit[1]:=1; %The big number starts with 1, last:=1; %Its highest-order digit is number 1. for n:=1 to FactorialLimit do %Step through producing 1!, 2!, 3!, 4!, etc. carry:=0; %Start a multiply by n. for i:=1 to last do %Step along every digit. d:=digit[i]*n + carry; %The classic multiply. digit[i]:=d mod Base; %The low-order digit of the result. carry:=d div Base; %The carry to the next digit. next i; while carry > 0 %Store the carry in the big number. if last >= Limit then croak("Overflow!"); %If possible! last:=last + 1; %One more digit. digit[last]:=carry mod Base; %Placed. carry:=carry div Base; %The carry reduced. Wend %With n > Base, maybe > 1 digit extra. text:=" "; %Now prepare the output. for i:=1 to last do %Translate from binary to text. text[Limit - i + 1]:=tdigit[digit[i]]; %Reversing the order. next i; %Arabic numerals put the low order last. Print text," = ",n,"!"; %Print the result! next n; %On to the next factorial up. END;
Name:
Anonymous2015-07-25 21:26
So many programmers don't realize that good code is self-documenting. Comments are meant for /why/ something is done as opposed to /how/. With minor exceptions such as regex.
Constant Base = 10; %The base of the simulated arithmetic. Thank you for this comment, I wasn't sure what else could Base be!
digit:=0; %Clear the whole array. I didn't know that either! I would have never guessed!
Instead, I think you should comment your code like this #!/usr/bin/perl use strict; # PERL by Example (2015) p. 77 use warnings; # PERL by Example (2015) p. 85 # use Encode; # 2016feb16: http://perldoc.perl.org/perlunitut.html # use utf8; # 2016feb16: for Cyrillic Russian characters # use feature "unicode_strings"; # 2016feb16: Perl_Programming/Unicode_UTF-8 # binmode STDIN, ":encoding(UTF-8)"; # 2016feb16 # ghost155.pl being coded on Sun.1.MAY.2016 or later # Please host the Ghost AI and install it for other persons. # http://doc.perl6.org/language/variables our $. = 0; # 2016jan14: line counter variable; PbyX 299 our $_ = " "; # 2016jan10: hidden variable; P_by_Ex p. 301 our $abc = ""; # AudBuffer() transfer character; our $act = 0; # 2016jan16: quasi-neuronal activation-level our $actbase = 0; # 2016jan23: AudRecog discrimination activation base our $actpsi = 0; # 2016apr11: psi from which activation is to be spread our $age = 0; # 2015apr26: Temporary age for loop-counting. our $aud = " "; # 2016jan28: explicit package from @ear array our $audbase = 0; # 2016jan27: recall-vector for VerbGen() our $audbeg = 0; # 2016jan17: auditory-beginning tag for start of word. our $audjuste = 0; # 2016feb12: NounPhrase motjuste aud to Speech() module our $audnew = 0; # 2016jan17: holds onset-tag while rest of word comes in. our $audpsi = 0; # 2016feb12: concept number of word in @ear array our $audrec = 0; # 2016jan23: auditory recognition concept-number our $audrv = 0; # 2016feb12: auditory recall-vector for Speech() our $audrun = 1; # 2016jan26: counter of loops through AudRecog() our $b01 = ""; # 2016apr02: for OutBuffer(); our $b02 = ""; # 2016apr02: for OutBuffer(); our $b03 = ""; # 2016apr02: for OutBuffer(); our $b04 = ""; # 2016apr02: for OutBuffer(); our $b05 = ""; # 2016apr02: for OutBuffer(); our $b06 = ""; # 2016apr02: for OutBuffer(); our $b07 = ""; # 2016apr02: for OutBuffer(); our $b08 = ""; # 2016apr02: for OutBuffer(); our $b09 = ""; # 2016apr02: for OutBuffer(); our $b10 = ""; # 2016apr02: for OutBuffer(); our $b11 = ""; # 2016apr02: for OutBuffer(); our $b12 = ""; # 2016apr02: for OutBuffer(); our $b13 = ""; # 2016apr02: for OutBuffer(); our $b14 = ""; # 2016apr02: for OutBuffer(); our $b15 = ""; # 2016apr02: for OutBuffer(); our $b16 = ""; # 2016apr02: for OutBuffer(); ...
sub TabulaRasa() { # 2016jan25: Establish size and emptiness of CNS. print "Size of AI memory is $cns human language code = $hlc \n"; #2016feb16 my $trc = 0; # 2015apr2015 $trc is "tabula rasa counter". until ($trc == $cns) { # 2015apr26 PbEx5e p. 193 "Loops". $psy[$trc] = "0,0,0,0,0,0,0,0,0,0,0,0,0"; # 2016mar26: adding $iob. $ear[$trc] = " ,0,0"; # 2016jan28: initialize three columns. $trc++; # 2015apr26: Increment tabula-rasa-counter $trc. } # End of loop filling auditory memory with blank engrams. } # 2016feb11: End of TabulaRasa "clean slate" sequence. ...
# 2015may28 Requirements of Speech mind-module: # Speech module shall output a single word starting at given @ear point. # Outputted word shall be fed internally into the ReEntry module. # Inflected nouns and verbs shall be spoken from NounGen or VerbGen. sub Speech() { # 2016feb12: output of a word as text or sound if ($age > $cns) { die "TERMINATING: memory full \n"; } # 2016jan28 $t2s = $aud; # 2016feb13: start from the auditory recall-vector $aud do { # PERL by Example (2015), p. 194: do/until Loops my @aud=split(',',$ear[$t2s]); # 2016jan28: expose @ear values $output = "$output" . "$aud[0]"; #2016apr09: commenting back in # $output eq "$output" . "$aud[0]"; #2016apr25 if ($t2s == $aud) { print "\N{U+00}" } # 2016apr04: TEST, FOR UNICODE print "$aud[0]"; # 2016mar29: say each character $idea = "$idea" . "$aud[0]"; #2016apr09: concatenate for re-entry $pov = 1; # 2016apr08: internal point-of-view during thinking. $t2s++ ; # 2016mar10: Increment time-to-speech to advance thru memory. # if ($aud[0] eq " ") { # 2016jan28: if no character is found if ($aud[0] eq " ") { # 2016apr29: if no character is found $audrv = $t2s; # 2015may13: Prepare for next word in memory. return; # 2015may13: Exit at end of a word }; # 2015may13: End of if-clause } until $t2s eq $cns; # Show the whole array of AI Mind memory. $phodex = 1; # 2016apr03: reset for AudBuffer() } # http://mind.sourceforge.net/speech.html
Notice, children, that it doesn't do any good to _downvote_ a Comment when the readership can still see that the "offending" comment was written by someone called "AiHasBeenSolved":
Anyway, if some corporate IT shop starts developing the Perl AI beyond my own meager efforts,
this almost could be self-awareness.
i don't understand why you can understand your failure to understand programming at least in flashes of lucidity, but then defend your ``code'' design to clearly experience Perl programmers, some even trying to drop hints about using NLP libraries in an effort to get through to your rational mind.
his emphasis, not mine. did you have a chuckle bolding those words Arthur?
Name:
Anonymous2016-05-12 5:31
>>21 What do you find unmaintanable about our $b01 = ""; # 2016apr02: for OutBuffer(); our $b02 = ""; # 2016apr02: for OutBuffer(); our $b03 = ""; # 2016apr02: for OutBuffer(); our $b04 = ""; # 2016apr02: for OutBuffer(); our $b05 = ""; # 2016apr02: for OutBuffer(); our $b06 = ""; # 2016apr02: for OutBuffer(); our $b07 = ""; # 2016apr02: for OutBuffer(); [...]?We've been mocking the distain for arrays since MindForth, and he still does it, so he must have a good reason.
Name:
Anonymous2016-05-13 3:07
Sup Mentifex. How's it going? Still a taxi driver? I hear you can make much more money from Uber.
Name:
Anonymous2016-05-13 3:14
>>22 Maybe that allows him easily changing array values? I'm sure there is some deep logic in there and we all just to stupid to understand his genial work.
Can you teach me greek Mentifex? Also, do you happen to have a free copy of your books? I am poor you see.
Name:
Anonymous2016-05-13 15:46
>>25 Actually, translator multi-lingual expert makes a lot more money that a programmer. So Mentifex could be a rich motherfucker, doing programming only as a hobby.