If you have time prepare a VB6 code to do this:
PHP Code:
// modern style, using high order functions
module generic_iterator {
do_while = lambda (f, p)->{
{
if p(f()) then loop
}
}
funcA=lambda (start_from, do_what) -> {
=lambda i=start_from, do_what ->{
call do_what(i)
=i
i++
}
}
funcPrint=lambda ->{
print number
}
call do_while(funcA(1, funcPrint), lambda->number mod 6 <>0)
}
generic_iterator
These things I do with M2000, but I would like to see the same at the new Twin Basic/ Rad Basic/ Olaf's Basic.
See all the code for the Rosetta task here:
https://rosettacode.org/wiki/Loops/D...00_Interpreter
Also can run old style BASIC like this:
PHP Code:
module Old_Style {
10 REM Loops/Do-while
20 LET I=0
30 LET I=I+1
40 PRINT I
50 IF INT(I/6)*6 <> I THEN 30
60 END
}
Old_Style
This language is a tool for testing algorithms for education, and has many programming paradigms, like functional style, and an environment with editor with syntax highlight, console with graphics, user defined Forms, and can connect with external dll, and ActiveX objects, also can use external controls for user forms.
The difference with forms in M2000 is that we make them by code, and in one module we may have several forms, including arrays of forms (and arrays of controls on forms if we like). This is like RC5/6 style, but with the exception of handling events, which we make static functions to serve events.
I am working on Version 12, revision 4, which change a lot the language (in code, but old m2000 code run as is). In this version I use the class RefArray which I introduce here, so this can be used (see the as integer):
PHP Code:
dim alfa(-1 to 5, -10 to 10) as integer=100
? alfa(2,2)=100
alfa(2,2)++
? alfa(2,2)=101
the alfa() array is a mArray class which have a ActualData variant, which can be either an array when used with no type same using as variant, or an object RefArray when we use type (we can use types boolean, integer, long, long long, double, single, currency, decimal, string, object).
So the ++ operator works either with one or other type and the good news for me was that I didn't have to alter the code for that, the same code works for ActualData as object and as Variant Array. Because the refArray has Default properties, with Optional arguments. So VB6 can use the parameter entry list according to what type ActualData is at Run Time. I don't now if that can be done with the Twin Basic and others.
Especially for string, I had to improve Interpreter to accept strings without the $ at the end. So now we can make string like this: s="alfa" or string s="alfa" or variant s="alfa" (variant can change types, but if we don't use it, variables can't change type in M2000, after first assign, or using type information at creation).
So today or tomorrow I put the revision 4 in git, stay tuned.