fb:porticula NoPaste
Iteratoren-Überladung
Uploader: | MOD |
Datum/Zeit: | 03.07.2010 21:49:46 |
Type typ
As Integer a, b
'für For ohne Step braucht man unbedingt ein LET
Declare Operator Let(wert As Integer)
Declare Operator For
Declare Operator For(stp As typ)
Declare Operator Step
Declare Operator Step(stp As typ)
Declare Operator Next(dat As typ) As Integer
Declare Operator Next(dat As typ, stp As typ) As Integer
End Type
Operator typ.Let(wert As Integer)
a = wert
b = wert
End Operator
Operator typ.for
End Operator
Operator typ.for(stp As typ)
End Operator
Operator typ.step
this.a += 1
this.b += 1
End Operator
Operator typ.step(stp As typ)
this.a += stp.a
this.b += stp.b
End Operator
Operator typ.next(dat As typ) As Integer
If this.a > dat.a And this.b > dat.b Then Return 0
Return -1
End Operator
Operator typ.next(dat As typ, stp As typ) As Integer
If ((stp.a >= 0 And this.a > dat.a) Or (stp.a <= 0 And this.a < dat.a)) And ((stp.b >= 0 And this.b > dat.b) Or (stp.b <= 0 And this.b < dat.b)) Then Return 0
Return -1
End Operator
Dim As typ i, start, ende, schritt
start = Type<typ>(5, 3)
ende = Type<typ>(9, 0)
schritt = Type(2, -1)
For i = start To ende Step schritt
Print i.a, i.b
Next
schritt= Type<typ>(1, 1)
For i = start To ende Step schritt
Print i.a, i.b
Next
For i = start To ende
Print i.a, i.b
Next
Sleep