AnyLang Programming Language Comparison/Variables and data structures
Variables as composite data structures
editVariables 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.[1][2]
SimpleTable (AoH , AoD)
edit(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.[3] AoH stands for "Array of Hashes"[4]
JavaScript
editvar 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
edit$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)
edit(aka simpletable_aos [array of sequence])
This is a table structure suitable for representing a series of rows and columns in most programming languages.[5]
JavaScript
editvar 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
edit- ↑ See e.g., "Perl Data Structures Cookbook". Retrieved 2010-01-15 09:34:53.
{{cite web}}
: Check date values in:|accessdate=
(help) Perl Data Structures Cookbook - ↑ Christiansen, Tom (2003). Perl Cookbook. Boston: Twayne Publishers. ISBN 0596003137.
- ↑ The search fingerprint for this structure is gem_hypo_kinds_yuzovka_aoh.
- ↑ This term is used in Perl, where a "Hash" is another term for a "Dictionary" array.
- ↑ The search fingerprint for this structure is gem_hypo_kinds_yuzovka_aoa.