requires: {}. provides: {#Method. #MethodConverse}. x@(Root traits) perform: selector "Included for Smalltalk compatibility and brevity." [ selector sendTo: {x} ]. condition@(Method traits) whileTrue: body [ [ condition value ifFalse: [^ Nil]. body value. ] loop ]. condition@(Method traits) whileTrue [ condition whileTrue: [] ]. condition@(Method traits) whileFalse: body [ [ condition value ifTrue: [^ Nil]. body value. ] loop ]. condition@(Method traits) whileFalse [ condition whileFalse: [] ]. count@(Integer traits) timesRepeat: block [ [count > 0] whileTrue: [ block value. count: count - 1 ] ]. start@(Integer traits) to: end do: block "Auto-detects the direction of the progression." [ start < end ifTrue: [start upTo: end do: block] ifFalse: [start downTo: end do: block] ]. start@(Integer traits) upTo: end do: block [ [start <= end] whileTrue: [ block value: start. start: start + 1 ] ]. start@(Integer traits) below: end do: block [ [start < end] whileTrue: [ block value: start. start: start + 1 ] ]. start@(Integer traits) downTo: end do: block [ [start >= end] whileTrue: [ block value: start. start: start - 1 ] ]. start@(Integer traits) above: end do: block [ [start > end] whileTrue: [ block value: start. start: start - 1 ] ]. start@(Number traits) downTo: end by: inc do: block [ [start >= end] whileTrue: [ block value: start. start: start - inc] ]. start@(Number traits) upTo: end by: inc do: block [ [start <= end] whileTrue: [ block value: start. start: start + inc] ]. prototypes addSlot: #MethodConverse valued: Cloneable derive. MethodConverse addSlot: #block. "A Method's converse takes the arguments in reverse to produce the same result. This implementation works on any method arity, but the client needs to be aware of this arity, naturally." m@(Method traits) converse "Creates a new method converse." [| newM | newM: MethodConverse clone. newM block: m. newM ]. mc@(MethodConverse traits) converse "A converse of a converse is the original method." [ mc block ]. mc@(MethodConverse traits) value [ mc block value ]. mc@(MethodConverse traits) value: obj [ mc block value: obj ]. mc@(MethodConverse traits) value: obj1 value: obj2 [ mc block value: obj2 value: obj1 ]. mc@(MethodConverse traits) value: obj1 value: obj2 value: obj3 [ mc block value: obj3 value: obj2 value: obj1 ]. mc@(MethodConverse traits) values: array [ mc block values: array reverse ].