411 REFERENCE · Wikibooks
AnyLang Programming Language Comparison/Variables and data structures
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Variables as composite data structures
Variables can be combined into composite data structures. Data structures are useful and common in mainstream programming languages, and they follow commonly recognized patterns which can be documented and re-used.See e.g., Perl Data Structures Cookbook http://perldoc.perl.org/perldsc.html 2010-01-15 09:34:53 Perl Data Structures Cookbook Christiansen Tom Perl Cookbook Twayne Publishers Boston 2003 0596003137
SimpleTable (AoH , AoD)
(aka simpletable_aoh [array of hash])
(aka simpletable_aod [array of dictionary])
This composite data structure is suitable for representing a series of rows and columns in most programming languages.The search fingerprint for this structure is gem_hypo_kinds_yuzovka_aoh. AoH stands for "Array of Hashes"This term is used in Perl, where a "Hash" is another term for a "Dictionary" array.
JavaScript
var mytable_aoh = [
{ "fname":"fred" , "lname":"flintstone" , "age":"33" , "sex":"male" , "motto":"yabbadabbadoo" }
,{ "fname":"wilma" , "lname":"flintstone" , "age":"28" , "sex":"female" , "motto":"" }
,{ "fname":"barney" , "lname":"rubble" , "age":"32" , "sex":"male" , "motto":"hiya fred!" }
,{ "fname":"Fred" , "lname":"Astaire" , "age":"76" , "sex":"male" , "motto":"Dancing is a sweat job" }
];
PHP
$mytable_aoh = Array(
Array( 'lname' => 'Simpson' ,'fname' => 'Homer' ,'age' => '35' ,'motto' => '_blank_' )
,Array( 'lname' => 'Simpson' ,'fname' => 'Marge' ,'age' => '34' ,'motto' => '_blank_' )
,Array( 'lname' => 'Flintstone' ,'fname' => 'Fred' ,'age' => '33' ,'motto' => '_blank_' )
,Array( 'lname' => 'John' ,'fname' => 'Doe' ,'age' => '0' ,'motto' => '_blank_' )
,Array( 'lname' => 'Flintstone' ,'fname' => 'Wilma' ,'age' => '29' ,'motto' => '_blank_' )
);
Rows are represented using an unordered sequence of name-value pairs (aka Dictionary, Hash, Object).
SimpleTable (AoA)
(aka simpletable_aos [array of sequence])
This is a table structure suitable for representing a series of rows and columns in most programming languages.The search fingerprint for this structure is gem_hypo_kinds_yuzovka_aoa.
JavaScript
var mytable_aoa = [
[ "fname" , "lname" , "age" , "sex" , "motto" ]
,[ "fred" , "flintstone" , "33" , "male" , "yabbadabbadoo" ]
,[ "wilma" , "flintstone" , "28" , "female" , "" ]
,[ "barney" , "rubble" , "32" , "male" , "hiya fred!" ]
,[ "Fred" , "Astaire" , "76" , "male" , "Dancing is a sweat job" ]
];
Rows are represented using an ordered sequence of values (aka Array, List).
Notes and references