[squeak-dev] The Inbox: Kernel-cbr.475.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Jul 28 03:48:06 UTC 2010
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-cbr.475.mcz
==================== Summary ====================
Name: Kernel-cbr.475
Author: cbr
Time: 27 July 2010, 8:47:17.817 pm
UUID: 31fff092-aa15-4aac-9cff-0edb485a0d25
Ancestors: Kernel-eem.474
A few of the chronology classes met my current heuristic for "comment is too small," and though the comments were fine as is, I added an example usage to each just for fun.
=============== Diff against Kernel-eem.474 ===============
Item was changed:
Timespan subclass: #Week
instanceVariableNames: ''
classVariableNames: 'StartDay'
poolDictionaries: 'ChronologyConstants'
category: 'Kernel-Chronology'!
+ !Week commentStamp: 'cbr 7/27/2010 20:28' prior: 0!
+ I represent a week.
+
+ To find out what days of the week on which Squeak is fun, select the following expression, and print it:
+
+ Week dayNames!
- !Week commentStamp: 'brp 5/13/2003 09:48' prior: 0!
- I represent a week.!
Item was changed:
Timespan subclass: #Year
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Chronology'!
+ !Year commentStamp: 'cbr 7/27/2010 20:41' prior: 0!
+ I represent a year.
+
+ Try me!! Select the following expression and print it:
+
+ Year current daysInYear "Try me again next leap year!!"!
- !Year commentStamp: 'dtl 7/11/2009 16:35' prior: 0!
- I represent a year.!
Item was changed:
Timespan subclass: #Month
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: 'ChronologyConstants'
category: 'Kernel-Chronology'!
+ !Month commentStamp: 'cbr 7/27/2010 20:34' prior: 0!
+ I represent a month.
+
+ For example, to get the number of days this month, you can evaluate the following expression:
+
+ Month current daysInMonth!
- !Month commentStamp: 'brp 5/13/2003 09:48' prior: 0!
- I represent a month.!
Item was removed:
- ----- Method: Integer>>isPrime (in category 'testing') -----
- isPrime
- "Answer true if the receiver is a prime number. See isProbablyPrime for a probabilistic
- implementation that is much faster for large integers, and that is correct to an extremely
- high statistical level of confidence (effectively deterministic)."
-
- self <= 1 ifTrue: [ ^false ].
- self even ifTrue: [ ^self = 2].
- 3 to: self sqrtFloor by: 2 do: [ :each |
- self \\ each = 0 ifTrue: [ ^false ] ].
- ^true!
Item was removed:
- ----- Method: Float class>>twoPi (in category 'constants') -----
- twoPi
-
- ^ Twopi
- !
Item was removed:
- ----- Method: Integer>>isProbablyPrimeWithK:andQ: (in category 'private') -----
- isProbablyPrimeWithK: k andQ: q
- "Algorithm P, probabilistic primality test, from
- Knuth, Donald E. 'The Art of Computer Programming', Vol 2,
- Third Edition, section 4.5.4, page 395, P1-P5 refer to Knuth description."
-
- "P1"
-
- | x j y |
- x := (self - 2) atRandom + 1.
- "P2"
- j := 0.
- y := x raisedToInteger: q modulo: self.
- "P3"
-
- [(((j = 0) & (y = 1)) | (y = (self - 1))) ifTrue: [^true].
- ((j > 0) & (y = 1)) ifTrue: [^false]. "P5"
- true]
- whileTrue:
- [j := j + 1.
- (j < k) ifTrue: [y := y squared \\ self]
- ifFalse:[^ false]]!
Item was removed:
- ----- Method: Object>>isArray (in category 'testing') -----
- isArray
- ^false!
Item was removed:
- ----- Method: Integer>>raisedToInteger:modulo: (in category 'mathematical functions') -----
- raisedToInteger: exp modulo: m
- (exp = 0) ifTrue: [^ 1].
- exp even
- ifTrue: [^ (self raisedToInteger: (exp // 2) modulo: m) squared \\ m]
- ifFalse: [^ (self * (self raisedToInteger: (exp - 1) modulo: m)) \\ m].!
More information about the Squeak-dev
mailing list
|