letowski
2012-06-17 16:24:26 UTC
Hi,
Here is my idea for making functional language more popular:
Compound data a'la Prolog (terms + lists), pattern matching a'la Ocaml,
lexical scoping and closures as in Scheme, garbage collecting,
but all this written in classic C/JavaScript syntax (curly braces, for, while, switch, return etc.).
What do you think ?
I have a working prototype implementation (as translator to Scheme),
please look at http://ml.pdg.pl/en/alfa3.html.
For example, here is qsort in Alfa (this is a name of the language):
function qsort( [] ) { return []; }
function qsort( [H| T ] )
{
function append( [], X ) { return X; }
function append( [H| T ], X ) { return [ H | append(T, X) ]; }
function select_less( x, [] ) { return []; }
function select_less( x, [H| T] ) {
if ( H < x )
return [ H | select_less(x, T ) ];
else
return select_less(x, T);
}
function select_notless( x, [] ) { return []; }
function select_notless( x, [H| T] )
{
if ( H >= x )
return [ H | select_notless(x, T ) ];
else
return select_notless(x, T);
}
var LNotLess = select_notless( H, T );
var LLess = select_less( H, T );
return append( qsort(LLess), [H| qsort(LNotLess) ] );
}
Mark
Here is my idea for making functional language more popular:
Compound data a'la Prolog (terms + lists), pattern matching a'la Ocaml,
lexical scoping and closures as in Scheme, garbage collecting,
but all this written in classic C/JavaScript syntax (curly braces, for, while, switch, return etc.).
What do you think ?
I have a working prototype implementation (as translator to Scheme),
please look at http://ml.pdg.pl/en/alfa3.html.
For example, here is qsort in Alfa (this is a name of the language):
function qsort( [] ) { return []; }
function qsort( [H| T ] )
{
function append( [], X ) { return X; }
function append( [H| T ], X ) { return [ H | append(T, X) ]; }
function select_less( x, [] ) { return []; }
function select_less( x, [H| T] ) {
if ( H < x )
return [ H | select_less(x, T ) ];
else
return select_less(x, T);
}
function select_notless( x, [] ) { return []; }
function select_notless( x, [H| T] )
{
if ( H >= x )
return [ H | select_notless(x, T ) ];
else
return select_notless(x, T);
}
var LNotLess = select_notless( H, T );
var LLess = select_less( H, T );
return append( qsort(LLess), [H| qsort(LNotLess) ] );
}
Mark