sumim #3966(2007/11/13 16:15 GMT) [ Smalltalk ] Rating1/1=1.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| bf st op in | bf := FileStream fileNamed: 'hello.bf'. in := FileStream fileNamed: 'in.txt'. in binary. st := WriteStream with: '| ss | ss := ReadWriteStream with: #(0). ss reset'. [(op := bf next) notNil] whileTrue: [ st nextPutAll: (op caseOf: { [$>] -> ['. ss next. ss atEnd ifTrue: [ss nextPut: 0; back]']. [$<] -> ['. ss back']. [$+] -> ['. ss nextPut: ss peek + 1; back']. [$-] -> ['. ss nextPut: ss peek - 1; back']. [$.] -> ['. Transcript show: (ss peek asCharacter)']. [$,] -> ['. ss nextPut: ', in next printString,' value; back']. [$[] -> ['. [ss peek isZero] whileFalse: [']. [$]] -> [']']} otherwise: [''])]. bf close. in close. World findATranscript: nil. Compiler evaluate: st contents
Rating1/1=1.00-0+
[ reply ]
sumim
#3966()
[
Smalltalk
]
Rating1/1=1.00
| bf st op in | bf := FileStream fileNamed: 'hello.bf'. in := FileStream fileNamed: 'in.txt'. in binary. st := WriteStream with: '| ss | ss := ReadWriteStream with: #(0). ss reset'. [(op := bf next) notNil] whileTrue: [ st nextPutAll: (op caseOf: { [$>] -> ['. ss next. ss atEnd ifTrue: [ss nextPut: 0; back]']. [$<] -> ['. ss back']. [$+] -> ['. ss nextPut: ss peek + 1; back']. [$-] -> ['. ss nextPut: ss peek - 1; back']. [$.] -> ['. Transcript show: (ss peek asCharacter)']. [$,] -> ['. ss nextPut: ', in next printString,' value; back']. [$[] -> ['. [ss peek isZero] whileFalse: [']. [$]] -> [']']} otherwise: [''])]. bf close. in close. World findATranscript: nil. Compiler evaluate: st contentsRating1/1=1.00-0+
[ reply ]