[Objectscript-devel] [OBJECTSCRIPT] Issue #OBJS135 modified
Brought to you by:
rob_d_clark
From: Rob C. <rob...@ma...> - 2003-05-26 17:09:01
|
Issue OBJS135 (idea: .os -> .html translator) has just been modified by user rob...@ma... You can view the issue detail at the following URL: <http://icandy.homeunix.org:443/scarab/issues/id/OBJS135> The following modifications were made to this issue: hmm, could do interesting things perhaps with an XML parser: <subsection name="Simple Examples"> <p> Well printing "Hello World!" is all well and good, but to do anything interesting, you'll probably need to define functions. For example, the following function will compute the fibonacci number of n: </p> <srcfile name="fib.os"> /* The mathmatical definition of fibonacci number of n: * Fn = 1 (n == 1) * = 1 (n == 2) * = F(n-1) + F(n-2) (otherwise) */ function fib(n) { if( n == 0 ) throw new Exception("Invalid Input"); else if( n == 1 ) return 1; else if( n == 2 ) return 1; else return fib(n-1) + fib(n-2); } <test> try { fib(0); error(); } catch(Exception e) {} catch(e) { error(); } if( fib(1) != 1 ) error(); if( fib(2) != 1 ) error(); if( fib(3) != 2 ) error(); if( fib(99) != ?? ) error(); </test> </srcfile> </subsection> when generating the .html, the .os -> .html translator could be used to syntax highlight. Also, the optional test block could be run to verify that the example code actually works properly. |