[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] SF.net SVN: supercollider:[8148] trunk/build/SCClassLibrary/Common/Math/ Integer.sc
Revision: 8148
http://supercollider.svn.sourceforge.net/supercollider/?rev=8148&view=rev
Author: joshpar
Date: 2008-12-15 15:56:04 +0000 (Mon, 15 Dec 2008)
Log Message:
-----------
add Integer:factorial
Modified Paths:
--------------
trunk/build/SCClassLibrary/Common/Math/Integer.sc
Modified: trunk/build/SCClassLibrary/Common/Math/Integer.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/Math/Integer.sc 2008-12-15 15:00:33 UTC (rev 8147)
+++ trunk/build/SCClassLibrary/Common/Math/Integer.sc 2008-12-15 15:56:04 UTC (rev 8148)
@@ -204,5 +204,13 @@
}
pidRunning { _PidRunning; ^this.primitiveFailed }
+
+ factorial {
+ var product = 1.0;
+ if(this <= 1) { ^1 } {
+ this.do { |x| product = product * (x+1) };
+ ^product
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
_______________________________________________
sc-dev mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/