Changeset 6350 for lang/smalltalk
- Timestamp:
- 02/08/08 00:25:19 (5 years ago)
- Files:
-
- 1 modified
-
lang/smalltalk/misc/gost.st (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/smalltalk/misc/gost.st
r5930 r6350 82 82 |> s 83 83 self P: s! 84 @ o 85 (o respondsTo: #collect:) and: [ ^o collect: [:i| self at: i ] ]. 86 ^self at: o! 84 87 85 88 !Symbol methodsFor: 'golf'! … … 123 126 124 127 !SequenceableCollection methodsFor: 'golf'! 125 / p 126 ^(p isKindOf: SequenceableCollection) ifTrue: [ 127 | s r | 128 s := self readStream. r := OrderedCollection new. 129 [ r add: (s upToAll: p). s atEnd ] whileFalse. 130 r. 131 ] ifFalse: [ super / p ]! 128 / o 129 | s r | 130 s := ReadStream on: self. 131 r := OrderedCollection new. 132 (o isKindOf: SequenceableCollection) and: [ 133 [ r add: (s upToAll: o). s atEnd ] whileFalse ]. 134 (o isKindOf: Integer) and: [ 135 [ r add: (s nextAvailable: o). s atEnd ] whileFalse ]. 136 ^r! 132 137 * o 133 138 ^(o isKindOf: Integer) … … 148 153 displayOn: s 149 154 | j | 150 (j := Golf.Dic at: $\) isNil 151 ifTrue: [ self do: [:x| x displayOn: s ] ] 152 ifFalse: [ self do: [:x| x displayOn: s ] separatedBy: [ j displayOn: s ] ]! 153 155 (j := Golf.Dic at: $\) 156 ifNil: [ self do: [:x| x displayOn: s ] ] 157 ifNotNil: [ self do: [:x| x displayOn: s ] separatedBy: [ j displayOn: s ] ]! 158 zip 159 "Transpose rows with columns (derived from GolfScript)." 160 | cols | 161 cols := 1 to: self size. 162 ^(1 to: self first size) collect: 163 [:i| cols collect: [:j| (self at: j) at: i ] ]! 164 154 165 !False methodsFor: 'golf'! 155 166 displayOn: s! … … 199 210 "Makes a [D]ictionary from an array of associations." 200 211 ^self asArray inject: Dictionary new into: [ :d :a | d add: a. d ]! 201 @ o202 ^(o respondsTo: #collect:)203 ifTrue: [ o collect: [:i| self at: i ] ]204 ifFalse: [ self at: o ]!205 212 + o 206 213 (o isKindOf: BlockClosure) and: [ ^self fold: o ]. 207 214 o isSymbol and: [ ^self fold: [:a :b| a perform: o with: b ] ]! 208 / n209 | r s |210 r := OrderedCollection new: (self size / n) ceiling.211 s := ReadStream on: self.212 [ r add: (s nextAvailable: n). s atEnd ] whileFalse.213 ^r!214 215 \ b 215 216 ^self collect: b!
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)