diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/fib.fwd | 12 | ||||
| -rw-r--r-- | examples/uniq.fwd | 16 | 
2 files changed, 13 insertions, 15 deletions
| diff --git a/examples/fib.fwd b/examples/fib.fwd index 8b0e055..4eb2e60 100644 --- a/examples/fib.fwd +++ b/examples/fib.fwd @@ -5,19 +5,19 @@   * bifurcating nature of fibonacci just gets mapped to a linear sequence of   * calls? */ -fib(n, res) +fib(int n, (int) res)  { -	fwd_if(n < 2) => { +	if n < 2 {  		res(1); -	} => { -		fib(n - 1) => f1; -		fib(n - 2) => f2; +	} else { +		fib(n - 1) => int f1; +		fib(n - 2) => int f2;  		res(f1 + f2);  	}  }  main()  { -	fib(6) => n; +	fib(6) => int n;  	fwd_println(n);  } diff --git a/examples/uniq.fwd b/examples/uniq.fwd index 490a702..c043a89 100644 --- a/examples/uniq.fwd +++ b/examples/uniq.fwd @@ -2,15 +2,13 @@  /* at some point I'll probably add in a type system as well, but for now let's   * pretend we're static-dynamic (or dynamic at compiletime? dunno) */ -readlines(set, next) +readlines(unordered_set![string] set, (unordered_set![string]) next)  { -	/* option![str] */ -	fwd_getline() => line; +	fwd_getline() => optional![string] line; -	/* unwraps option![str] -> str */ -	fwd_some(line) => line { +	fwd_some(line) => string line {  		/* we had something in our option */ -		fwd_insert(set, line) => set; +		fwd_insert(set, line) => unordered_set![string] set;  		/* at the moment the only supported looping construct is  		 * recursion */ @@ -25,9 +23,9 @@ main()  {  	/* fwdlib.hpp uses namespace std, not good practice but allows us to do  	 * stuff like this: */ -	unordered_set![string]{} => set; -	readlines(set) => set; -	fwd_foreach(set) => node { +	unordered_set![string]{} => unordered_set![string] set; +	readlines(set) => unordered_set![string] set; +	fwd_foreach(set) => string node {  		fwd_println(node);  	}  } | 
