Object subclass: #Consc instanceVariableNames: 'hd tl' classVariableNames: '' poolDictionaries: '' category: 'Thur19Apr'! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/19/2012 12:31'! append: other ^ Consc new car: (self car) cdr: (self cdr append: other).! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:13'! car ^ hd.! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:13'! car: a hd := a.! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:12'! car: a cdr: b hd := a. tl := b. ! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:13'! cdr ^ tl.! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:13'! cdr: a tl := a.! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/19/2012 12:27'! length ^ self cdr length + 1.! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:14'! null ^ false.! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/19/2012 12:35'! print Transcript show: '('; show: self car. self cdr printascdr.! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/19/2012 12:36'! printascdr Transcript show: ' '; show: self car. self cdr printascdr.! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:28'! reverse ^ self reverse: self onto: Nil new.! ! !Consc methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:26'! reverse: in onto: acc in null ifTrue: [ ^ acc ]. ^ self reverse: (in cdr) onto: (Consc new car: (in car) cdr: acc).! ! Object subclass: #Nil instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Thur19Apr'! !Nil methodsFor: 'as yet unclassified' stamp: 'x 4/19/2012 12:29'! append: other ^ other.! ! !Nil methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:22'! length ^ 0.! ! !Nil methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 18:16'! null ^ true.! ! !Nil methodsFor: 'as yet unclassified' stamp: 'x 4/19/2012 12:33'! print Transcript show: 'nil'.! ! !Nil methodsFor: 'as yet unclassified' stamp: 'x 4/19/2012 12:32'! printascdr Transcript show: ')'.! ! Object subclass: #Num instanceVariableNames: 'val' classVariableNames: '' poolDictionaries: '' category: 'Thur19Apr'! !Num methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 17:41'! become: x val := x.! ! !Num methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 17:43'! decrease val := val-1.! ! !Num methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 17:42'! display Transcript show: val; show: ' '.! ! !Num methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 17:59'! factorial (val=0) ifTrue: [ self become: 1 ] ifFalse: [ |orig| orig:=val. self decrease; factorial; mulby: orig ]. ! ! !Num methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 17:59'! mulby: n val := val * n.! ! !Num methodsFor: 'as yet unclassified' stamp: 'x 4/18/2012 17:41'! value ^ val.! !