As an simple test, try writing ktourw in
http://www.jsoftware.com/jwiki/Essays/Knight's_Tour#Warnsdorff
without control structures, then compare
the result with ktourw.



----- Original Message -----
From: David Ward Lambert <[email protected]>
Date: Tuesday, February 2, 2010 16:43
Subject: [Jprogramming] j control structures
To: [email protected]

> case statement:
> In place of 
>    if. 0>(*:b)-4*a*c do. 'complex roots' else. 'real 
> roots' end.
> I'd write
>    > (1+*(*:b)-4*a*c) { 'complex';'double';'real'['a b 
> c'=.1 0 _1
> There are more extreme examples.
> Long case statements are common in shell script argument parsing.
> flex & bison write hairy switch statements.
> None-the-less, I've haven't written one in many years.  In 
> c I use
> function tables.  By replacing the function table with 
> another the
> behavior of the code can be changed, for instance with a debugging
> version or pretty printer.  In python...GVR won't add case 
> to python,
> use a hash of functions instead.  This is my particular bias.
> 
> 
> for loops
> I might not use these if I can finally understand ^:
> 
> 
> j whilst
> Is the only construct I'm aware of addressing
> 
>   setup
>   while test
>     setup
> 
> try/throw/catches
> catchd looks like a strong debugging tool.  The try. 
> example in the
> dictionary shows bad data type.  Will try also cause an 
> exception for
> out-of-memory?  
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to