[nem-pl] stos
Lukasz Kaiser
kaiser at tenet.pl
Thu Feb 19 17:20:37 CET 2004
Hej.
Jak to jest z ustawianiem wielkosci stosu ?
Uzywam Nemerle 0.1, ostatnio Michal cos poprawial, ale
chyba dla tego programu ktory wysylam to niewiele da.
Moglby ktos zobaczyc dla jakich wartosci n pod
jakimi srodowiskami sie wysypuje ? U mnie pod mono
0.30 juz nie dziala dla 15, chociaz OCaml wytrzymuje
az do 18. Tylko nie piszcie ze nikt normalny nie pisze
takich programow.
- lk
-------------- next part --------------
using Nemerle.Collections.List ;
using System.Console ;
module MyModuleForShortPrograms {
variant tree <'a> {
| Leaf { id : 'a ; }
| Tree { left : tree <'a> ; right : tree <'a> ; id : 'a ; }
}
Main () : void { // I want type inference, so all functions are defined local.
def makeTree (n) {
if (n == 0) Leaf (0)
else Tree ( makeTree (n-1), makeTree (n-1), n ) ;
} ;
def foldTree (t) {
match (t) {
| Leaf (n) => [n] ;
| Tree (l,r,n) => n :: Append ( foldTree (l), foldTree (r) ) ;
}
} ;
def addList (l : list<int>) {
match (l) {
| [] => 0 ;
| x :: xs => x + addList (xs) ;
}
} ;
def n = 15 ;
WriteLine ("Add of Tree {0} is {1}.", n, addList ( foldTree ( makeTree (n))) );
} // End of functions definitions.
} // End of module.
More information about the devel-pl
mailing list