I managed to get the results of the first example of FBSL. It works similar like the first example above:
'Oxygenbasic A43 2017-08-07
include "$/inc/console.inc"
#lookahead
int e[] = {1, 2, 3}
MyMap(@Add42, int e[], countof e)
printl
for x = 1 to countof e
print e[x] " "
next
printl "Enter ..." : pause
function MyMap(sys @f, int a[], int c)
int *retval[] = @a[]
int e 'different from e[]
for e = 1 to c
retval[e] = call f(a[e])
next
return retval[]
end function
function Add42(int n) as int : return n + 42 : end function
Output:
43 44 45
Enter ...
I will also get the results of FBSL's second example. But I assume this is no mapping at all?
'Oxygenbasic A43 2017-08-07
include "$/inc/console.inc"
type language
string lang
string numbers[10]
end type
language languages[2]
languages[1].lang = "English"
languages[1].numbers[] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"}
languages[2].lang = "French"
languages[2].numbers[] = {"un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix"}
sub NameANumber(string lang, int nb, string number)
printl "The number " nb " is called " number " in " lang
end sub
sub SpeakALanguage(language lang[], int c)
for x=1 to c
for y=1 to 10
NameANumber(lang[x].lang, y, lang[x].numbers[y])
next
printl string(40, "-")
next
end sub
SpeakALanguage(languages[], countof languages)
printl "Enter ..." : waitkey
Output:
The number 1 is called one in English
The number 2 is called two in English
The number 3 is called three in English
The number 4 is called four in English
The number 5 is called five in English
The number 6 is called six in English
The number 7 is called seven in English
The number 8 is called eight in English
The number 9 is called nine in English
The number 10 is called ten in English
----------------------------------------
The number 1 is called un in French
The number 2 is called deux in French
The number 3 is called trois in French
The number 4 is called quatre in French
The number 5 is called cinq in French
The number 6 is called six in French
The number 7 is called sept in French
The number 8 is called huit in French
The number 9 is called neuf in French
The number 10 is called dix in French
----------------------------------------
Enter ...