Hi,
not sure of the status of this, but perhaps it might be useful ... if
you remove the "noinline" qualifier, you end up with cpp errors.
Jonathan.
#import <flx.flxh>;
open List;
open C_hack;
open Avl;
open Double;
open VArray;
module VArray {
class vArray[T] {
//var cmp:T*T->int;
var arr:avl[aNode[T]];
var dflt:T;
//ctor(default:T, compare:T*T->int) {
ctor(value:T) {
//cmp = compare;
dflt = value;
arr = Nil[aNode[T]];
}
}
class aNode[T] {
var index:int;
var element:T;
ctor(idx:int, x:T) {
index = idx;
element = x;
}
}
fun cmp[T](x:aNode[T], y:aNode[T]) = {
return cmp(x.index, y.index);
}
noinline proc adder[T](arr:vArray[T], i:int, x:T) {
var z <- new aNode[T](i, x);
arr.arr = insert(arr.arr, z, cmp of (aNode[T]*aNode[T]));
}
}
proc pr_treet[T](tree:avl[aNode[T]]) {
Avl::iter[aNode[T]] ((pr_node of (int*aNode[T])), tree);
}
proc pr_treed[double](tree:avl[aNode[double]]) {
Avl::iter[aNode[double]] ((pr_node of (int*aNode[double])), tree);
}
proc pr_node (d:int, x:aNode[int]) {
print$ " " * d;
print$ f"B(%d.%d)\n" (x.index, x.element);
}
proc pr_node (d:int, x:aNode[double]) {
print$ " " * d;
print$ f"B(%d=%.1f)\n" (x.index, x.element);
}
proc pr_node[T] (d:int, x:aNode[T]) {
print$ " " * d;
print$ f"B(%d)\n" (x.index);
}
fun main () =
{
var ar <- new vArray[double](0.0);
adder(ar, 4, 88.1);
adder(ar, 5, 83.1);
pr_treet(ar.arr);
endl;
return 0;
}
System::exit (main());
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language