This comment is reply for 2106 sumim: Squeak Smalltalk で。(与えた条件を満たす候補). Go to thread root.
sumim #2132(2007/08/14 02:56 GMT) [ Smalltalk ] Rating0/0=0.00
#(not not not) などに対応できる版を Squeak Smalltalk で。
1 2 3 4 5 6 7 8 9 10
| input numArgs | input := #(& | not &). numArgs := (input collect: [:sel | sel numArgs]) sum + 1. World findATranscript: nil. {true. false} asDigitsToPower: numArgs do: [:xs | | xsStream expression | xsStream := xs readStream. expression := input inject: xsStream next printString into: [:expStr :sel | expStr, ' ', sel, (sel == #not ifFalse: [xsStream next printString] ifTrue: [''])]. (Compiler evaluate: expression) ifTrue: [Transcript cr; show: xs]]
Rating0/0=0.00-0+
[ reply ]
sumim
#2132()
[
Smalltalk
]
Rating0/0=0.00
| input numArgs | input := #(& | not &). numArgs := (input collect: [:sel | sel numArgs]) sum + 1. World findATranscript: nil. {true. false} asDigitsToPower: numArgs do: [:xs | | xsStream expression | xsStream := xs readStream. expression := input inject: xsStream next printString into: [:expStr :sel | expStr, ' ', sel, (sel == #not ifFalse: [xsStream next printString] ifTrue: [''])]. (Compiler evaluate: expression) ifTrue: [Transcript cr; show: xs]]Rating0/0=0.00-0+