Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2(pesnta/xelos-%I%) 9/18/84; site pesnta.UUCP Path: utzoo!lsuc!pesnta!earlw From: earlw@pesnta.UUCP (Earl Wallace) Newsgroups: pe.cust.sources Subject: Little Smalltalk Source, *New* Part 7 of 20 Message-ID: <2768@pesnta.UUCP> Date: Thu, 13-Jun-85 15:19:04 EDT Article-I.D.: pesnta.2768 Posted: Thu Jun 13 15:19:04 1985 Date-Received: Sat, 15-Jun-85 10:18:21 EDT Organization: Perkin-Elmer Data Systems Group / Customer Service Lines: 2511 #! /bin/sh # # This is an another posting of the Little Smalltalk source, the last posting # of this source went out in 5 parts and they were too big (>200k) for most # sites so I redid the whole mess to keep the files around the 50k range. # # The complete set is now 20 parts. # # P.S. - If you don't receive all 20 parts within 5 days, drop me a line. # Also, I have the Rand sources of May 1984, if someone has a more # updated copy, I'll be happy to post them (or YOU can post them :-)) # # -earlw@pesnta # #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # prelude/boolean.p # prelude/boolean.st # prelude/bytearray.p # prelude/bytearray.st # prelude/char.p # prelude/char.st # prelude/class.p # prelude/class.st # prelude/collection.p # prelude/collection.st # prelude/dictionary.p # prelude/dictionary.st # prelude/false.p # prelude/false.st # prelude/file.p # prelude/file.st # prelude/float.p # prelude/float.st # prelude/init # prelude/integer.p # prelude/integer.st # prelude/interval.p # prelude/interval.st # prelude/kcollection.p # prelude/kcollection.st # prelude/larray.p # prelude/larray.st # prelude/list.p # prelude/list.st # prelude/magnitude.p # prelude/magnitude.st # prelude/nil.p # prelude/nil.st # prelude/number.p # This archive created: Thu Jun 13 11:32:04 1985 # By: Earl Wallace (Perkin-Elmer Data Systems Group / Customer Service) export PATH; PATH=/bin:$PATH if test -f 'prelude/boolean.p' then echo shar: will not over-write existing file "'prelude/boolean.p'" else cat << \SHAR_EOF > 'prelude/boolean.p' temp <- > SHAR_EOF if test 634 -ne "`wc -c < 'prelude/boolean.p'`" then echo shar: error transmitting "'prelude/boolean.p'" '(should have been 634 characters)' fi fi # end of overwriting check if test -f 'prelude/boolean.st' then echo shar: will not over-write existing file "'prelude/boolean.st'" else cat << \SHAR_EOF > 'prelude/boolean.st' Class Boolean [ & aBoolean ^ self and: [aBoolean] | | aBoolean ^ self or: [aBoolean] | and: aBlock ^ self and: [aBlock value] | or: aBlock ^ self or: [aBlock value] | eqv: aBoolean ^ self == aBoolean | xor: aBoolean ^ self ~~ aBoolean ] SHAR_EOF if test 297 -ne "`wc -c < 'prelude/boolean.st'`" then echo shar: error transmitting "'prelude/boolean.st'" '(should have been 297 characters)' fi fi # end of overwriting check if test -f 'prelude/bytearray.p' then echo shar: will not over-write existing file "'prelude/bytearray.p'" else cat << \SHAR_EOF > 'prelude/bytearray.p' temp <- > SHAR_EOF if test 712 -ne "`wc -c < 'prelude/bytearray.p'`" then echo shar: error transmitting "'prelude/bytearray.p'" '(should have been 712 characters)' fi fi # end of overwriting check if test -f 'prelude/bytearray.st' then echo shar: will not over-write existing file "'prelude/bytearray.st'" else cat << \SHAR_EOF > 'prelude/bytearray.st' Class ByteArray :ArrayedCollection [ new: size ^ | at: index ^ | at: index put: value | printString | str | str <- '#[ '. (1 to: self size) do: [:i | str <- str , (self at: i) printString , ' ']. ^ str , ']' | size ^ ] SHAR_EOF if test 344 -ne "`wc -c < 'prelude/bytearray.st'`" then echo shar: error transmitting "'prelude/bytearray.st'" '(should have been 344 characters)' fi fi # end of overwriting check if test -f 'prelude/char.p' then echo shar: will not over-write existing file "'prelude/char.p'" else cat << \SHAR_EOF > 'prelude/char.p' temp <- " \ #( #[ 32 33 250 2 6 247 7 32 33 250 2 43 248 4 242 \ 32 10 19 243 245] \ #( ) ) > #= #< #== ) \ temp 2 4 > > SHAR_EOF if test 2174 -ne "`wc -c < 'prelude/char.p'`" then echo shar: error transmitting "'prelude/char.p'" '(should have been 2174 characters)' fi fi # end of overwriting check if test -f 'prelude/char.st' then echo shar: will not over-write existing file "'prelude/char.st'" else cat << \SHAR_EOF > 'prelude/char.st' Class Char :Magnitude [ == aChar ^ ifTrue: [] ifFalse: [false] | < aChar ^ ifTrue: [] ifFalse: [self compareError] | = aChar ^ ifTrue: [] ifFalse: [self compareError] | > aChar ^ ifTrue: [] ifFalse: [self compareError] | asciiValue ^ | asLowercase ^ ifTrue: [] ifFalse: [self] | asUppercase ^ ifTrue: [] ifFalse: [self] | asString ^ | compareError ^ self error: 'char cannot be compared to non char' | digitValue | i | ((i <- ) isNil) ifTrue: [self error: 'digitValue on nondigit char']. ^ i | isAlphaNumeric ^ | isDigit ^ self between: $0 and: $9 | isLetter ^ self isLowercase or: [self isUppercase] | isLowercase ^ self between: $a and: $z | isSeparator ^ | isUppercase ^ (self between: $A and: $Z) | isVowel ^ | printString ^ '$' , ] SHAR_EOF if test 1255 -ne "`wc -c < 'prelude/char.st'`" then echo shar: error transmitting "'prelude/char.st'" '(should have been 1255 characters)' fi fi # end of overwriting check if test -f 'prelude/class.p' then echo shar: will not over-write existing file "'prelude/class.p'" else cat << \SHAR_EOF > 'prelude/class.p' temp <- > SHAR_EOF if test 1351 -ne "`wc -c < 'prelude/class.p'`" then echo shar: error transmitting "'prelude/class.p'" '(should have been 1351 characters)' fi fi # end of overwriting check if test -f 'prelude/class.st' then echo shar: will not over-write existing file "'prelude/class.st'" else cat << \SHAR_EOF > 'prelude/class.st' Class Class [ edit | list | new | superclass newinstance | superclass <- . ifTrue: [newinstance <- superclass new ]. newinstance <- . ifTrue: [newinstance <- newinstance new]. ^ newinstance | new: aValue | superclass newinstance | superclass <- . ifTrue: [newinstance <- superclass new ]. newinstance <- . ifTrue: [newinstance <- newinstance new: aValue ]. ^ newinstance | printString ^ | respondsTo | respondsTo: aSymbol | aClass | aClass <- self. [aClass notNil] whileTrue: [ ifTrue: [ ^ true ]. aClass <- aClass superClass ]. ^ false | superClass ^ | variables ^ | view ] SHAR_EOF if test 1048 -ne "`wc -c < 'prelude/class.st'`" then echo shar: error transmitting "'prelude/class.st'" '(should have been 1048 characters)' fi fi # end of overwriting check if test -f 'prelude/collection.p' then echo shar: will not over-write existing file "'prelude/collection.p'" else cat << \SHAR_EOF > 'prelude/collection.p' temp <- > SHAR_EOF if test 3180 -ne "`wc -c < 'prelude/collection.p'`" then echo shar: error transmitting "'prelude/collection.p'" '(should have been 3180 characters)' fi fi # end of overwriting check if test -f 'prelude/collection.st' then echo shar: will not over-write existing file "'prelude/collection.st'" else cat << \SHAR_EOF > 'prelude/collection.st' Class Collection [ addAll: aCollection aCollection do: [:x | self add: x ] | asArray ^ Array new: self size ; replaceFrom: 1 to: self size with: self | asBag ^ Bag new addAll: self | asSet ^ Set new addAll: self | asList ^ List new addAllLast: self | asString ^ String new: self size ; replaceFrom: 1 to: self size with: self | coerce: aCollection | newobj | newobj <- self new. aCollection do: [:x | newobj add: x]. ^ newobj | collect: aBlock ^ self inject: self class new into: [:x :y | x add: (aBlock value: y). x ] | deepCopy | newobj | newobj <- List new . self do: [:x | newobj addLast: x copy ]. ^ self coerce: newobj | detect: aBlock ^ self detect: aBlock ifAbsent: [self error: 'no object found matching detect'] | detect: aBlock ifAbsent: exceptionBlock self do: [:x | (aBlock value: x) ifTrue: [^ x]]. ^ exceptionBlock value | first ^ self error: 'subclass should implement first' | includes: anObject self do: [:x | (x = anObject) ifTrue: [^ true]]. ^ false | inject: thisValue into: binaryBlock | last | last <- thisValue. self do: [:x | last <- binaryBlock value: last value: x]. ^ last | isEmpty ^ (self size = 0) | occurrencesOf: anObject ^ self inject: 0 into: [:x :y | (y = anObject) ifTrue: [x + 1] ifFalse: [x] ] | printString ^ ( self inject: self class printString , ' (' into: [:x :y | x , ' ' , y printString]), ' )' | reject: aBlock ^ self select: [:x | (aBlock value: x) not ] | remove: oldObject self remove: oldObject ifAbsent: [^ self error: 'attempt to remove object not found in collection' ]. ^ oldObject | remove: oldObject ifAbsent: exceptionBlock ^ (self includes: oldObject) ifTrue: [self remove: oldObject] ifFalse: exceptionBlock | select: aBlock ^ self inject: self class new into: [:x :y | (aBlock value: y) ifTrue: [x add: y]. x] | shallowCopy | newobj | newobj <- List new . self do: [:x | newobj addLast: x]. ^ self coerce: newobj | size | i | i <- 0. self do: [:x | i <- i + 1 ]. ^ i ] SHAR_EOF if test 2501 -ne "`wc -c < 'prelude/collection.st'`" then echo shar: error transmitting "'prelude/collection.st'" '(should have been 2501 characters)' fi fi # end of overwriting check if test -f 'prelude/dictionary.p' then echo shar: will not over-write existing file "'prelude/dictionary.p'" else cat << \SHAR_EOF > 'prelude/dictionary.p' temp <- > SHAR_EOF if test 2139 -ne "`wc -c < 'prelude/dictionary.p'`" then echo shar: error transmitting "'prelude/dictionary.p'" '(should have been 2139 characters)' fi fi # end of overwriting check if test -f 'prelude/dictionary.st' then echo shar: will not over-write existing file "'prelude/dictionary.st'" else cat << \SHAR_EOF > 'prelude/dictionary.st' " Dictionarys are implemented using Points in order to reduce the number of classes in the standard prelude this also has the advantage of making the output appear in key @ value form " Class Dictionary :KeyedCollection | hashTable currentBucket currentList | [ new hashTable <- Array new: 17 | hashNumber: aKey ^ ( \\ hashTable size) + 1 | getList: aKey | list bucketNumber | bucketNumber <- self hashNumber: aKey. list <- hashTable at: bucketNumber. (list isNil) ifTrue: [list <- List new. hashTable at: bucketNumber put: list]. ^ list | at: aKey put: anObject | list anAssoc | list <- self getList: aKey. anAssoc <- self findAssociation: aKey inList: list. (anAssoc isNil) ifTrue: [anAssoc <- (Point new x: aKey) y: anObject. list add: anAssoc] ifFalse: [anAssoc y: anObject]. ^ anObject | at: aKey ifAbsent: exceptionBlock | list anAssoc | list <- self getList: aKey. anAssoc <- self findAssociation: aKey inList: list. (anAssoc isNil) ifTrue: [^ exceptionBlock value]. ^ anAssoc y | removeKey: aKey ifAbsent: exceptionBlock | list anAssoc| list <- self getList: aKey. anAssoc <- self findAssociation: aKey inList: list. (anAssoc isNil) ifTrue: [^ exceptionBlock value]. ^ ( list remove: anAssoc ifAbsent: [ ^ exceptionBlock value ] ) y | findAssociation: aKey inList: linkedList linkedList do: [:item | (item x = aKey) ifTrue: [^ item]]. ^ nil | first | item | (1 to: 17) do: [:i | ((item <- self checkBucket: i) notNil) ifTrue: [ ^ item y] ] . ^ nil | next | item | ((item <- currentList next) notNil) ifTrue: [ ^ item y ]. [currentBucket < 17] whileTrue: [currentBucket <- currentBucket + 1. ((item <- self checkBucket: currentBucket) notNil) ifTrue: [ ^ item y ] ]. ^ nil | printString ^ (self inject: (self class printString) , ' ( ' into: [ :aString :aValue | aString , self currentKey printString , ' @ ' , aValue printString , ' ' ] ) , ')' | currentKey | clist| ^ (currentList notNil) ifTrue: [clist <- currentList current. (clist notNil) ifTrue: [clist x] ] | checkBucket: bucketNumber ((currentList <- hashTable at: (currentBucket <- bucketNumber)) isNil) ifTrue: [ ^ nil ]. ^ currentList first ] SHAR_EOF if test 2333 -ne "`wc -c < 'prelude/dictionary.st'`" then echo shar: error transmitting "'prelude/dictionary.st'" '(should have been 2333 characters)' fi fi # end of overwriting check if test -f 'prelude/false.p' then echo shar: will not over-write existing file "'prelude/false.p'" else cat << \SHAR_EOF > 'prelude/false.p' temp <- > SHAR_EOF if test 580 -ne "`wc -c < 'prelude/false.p'`" then echo shar: error transmitting "'prelude/false.p'" '(should have been 580 characters)' fi fi # end of overwriting check if test -f 'prelude/false.st' then echo shar: will not over-write existing file "'prelude/false.st'" else cat << \SHAR_EOF > 'prelude/false.st' Class False :Boolean [ ifTrue: trueAlternativeBlock ifFalse: falseAlternativeBlock ^ falseAlternativeBlock value ! ifFalse: falseAlternativeBlock ifTrue: trueAlternativeBlock ^ falseAlternativeBlock value ! ifTrue: trueAlternativeBlock ^ nil ! ifFalse: falseAlternativeBlock ^ falseAlternativeBlock value ! not ^ true ] SHAR_EOF if test 436 -ne "`wc -c < 'prelude/false.st'`" then echo shar: error transmitting "'prelude/false.st'" '(should have been 436 characters)' fi fi # end of overwriting check if test -f 'prelude/file.p' then echo shar: will not over-write existing file "'prelude/file.p'" else cat << \SHAR_EOF > 'prelude/file.p' temp <- > SHAR_EOF if test 1377 -ne "`wc -c < 'prelude/file.p'`" then echo shar: error transmitting "'prelude/file.p'" '(should have been 1377 characters)' fi fi # end of overwriting check if test -f 'prelude/file.st' then echo shar: will not over-write existing file "'prelude/file.st'" else cat << \SHAR_EOF > 'prelude/file.st' Class File :SequenceableCollection [ modeCharacter | modeInteger | modeString | at: aPosition . ^ self read | at: aPosition put: anObject . ^ self write: anObject | currentKey ^ | first ^ self at: 0 | next ^ self read | open: aName | open: aName for: opType | read ^ | size ^ | write: anObject ^ ] SHAR_EOF if test 630 -ne "`wc -c < 'prelude/file.st'`" then echo shar: error transmitting "'prelude/file.st'" '(should have been 630 characters)' fi fi # end of overwriting check if test -f 'prelude/float.p' then echo shar: will not over-write existing file "'prelude/float.p'" else cat << \SHAR_EOF > 'prelude/float.p' temp <- " \ #( #[ 32 33 250 2 6 247 7 32 33 250 2 63 248 5 242 \ 32 33 145 0 243 245] \ #( #> ) ) > 'prelude/float.st' Class Float :Number [ = aNumber ^ ifTrue: [] ifFalse: [super = aNumber] | < aNumber ^ ifTrue: [] ifFalse: [super < aNumber] | > aNumber ^ ifTrue: [] ifFalse: [ super > aNumber] | + aNumber ^ ifTrue: [] ifFalse: [super + aNumber] | - aNumber ^ ifTrue: [] ifFalse: [super - aNumber] | * aNumber ^ ifTrue: [] ifFalse: [super * aNumber] | / aNumber ^ ifTrue: [] ifFalse: [super / aNumber] | ^ aNumber ^ ifTrue: [] ifFalse: [super raisedTo: aNumber] | arcCos ^ Radian new: | arcSin ^ Radian new: | arcTan ^ Radian new: | asFloat ^ self | asString ^ | ceiling ^ | coerce: aNumber ^ aNumber asFloat | exp ^ | floor ^ | fractionPart ^ | gamma ^ | integerPart ^ | ln ^ | radix: aNumber ^ | rounded ^ | sqrt ^ | truncated ^ (self < 0.0) ifTrue: [] ifFalse: [] ] SHAR_EOF if test 1655 -ne "`wc -c < 'prelude/float.st'`" then echo shar: error transmitting "'prelude/float.st'" '(should have been 1655 characters)' fi fi # end of overwriting check if test -f 'prelude/init' then echo shar: will not over-write existing file "'prelude/init'" else cat << \SHAR_EOF > 'prelude/init' smalltalk new SHAR_EOF if test 14 -ne "`wc -c < 'prelude/init'`" then echo shar: error transmitting "'prelude/init'" '(should have been 14 characters)' fi fi # end of overwriting check if test -f 'prelude/integer.p' then echo shar: will not over-write existing file "'prelude/integer.p'" else cat << \SHAR_EOF > 'prelude/integer.p' temp <- " \ #( #[ 32 33 250 2 6 247 7 32 33 250 2 13 248 5 242 \ 32 33 145 0 243 245] \ #( #> ) ) > 'prelude/integer.st' Class Integer :Number [ = aNumber ^ ifTrue: [ ] ifFalse: [ super = aNumber ] | > aNumber ^ ifTrue: [ ] ifFalse: [ super > aNumber ] | < aNumber ^ ifTrue: [ ] ifFalse: [ super < aNumber ] | + aNumber ^ ifTrue: [ ] ifFalse: [ super + aNumber ] | - aNumber ^ ifTrue: [] ifFalse: [ super - aNumber ] | * aNumber ^ ifTrue: [] ifFalse: [ super * aNumber ] | / aNumber ^ self asFloat / aNumber | // aNumber ^ ifTrue: [] ifFalse: [self opError] | \\ aNumber | i | ^ ifTrue: [i <- self * ( (self < 0) ifTrue: [ -1 ] ifFalse: [ 1 ] ). i rem: aNumber] ifFalse: [self opError] | allMask: anInteger ^ anInteger = | anyMask: anInteger ^ 0 ~= | asCharacter ^ | asFloat ^ | asString ^ | bitAnd: anInteger ^ | bitAt: anInteger ^ | bitInvert ^ | bitOr: anInteger ^ | bitShift: anInteger ^ | bitXor: anInteger ^ | even ^ (self rem: 2) = 0 | factorial ^ | gcd: anInteger ^ ifTrue: [] ifFalse: [self opError] | highBit ^ | lcm: anInteger ^ ifTrue: [self * anInteger quo: (self gcd: anInteger)] ifFalse: [self opError] | noMask: anInteger ^ 0 = (self bitAnd: anInteger) | odd ^ (self rem: 2) ~= 0 | quo: anInteger ^ ifTrue: [] ifFalse: [self opError] | radix: aNumber ^ | rem: anInteger ^ ifTrue: [] ifFalse: [self opError] | timesRepeat: aBlock | i | i <- 0. [i < self] whileTrue: [aBlock value. i <- i + 1] ] SHAR_EOF if test 2472 -ne "`wc -c < 'prelude/integer.st'`" then echo shar: error transmitting "'prelude/integer.st'" '(should have been 2472 characters)' fi fi # end of overwriting check if test -f 'prelude/interval.p' then echo shar: will not over-write existing file "'prelude/interval.p'" else cat << \SHAR_EOF > 'prelude/interval.p' temp <- > SHAR_EOF if test 1805 -ne "`wc -c < 'prelude/interval.p'`" then echo shar: error transmitting "'prelude/interval.p'" '(should have been 1805 characters)' fi fi # end of overwriting check if test -f 'prelude/interval.st' then echo shar: will not over-write existing file "'prelude/interval.st'" else cat << \SHAR_EOF > 'prelude/interval.st' Class Interval :SequenceableCollection | lower upper step current | [ from: lowerBound to: upperBound by: stepSize current <- lower <- lowerBound. upper <- upperBound. step <- stepSize | size ^ ((step strictlyPositive) ifTrue: [upper < lower] ifFalse: [lower < upper] ) ifTrue: [ 0 ] ifFalse: [upper - lower // step + 1] | inRange: value ^ (step strictlyPositive) ifTrue: [(value >= lower) and: [value <= upper]] ifFalse: [(value >= upper) and: [value <= lower]] | first current <- lower. ^ (self inRange: current) ifTrue: [current] | next current <- current + step. ^ (self inRange: current) ifTrue: [current] | at: index ifAbsent: exceptionBlock | val | val <- lower + (step * (index - 1)). ^ (self inRange: val) ifTrue: [ val ] ifFalse: [exceptionBlock value] | printString ^ 'Interval ', lower printString , ' to ', upper printString , ' by ' , step printString | coerce: newcollection ^ newcollection asArray | at: index put: val ^ self error: 'cannot store into Interval' | add: val ^ self error: 'cannot store into Interval' | removeKey: key ifAbsent: exceptionBlock self error: 'cannot remove from Interval'. ^ exceptionBlock value | deepCopy ^ lower to: upper by: step | shallowCopy ^ lower to: upper by: step ] SHAR_EOF if test 1369 -ne "`wc -c < 'prelude/interval.st'`" then echo shar: error transmitting "'prelude/interval.st'" '(should have been 1369 characters)' fi fi # end of overwriting check if test -f 'prelude/kcollection.p' then echo shar: will not over-write existing file "'prelude/kcollection.p'" else cat << \SHAR_EOF > 'prelude/kcollection.p' temp <- > SHAR_EOF if test 2622 -ne "`wc -c < 'prelude/kcollection.p'`" then echo shar: error transmitting "'prelude/kcollection.p'" '(should have been 2622 characters)' fi fi # end of overwriting check if test -f 'prelude/kcollection.st' then echo shar: will not over-write existing file "'prelude/kcollection.st'" else cat << \SHAR_EOF > 'prelude/kcollection.st' Class KeyedCollection :Collection [ add: anElement ^ self error: 'Must add with explicit key' | addAll: aCollection aCollection binaryDo: [:x :y | self at: x put: y]. ^ aCollection | asDictionary | newCollection | newCollection <- Dictionary new. self binaryDo: [:key :val | newCollection at: key put: val]. ^ newCollection | at: key ^ self at: key ifAbsent: [self error: (key printString , ': association not found'). ^ key] | atAll: aCollection put: anObject aCollection do: [:x | self at: x put: anObject] | binaryDo: aBlock | item | self do: [:x | aBlock value: self currentKey value: x ]. ^ nil | collect: aBlock ^ self coerce: (self inject: Dictionary new into: [:x :y | x at: self currentKey put: (aBlock value: y) . x ] ) | includesKey: key self at: key ifAbsent: [^ false]. ^ true | indexOf: anElement ^ self indexOf: anElement ifAbsent: [self error: 'indexOf element not found'] | indexOf: anElement ifAbsent: exceptionBlock self do: [:x | (x = anElement) ifTrue: [ ^ self currentKey ]]. ^ exceptionBlock value | keys | newset | newset <- Set new. self keysDo: [:x | newset add: x]. ^ newset | keysDo: aBlock ^ self do: [ :x | aBlock value: self currentKey ] | keysSelect: aBlock ^ self coerce: (self inject: Dictionary new into: [:x :y | (aBlock value: y currentKey) ifTrue: [x at: self currentKey put: y]. x ] ) | remove: anElement ^ self error: 'object must be removed with explicit key' | removeKey: key ^ self removeKey: key ifAbsent: [self error: 'no element associated with key'. ^ key] | removeKey: key ifAbsent: exceptionBlock ^ self error: 'subclass should implement RemoveKey:ifAbsent:' | select: aBlock ^ self coerce: (self inject: Dictionary new into: [:x :y | (aBlock value: y) ifTrue: [x at: self currentKey put: y]. x ] ) | values | newbag | newbag <- Bag new. self do: [:x | newbag add: x]. ^ newbag ] SHAR_EOF if test 2628 -ne "`wc -c < 'prelude/kcollection.st'`" then echo shar: error transmitting "'prelude/kcollection.st'" '(should have been 2628 characters)' fi fi # end of overwriting check if test -f 'prelude/larray.p' then echo shar: will not over-write existing file "'prelude/larray.p'" else cat << \SHAR_EOF > 'prelude/larray.p' temp <- > SHAR_EOF if test 250 -ne "`wc -c < 'prelude/larray.p'`" then echo shar: error transmitting "'prelude/larray.p'" '(should have been 250 characters)' fi fi # end of overwriting check if test -f 'prelude/larray.st' then echo shar: will not over-write existing file "'prelude/larray.st'" else cat << \SHAR_EOF > 'prelude/larray.st' Class ArrayedCollection " This is just a null version of ArrayedCollection to serve as a place holder until the real version is read in during the prelude " [ nothing 1 ] SHAR_EOF if test 175 -ne "`wc -c < 'prelude/larray.st'`" then echo shar: error transmitting "'prelude/larray.st'" '(should have been 175 characters)' fi fi # end of overwriting check if test -f 'prelude/list.p' then echo shar: will not over-write existing file "'prelude/list.p'" else cat << \SHAR_EOF > 'prelude/list.p' temp <- > SHAR_EOF if test 2388 -ne "`wc -c < 'prelude/list.p'`" then echo shar: error transmitting "'prelude/list.p'" '(should have been 2388 characters)' fi fi # end of overwriting check if test -f 'prelude/list.st' then echo shar: will not over-write existing file "'prelude/list.st'" else cat << \SHAR_EOF > 'prelude/list.st' " Lists are implemented using Points in order to reduce the number of classes in the standard prelude " Class List :SequenceableCollection | first current | [ add: anItem first <- (Point new x: anItem ) y: first . ^ anItem | addFirst: anItem first <- (Point new x: anItem ) y: first . ^ anItem | addLast: anItem (first isNil) ifTrue: [^ self addFirst: anItem]. (self findLast) y: ((Point new x: anItem) y: nil). ^ anItem | addAllFirst: aCollection aCollection do: [:x | self addFirst: x] | addAllLast: aCollection aCollection do: [:x | self addLast: x] | coerce: aCollection | newList | newList <- List new. aCollection do: [:x | newList addLast: x]. ^ newList | findLast | item | ((item <- first) isNil) ifTrue: [^ nil]. [(item y) notNil] whileTrue: [item <- item y]. ^ item | remove: anItem ^ self remove: anItem ifAbsent: [self error: 'cant find item'] | remove: anItem ifAbsent: exceptionBlock (first isNil) ifTrue: [^ exceptionBlock value]. self inject: nil into: [:prev :current | (current x == anItem) ifTrue: [(prev isNil) ifTrue: [first <- current y] ifFalse: [prev y: (current y)]. ^ anItem]. current ] . ^ exceptionBlock value | removeError ^ self error: 'cannot remove from an empty list' | removeFirst | item | (first isNil) ifTrue: [^ self removeError]. item <- first. first <- first y. ^ item x | removeLast (first isNil) ifTrue: [^ self removeError]. ^ self remove: self last ifAbsent: [self removeError] | first ^ ((current <- first) notNil) ifTrue: [ current x ] | next ^ ((current <- current y) notNil) ifTrue: [ current x ] | current ^ current x | last (first isNil) ifTrue: [^ nil]. ^ self findLast x | isEmpty ^ first == nil ] SHAR_EOF if test 1802 -ne "`wc -c < 'prelude/list.st'`" then echo shar: error transmitting "'prelude/list.st'" '(should have been 1802 characters)' fi fi # end of overwriting check if test -f 'prelude/magnitude.p' then echo shar: will not over-write existing file "'prelude/magnitude.p'" else cat << \SHAR_EOF > 'prelude/magnitude.p' temp <- " \ #( #[ 33 32 199 243 245] \ #( ) ) > = " \ #( #[ 32 33 204 251 3 32 33 201 243 245] \ #( ) ) > 'prelude/magnitude.st' Class Magnitude [ <= arg ^ (self < arg) or: [self = arg] | < arg ^ (arg > self) | = arg ^ (self > arg or: [self < arg]) not | ~= arg ^ (self = arg) not | >= arg ^ (self > arg) or: [self = arg] | > arg ^ arg < self | between: low and: high ^ (self >= low) and: [self <= high] | min: arg ^ (self < arg) ifTrue: [self] ifFalse: [arg] | max: arg ^ (self > arg) ifTrue: [self] ifFalse: [arg] ] SHAR_EOF if test 416 -ne "`wc -c < 'prelude/magnitude.st'`" then echo shar: error transmitting "'prelude/magnitude.st'" '(should have been 416 characters)' fi fi # end of overwriting check if test -f 'prelude/nil.p' then echo shar: will not over-write existing file "'prelude/nil.p'" else cat << \SHAR_EOF > 'prelude/nil.p' temp <- > SHAR_EOF if test 409 -ne "`wc -c < 'prelude/nil.p'`" then echo shar: error transmitting "'prelude/nil.p'" '(should have been 409 characters)' fi fi # end of overwriting check if test -f 'prelude/nil.st' then echo shar: will not over-write existing file "'prelude/nil.st'" else cat << \SHAR_EOF > 'prelude/nil.st' Class UndefinedObject [ isNil ^ true | notNil ^ false | printString ^ 'nil' ] SHAR_EOF if test 150 -ne "`wc -c < 'prelude/nil.st'`" then echo shar: error transmitting "'prelude/nil.st'" '(should have been 150 characters)' fi fi # end of overwriting check if test -f 'prelude/number.p' then echo shar: will not over-write existing file "'prelude/number.p'" else cat << \SHAR_EOF > 'prelude/number.p' temp <- " \ #( #[ 32 33 11 34 33 32 11 34 204 243 245] \ #( ) ) > #< #= #maxtype: ) \ temp 3 6 > > SHAR_EOF if test 3046 -ne "`wc -c < 'prelude/number.p'`" then echo shar: error transmitting "'prelude/number.p'" '(should have been 3046 characters)' fi fi # end of overwriting check # End of shell archive exit 0