[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] pi



> Let's offer an irrational prize for the first one who can give us a 
> Perl script that speaks pi out at the level of precision requested. 
> Or maybe Kevin Reid could do something interesting visually...

Code to do this forthcoming...  Please stand by.

Meanwhile, here's a first stab at it:

#!perl -w

# How to Speak Pi
# "Fred" seems to be the best voice for this.

use Mac::Speech;
my $pi;

$pi = <<EOF ;
3.1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0 2 8 8 4 
1 9
7 1 6 9 3 9 9 3 7 5 1 0 5 8 2 0 9 7 4 9 4 4 5 9 2 3 0 7 8 1 6 4 0 6 2 8 6 
2
0 8 9 9 8 6 2 8 0 3 4 8 2 5 3 4 2 1 1 7 0 6 7 9 8 2 1 4 8 0 8 6 5 1 3 2 8 
2
3 0 6 6 4 7 0 9 3 8 4 4 6 0 9 5 5 0 5 8 2 2 3 1 7 2 5 3 5 9 4 0 8 1 2 8 4 
8
1 1 1 7 4 5 0 2 8 4 1 0 2 7 0 1 9 3 8 5 2 1 1 0 5 5 5 9 6 4 4 6 2 2 9 4 8 
9
5 4 9 3 0 3 8 1 9 6 4 4 2 8 8 1 0 9 7 5 6 6 5 9 3 3 4 4 6 1 2 8 4 7 5 6 4 
8
EOF

$speaker = "Fred";

$speech = "Pie is equal to $pi";

&give_speech;

sub give_speech {
	if (! $speaker) { $speaker = "Fred" }
	$voice = $Voice{$speaker};
	$channel = NewSpeechChannel($voice) or die $^E;
		SpeakText($channel, $speech) || die $^E;
		while (SpeechBusy()) {}
		DisposeSpeechChannel($channel);
		$speech=$speaker="";
}

# Each line of pi in the quote above corresponds to half a line
# of pi here below. You may add or subtract digits as you like,
# as long as each digit is seperated by a space.
#
#3.141592653589793238462643383279502884197169399375105820974944592307816406
2862
# 
089986280348253421170679821480865132823066470938446095505822317253594081284
8
# 
111745028410270193852110555964462294895493038196442881097566593344612847564
8
# 
233786783165271201909145648566923460348610454326648213393607260249141273724
5
# 
870066063155881748815209209628292540917153643678925903600113305305488204665
2
# 
138414695194151160943305727036575959195309218611738193261179310511854807446
2
# 
379962749567351885752724891227938183011949129833673362440656643086021394946
3
# 
952247371907021798609437027705392171762931767523846748184676694051320005681
2
# 
714526356082778577134275778960917363717872146844090122495343014654958537105
0
# 
792279689258923542019956112129021960864034418159813629774771309960518707211
3
# 
499999983729780499510597317328160963185950244594553469083026425223082533446
8
# 
503526193118817101000313783875288658753320838142061717766914730359825349042
8
# 
755468731159562863882353787593751957781857780532171226806613001927876611195
9
# 092164201989 



--B

# Fungal Parataxonomy                   Mycology Information (Mycoinfo)
# Webmaster, Staff Writer      **The World's First Mycology E-Journal**   
# <mailto:webmaster@mycoinfo.com>            <http://www.mycoinfo.com/> 
#
# First they ignore you. Then they laugh at you. Then they fight you.
# Then you win.                                     --Mohandas Gandhi


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org