1.2.53. test/regress/rt-1.01.53

Start felix section to test/regress/rt-1.01.53-0.flx[1 /1 ]
     1: #line 2118 "./lpsrc/flx_regress.pak"
     2: //Check purely functional
     3: #import <flx.flxh>;
     4: 
     5: open List;
     6: 
     7: open Avl;
     8: 
     9: proc pr_node (x:int) {
    10:     print "B(";
    11:     print x;
    12:     print ")\n";
    13: }
    14: 
    15: proc pr_tree(tree:avl[int]) {
    16:     Avl::iter[int] (pr_node of int, tree);
    17: }
    18: 
    19: proc pr_node (d:int, x:int) {
    20:     print ("  " * d);
    21:     print "B(";
    22:     print x;
    23:     print ")\n";
    24: }
    25: 
    26: proc pr_treed(tree:avl[int]) {
    27:     Avl::iter[int] (pr_node of (int*int), tree);
    28: }
    29: 
    30: proc print_string (x:string) {
    31:     print x;
    32: }
    33: 
    34: fun cmp_int(x:int, y:int) =>
    35:     if x > y then
    36:         1
    37:     elif x < y then
    38:         -1
    39:     else
    40:         0
    41:     endif
    42: ;
    43: 
    44: fun cadd_list_to_int (x:int) (y:list[int]) =>
    45:     y + x
    46: ;
    47: 
    48: fun cadd_int_to_list (y:list[int]) (x:int) =>
    49:     y + x
    50: ;
    51: 
    52: fun cadd_int_to_avl (y:avl[int]) (x:int) =>
    53:     Avl::insert[int](y, x, cmp_int of (int*int));
    54: 
    55: fun main () =
    56: {
    57: 
    58:     var y = list(1, 3, 5, 7, 9 );
    59:     var z:avl[int] = (fold_left (the cadd_int_to_avl)  (avl[int]())  y);
    60:     pr_treed(z);
    61:     endl;
    62: 
    63:     z = remove[int](z, 7, cmp_int of (int*int));
    64:     pr_treed(z);
    65:     endl;
    66: 
    67:     z = insert(z, 11, cmp_int of(int*int));
    68:     pr_treed(z);
    69:     endl;
    70: 
    71:     print_line$ first(z);
    72:     endl;
    73: 
    74:     z = all_but_first(z);
    75:     pr_treed(z);
    76:     endl;
    77: 
    78:     print_line$ last(z);
    79:     endl;
    80: 
    81:     z = all_but_last(z);
    82:     pr_treed(z);
    83:     endl;
    84: 
    85:     return 0;
    86: }
    87: 
    88: System::exit (main());
End felix section to test/regress/rt-1.01.53-0.flx[1]
Start data section to test/regress/rt-1.01.53-0.expect[1 /1 ]
     1:   B(1)
     2: B(3)
     3:     B(5)
     4:   B(7)
     5:     B(9)
     6: 
     7:   B(1)
     8: B(3)
     9:   B(5)
    10:     B(9)
    11: 
    12:   B(1)
    13: B(3)
    14:     B(5)
    15:   B(9)
    16:     B(11)
    17: 
    18: 1
    19: 
    20:   B(3)
    21:     B(5)
    22: B(9)
    23:   B(11)
    24: 
    25: 11
    26: 
    27: B(3)
    28:     B(5)
    29:   B(9)
    30: 
End data section to test/regress/rt-1.01.53-0.expect[1]